AccountSignerLib
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
| Name | Type | Description |
|---|---|---|
| $ | AccountSignerStorage |
__AccountSigner_init
Seeds the ECDSA signing owner during diamond initialization.
function __AccountSigner_init(address owner_) internal;Parameters
| Name | Type | Description |
|---|---|---|
| owner_ | address |
owner
function owner() internal view returns (address);Returns
| Name | Type | Description |
|---|---|---|
| <none> | address |
signerType
function signerType() internal view returns (IAccountSigner.SignerType);Returns
| Name | Type | Description |
|---|---|---|
| <none> | IAccountSigner.SignerType |
p256PublicKey
function p256PublicKey() internal view returns (bytes32 x, bytes32 y);Returns
| Name | Type | Description |
|---|---|---|
| x | bytes32 | |
| y | bytes32 |
requireUserVerification
function requireUserVerification() internal view returns (bool);Returns
| Name | Type | Description |
|---|---|---|
| <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
| Name | Type | Description |
|---|---|---|
| hash | bytes32 | |
| signature | bytes |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | bool |
setOwner
Sets an ECDSA owner and re-arms the ECDSA scheme. Admin only.
function setOwner(address newOwner) internal;Parameters
| Name | Type | Description |
|---|---|---|
| newOwner | address |
setP256Signer
Sets a raw P256 (secp256r1) public key as the owner. Admin only.
function setP256Signer(bytes32 x, bytes32 y) internal;Parameters
| Name | Type | Description |
|---|---|---|
| x | bytes32 | |
| y | bytes32 |
setWebAuthnSigner
Sets a WebAuthn passkey (P256 key + UV policy) as the owner. Admin only.
function setWebAuthnSigner(bytes32 x, bytes32 y, bool requireUV) internal;Parameters
| Name | Type | Description |
|---|---|---|
| x | bytes32 | |
| y | bytes32 | |
| requireUV | bool |
setHederaAccountSigner
Sets a native Hedera account (ED25519 or ECDSA key) as the owner. Admin only.
function setHederaAccountSigner(address account) internal;Parameters
| Name | Type | Description |
|---|---|---|
| account | address |
_setOwner
function _setOwner(address newOwner) private;Parameters
| Name | Type | Description |
|---|---|---|
| newOwner | address |
_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
| Name | Type | Description |
|---|---|---|
| account | address |
_setSigner
function _setSigner(IAccountSigner.SignerType t, bytes32 x, bytes32 y, bool uv) private;Parameters
| Name | Type | Description |
|---|---|---|
| t | IAccountSigner.SignerType | |
| x | bytes32 | |
| y | bytes32 | |
| uv | bool |