diff --git a/l1-contracts/src/core/libraries/RollupLibs/ProposeLib.sol b/l1-contracts/src/core/libraries/RollupLibs/ProposeLib.sol index 59b4e10a7a6..5dbc8b27dae 100644 --- a/l1-contracts/src/core/libraries/RollupLibs/ProposeLib.sol +++ b/l1-contracts/src/core/libraries/RollupLibs/ProposeLib.sol @@ -15,6 +15,6 @@ struct ProposeArgs { library ProposeLib { function digest(ProposeArgs memory _args) internal pure returns (bytes32) { - return keccak256(abi.encode(SignatureLib.SignatureDomainSeperator.blockAttestation, _args)); + return keccak256(abi.encode(SignatureLib.SignatureDomainSeparator.blockAttestation, _args)); } } diff --git a/l1-contracts/src/core/libraries/crypto/SignatureLib.sol b/l1-contracts/src/core/libraries/crypto/SignatureLib.sol index 4223f5ddafe..1265adb305f 100644 --- a/l1-contracts/src/core/libraries/crypto/SignatureLib.sol +++ b/l1-contracts/src/core/libraries/crypto/SignatureLib.sol @@ -13,9 +13,9 @@ struct Signature { library SignatureLib { /** - * @notice The domain seperator for the signatures + * @notice The domain separator for the signatures */ - enum SignatureDomainSeperator { + enum SignatureDomainSeparator { blockProposal, blockAttestation } diff --git a/noir-projects/noir-protocol-circuits/.yarn/install-state.gz b/noir-projects/noir-protocol-circuits/.yarn/install-state.gz index 5c46fdd2fed..a46c5f7e9d8 100644 Binary files a/noir-projects/noir-protocol-circuits/.yarn/install-state.gz and b/noir-projects/noir-protocol-circuits/.yarn/install-state.gz differ diff --git a/noir-projects/noir-protocol-circuits/package.json b/noir-projects/noir-protocol-circuits/package.json index 2f5efb48850..0fe327c2d05 100644 --- a/noir-projects/noir-protocol-circuits/package.json +++ b/noir-projects/noir-protocol-circuits/package.json @@ -4,5 +4,6 @@ "main": "index.js", "dependencies": { "@iarna/toml": "^2.2.5" - } + }, + "packageManager": "yarn@4.5.2+sha512.570504f67349ef26d2d86a768dc5ec976ead977aa086b0bb4237e97d5db7ae5c620f9f0e0edf3ea5047205063faff102bf2a2d778664a94eaaa1085ad483fe2e" } diff --git a/yarn-project/archiver/src/archiver/archiver_store_test_suite.ts b/yarn-project/archiver/src/archiver/archiver_store_test_suite.ts index 50730dbb56e..961a9306379 100644 --- a/yarn-project/archiver/src/archiver/archiver_store_test_suite.ts +++ b/yarn-project/archiver/src/archiver/archiver_store_test_suite.ts @@ -223,7 +223,7 @@ export function describeArchiverDataStore(testName: string, getStore: () => Arch }); it('returns undefined if tx is not found', async () => { - await expect(store.getTxEffect(new TxHash(Fr.random().toBuffer()))).resolves.toBeUndefined(); + await expect(store.getTxEffect(TxHash.random())).resolves.toBeUndefined(); }); it.each([ @@ -241,7 +241,7 @@ export function describeArchiverDataStore(testName: string, getStore: () => Arch }); it('returns undefined if tx is not found', async () => { - await expect(store.getTxEffect(new TxHash(Fr.random().toBuffer()))).resolves.toBeUndefined(); + await expect(store.getTxEffect(TxHash.random())).resolves.toBeUndefined(); }); }); @@ -645,7 +645,7 @@ export function describeArchiverDataStore(testName: string, getStore: () => Arch it('"txHash" filter param is ignored when "afterLog" is set', async () => { // Get random txHash - const txHash = new TxHash(randomBytes(TxHash.SIZE)); + const txHash = TxHash.random(); const afterLog = new LogId(1, 0, 0); const response = await store.getUnencryptedLogs({ txHash, afterLog }); diff --git a/yarn-project/aztec.js/src/contract/sent_tx.test.ts b/yarn-project/aztec.js/src/contract/sent_tx.test.ts index c0f7daf8a57..2d03462f19f 100644 --- a/yarn-project/aztec.js/src/contract/sent_tx.test.ts +++ b/yarn-project/aztec.js/src/contract/sent_tx.test.ts @@ -1,4 +1,5 @@ import { type PXE, TxHash, type TxReceipt, TxStatus } from '@aztec/circuit-types'; +import { Fr } from '@aztec/circuits.js'; import { type MockProxy, mock } from 'jest-mock-extended'; @@ -12,7 +13,7 @@ describe('SentTx', () => { beforeEach(() => { pxe = mock(); - txHashPromise = Promise.resolve(TxHash.fromBigInt(1n)); + txHashPromise = Promise.resolve(new TxHash(new Fr(1n))); sentTx = new SentTx(pxe, txHashPromise); }); diff --git a/yarn-project/circuit-types/src/interfaces/archiver.test.ts b/yarn-project/circuit-types/src/interfaces/archiver.test.ts index 4824b95365a..05ad8002117 100644 --- a/yarn-project/circuit-types/src/interfaces/archiver.test.ts +++ b/yarn-project/circuit-types/src/interfaces/archiver.test.ts @@ -100,12 +100,12 @@ describe('ArchiverApiSchema', () => { }); it('getTxEffect', async () => { - const result = await context.client.getTxEffect(new TxHash(Buffer.alloc(32, 1))); + const result = await context.client.getTxEffect(TxHash.fromBuffer(Buffer.alloc(32, 1))); expect(result!.data).toBeInstanceOf(TxEffect); }); it('getSettledTxReceipt', async () => { - const result = await context.client.getSettledTxReceipt(new TxHash(Buffer.alloc(32, 1))); + const result = await context.client.getSettledTxReceipt(TxHash.fromBuffer(Buffer.alloc(32, 1))); expect(result).toBeInstanceOf(TxReceipt); }); diff --git a/yarn-project/circuit-types/src/logs/get_logs_response.ts b/yarn-project/circuit-types/src/logs/get_logs_response.ts index 62b2ff6d833..13aab991d0d 100644 --- a/yarn-project/circuit-types/src/logs/get_logs_response.ts +++ b/yarn-project/circuit-types/src/logs/get_logs_response.ts @@ -73,7 +73,7 @@ export class TxScopedL2Log { static fromBuffer(buffer: Buffer) { const reader = BufferReader.asReader(buffer); return new TxScopedL2Log( - TxHash.fromField(reader.readObject(Fr)), + reader.readObject(TxHash), reader.readNumber(), reader.readNumber(), reader.readBoolean(), diff --git a/yarn-project/circuit-types/src/mocks.ts b/yarn-project/circuit-types/src/mocks.ts index 9909b1e179e..54b55ca1e5d 100644 --- a/yarn-project/circuit-types/src/mocks.ts +++ b/yarn-project/circuit-types/src/mocks.ts @@ -34,7 +34,7 @@ import { PublicExecutionRequest } from './public_execution_request.js'; import { PublicSimulationOutput, Tx, TxHash, TxSimulationResult, accumulatePrivateReturnValues } from './tx/index.js'; import { TxEffect } from './tx_effect.js'; -export const randomTxHash = (): TxHash => new TxHash(randomBytes(32)); +export const randomTxHash = (): TxHash => TxHash.random(); export const mockPrivateExecutionResult = ( seed = 1, diff --git a/yarn-project/circuit-types/src/notes/extended_note.ts b/yarn-project/circuit-types/src/notes/extended_note.ts index cac982b01b8..85c8bda5ed2 100644 --- a/yarn-project/circuit-types/src/notes/extended_note.ts +++ b/yarn-project/circuit-types/src/notes/extended_note.ts @@ -1,7 +1,7 @@ import { AztecAddress, Fr } from '@aztec/circuits.js'; import { NoteSelector } from '@aztec/foundation/abi'; import { schemas } from '@aztec/foundation/schemas'; -import { BufferReader } from '@aztec/foundation/serialize'; +import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize'; import { bufferToHex, hexToBuffer } from '@aztec/foundation/string'; import { z } from 'zod'; @@ -29,25 +29,25 @@ export class ExtendedNote { ) {} toBuffer(): Buffer { - return Buffer.concat([ - this.note.toBuffer(), - this.owner.toBuffer(), - this.contractAddress.toBuffer(), - this.storageSlot.toBuffer(), - this.noteTypeId.toBuffer(), - this.txHash.buffer, + return serializeToBuffer([ + this.note, + this.owner, + this.contractAddress, + this.storageSlot, + this.noteTypeId, + this.txHash, ]); } static fromBuffer(buffer: Buffer | BufferReader) { const reader = BufferReader.asReader(buffer); - const note = Note.fromBuffer(reader); - const owner = AztecAddress.fromBuffer(reader); - const contractAddress = AztecAddress.fromBuffer(reader); - const storageSlot = Fr.fromBuffer(reader); + const note = reader.readObject(Note); + const owner = reader.readObject(AztecAddress); + const contractAddress = reader.readObject(AztecAddress); + const storageSlot = reader.readObject(Fr); const noteTypeId = reader.readObject(NoteSelector); - const txHash = new TxHash(reader.readBytes(TxHash.SIZE)); + const txHash = reader.readObject(TxHash); return new this(note, owner, contractAddress, storageSlot, noteTypeId, txHash); } @@ -124,14 +124,14 @@ export class UniqueNote extends ExtendedNote { } override toBuffer(): Buffer { - return Buffer.concat([ - this.note.toBuffer(), - this.owner.toBuffer(), - this.contractAddress.toBuffer(), - this.storageSlot.toBuffer(), - this.noteTypeId.toBuffer(), - this.txHash.buffer, - this.nonce.toBuffer(), + return serializeToBuffer([ + this.note, + this.owner, + this.contractAddress, + this.storageSlot, + this.noteTypeId, + this.txHash, + this.nonce, ]); } @@ -150,13 +150,13 @@ export class UniqueNote extends ExtendedNote { static override fromBuffer(buffer: Buffer | BufferReader) { const reader = BufferReader.asReader(buffer); - const note = Note.fromBuffer(reader); - const owner = AztecAddress.fromBuffer(reader); - const contractAddress = AztecAddress.fromBuffer(reader); - const storageSlot = Fr.fromBuffer(reader); + const note = reader.readObject(Note); + const owner = reader.readObject(AztecAddress); + const contractAddress = reader.readObject(AztecAddress); + const storageSlot = reader.readObject(Fr); const noteTypeId = reader.readObject(NoteSelector); - const txHash = new TxHash(reader.readBytes(TxHash.SIZE)); - const nonce = Fr.fromBuffer(reader); + const txHash = reader.readObject(TxHash); + const nonce = reader.readObject(Fr); return new this(note, owner, contractAddress, storageSlot, noteTypeId, txHash, nonce); } diff --git a/yarn-project/circuit-types/src/p2p/block_attestation.ts b/yarn-project/circuit-types/src/p2p/block_attestation.ts index 4ac0babe690..d4fea987a54 100644 --- a/yarn-project/circuit-types/src/p2p/block_attestation.ts +++ b/yarn-project/circuit-types/src/p2p/block_attestation.ts @@ -10,7 +10,7 @@ import { z } from 'zod'; import { ConsensusPayload } from './consensus_payload.js'; import { Gossipable } from './gossipable.js'; -import { SignatureDomainSeperator, getHashedSignaturePayloadEthSignedMessage } from './signature_utils.js'; +import { SignatureDomainSeparator, getHashedSignaturePayloadEthSignedMessage } from './signature_utils.js'; import { TopicType, createTopicString } from './topic_type.js'; export class BlockAttestationHash extends Buffer32 { @@ -65,7 +65,7 @@ export class BlockAttestation extends Gossipable { getSender() { if (!this.sender) { // Recover the sender from the attestation - const hashed = getHashedSignaturePayloadEthSignedMessage(this.payload, SignatureDomainSeperator.blockAttestation); + const hashed = getHashedSignaturePayloadEthSignedMessage(this.payload, SignatureDomainSeparator.blockAttestation); // Cache the sender for later use this.sender = recoverAddress(hashed, this.signature); } @@ -74,7 +74,7 @@ export class BlockAttestation extends Gossipable { } getPayload(): Buffer { - return this.payload.getPayloadToSign(SignatureDomainSeperator.blockAttestation); + return this.payload.getPayloadToSign(SignatureDomainSeparator.blockAttestation); } toBuffer(): Buffer { diff --git a/yarn-project/circuit-types/src/p2p/block_proposal.ts b/yarn-project/circuit-types/src/p2p/block_proposal.ts index 207312ba4a1..b65b0870833 100644 --- a/yarn-project/circuit-types/src/p2p/block_proposal.ts +++ b/yarn-project/circuit-types/src/p2p/block_proposal.ts @@ -8,7 +8,7 @@ import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize'; import { ConsensusPayload } from './consensus_payload.js'; import { Gossipable } from './gossipable.js'; import { - SignatureDomainSeperator, + SignatureDomainSeparator, getHashedSignaturePayload, getHashedSignaturePayloadEthSignedMessage, } from './signature_utils.js'; @@ -57,7 +57,7 @@ export class BlockProposal extends Gossipable { payload: ConsensusPayload, payloadSigner: (payload: Buffer32) => Promise, ) { - const hashed = getHashedSignaturePayload(payload, SignatureDomainSeperator.blockProposal); + const hashed = getHashedSignaturePayload(payload, SignatureDomainSeparator.blockProposal); const sig = await payloadSigner(hashed); return new BlockProposal(payload, sig); @@ -68,7 +68,7 @@ export class BlockProposal extends Gossipable { */ getSender() { if (!this.sender) { - const hashed = getHashedSignaturePayloadEthSignedMessage(this.payload, SignatureDomainSeperator.blockProposal); + const hashed = getHashedSignaturePayloadEthSignedMessage(this.payload, SignatureDomainSeparator.blockProposal); // Cache the sender for later use this.sender = recoverAddress(hashed, this.signature); } @@ -77,7 +77,7 @@ export class BlockProposal extends Gossipable { } getPayload() { - return this.payload.getPayloadToSign(SignatureDomainSeperator.blockProposal); + return this.payload.getPayloadToSign(SignatureDomainSeparator.blockProposal); } toBuffer(): Buffer { diff --git a/yarn-project/circuit-types/src/p2p/consensus_payload.ts b/yarn-project/circuit-types/src/p2p/consensus_payload.ts index 37fedc508da..b1e72369013 100644 --- a/yarn-project/circuit-types/src/p2p/consensus_payload.ts +++ b/yarn-project/circuit-types/src/p2p/consensus_payload.ts @@ -8,7 +8,7 @@ import { encodeAbiParameters, parseAbiParameters } from 'viem'; import { z } from 'zod'; import { TxHash } from '../tx/tx_hash.js'; -import { type Signable, type SignatureDomainSeperator } from './signature_utils.js'; +import { type Signable, type SignatureDomainSeparator } from './signature_utils.js'; export class ConsensusPayload implements Signable { private size: number | undefined; @@ -36,11 +36,11 @@ export class ConsensusPayload implements Signable { return [fields.header, fields.archive, fields.txHashes] as const; } - getPayloadToSign(domainSeperator: SignatureDomainSeperator): Buffer { + getPayloadToSign(domainSeparator: SignatureDomainSeparator): Buffer { const abi = parseAbiParameters('uint8, (bytes32, bytes32, (uint256, uint256), bytes, bytes32[])'); const txArray = this.txHashes.map(tx => tx.toString()); const encodedData = encodeAbiParameters(abi, [ - domainSeperator, + domainSeparator, [ this.archive.toString(), this.header.hash().toString(), diff --git a/yarn-project/circuit-types/src/p2p/mocks.ts b/yarn-project/circuit-types/src/p2p/mocks.ts index 1e4e99ac042..8896980843b 100644 --- a/yarn-project/circuit-types/src/p2p/mocks.ts +++ b/yarn-project/circuit-types/src/p2p/mocks.ts @@ -7,7 +7,7 @@ import { TxHash } from '../tx/tx_hash.js'; import { BlockAttestation } from './block_attestation.js'; import { BlockProposal } from './block_proposal.js'; import { ConsensusPayload } from './consensus_payload.js'; -import { SignatureDomainSeperator, getHashedSignaturePayloadEthSignedMessage } from './signature_utils.js'; +import { SignatureDomainSeparator, getHashedSignaturePayloadEthSignedMessage } from './signature_utils.js'; export interface MakeConsensusPayloadOptions { signer?: Secp256k1Signer; @@ -17,7 +17,7 @@ export interface MakeConsensusPayloadOptions { } const makeAndSignConsensusPayload = ( - domainSeperator: SignatureDomainSeperator, + domainSeparator: SignatureDomainSeparator, options?: MakeConsensusPayloadOptions, ) => { const { @@ -33,19 +33,19 @@ const makeAndSignConsensusPayload = ( txHashes, }); - const hash = getHashedSignaturePayloadEthSignedMessage(payload, domainSeperator); + const hash = getHashedSignaturePayloadEthSignedMessage(payload, domainSeparator); const signature = signer.sign(hash); return { payload, signature }; }; export const makeBlockProposal = (options?: MakeConsensusPayloadOptions): BlockProposal => { - const { payload, signature } = makeAndSignConsensusPayload(SignatureDomainSeperator.blockProposal, options); + const { payload, signature } = makeAndSignConsensusPayload(SignatureDomainSeparator.blockProposal, options); return new BlockProposal(payload, signature); }; // TODO(https://github.com/AztecProtocol/aztec-packages/issues/8028) export const makeBlockAttestation = (options?: MakeConsensusPayloadOptions): BlockAttestation => { - const { payload, signature } = makeAndSignConsensusPayload(SignatureDomainSeperator.blockAttestation, options); + const { payload, signature } = makeAndSignConsensusPayload(SignatureDomainSeparator.blockAttestation, options); return new BlockAttestation(payload, signature); }; diff --git a/yarn-project/circuit-types/src/p2p/signature_utils.ts b/yarn-project/circuit-types/src/p2p/signature_utils.ts index 25e20ded5d8..4c05ccb3823 100644 --- a/yarn-project/circuit-types/src/p2p/signature_utils.ts +++ b/yarn-project/circuit-types/src/p2p/signature_utils.ts @@ -1,13 +1,13 @@ import { Buffer32 } from '@aztec/foundation/buffer'; import { keccak256, makeEthSignDigest } from '@aztec/foundation/crypto'; -export enum SignatureDomainSeperator { +export enum SignatureDomainSeparator { blockProposal = 0, blockAttestation = 1, } export interface Signable { - getPayloadToSign(domainSeperator: SignatureDomainSeperator): Buffer; + getPayloadToSign(domainSeparator: SignatureDomainSeparator): Buffer; } /** @@ -15,8 +15,8 @@ export interface Signable { * @param s - The `Signable` to sign * @returns The hashed payload for the signature of the `Signable` */ -export function getHashedSignaturePayload(s: Signable, domainSeperator: SignatureDomainSeperator): Buffer32 { - return Buffer32.fromBuffer(keccak256(s.getPayloadToSign(domainSeperator))); +export function getHashedSignaturePayload(s: Signable, domainSeparator: SignatureDomainSeparator): Buffer32 { + return Buffer32.fromBuffer(keccak256(s.getPayloadToSign(domainSeparator))); } /** @@ -26,8 +26,8 @@ export function getHashedSignaturePayload(s: Signable, domainSeperator: Signatur */ export function getHashedSignaturePayloadEthSignedMessage( s: Signable, - domainSeperator: SignatureDomainSeperator, + domainSeparator: SignatureDomainSeparator, ): Buffer32 { - const payload = getHashedSignaturePayload(s, domainSeperator); + const payload = getHashedSignaturePayload(s, domainSeparator); return makeEthSignDigest(payload); } diff --git a/yarn-project/circuit-types/src/tx/processed_tx.ts b/yarn-project/circuit-types/src/tx/processed_tx.ts index ddbc926647c..b9c4c465333 100644 --- a/yarn-project/circuit-types/src/tx/processed_tx.ts +++ b/yarn-project/circuit-types/src/tx/processed_tx.ts @@ -103,7 +103,7 @@ export function makeEmptyProcessedTx( clientProofOutput.constants = constants; return { - hash: new TxHash(Fr.ZERO.toBuffer()), + hash: new TxHash(Fr.ZERO), data: clientProofOutput, clientIvcProof: ClientIvcProof.empty(), avmProvingRequest: undefined, diff --git a/yarn-project/circuit-types/src/tx/tx.ts b/yarn-project/circuit-types/src/tx/tx.ts index 1e8a03107d1..4f95a81af7b 100644 --- a/yarn-project/circuit-types/src/tx/tx.ts +++ b/yarn-project/circuit-types/src/tx/tx.ts @@ -4,7 +4,7 @@ import { type PrivateToPublicAccumulatedData, type ScopedLogHash, } from '@aztec/circuits.js'; -import { type Buffer32 } from '@aztec/foundation/buffer'; +import { Buffer32 } from '@aztec/foundation/buffer'; import { arraySerializedSizeOfNonEmpty } from '@aztec/foundation/collection'; import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize'; import { type FieldsOf } from '@aztec/foundation/types'; @@ -65,7 +65,7 @@ export class Tx extends Gossipable { // Gossipable method override p2pMessageIdentifier(): Buffer32 { - return this.getTxHash(); + return new Buffer32(this.getTxHash().toBuffer()); } hasPublicCalls() { @@ -176,7 +176,7 @@ export class Tx extends Gossipable { if (!firstNullifier || firstNullifier.isZero()) { throw new Error(`Cannot get tx hash since first nullifier is missing`); } - return new TxHash(firstNullifier.toBuffer()); + return new TxHash(firstNullifier); } /** Returns the tx hash, or undefined if none is set. */ diff --git a/yarn-project/circuit-types/src/tx/tx_hash.ts b/yarn-project/circuit-types/src/tx/tx_hash.ts index f2477823ab2..98a3c6ed8d2 100644 --- a/yarn-project/circuit-types/src/tx/tx_hash.ts +++ b/yarn-project/circuit-types/src/tx/tx_hash.ts @@ -1,32 +1,62 @@ import { Fr } from '@aztec/circuits.js'; -import { Buffer32 } from '@aztec/foundation/buffer'; import { schemas } from '@aztec/foundation/schemas'; +import { BufferReader } from '@aztec/foundation/serialize'; /** * A class representing hash of Aztec transaction. */ -export class TxHash extends Buffer32 { +export class TxHash { constructor( - /** The buffer containing the hash. */ - hash: Buffer, - ) { - super(hash); - } + /** A field representing the tx hash (tx hash is an output of poseidon hash hence it's a field). */ + public readonly hash: Fr, + ) {} /* * TxHashes are generated from the first nullifier of a transaction, which is a Fr. - * Using Buffer32.random() could potentially generate invalid TxHashes. * @returns A random TxHash. */ - static override random() { - return new TxHash(Fr.random().toBuffer()); + static random() { + return new TxHash(Fr.random()); + } + + static fromBuffer(buffer: Uint8Array | BufferReader) { + const reader = BufferReader.asReader(buffer); + return new this(reader.readObject(Fr)); + } + + static fromString(str: string) { + return new TxHash(Fr.fromString(str)); + } + + static fromBigInt(value: bigint) { + return new TxHash(new Fr(value)); + } + + public toBuffer() { + return this.hash.toBuffer(); + } + + public toString() { + return this.hash.toString(); + } + + public toBigInt() { + return this.hash.toBigInt(); + } + + public equals(other: TxHash) { + return this.hash.equals(other.hash); } static get schema() { - return schemas.BufferHex.transform(value => new TxHash(value)); + return schemas.Fr.transform(value => new TxHash(value)); } static zero() { - return new TxHash(Buffer32.ZERO.toBuffer()); + return new TxHash(Fr.ZERO); + } + + static get SIZE() { + return Fr.SIZE_IN_BYTES; } } diff --git a/yarn-project/circuit-types/src/tx_effect.ts b/yarn-project/circuit-types/src/tx_effect.ts index 924f2e5bc95..d0ae676ad39 100644 --- a/yarn-project/circuit-types/src/tx_effect.ts +++ b/yarn-project/circuit-types/src/tx_effect.ts @@ -550,6 +550,6 @@ export class TxEffect { } get txHash(): TxHash { - return new TxHash(this.nullifiers[0].toBuffer()); + return new TxHash(this.nullifiers[0]); } } diff --git a/yarn-project/end-to-end/src/e2e_p2p/reex.test.ts b/yarn-project/end-to-end/src/e2e_p2p/reex.test.ts index be5475755c0..b91d154f1dc 100644 --- a/yarn-project/end-to-end/src/e2e_p2p/reex.test.ts +++ b/yarn-project/end-to-end/src/e2e_p2p/reex.test.ts @@ -2,7 +2,7 @@ import { type AztecNodeService } from '@aztec/aztec-node'; import { type SentTx, sleep } from '@aztec/aztec.js'; /* eslint-disable-next-line no-restricted-imports */ -import { BlockProposal, SignatureDomainSeperator, getHashedSignaturePayload } from '@aztec/circuit-types'; +import { BlockProposal, SignatureDomainSeparator, getHashedSignaturePayload } from '@aztec/circuit-types'; import { beforeAll, describe, it, jest } from '@jest/globals'; import fs from 'fs'; @@ -92,7 +92,7 @@ describe('e2e_p2p_reex', () => { const signer = (node as any).sequencer.sequencer.validatorClient.validationService.keyStore; const newProposal = new BlockProposal( proposal.payload, - await signer.signMessage(getHashedSignaturePayload(proposal.payload, SignatureDomainSeperator.blockProposal)), + await signer.signMessage(getHashedSignaturePayload(proposal.payload, SignatureDomainSeparator.blockProposal)), ); return (node as any).p2pClient.p2pService.propagate(newProposal); diff --git a/yarn-project/p2p/src/mem_pools/attestation_pool/mocks.ts b/yarn-project/p2p/src/mem_pools/attestation_pool/mocks.ts index 8a1b60a9ffd..7cbf84dfcbe 100644 --- a/yarn-project/p2p/src/mem_pools/attestation_pool/mocks.ts +++ b/yarn-project/p2p/src/mem_pools/attestation_pool/mocks.ts @@ -1,7 +1,7 @@ import { BlockAttestation, ConsensusPayload, - SignatureDomainSeperator, + SignatureDomainSeparator, TxHash, getHashedSignaturePayloadEthSignedMessage, } from '@aztec/circuit-types'; @@ -37,7 +37,7 @@ export const mockAttestation = ( const header = makeHeader(1, 2, slot); const payload = new ConsensusPayload(header, archive, txs); - const hash = getHashedSignaturePayloadEthSignedMessage(payload, SignatureDomainSeperator.blockAttestation); + const hash = getHashedSignaturePayloadEthSignedMessage(payload, SignatureDomainSeparator.blockAttestation); const signature = signer.sign(hash); return new BlockAttestation(payload, signature); diff --git a/yarn-project/prover-client/src/block_builder/light.ts b/yarn-project/prover-client/src/block_builder/light.ts index e56986b839a..39d5b7a2185 100644 --- a/yarn-project/prover-client/src/block_builder/light.ts +++ b/yarn-project/prover-client/src/block_builder/light.ts @@ -4,6 +4,7 @@ import { MerkleTreeId, type MerkleTreeWriteOperations, type ProcessedTx, + TxHash, makeEmptyProcessedTx, toNumBlobFields, } from '@aztec/circuit-types'; @@ -53,7 +54,7 @@ export class LightweightBlockBuilder implements BlockBuilder { this.numTxs = Math.max(2, txs.length); this.spongeBlobState = SpongeBlob.init(toNumBlobFields(txs)); for (const tx of txs) { - this.logger.debug(tx.hash.isZero() ? 'Adding padding tx to block' : 'Adding new tx to block', { + this.logger.debug(tx.hash.equals(TxHash.zero()) ? 'Adding padding tx to block' : 'Adding new tx to block', { txHash: tx.hash.toString(), }); this.txs.push(tx); diff --git a/yarn-project/pxe/src/database/incoming_note_dao.ts b/yarn-project/pxe/src/database/incoming_note_dao.ts index d4c4192c3a5..93464386ec9 100644 --- a/yarn-project/pxe/src/database/incoming_note_dao.ts +++ b/yarn-project/pxe/src/database/incoming_note_dao.ts @@ -76,7 +76,7 @@ export class IncomingNoteDao implements NoteData { this.contractAddress, this.storageSlot, this.noteTypeId, - this.txHash.buffer, + this.txHash, this.l2BlockNumber, Fr.fromHexString(this.l2BlockHash), this.nonce, diff --git a/yarn-project/pxe/src/database/outgoing_note_dao.ts b/yarn-project/pxe/src/database/outgoing_note_dao.ts index 211c66cea7b..50fae33c524 100644 --- a/yarn-project/pxe/src/database/outgoing_note_dao.ts +++ b/yarn-project/pxe/src/database/outgoing_note_dao.ts @@ -69,7 +69,7 @@ export class OutgoingNoteDao { this.contractAddress, this.storageSlot, this.noteTypeId, - this.txHash.buffer, + this.txHash, this.l2BlockNumber, Fr.fromHexString(this.l2BlockHash), this.nonce, @@ -85,7 +85,7 @@ export class OutgoingNoteDao { const contractAddress = AztecAddress.fromBuffer(reader); const storageSlot = Fr.fromBuffer(reader); const noteTypeId = reader.readObject(NoteSelector); - const txHash = new TxHash(reader.readBytes(TxHash.SIZE)); + const txHash = reader.readObject(TxHash); const l2BlockNumber = reader.readNumber(); const l2BlockHash = Fr.fromBuffer(reader).toString(); const nonce = Fr.fromBuffer(reader); diff --git a/yarn-project/sequencer-client/src/publisher/l1-publisher.ts b/yarn-project/sequencer-client/src/publisher/l1-publisher.ts index 3642f039874..3cb77697008 100644 --- a/yarn-project/sequencer-client/src/publisher/l1-publisher.ts +++ b/yarn-project/sequencer-client/src/publisher/l1-publisher.ts @@ -3,7 +3,7 @@ import { type EpochProofClaim, type EpochProofQuote, type L2Block, - SignatureDomainSeperator, + SignatureDomainSeparator, type TxHash, getHashedSignaturePayload, } from '@aztec/circuit-types'; @@ -534,7 +534,7 @@ export class L1Publisher { const consensusPayload = new ConsensusPayload(block.header, block.archive.root, txHashes ?? []); - const digest = getHashedSignaturePayload(consensusPayload, SignatureDomainSeperator.blockAttestation); + const digest = getHashedSignaturePayload(consensusPayload, SignatureDomainSeparator.blockAttestation); const proposeTxArgs = { header: block.header.toBuffer(), archive: block.archive.root.toBuffer(), diff --git a/yarn-project/simulator/src/avm/fixtures/index.ts b/yarn-project/simulator/src/avm/fixtures/index.ts index fce5fb7eff4..7990a0b2c3b 100644 --- a/yarn-project/simulator/src/avm/fixtures/index.ts +++ b/yarn-project/simulator/src/avm/fixtures/index.ts @@ -55,7 +55,7 @@ export function initPersistableStateManager(overrides?: { overrides?.nullifiers || new NullifierManager(worldStateDB), overrides?.doMerkleOperations || false, overrides?.merkleTrees || mock(), - overrides?.txHash || new TxHash(new Fr(27).toBuffer()), + overrides?.txHash || new TxHash(new Fr(27)), ); } diff --git a/yarn-project/simulator/src/public/public_tx_context.ts b/yarn-project/simulator/src/public/public_tx_context.ts index 62dab19d16e..0c376934a20 100644 --- a/yarn-project/simulator/src/public/public_tx_context.ts +++ b/yarn-project/simulator/src/public/public_tx_context.ts @@ -459,5 +459,5 @@ function fetchTxHash(nonRevertibleAccumulatedData: PrivateToPublicAccumulatedDat if (!firstNullifier || firstNullifier.isZero()) { throw new Error(`Cannot get tx hash since first nullifier is missing`); } - return new TxHash(firstNullifier.toBuffer()); + return new TxHash(firstNullifier); } diff --git a/yarn-project/txe/src/node/txe_node.ts b/yarn-project/txe/src/node/txe_node.ts index a5c8570be2f..8a5bbe90def 100644 --- a/yarn-project/txe/src/node/txe_node.ts +++ b/yarn-project/txe/src/node/txe_node.ts @@ -149,7 +149,7 @@ export class TXENode implements AztecNode { const tag = log.fields[0]; const currentLogs = this.#logsByTags.get(tag.toString()) ?? []; const scopedLog = new TxScopedL2Log( - new TxHash(new Fr(blockNumber).toBuffer()), + new TxHash(new Fr(blockNumber)), this.#noteIndex, blockNumber, false, @@ -193,7 +193,7 @@ export class TXENode implements AztecNode { const currentLogs = this.#logsByTags.get(tag.toString()) ?? []; const scopedLog = new TxScopedL2Log( - new TxHash(new Fr(blockNumber).toBuffer()), + new TxHash(new Fr(blockNumber)), this.#noteIndex, blockNumber, true, diff --git a/yarn-project/txe/src/oracle/txe_oracle.ts b/yarn-project/txe/src/oracle/txe_oracle.ts index ec4c7818525..608263ea150 100644 --- a/yarn-project/txe/src/oracle/txe_oracle.ts +++ b/yarn-project/txe/src/oracle/txe_oracle.ts @@ -649,7 +649,7 @@ export class TXE implements TypedOracle { // index = await (await this.trees.getLatest()).findLeafIndex(MerkleTreeId.NULLIFIER_TREE, Fr.random().toBuffer()); // console.log('INDEX OF RANDOM', index); - this.node.setTxEffect(blockNumber, new TxHash(new Fr(blockNumber).toBuffer()), txEffect); + this.node.setTxEffect(blockNumber, new TxHash(new Fr(blockNumber)), txEffect); this.node.setNullifiersIndexesWithBlock(blockNumber, txEffect.nullifiers); this.node.addNoteLogsByTags(this.blockNumber, this.privateLogs); this.node.addPublicLogsByTags(this.blockNumber, this.publicLogs); diff --git a/yarn-project/validator-client/src/duties/validation_service.ts b/yarn-project/validator-client/src/duties/validation_service.ts index e79fe5fa8c1..0772063a1f3 100644 --- a/yarn-project/validator-client/src/duties/validation_service.ts +++ b/yarn-project/validator-client/src/duties/validation_service.ts @@ -2,7 +2,7 @@ import { BlockAttestation, BlockProposal, ConsensusPayload, - SignatureDomainSeperator, + SignatureDomainSeparator, type TxHash, } from '@aztec/circuit-types'; import { type BlockHeader } from '@aztec/circuits.js'; @@ -43,7 +43,7 @@ export class ValidationService { // TODO(https://github.com/AztecProtocol/aztec-packages/issues/7961): check that the current validator is correct const buf = Buffer32.fromBuffer( - keccak256(proposal.payload.getPayloadToSign(SignatureDomainSeperator.blockAttestation)), + keccak256(proposal.payload.getPayloadToSign(SignatureDomainSeparator.blockAttestation)), ); const sig = await this.keyStore.signMessage(buf); return new BlockAttestation(proposal.payload, sig);