-
Notifications
You must be signed in to change notification settings - Fork 297
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
Showing
18 changed files
with
189 additions
and
46 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
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
53 changes: 53 additions & 0 deletions
53
yarn-project/circuit-types/src/prover_coordination/epoch_proof_quote_hasher.ts
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,53 @@ | ||
import { Buffer32 } from '@aztec/foundation/buffer'; | ||
|
||
import { hashTypedData } from 'viem'; | ||
|
||
import { EpochProofQuotePayload, EthAddress } from './epoch_proof_quote_payload.js'; | ||
|
||
/** | ||
* A utility class to hash EpochProofQuotePayloads following the EIP-712 standard. | ||
*/ | ||
export class EpochProofQuoteHasher { | ||
// Domain information | ||
private readonly domain: { | ||
name: string; | ||
version: string; | ||
chainId: number; | ||
verifyingContract: `0x${string}`; | ||
}; | ||
private readonly types: { | ||
EpochProofQuote: { | ||
name: string; | ||
type: string; | ||
}[]; | ||
}; | ||
|
||
constructor(rollupAddress: EthAddress, chainId: number) { | ||
this.domain = { | ||
name: 'Aztec Rollup', | ||
version: '1', | ||
chainId, | ||
verifyingContract: rollupAddress.toString(), | ||
}; | ||
this.types = { | ||
EpochProofQuote: [ | ||
{ name: 'epochToProve', type: 'uint256' }, | ||
{ name: 'validUntilSlot', type: 'uint256' }, | ||
{ name: 'bondAmount', type: 'uint256' }, | ||
{ name: 'prover', type: 'address' }, | ||
{ name: 'basisPointFee', type: 'uint32' }, | ||
], | ||
}; | ||
} | ||
|
||
hash(payload: EpochProofQuotePayload): Buffer32 { | ||
return Buffer32.fromString( | ||
hashTypedData({ | ||
domain: this.domain, | ||
types: this.types, | ||
primaryType: 'EpochProofQuote', | ||
message: payload.toViemArgs(), | ||
}), | ||
); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from './epoch_proof_quote.js'; | ||
export * from './epoch_proof_quote_hasher.js'; | ||
export * from './epoch_proof_quote_payload.js'; | ||
export * from './epoch_proof_claim.js'; |
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
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
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
Oops, something went wrong.