Skip to content

domain_account_abstraction_ed25519_hex - [mainnet]

Domain account abstraction using ed25519 hex for signing.

Authentication takes digest, converts to hex (prefixed with 0x, with lowercase letters), and then expects that to be signed. authenticator is expected to be signature: vector account_identity is raw public_key.

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

Authorization function for domain account abstraction.

public fun authenticate(account: signer, aa_auth_data: auth_data::AbstractionAuthData): signer
Implementation
public fun authenticate(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
}