Skip to content
Lattice

AccountSignerLib

Git Source

Title: AccountSignerLib

Author: David Dada <daveproxy80@gmail.com> (https://github.com/dadadave80)

Logic + ERC-7201 storage for the account's single owner, backing both ERC-4337 validateUserOp and ERC-1271 isValidSignature. ECDSA is the default scheme; a P256 raw key, a WebAuthn passkey, or a native Hedera account can be set as the owner instead.

isValidSignatureNow is the signer seam consumed unchanged by the validation / 1271 / executor facets. It dispatches on the STORED signer type (not the signature shape) and never reverts on malformed input (returns false), so the 4337 path yields SIG_VALIDATION_FAILED rather than reverting. P256/WebAuthn verification is delegated to vendored audited Solady libs (RIP-7212 precompile with a verifier fallback; low-S enforced); Hedera-account verification is delegated to the HAS system contract through HASSignatureVerifierLib, which reports every system-contract revert as false. The ECDSA branch is byte-for-byte the legacy path.

Functions

accountSignerStorage

function accountSignerStorage() internal pure returns (AccountSignerStorage storage $);

Returns

NameTypeDescription
$AccountSignerStorage

__AccountSigner_init

Seeds the ECDSA signing owner during diamond initialization.

function __AccountSigner_init(address owner_) internal;

Parameters

NameTypeDescription
owner_address

owner

function owner() internal view returns (address);

Returns

NameTypeDescription
<none>address

signerType

function signerType() internal view returns (IAccountSigner.SignerType);

Returns

NameTypeDescription
<none>IAccountSigner.SignerType

p256PublicKey

function p256PublicKey() internal view returns (bytes32 x, bytes32 y);

Returns

NameTypeDescription
xbytes32
ybytes32

requireUserVerification

function requireUserVerification() internal view returns (bool);

Returns

NameTypeDescription
<none>bool

isValidSignatureNow

True if signature is valid over hash for the configured owner (ECDSA / P256 / WebAuthn).

function isValidSignatureNow(bytes32 hash, bytes memory signature) internal view returns (bool);

Parameters

NameTypeDescription
hashbytes32
signaturebytes

Returns

NameTypeDescription
<none>bool

setOwner

Sets an ECDSA owner and re-arms the ECDSA scheme. Admin only.

function setOwner(address newOwner) internal;

Parameters

NameTypeDescription
newOwneraddress

setP256Signer

Sets a raw P256 (secp256r1) public key as the owner. Admin only.

function setP256Signer(bytes32 x, bytes32 y) internal;

Parameters

NameTypeDescription
xbytes32
ybytes32

setWebAuthnSigner

Sets a WebAuthn passkey (P256 key + UV policy) as the owner. Admin only.

function setWebAuthnSigner(bytes32 x, bytes32 y, bool requireUV) internal;

Parameters

NameTypeDescription
xbytes32
ybytes32
requireUVbool

setHederaAccountSigner

Sets a native Hedera account (ED25519 or ECDSA key) as the owner. Admin only.

function setHederaAccountSigner(address account) internal;

Parameters

NameTypeDescription
accountaddress

_setOwner

function _setOwner(address newOwner) private;

Parameters

NameTypeDescription
newOwneraddress

_setHederaAccountSigner

Stores the Hedera account in _owner (the scheme keeps no key material) and clears the passkey fields, so no stale P256 key or UV policy survives the switch. Owner, scheme and UV policy share slot 0; the two key words are cleared separately.

REFUSES a chain where HAS does not answer. An account is its own admin, so the signer this call installs is the same signer every later admin call must satisfy — including setOwner, the only route back. Arming a Hedera signer without a live HAS therefore strands the account for good, and it would do so SILENTLY: the setter would succeed and only the next signature would reveal it.

function _setHederaAccountSigner(address account) private;

Parameters

NameTypeDescription
accountaddress

_setSigner

function _setSigner(IAccountSigner.SignerType t, bytes32 x, bytes32 y, bool uv) private;

Parameters

NameTypeDescription
tIAccountSigner.SignerType
xbytes32
ybytes32
uvbool