Module to ECDSA signatures over structured data, following the EIP712 standard
- Source:
Methods
(inner) generateACEDomainParams(verifyingContract) → {Object}
Generate EIP712 domain parameters for ACE.sol
Parameters:
| Name | Type | Description |
|---|---|---|
verifyingContract |
string |
address of target contract |
- Source:
(inner) generateDAIDomainParams()
Generate EIP712 domain parameters for DAI token
Parameters:
| Type | Description |
|---|---|
- Source:
(inner) generateZKAssetDomainParams(verifyingContract) → {Object}
Generate EIP712 domain parameters for ZkAsset.sol
Parameters:
| Name | Type | Description |
|---|---|---|
verifyingContract |
string |
address of target contract |
- Source:
(inner) signApprovalForProof(verifyingContract, proofOutputs, spender, approval, privateKey) → {string}
Create an EIP712 ECDSA signature over an AZTEC proof, used to either grant or revoke delegation of proof execution to a third party using the approveProof() method of a ZkAsset.
ECSA signature is formatted as follows:
randsoccupy 32 bytesvoccupies 1 byte
Parameters:
| Name | Type | Description |
|---|---|---|
verifyingContract |
string |
address of target contract |
proofOutputs |
string |
outputs of a proof |
spender |
string |
address to which note control is being delegated |
approval |
bool |
boolean (true for approval, false for revocation) |
privateKey |
string |
the private key of message signer |
- Source:
(inner) signNoteACEDomain(verifyingContract, spender, privateKey) → {Array.<string>}
Create an EIP712 ECDSA signature over an AZTEC note, for an ACE.sol domain.
Formats r and s as occupying 32 bytes, and v as occupying 1 byte
Parameters:
| Name | Type | Description |
|---|---|---|
verifyingContract |
string |
address of target contract |
spender |
string |
address of the note spender |
privateKey |
string |
the private key of message signer |
- Source:
(inner) signNoteForConfidentialApprove(verifyingContract, noteHash, spender, spenderApproval, privateKey) → {string}
Create an EIP712 ECDSA signature over an AZTEC note, suited for the confidentialApprove() method of a ZkAsset. The ZkAsset.confidentialApprove() method must be called when granting note spending permission to a third party and is required in order for ZkAsset.confidentialTransferFrom() to be successful.
This is expected to be the most commonly used note signing() function. However for use cases, such as testing, where ACE domain params are required then the signNoteACEDomain() function is available.
Formats r and s as occupying 32 bytes, and v as occupying 1 byte
Parameters:
| Name | Type | Description |
|---|---|---|
verifyingContract |
string |
address of target contract |
noteHash |
string |
noteHash of the note being signed |
spender |
string |
address of the note spender |
spenderApproval |
bool |
boolean determining whether the spender is being granted approval or revoked |
privateKey |
string |
the private key of message signer |
- Source:
(inner) signNoteForConfidentialTransfer(verifyingContract, noteOwnerAccount, noteHash, challenge, sender) → {string}
Create an EIP712 ECDSA signature over an AZTEC note, to be used to give permission for note expenditure during a zkAsset confidentialTransfer() method call.
Uses the default format of r, s and v as occupying 32 bytes
Parameters:
| Name | Type | Description |
|---|---|---|
verifyingContract |
string |
address of target contract |
noteOwnerAccount |
string |
Ethereum account (privateKey, publicKey and address) of owner of the note being signed |
noteHash |
string |
hash of the note being signed |
challenge |
string |
hexadecimal representation of the challenge variable |
sender |
string |
address of the transaction sender |
- Source:
(inner) signNotesForConfidentialTransfer(verifyingContract, noteOwnerAccounts, notes, challenge, spender) → {string}
Construct EIP712 ECDSA signatures over an array of notes for use in calling confidentialTransfer()
Parameters:
| Name | Type | Description |
|---|---|---|
verifyingContract |
string |
address of target contract |
noteOwnerAccounts |
Array.<Object> |
Ethereum accounts of the owners of the notes over which signatures are being created. Included in each account is: address, publicKey, privateKey |
notes |
Array.<Object> |
array of notes over which signatures are being constructed |
challenge |
string |
cryptographic challenge, unique identifier for a proof |
spender |
string |
address of the note spender |
- Source:
(inner) signPermit(holderAccount, spender, nonce, expiry, allowed)
Allows a user to create a signature for use in the DAI.permit() function. Creates an EIP712 ECDSA signature
Parameters:
| Name | Type | Description |
|---|---|---|
holderAccount |
Object |
address that owns the tokens, which is approving a spender to spend |
spender |
Address |
address being approved to spend the tokens |
nonce |
Number |
nonce of the transaction. Used for replay protection in the DAI token contract |
expiry |
Number |
unix timestamp corresponding to the upper boundary for when the permit is valid |
allowed |
Bool |
whether approval is being granted or revoked |
- Source:
(inner) signTypedData(schema, domain, message, privateKey) → {Array.<string>}
Create an EIP712 ECDSA signature over structured data. This is a low level function that returns the signature parameters
in an unstructured form - r, s and v are all 32 bytes in size.
Higher level functions such as signNoteForConfidentialApprove() and signNotesForConfidentialTransfer() will then format the signature params as required by the relevant verification procedure.
Parameters:
| Name | Type | Description |
|---|---|---|
schema |
string |
JSON object that defines the structured data of the signature |
domain |
Array.<string> |
variables required for the domain hash part of the signature |
message |
string |
the Ethereum address sending the AZTEC transaction (not necessarily the note signer) |
privateKey |
string |
the private key of message signer |
- Source: