ERC6538RegistryLib
Title: ERC6538RegistryLib
Authors: David Dada <daveproxy80@gmail.com> (https://github.com/dadadave80), Modified from ScopeLift (https://github.com/ScopeLift/stealth-address-erc-contracts), Conforms to ERC-6538 (https://eips.ethereum.org/EIPS/eip-6538)
Library implementing the ERC-6538 stealth meta-address registry.
Reuses the shared EIP712 module for the domain separator + typed-data hashing, and
SignatureChecker for ECDSA + ERC-1271 verification — mirroring the canonical reference's
registerKeysOnBehalf exactly. The nonce is registry-local (this module's own storage), so
nonceOf is independent of any token permit / vote-delegation nonce in the same diamond.
The EIP-712 domain is the host diamond's shared domain; initialize EIP712 with name
"ERC6538Registry" / version "1.0" for canonical ERC-6538 signer compatibility.
Functions
erc6538RegistryStorage
function erc6538RegistryStorage() internal pure returns (ERC6538RegistryStorage storage $);Returns
| Name | Type | Description |
|---|---|---|
| $ | ERC6538RegistryStorage |
__ERC6538Registry_init
Initializes the ERC6538Registry module.
Must be called inside a pre/postInitializer block. Registers IERC6538Registry for ERC-165. EIP712 must be initialized separately (the registry reuses its domain for hashing).
function __ERC6538Registry_init() internal;registerInterface
Registers support for the IERC6538Registry interface via ERC-165.
function registerInterface() internal;registerKeys
Registers the caller's stealth meta-address for schemeId (last-write-wins).
function registerKeys(uint256 schemeId, bytes calldata stealthMetaAddress) internal;Parameters
| Name | Type | Description |
|---|---|---|
| schemeId | uint256 | The stealth-address scheme id. |
| stealthMetaAddress | bytes | The caller's stealth meta-address bytes. |
registerKeysOnBehalf
Registers registrant's stealth meta-address from an EIP-712 signature.
Consumes the registrant's nonce BEFORE verifying, so a failed verification reverts the whole call and rolls the consumed nonce back (no griefing). Supports EOA + ERC-1271 signers.
function registerKeysOnBehalf(
address registrant,
uint256 schemeId,
bytes calldata signature,
bytes calldata stealthMetaAddress
) internal;Parameters
| Name | Type | Description |
|---|---|---|
| registrant | address | The account authorizing the registration. |
| schemeId | uint256 | The stealth-address scheme id. |
| signature | bytes | The registrant's EIP-712 signature. |
| stealthMetaAddress | bytes | The stealth meta-address bytes to store. |
incrementNonce
Advances the caller's nonce, invalidating outstanding on-behalf signatures.
function incrementNonce() internal;stealthMetaAddressOf
Returns the stealth meta-address registered by registrant for schemeId.
function stealthMetaAddressOf(address registrant, uint256 schemeId) internal view returns (bytes memory);Parameters
| Name | Type | Description |
|---|---|---|
| registrant | address | The account to query. |
| schemeId | uint256 | The stealth-address scheme id. |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | bytes | The registered stealth meta-address bytes (empty if unset). |
nonceOf
Returns the current on-behalf-registration nonce for registrant.
function nonceOf(address registrant) internal view returns (uint256);Parameters
| Name | Type | Description |
|---|---|---|
| registrant | address | The account to query. |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint256 | The current nonce. |
entryTypeHash
Returns the EIP-712 type hash used in registerKeysOnBehalf.
function entryTypeHash() internal pure returns (bytes32);Returns
| Name | Type | Description |
|---|---|---|
| <none> | bytes32 |