-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
54a0f76
commit 0154774
Showing
8 changed files
with
548 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{ | ||
"erc5564-interface": "ERC5564Announcer.sol Interface", | ||
"erc6538-interface": "ERC6538Registry.sol Interface" | ||
"erc5564-interface": "IERC5564Announcer.sol", | ||
"erc6538-interface": "IERC6538Registry.sol" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# IERC5564Announcer | ||
|
||
Interface for calling the `ERC5564Announcer` contract, which emits an `Announcement` event to broadcast information about a transaction involving a stealth address. See [ERC-5564](https://eips.ethereum.org/EIPS/eip-5564) to learn more. | ||
|
||
### Code: [`IERC5564Announcer.sol`](https://github.com/ScopeLift/stealth-address-erc-contracts/blob/b6f7d989b6247f81ceede5d1be2ffb23c1cb39b5/src/interfaces/IERC5564Announcer.sol) | ||
|
||
## Functions | ||
|
||
### announce | ||
|
||
```solidity | ||
function announce( | ||
uint256 schemeId, | ||
address stealthAddress, | ||
bytes memory ephemeralPubKey, | ||
bytes memory metadata | ||
) external | ||
``` | ||
|
||
Called by integrators to emit an `Announcement` event. | ||
|
||
#### Parameters: | ||
|
||
| Type | Name | Description | | ||
| --------- | ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| `uint256` | `schemeId` | Identifier corresponding to the applied stealth address scheme, e.g., 1 for `secp256k1`, as specified in [ERC-5564](https://eips.ethereum.org/EIPS/eip-5564). | | ||
| `address` | `stealthAddress` | The computed stealth address for the recipient. | | ||
| `bytes` | `ephemeralPubKey` | Ephemeral public key used by the sender. | | ||
| `bytes` | `metadata` | Arbitrary data to emit with the event. The first byte MUST be the view tag. The remaining metadata can be used freely by the senders. | | ||
|
||
## Events | ||
|
||
### Announcement | ||
|
||
```solidity | ||
event Announcement( | ||
uint256 indexed schemeId, | ||
address indexed stealthAddress, | ||
address indexed caller, | ||
bytes ephemeralPubKey, | ||
bytes metadata | ||
); | ||
``` | ||
|
||
Emitted when something is sent to a stealth address. | ||
|
||
#### Parameters: | ||
|
||
| Type | Name | Description | | ||
| --------- | ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| `uint256` | `schemeId` | Identifier corresponding to the applied stealth address scheme, e.g., 1 for `secp256k1`, as specified in [ERC-5564](https://eips.ethereum.org/EIPS/eip-5564). | | ||
| `address` | `stealthAddress` | The computed stealth address for the recipient. | | ||
| `address` | `caller` | The caller of the `announce` function that emitted this event. | | ||
| `bytes` | `ephemeralPubKey` | Ephemeral public key used by the sender to derive the `stealthAddress`. | | ||
| `bytes` | `metadata` | Arbitrary data to emit with the event. The first byte MUST be the view tag. The remaining metadata can be used by the senders as they like. See [ERC-5564](https://eips.ethereum.org/EIPS/eip-5564) for recommendations on how to structure this metadata. | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
# IERC6538Registry | ||
|
||
Interface for calling the `ERC6538Registry` contract to map accounts to their stealth meta-addresses. See [ERC-6538](https://eips.ethereum.org/EIPS/eip-6538) to learn more. | ||
|
||
### Code: [`IERC6538Registry.sol`](https://github.com/ScopeLift/stealth-address-erc-contracts/blob/b6f7d989b6247f81ceede5d1be2ffb23c1cb39b5/src/interfaces/IERC6538Registry.sol) | ||
|
||
## Functions | ||
|
||
### registerKeys | ||
|
||
```solidity | ||
function registerKeys(uint256 schemeId, bytes calldata stealthMetaAddress) external | ||
``` | ||
|
||
Sets the caller's stealth meta-address for the given scheme ID. | ||
|
||
#### Parameters: | ||
|
||
| Type | Name | Description | | ||
| --------- | -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| `uint256` | `schemeId` | Identifier corresponding to the applied stealth address scheme, e.g., 1 for `secp256k1`, as specified in [ERC-5564](https://eips.ethereum.org/EIPS/eip-5564). | | ||
| `bytes` | `stealthMetaAddress` | The stealth meta-address to register. | | ||
|
||
### registerKeysOnBehalf | ||
|
||
```solidity | ||
function registerKeysOnBehalf( | ||
address registrant, | ||
uint256 schemeId, | ||
bytes memory signature, | ||
bytes calldata stealthMetaAddress | ||
) external | ||
``` | ||
|
||
Sets the `registrant`'s stealth meta-address for the given scheme ID. | ||
|
||
#### Parameters: | ||
|
||
| Type | Name | Description | | ||
| --------- | -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| `address` | `registrant` | Address of the registrant. | | ||
| `uint256` | `schemeId` | Identifier corresponding to the applied stealth address scheme, e.g., 1 for `secp256k1`, as specified in [ERC-5564](https://eips.ethereum.org/EIPS/eip-5564). | | ||
| `bytes` | `signature` | A signature from the `registrant` authorizing the registration. | | ||
| `bytes` | `stealthMetaAddress` | The stealth meta-address to register. | | ||
|
||
### incrementNonce | ||
|
||
```solidity | ||
function incrementNonce() external | ||
``` | ||
|
||
Increments the nonce of the sender to invalidate existing signatures. | ||
|
||
### DOMAIN_SEPARATOR | ||
|
||
```solidity | ||
function DOMAIN_SEPARATOR() external view returns (bytes32) | ||
``` | ||
|
||
Returns the domain separator used in this contract. | ||
|
||
### stealthMetaAddressOf | ||
|
||
```solidity | ||
function stealthMetaAddressOf(address registrant, uint256 schemeId) external view returns (bytes memory) | ||
``` | ||
|
||
Returns the stealth meta-address for the given `registrant` and `schemeId`. | ||
|
||
#### Parameters: | ||
|
||
| Type | Name | Description | | ||
| --------- | ------------ | --------------------------------------------------------------- | | ||
| `address` | `registrant` | The address of the registrant. | | ||
| `uint256` | `schemeId` | Identifier corresponding to the applied stealth address scheme. | | ||
|
||
#### Return Values: | ||
|
||
| Type | Description | | ||
| ------- | ------------------------- | | ||
| `bytes` | The stealth meta-address. | | ||
|
||
### ERC6538REGISTRY_ENTRY_TYPE_HASH | ||
|
||
```solidity | ||
function ERC6538REGISTRY_ENTRY_TYPE_HASH() external view returns (bytes32) | ||
``` | ||
|
||
Returns the EIP-712 type hash used in `registerKeysOnBehalf`. | ||
|
||
#### Return Values: | ||
|
||
| Type | Description | | ||
| --------- | ---------------------- | | ||
| `bytes32` | The EIP-712 type hash. | | ||
|
||
### nonceOf | ||
|
||
```solidity | ||
function nonceOf(address registrant) external view returns (uint256) | ||
``` | ||
|
||
Returns the nonce of the given `registrant`. | ||
|
||
#### Parameters: | ||
|
||
| Type | Name | Description | | ||
| --------- | ------------ | ------------------------------ | | ||
| `address` | `registrant` | The address of the registrant. | | ||
|
||
#### Return Values: | ||
|
||
| Type | Description | | ||
| --------- | ----------- | | ||
| `uint256` | The nonce. | | ||
|
||
## Events | ||
|
||
### StealthMetaAddressSet | ||
|
||
```solidity | ||
event StealthMetaAddressSet( | ||
address indexed registrant, uint256 indexed schemeId, bytes stealthMetaAddress | ||
); | ||
``` | ||
|
||
Emitted when a registrant updates their stealth meta-address. | ||
|
||
#### Parameters: | ||
|
||
| Type | Name | Description | | ||
| --------- | -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| `address` | `registrant` | The address of the registrant of the stealth meta-address. | | ||
| `uint256` | `schemeId` | Identifier corresponding to the applied stealth address scheme, e.g., 1 for `secp256k1`, as specified in [ERC-5564](https://eips.ethereum.org/EIPS/eip-5564). | | ||
| `bytes` | `stealthMetaAddress` | The stealth meta-address. Based on [ERC-5564](https://eips.ethereum.org/EIPS/eip-5564). | | ||
|
||
### NonceIncremented | ||
|
||
```solidity | ||
event NonceIncremented(address indexed registrant, uint256 newNonce); | ||
``` | ||
|
||
Emitted when a registrant increments their nonce. | ||
|
||
#### Parameters: | ||
|
||
| Type | Name | Description | | ||
| --------- | ------------ | --------------------------------------- | | ||
| `address` | `registrant` | The account that incremented the nonce. | | ||
| `uint256` | `newNonce` | The new nonce value. | | ||
|
||
## Errors | ||
|
||
### ERC6538Registry\_\_InvalidSignature | ||
|
||
```solidity | ||
error ERC6538Registry__InvalidSignature(); | ||
``` | ||
|
||
Emitted when an invalid signature is provided to `registerKeysOnBehalf`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# ERC5564Announcer.sol | ||
|
||
## Overview | ||
|
||
The `ERC5564Announcer` contract is designed to facilitate the broadcasting of transactions involving stealth addresses by emitting an `Announcement` event. This event contains relevant information that can be used to reconstruct the transaction and validate its parameters. | ||
|
||
### Code: [`ERC5564Announcer.sol`](https://github.com/ScopeLift/stealth-address-erc-contracts/blob/b6f7d989b6247f81ceede5d1be2ffb23c1cb39b5/src/ERC5564Announcer.sol) | ||
|
||
## Events | ||
|
||
### Announcement | ||
|
||
The `Announcement` event is emitted when the `announce` function is called. Here are the key components of this event: | ||
|
||
- **schemeId** (`uint256`): Identifier corresponding to the applied stealth address scheme (e.g., `1` for `secp256k1` as specified in [ERC-5564](https://eips.ethereum.org/EIPS/eip-5564)). | ||
- **stealthAddress** (`address`): The computed stealth address for the recipient. | ||
- **caller** (`address`): The address that called the `announce` function. | ||
- **ephemeralPubKey** (`bytes`): Ephemeral public key used by the sender to derive the `stealthAddress`. | ||
- **metadata** (`bytes`): Arbitrary data to emit with the event. The first byte MUST be the view tag. The remaining metadata can be used by the senders as per their requirements (refer to [ERC-5564](https://eips.ethereum.org/EIPS/eip-5564) for recommended metadata structure). | ||
|
||
#### Event Signature | ||
|
||
```solidity | ||
event Announcement( | ||
uint256 indexed schemeId, | ||
address indexed stealthAddress, | ||
address indexed caller, | ||
bytes ephemeralPubKey, | ||
bytes metadata | ||
); | ||
``` | ||
|
||
## Functions | ||
|
||
### announce | ||
|
||
The `announce` function is used by integrators to emit the `Announcement` event. It takes the following parameters: | ||
|
||
- **schemeId** (`uint256`): Identifier corresponding to the applied stealth address scheme. | ||
- **stealthAddress** (`address`): The computed stealth address for the recipient. | ||
- **ephemeralPubKey** (`bytes`): The ephemeral public key used by the sender. | ||
- **metadata** (`bytes`): Arbitrary data to emit with the event. The first byte MUST be the view tag. The remaining metadata can be used freely by the senders. | ||
|
||
#### Function Signature | ||
|
||
```solidity | ||
function announce( | ||
uint256 schemeId, | ||
address stealthAddress, | ||
bytes memory ephemeralPubKey, | ||
bytes memory metadata | ||
) external | ||
``` | ||
|
||
#### Description | ||
|
||
When called, this function emits the `Announcement` event with all the parameters supplied to it. | ||
|
||
#### Usage | ||
|
||
To use the `announce` function, you need to pass the required parameters as per the function signature: | ||
|
||
```solidity | ||
contract MyContract { | ||
ERC5564Announcer public announcer; | ||
constructor(address announcerAddress) { | ||
announcer = ERC5564Announcer(announcerAddress); | ||
} | ||
function myAnnounceFunction(uint256 _schemeId, address _stealthAddress, bytes memory _ephemeralPubKey, bytes memory _metadata) public { | ||
announcer.announce(_schemeId, _stealthAddress, _ephemeralPubKey, _metadata); | ||
} | ||
} | ||
``` | ||
|
||
## Related Links | ||
|
||
- [ERC-5564](https://eips.ethereum.org/EIPS/eip-5564) |
Oops, something went wrong.