Skip to content

common_domain_aa_auths - [mainnet]

use 0x1::auth_data;
use 0x1::ed25519;
use 0x1::error;
use 0x1::string;
use 0x1::string_utils;

Constants

const EINVALID_SIGNATURE: u64 = 1;

Functions

authenticate_ed25519_hex

public fun authenticate_ed25519_hex(account: signer, aa_auth_data: auth_data::AbstractionAuthData): signer
Implementation
public fun authenticate_ed25519_hex(account: signer, aa_auth_data: AbstractionAuthData): signer {
    let hex_digest = string_utils::to_string(aa_auth_data.digest());

    let public_key = new_unvalidated_public_key_from_bytes(*aa_auth_data.domain_account_identity());
    let signature = new_signature_from_bytes(*aa_auth_data.domain_authenticator());
    assert!(
        ed25519::signature_verify_strict(
            &signature,
            &public_key,
            *hex_digest.bytes(),
        ),
        error::permission_denied(EINVALID_SIGNATURE)
    );

    account
}