@aztec/stdlib 3.0.0-nightly.20251114 → 3.0.0-nightly.20251118

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/dest/avm/avm.d.ts +139 -45
  2. package/dest/avm/avm.d.ts.map +1 -1
  3. package/dest/avm/avm.js +58 -19
  4. package/dest/avm/avm_proving_request.d.ts +21 -21
  5. package/dest/avm/public_data_write.d.ts +1 -1
  6. package/dest/avm/public_data_write.d.ts.map +1 -1
  7. package/dest/avm/revert_code.d.ts +2 -1
  8. package/dest/avm/revert_code.d.ts.map +1 -1
  9. package/dest/avm/revert_code.js +8 -8
  10. package/dest/block/body.d.ts +3 -6
  11. package/dest/block/body.d.ts.map +1 -1
  12. package/dest/block/body.js +6 -25
  13. package/dest/block/index.d.ts +1 -0
  14. package/dest/block/index.d.ts.map +1 -1
  15. package/dest/block/index.js +1 -0
  16. package/dest/block/l2_block.d.ts +5 -0
  17. package/dest/block/l2_block.d.ts.map +1 -1
  18. package/dest/block/l2_block.js +34 -4
  19. package/dest/block/l2_block_new.d.ts +97 -0
  20. package/dest/block/l2_block_new.d.ts.map +1 -0
  21. package/dest/block/l2_block_new.js +113 -0
  22. package/dest/checkpoint/checkpoint.d.ts +108 -0
  23. package/dest/checkpoint/checkpoint.d.ts.map +1 -0
  24. package/dest/checkpoint/checkpoint.js +39 -0
  25. package/dest/checkpoint/index.d.ts +1 -1
  26. package/dest/checkpoint/index.d.ts.map +1 -1
  27. package/dest/checkpoint/index.js +1 -1
  28. package/dest/interfaces/proving-job.d.ts +21 -21
  29. package/dest/logs/private_log.d.ts +1 -1
  30. package/dest/logs/private_log.d.ts.map +1 -1
  31. package/dest/logs/private_log.js +2 -5
  32. package/dest/messaging/in_hash.d.ts +4 -0
  33. package/dest/messaging/in_hash.d.ts.map +1 -0
  34. package/dest/messaging/in_hash.js +15 -0
  35. package/dest/messaging/index.d.ts +2 -0
  36. package/dest/messaging/index.d.ts.map +1 -1
  37. package/dest/messaging/index.js +2 -0
  38. package/dest/messaging/out_hash.d.ts +5 -0
  39. package/dest/messaging/out_hash.d.ts.map +1 -0
  40. package/dest/messaging/out_hash.js +28 -0
  41. package/dest/rollup/checkpoint_constant_data.d.ts +16 -0
  42. package/dest/rollup/checkpoint_constant_data.d.ts.map +1 -1
  43. package/dest/rollup/checkpoint_constant_data.js +17 -0
  44. package/dest/tests/factories.d.ts +21 -25
  45. package/dest/tests/factories.d.ts.map +1 -1
  46. package/dest/tests/factories.js +24 -121
  47. package/dest/tests/mocks.d.ts +17 -1
  48. package/dest/tests/mocks.d.ts.map +1 -1
  49. package/dest/tests/mocks.js +108 -4
  50. package/dest/tx/partial_state_reference.d.ts +3 -0
  51. package/dest/tx/partial_state_reference.d.ts.map +1 -1
  52. package/dest/tx/partial_state_reference.js +10 -0
  53. package/dest/tx/state_reference.d.ts +3 -0
  54. package/dest/tx/state_reference.d.ts.map +1 -1
  55. package/dest/tx/state_reference.js +9 -0
  56. package/dest/tx/tx_effect.d.ts +9 -6
  57. package/dest/tx/tx_effect.d.ts.map +1 -1
  58. package/dest/tx/tx_effect.js +53 -57
  59. package/dest/vks/verification_key.d.ts +9 -0
  60. package/dest/vks/verification_key.d.ts.map +1 -1
  61. package/dest/vks/verification_key.js +20 -0
  62. package/package.json +8 -8
  63. package/src/avm/avm.ts +66 -28
  64. package/src/avm/public_data_write.ts +1 -1
  65. package/src/avm/revert_code.ts +9 -8
  66. package/src/block/body.ts +7 -32
  67. package/src/block/index.ts +1 -0
  68. package/src/block/l2_block.ts +33 -2
  69. package/src/block/l2_block_new.ts +143 -0
  70. package/src/checkpoint/checkpoint.ts +46 -0
  71. package/src/checkpoint/index.ts +1 -1
  72. package/src/logs/private_log.ts +2 -3
  73. package/src/messaging/in_hash.ts +15 -0
  74. package/src/messaging/index.ts +2 -0
  75. package/src/messaging/out_hash.ts +36 -0
  76. package/src/rollup/checkpoint_constant_data.ts +20 -0
  77. package/src/tests/factories.ts +109 -211
  78. package/src/tests/mocks.ts +196 -4
  79. package/src/tx/partial_state_reference.ts +9 -0
  80. package/src/tx/state_reference.ts +9 -0
  81. package/src/tx/tx_effect.ts +61 -67
  82. package/src/vks/verification_key.ts +25 -0
  83. package/dest/checkpoint/checkpoint_body.d.ts +0 -4
  84. package/dest/checkpoint/checkpoint_body.d.ts.map +0 -1
  85. package/dest/checkpoint/checkpoint_body.js +0 -9
  86. package/src/checkpoint/checkpoint_body.ts +0 -10
@@ -1,8 +1,12 @@
1
- import { MAX_ENQUEUED_CALLS_PER_TX, MAX_INCLUDE_BY_TIMESTAMP_DURATION } from '@aztec/constants';
1
+ import { FIXED_DA_GAS, FIXED_L2_GAS, MAX_ENQUEUED_CALLS_PER_TX, MAX_INCLUDE_BY_TIMESTAMP_DURATION, MAX_NULLIFIERS_PER_TX, MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX } from '@aztec/constants';
2
+ import { makeTuple } from '@aztec/foundation/array';
2
3
  import { Buffer32 } from '@aztec/foundation/buffer';
3
- import { times } from '@aztec/foundation/collection';
4
+ import { padArrayEnd, times } from '@aztec/foundation/collection';
4
5
  import { Secp256k1Signer, randomBytes } from '@aztec/foundation/crypto';
5
6
  import { Fr } from '@aztec/foundation/fields';
7
+ import { AvmCircuitPublicInputs } from '../avm/avm_circuit_public_inputs.js';
8
+ import { PublicDataWrite } from '../avm/public_data_write.js';
9
+ import { RevertCode } from '../avm/revert_code.js';
6
10
  import { AztecAddress } from '../aztec-address/index.js';
7
11
  import { CommitteeAttestation, L1PublishedData } from '../block/index.js';
8
12
  import { L2Block } from '../block/l2_block.js';
@@ -10,13 +14,16 @@ import { PublishedL2Block } from '../block/published_l2_block.js';
10
14
  import { computeContractAddressFromInstance } from '../contract/contract_address.js';
11
15
  import { getContractClassFromArtifact } from '../contract/contract_class.js';
12
16
  import { SerializableContractInstance } from '../contract/contract_instance.js';
17
+ import { computeEffectiveGasFees } from '../fees/transaction_fee.js';
13
18
  import { Gas } from '../gas/gas.js';
14
19
  import { GasFees } from '../gas/gas_fees.js';
15
20
  import { GasSettings } from '../gas/gas_settings.js';
16
21
  import { Nullifier } from '../kernel/nullifier.js';
17
22
  import { PrivateCircuitPublicInputs } from '../kernel/private_circuit_public_inputs.js';
18
23
  import { PartialPrivateTailPublicInputsForPublic, PrivateKernelTailCircuitPublicInputs } from '../kernel/private_kernel_tail_circuit_public_inputs.js';
24
+ import { PrivateToAvmAccumulatedData } from '../kernel/private_to_avm_accumulated_data.js';
19
25
  import { PrivateToPublicAccumulatedDataBuilder } from '../kernel/private_to_public_accumulated_data_builder.js';
26
+ import { PublicCallRequestArrayLengths } from '../kernel/public_call_request.js';
20
27
  import { Note } from '../note/note.js';
21
28
  import { UniqueNote } from '../note/unique_note.js';
22
29
  import { BlockAttestation } from '../p2p/block_attestation.js';
@@ -24,12 +31,14 @@ import { BlockProposal } from '../p2p/block_proposal.js';
24
31
  import { ConsensusPayload } from '../p2p/consensus_payload.js';
25
32
  import { SignatureDomainSeparator, getHashedSignaturePayloadEthSignedMessage } from '../p2p/signature_utils.js';
26
33
  import { ChonkProof } from '../proofs/chonk_proof.js';
27
- import { HashedValues, PrivateCallExecutionResult, PrivateExecutionResult, Tx } from '../tx/index.js';
34
+ import { ProvingRequestType } from '../proofs/proving_request_type.js';
35
+ import { AppendOnlyTreeSnapshot } from '../trees/append_only_tree_snapshot.js';
36
+ import { GlobalVariables, HashedValues, PrivateCallExecutionResult, PrivateExecutionResult, Tx, TxConstantData, makeProcessedTxFromPrivateOnlyTx, makeProcessedTxFromTxWithPublicCalls } from '../tx/index.js';
28
37
  import { NestedProcessReturnValues, PublicSimulationOutput } from '../tx/public_simulation_output.js';
29
38
  import { TxSimulationResult } from '../tx/simulated_tx.js';
30
39
  import { TxEffect } from '../tx/tx_effect.js';
31
40
  import { TxHash } from '../tx/tx_hash.js';
32
- import { makeGas, makeGlobalVariables, makeL2BlockHeader, makePublicCallRequest } from './factories.js';
41
+ import { makeAvmCircuitInputs, makeAztecAddress, makeGas, makeGlobalVariables, makeHeader, makeL2BlockHeader, makePrivateToPublicAccumulatedData, makePrivateToRollupAccumulatedData, makeProtocolContracts, makePublicCallRequest, makePublicDataWrite } from './factories.js';
33
42
  export const randomTxHash = ()=>TxHash.random();
34
43
  export const randomUniqueNote = async ({ note = Note.random(), recipient = undefined, contractAddress = undefined, txHash = randomTxHash(), storageSlot = Fr.random(), noteNonce = Fr.random() } = {})=>{
35
44
  return new UniqueNote(note, recipient ?? await AztecAddress.random(), contractAddress ?? await AztecAddress.random(), storageSlot, txHash, noteNonce);
@@ -88,6 +97,101 @@ export const mockTxForRollup = (seed = 1, opts = {})=>mockTx(seed, {
88
97
  numberOfNonRevertiblePublicCallRequests: 0,
89
98
  numberOfRevertiblePublicCallRequests: 0
90
99
  });
100
+ /** Mock a processed tx for testing purposes. */ export async function mockProcessedTx({ seed = 1, anchorBlockHeader, db, chainId = Fr.ZERO, version = Fr.ZERO, gasSettings = GasSettings.default({
101
+ maxFeesPerGas: new GasFees(10, 10)
102
+ }), vkTreeRoot = Fr.ZERO, protocolContracts = makeProtocolContracts(seed + 0x100), globalVariables = GlobalVariables.empty(), newL1ToL2Snapshot = AppendOnlyTreeSnapshot.empty(), feePayer, feePaymentPublicDataWrite, // The default gasUsed is the tx overhead.
103
+ gasUsed = Gas.from({
104
+ daGas: FIXED_DA_GAS,
105
+ l2Gas: FIXED_L2_GAS
106
+ }), privateOnly = false, ...mockTxOpts } = {}) {
107
+ seed *= 0x1000; // Avoid clashing with the previous mock values if seed only increases by 1.
108
+ anchorBlockHeader ??= db?.getInitialHeader() ?? makeHeader(seed);
109
+ feePayer ??= makeAztecAddress(seed + 0x100);
110
+ feePaymentPublicDataWrite ??= makePublicDataWrite(seed + 0x200);
111
+ const txConstantData = TxConstantData.empty();
112
+ txConstantData.anchorBlockHeader = anchorBlockHeader;
113
+ txConstantData.txContext.chainId = chainId;
114
+ txConstantData.txContext.version = version;
115
+ txConstantData.txContext.gasSettings = gasSettings;
116
+ txConstantData.vkTreeRoot = vkTreeRoot;
117
+ txConstantData.protocolContractsHash = await protocolContracts.hash();
118
+ const tx = !privateOnly ? await mockTx(seed, {
119
+ feePayer,
120
+ gasUsed,
121
+ ...mockTxOpts
122
+ }) : await mockTx(seed, {
123
+ numberOfNonRevertiblePublicCallRequests: 0,
124
+ numberOfRevertiblePublicCallRequests: 0,
125
+ feePayer,
126
+ gasUsed,
127
+ ...mockTxOpts
128
+ });
129
+ tx.data.constants = txConstantData;
130
+ const transactionFee = tx.data.gasUsed.computeFee(globalVariables.gasFees);
131
+ if (privateOnly) {
132
+ const data = makePrivateToRollupAccumulatedData(seed + 0x1000, {
133
+ numContractClassLogs: 0
134
+ });
135
+ tx.data.forRollup.end = data;
136
+ await tx.recomputeHash();
137
+ return makeProcessedTxFromPrivateOnlyTx(tx, transactionFee, feePaymentPublicDataWrite, globalVariables);
138
+ } else {
139
+ const dataFromPrivate = tx.data.forPublic;
140
+ const nonRevertibleData = dataFromPrivate.nonRevertibleAccumulatedData;
141
+ // Create revertible data.
142
+ const revertibleData = makePrivateToPublicAccumulatedData(seed + 0x1000, {
143
+ numContractClassLogs: 0
144
+ });
145
+ revertibleData.nullifiers[MAX_NULLIFIERS_PER_TX - 1] = Fr.ZERO; // Leave one space for the tx hash nullifier in nonRevertibleAccumulatedData.
146
+ dataFromPrivate.revertibleAccumulatedData = revertibleData;
147
+ // Create avm output.
148
+ const avmOutput = AvmCircuitPublicInputs.empty();
149
+ // Assign data from hints.
150
+ avmOutput.protocolContracts = protocolContracts;
151
+ avmOutput.startTreeSnapshots.l1ToL2MessageTree = newL1ToL2Snapshot;
152
+ avmOutput.endTreeSnapshots.l1ToL2MessageTree = newL1ToL2Snapshot;
153
+ avmOutput.effectiveGasFees = computeEffectiveGasFees(globalVariables.gasFees, gasSettings);
154
+ // Assign data from private.
155
+ avmOutput.globalVariables = globalVariables;
156
+ avmOutput.startGasUsed = tx.data.gasUsed;
157
+ avmOutput.gasSettings = gasSettings;
158
+ avmOutput.feePayer = feePayer;
159
+ avmOutput.publicCallRequestArrayLengths = new PublicCallRequestArrayLengths(tx.data.numberOfNonRevertiblePublicCallRequests(), tx.data.numberOfRevertiblePublicCallRequests(), tx.data.hasTeardownPublicCallRequest());
160
+ avmOutput.publicSetupCallRequests = dataFromPrivate.nonRevertibleAccumulatedData.publicCallRequests;
161
+ avmOutput.publicAppLogicCallRequests = dataFromPrivate.revertibleAccumulatedData.publicCallRequests;
162
+ avmOutput.publicTeardownCallRequest = dataFromPrivate.publicTeardownCallRequest;
163
+ avmOutput.previousNonRevertibleAccumulatedData = new PrivateToAvmAccumulatedData(dataFromPrivate.nonRevertibleAccumulatedData.noteHashes, dataFromPrivate.nonRevertibleAccumulatedData.nullifiers, dataFromPrivate.nonRevertibleAccumulatedData.l2ToL1Msgs);
164
+ avmOutput.previousNonRevertibleAccumulatedDataArrayLengths = avmOutput.previousNonRevertibleAccumulatedData.getArrayLengths();
165
+ avmOutput.previousRevertibleAccumulatedData = new PrivateToAvmAccumulatedData(dataFromPrivate.revertibleAccumulatedData.noteHashes, dataFromPrivate.revertibleAccumulatedData.nullifiers, dataFromPrivate.revertibleAccumulatedData.l2ToL1Msgs);
166
+ avmOutput.previousRevertibleAccumulatedDataArrayLengths = avmOutput.previousRevertibleAccumulatedData.getArrayLengths();
167
+ // Assign final data emitted from avm.
168
+ avmOutput.accumulatedData.noteHashes = revertibleData.noteHashes;
169
+ avmOutput.accumulatedData.nullifiers = padArrayEnd(nonRevertibleData.nullifiers.concat(revertibleData.nullifiers).filter((n)=>!n.isEmpty()), Fr.ZERO, MAX_NULLIFIERS_PER_TX);
170
+ avmOutput.accumulatedData.l2ToL1Msgs = revertibleData.l2ToL1Msgs;
171
+ avmOutput.accumulatedData.publicDataWrites = makeTuple(MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, (i)=>new PublicDataWrite(new Fr(i), new Fr(i + 10)), seed + 0x2000);
172
+ avmOutput.accumulatedData.publicDataWrites[0] = feePaymentPublicDataWrite;
173
+ avmOutput.accumulatedDataArrayLengths = avmOutput.accumulatedData.getArrayLengths();
174
+ avmOutput.gasSettings = gasSettings;
175
+ // Note: The fee is computed from the tx's gas used, which only includes the gas used in private. But this shouldn't
176
+ // be a problem for the tests.
177
+ avmOutput.transactionFee = transactionFee;
178
+ const avmCircuitInputs = await makeAvmCircuitInputs(seed + 0x3000, {
179
+ publicInputs: avmOutput
180
+ });
181
+ avmCircuitInputs.hints.startingTreeRoots.l1ToL2MessageTree = newL1ToL2Snapshot;
182
+ const gasUsed = {
183
+ totalGas: Gas.empty(),
184
+ teardownGas: Gas.empty(),
185
+ publicGas: Gas.empty(),
186
+ billedGas: Gas.empty()
187
+ };
188
+ await tx.recomputeHash();
189
+ return makeProcessedTxFromTxWithPublicCalls(tx, {
190
+ type: ProvingRequestType.PUBLIC_VM,
191
+ inputs: avmCircuitInputs
192
+ }, gasUsed, RevertCode.OK, undefined /* revertReason */ );
193
+ }
194
+ }
91
195
  const emptyPrivateCallExecutionResult = ()=>new PrivateCallExecutionResult(Buffer.from(''), Buffer.from(''), new Map(), PrivateCircuitPublicInputs.empty(), new Map(), [], new Map(), [], [], [], [], []);
92
196
  const emptyPrivateExecutionResult = ()=>new PrivateExecutionResult(emptyPrivateCallExecutionResult(), Fr.zero(), []);
93
197
  export const mockSimulatedTx = async (seed = 1)=>{
@@ -1,6 +1,7 @@
1
1
  import type { ViemPartialStateReference } from '@aztec/ethereum';
2
2
  import type { Fr } from '@aztec/foundation/fields';
3
3
  import { BufferReader, FieldReader } from '@aztec/foundation/serialize';
4
+ import type { FieldsOf } from '@aztec/foundation/types';
4
5
  import { z } from 'zod';
5
6
  import { AppendOnlyTreeSnapshot } from '../trees/append_only_tree_snapshot.js';
6
7
  /**
@@ -92,6 +93,8 @@ export declare class PartialStateReference {
92
93
  };
93
94
  }>;
94
95
  getSize(): number;
96
+ static getFields(fields: FieldsOf<PartialStateReference>): readonly [AppendOnlyTreeSnapshot, AppendOnlyTreeSnapshot, AppendOnlyTreeSnapshot];
97
+ static from(fields: FieldsOf<PartialStateReference>): PartialStateReference;
95
98
  static fromBuffer(buffer: Buffer | BufferReader): PartialStateReference;
96
99
  static fromFields(fields: Fr[] | FieldReader): PartialStateReference;
97
100
  static fromViem(stateReference: ViemPartialStateReference): PartialStateReference;
@@ -1 +1 @@
1
- {"version":3,"file":"partial_state_reference.d.ts","sourceRoot":"","sources":["../../src/tx/partial_state_reference.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AACjE,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,WAAW,EAAqB,MAAM,6BAA6B,CAAC;AAE3F,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAE/E;;GAEG;AACH,qBAAa,qBAAqB;IAE9B,sCAAsC;aACtB,YAAY,EAAE,sBAAsB;IACpD,sCAAsC;aACtB,aAAa,EAAE,sBAAsB;IACrD,wCAAwC;aACxB,cAAc,EAAE,sBAAsB;;IALtD,sCAAsC;IACtB,YAAY,EAAE,sBAAsB;IACpD,sCAAsC;IACtB,aAAa,EAAE,sBAAsB;IACrD,wCAAwC;IACxB,cAAc,EAAE,sBAAsB;IAGxD,MAAM,KAAK,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAWhB;IAED,OAAO;IAIP,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,GAAG,qBAAqB;IASvE,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,EAAE,EAAE,GAAG,WAAW,GAAG,qBAAqB;IAUpE,MAAM,CAAC,QAAQ,CAAC,cAAc,EAAE,yBAAyB;IAQzD,MAAM,CA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,CAAC,MAAM,EAAE,QAAQ,CAAC,qBAAqB,CAAC;IAIxD,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,qBAAqB,CAAC;IAInD,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,GAAG,qBAAqB;IASvE,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,EAAE,EAAE,GAAG,WAAW,GAAG,qBAAqB;IAUpE,MAAM,CAAC,QAAQ,CAAC,cAAc,EAAE,yBAAyB;IAQzD,MAAM,CAAC,MAAM,IAAI,qBAAqB;IAQtC,MAAM,IAAI,yBAAyB;IAQnC,KAAK,IAAI;QACP,UAAU,CAAC,sBAAsB,CAAC,OAAO,CAAC,CAAC;QAC3C,UAAU,CAAC,sBAAsB,CAAC,OAAO,CAAC,CAAC;QAC3C,UAAU,CAAC,sBAAsB,CAAC,OAAO,CAAC,CAAC;KAC5C;IAID,MAAM,CAAC,KAAK,IAAI,qBAAqB;IAQrC,QAAQ;IAIR,QAAQ;IAcR,OAAO,IAAI,OAAO;IAIX,MAAM,CAAC,KAAK,EAAE,IAAI,GAAG,OAAO;CAOpC"}
@@ -23,6 +23,16 @@ import { AppendOnlyTreeSnapshot } from '../trees/append_only_tree_snapshot.js';
23
23
  getSize() {
24
24
  return this.noteHashTree.getSize() + this.nullifierTree.getSize() + this.publicDataTree.getSize();
25
25
  }
26
+ static getFields(fields) {
27
+ return [
28
+ fields.noteHashTree,
29
+ fields.nullifierTree,
30
+ fields.publicDataTree
31
+ ];
32
+ }
33
+ static from(fields) {
34
+ return new PartialStateReference(...PartialStateReference.getFields(fields));
35
+ }
26
36
  static fromBuffer(buffer) {
27
37
  const reader = BufferReader.asReader(buffer);
28
38
  return new PartialStateReference(reader.readObject(AppendOnlyTreeSnapshot), reader.readObject(AppendOnlyTreeSnapshot), reader.readObject(AppendOnlyTreeSnapshot));
@@ -1,6 +1,7 @@
1
1
  import type { ViemStateReference } from '@aztec/ethereum';
2
2
  import type { Fr } from '@aztec/foundation/fields';
3
3
  import { BufferReader, FieldReader } from '@aztec/foundation/serialize';
4
+ import type { FieldsOf } from '@aztec/foundation/types';
4
5
  import { inspect } from 'util';
5
6
  import { z } from 'zod';
6
7
  import { AppendOnlyTreeSnapshot } from '../trees/append_only_tree_snapshot.js';
@@ -146,6 +147,8 @@ export declare class StateReference {
146
147
  };
147
148
  }>;
148
149
  getSize(): number;
150
+ static getFields(fields: FieldsOf<StateReference>): readonly [AppendOnlyTreeSnapshot, PartialStateReference];
151
+ static from(fields: FieldsOf<StateReference>): StateReference;
149
152
  toBuffer(): Buffer<ArrayBufferLike>;
150
153
  toFields(): Fr[];
151
154
  static fromBuffer(buffer: Buffer | BufferReader): StateReference;
@@ -1 +1 @@
1
- {"version":3,"file":"state_reference.d.ts","sourceRoot":"","sources":["../../src/tx/state_reference.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,WAAW,EAAqB,MAAM,6BAA6B,CAAC;AAE3F,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAC/E,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAErE;;GAEG;AACH,qBAAa,cAAc;IAEvB,6CAA6C;IACtC,iBAAiB,EAAE,sBAAsB;IAChD,0CAA0C;IACnC,OAAO,EAAE,qBAAqB;;IAHrC,6CAA6C;IACtC,iBAAiB,EAAE,sBAAsB;IAChD,0CAA0C;IACnC,OAAO,EAAE,qBAAqB;IAGvC,MAAM,KAAK,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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ference } from './partial_state_reference.js';
22
22
  getSize() {
23
23
  return this.l1ToL2MessageTree.getSize() + this.partial.getSize();
24
24
  }
25
+ static getFields(fields) {
26
+ return [
27
+ fields.l1ToL2MessageTree,
28
+ fields.partial
29
+ ];
30
+ }
31
+ static from(fields) {
32
+ return new StateReference(...StateReference.getFields(fields));
33
+ }
25
34
  toBuffer() {
26
35
  // Note: The order here must match the order in the ProposedHeaderLib solidity library.
27
36
  return serializeToBuffer(this.l1ToL2MessageTree, this.partial);
@@ -1,7 +1,8 @@
1
+ import { type TxBlobData, type TxStartMarker } from '@aztec/blob-lib/encoding';
1
2
  import { type FieldsOf } from '@aztec/foundation/array';
2
3
  import { Fr } from '@aztec/foundation/fields';
3
4
  import { type ZodFor } from '@aztec/foundation/schemas';
4
- import { BufferReader, FieldReader } from '@aztec/foundation/serialize';
5
+ import { BufferReader } from '@aztec/foundation/serialize';
5
6
  import { inspect } from 'util';
6
7
  import { PublicDataWrite } from '../avm/public_data_write.js';
7
8
  import { RevertCode } from '../avm/revert_code.js';
@@ -95,8 +96,6 @@ export declare class TxEffect {
95
96
  contractClassLogs: ContractClassLog[]);
96
97
  toBuffer(): Buffer;
97
98
  equals(other: TxEffect): boolean;
98
- /** Returns the size of this tx effect in bytes as serialized onto DA. */
99
- getDASize(): number;
100
99
  /**
101
100
  * Deserializes the TxEffect object from a Buffer.
102
101
  * @param buffer - Buffer or BufferReader object to deserialize.
@@ -107,20 +106,24 @@ export declare class TxEffect {
107
106
  * Computes txOutHash of this tx effect.
108
107
  * @dev Follows new_sha in unbalanced_merkle_tree.nr
109
108
  */
110
- txOutHash(): Buffer;
109
+ txOutHash(): Fr;
111
110
  static random(numPublicCallsPerTx?: number, numPublicLogsPerCall?: number, maxEffects?: number | undefined): Promise<TxEffect>;
112
111
  static empty(): TxEffect;
113
112
  /** Returns a hex representation of the TxEffect object. */
114
113
  toString(): `0x${string}`;
114
+ getNumBlobFields(): number;
115
+ toBlobFields(): Fr[];
116
+ static fromBlobFields(fields: Fr[]): TxEffect;
117
+ getTxStartMarker(): TxStartMarker;
115
118
  /**
116
119
  * Returns a flat packed array of fields of all tx effects, to be appended to blobs.
117
120
  * Must match the implementation in noir-protocol-circuits/crates/rollup-lib/src/tx_base/components/tx_blob_data.nr
118
121
  */
119
- toBlobFields(): Fr[];
122
+ toTxBlobData(): TxBlobData;
120
123
  /**
121
124
  * Decodes a flat packed array of fields to TxEffect.
122
125
  */
123
- static fromBlobFields(fields: Fr[] | FieldReader): TxEffect;
126
+ static fromTxBlobData(txBlobData: TxBlobData): TxEffect;
124
127
  static from(fields: FieldsOf<TxEffect>): TxEffect;
125
128
  static get schema(): ZodFor<TxEffect>;
126
129
  [inspect.custom](): string;
@@ -1 +1 @@
1
- {"version":3,"file":"tx_effect.d.ts","sourceRoot":"","sources":["../../src/tx/tx_effect.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,KAAK,QAAQ,EAA6B,MAAM,yBAAyB,CAAC;AACnF,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,EAAE,KAAK,MAAM,EAAW,MAAM,2BAA2B,CAAC;AACjE,OAAO,EACL,YAAY,EACZ,WAAW,EAGZ,MAAM,6BAA6B,CAAC;AAIrC,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAG/B,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAkB,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC,qBAAa,QAAQ;IAEjB;;OAEG;IACI,UAAU,EAAE,UAAU;IAC7B;;OAEG;IACI,MAAM,EAAE,MAAM;IACrB;;OAEG;IACI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Ae1B;;OAEG;IACH,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,UAAU;IA8B5C,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,QAAQ,CAAC;IAetC,MAAM,KAAK,MAAM,IAAI,MAAM,CAAC,QAAQ,CAAC,CAepC;IAED,CAAC,OAAO,CAAC,MAAM,CAAC;IAsBhB;;;;OAIG;IACH,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,MAAM;CAG9B"}
@@ -1,11 +1,10 @@
1
- import { decodeTxStartMarker, encodeTxStartMarker, isValidTxStartMarker } from '@aztec/blob-lib/encoding';
1
+ import { decodeTxBlobData, encodeTxBlobData, getNumTxBlobFields } from '@aztec/blob-lib/encoding';
2
2
  import { MAX_CONTRACT_CLASS_LOGS_PER_TX, MAX_L2_TO_L1_MSGS_PER_TX, MAX_NOTE_HASHES_PER_TX, MAX_NULLIFIERS_PER_TX, MAX_PRIVATE_LOGS_PER_TX, MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX } from '@aztec/constants';
3
3
  import { makeTuple, makeTupleAsync } from '@aztec/foundation/array';
4
4
  import { Fr } from '@aztec/foundation/fields';
5
5
  import { schemas } from '@aztec/foundation/schemas';
6
- import { BufferReader, FieldReader, serializeArrayOfBufferableToVector, serializeToBuffer } from '@aztec/foundation/serialize';
6
+ import { BufferReader, serializeArrayOfBufferableToVector, serializeToBuffer } from '@aztec/foundation/serialize';
7
7
  import { bufferToHex, hexToBuffer } from '@aztec/foundation/string';
8
- import { computeUnbalancedMerkleTreeRoot } from '@aztec/foundation/trees';
9
8
  import { inspect } from 'util';
10
9
  import { z } from 'zod';
11
10
  import { PublicDataWrite } from '../avm/public_data_write.js';
@@ -13,6 +12,7 @@ import { RevertCode } from '../avm/revert_code.js';
13
12
  import { ContractClassLog } from '../logs/contract_class_log.js';
14
13
  import { PrivateLog } from '../logs/private_log.js';
15
14
  import { FlatPublicLogs, PublicLog } from '../logs/public_log.js';
15
+ import { computeTxOutHash } from '../messaging/out_hash.js';
16
16
  import { TxHash } from './tx_hash.js';
17
17
  export class TxEffect {
18
18
  revertCode;
@@ -117,9 +117,6 @@ export class TxEffect {
117
117
  equals(other) {
118
118
  return this.revertCode.equals(other.revertCode) && this.txHash.equals(other.txHash) && this.transactionFee.equals(other.transactionFee) && this.noteHashes.length === other.noteHashes.length && this.noteHashes.every((h, i)=>h.equals(other.noteHashes[i])) && this.nullifiers.length === other.nullifiers.length && this.nullifiers.every((h, i)=>h.equals(other.nullifiers[i])) && this.l2ToL1Msgs.length === other.l2ToL1Msgs.length && this.l2ToL1Msgs.every((h, i)=>h.equals(other.l2ToL1Msgs[i])) && this.publicDataWrites.length === other.publicDataWrites.length && this.publicDataWrites.every((h, i)=>h.equals(other.publicDataWrites[i])) && this.privateLogs.length === other.privateLogs.length && this.privateLogs.every((h, i)=>h.equals(other.privateLogs[i])) && this.publicLogs.length === other.publicLogs.length && this.publicLogs.every((h, i)=>h.equals(other.publicLogs[i])) && this.contractClassLogs.length === other.contractClassLogs.length && this.contractClassLogs.every((h, i)=>h.equals(other.contractClassLogs[i]));
119
119
  }
120
- /** Returns the size of this tx effect in bytes as serialized onto DA. */ getDASize() {
121
- return this.toBlobFields().length * Fr.SIZE_IN_BYTES;
122
- }
123
120
  /**
124
121
  * Deserializes the TxEffect object from a Buffer.
125
122
  * @param buffer - Buffer or BufferReader object to deserialize.
@@ -132,11 +129,7 @@ export class TxEffect {
132
129
  * Computes txOutHash of this tx effect.
133
130
  * @dev Follows new_sha in unbalanced_merkle_tree.nr
134
131
  */ txOutHash() {
135
- const { l2ToL1Msgs } = this;
136
- if (l2ToL1Msgs.length == 0) {
137
- return Buffer.alloc(32);
138
- }
139
- return computeUnbalancedMerkleTreeRoot(l2ToL1Msgs.map((msg)=>msg.toBuffer()));
132
+ return computeTxOutHash(this.l2ToL1Msgs);
140
133
  }
141
134
  static async random(numPublicCallsPerTx = 3, numPublicLogsPerCall = 1, maxEffects = undefined) {
142
135
  return new TxEffect(RevertCode.random(), TxHash.random(), new Fr(Math.floor(Math.random() * 100_000)), makeTuple(maxEffects === undefined ? MAX_NOTE_HASHES_PER_TX : Math.min(maxEffects, MAX_NOTE_HASHES_PER_TX), Fr.random), makeTuple(maxEffects === undefined ? MAX_NULLIFIERS_PER_TX : Math.min(maxEffects, MAX_NULLIFIERS_PER_TX), Fr.random), makeTuple(maxEffects === undefined ? MAX_L2_TO_L1_MSGS_PER_TX : Math.min(maxEffects, MAX_L2_TO_L1_MSGS_PER_TX), Fr.random), makeTuple(maxEffects === undefined ? MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX : Math.min(maxEffects, MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX), PublicDataWrite.random), makeTuple(MAX_PRIVATE_LOGS_PER_TX, ()=>PrivateLog.random()), await Promise.all(new Array(numPublicCallsPerTx * numPublicLogsPerCall).fill(null).map(()=>PublicLog.random())), await makeTupleAsync(MAX_CONTRACT_CLASS_LOGS_PER_TX, ContractClassLog.random));
@@ -147,63 +140,66 @@ export class TxEffect {
147
140
  /** Returns a hex representation of the TxEffect object. */ toString() {
148
141
  return bufferToHex(this.toBuffer());
149
142
  }
150
- /**
151
- * Returns a flat packed array of fields of all tx effects, to be appended to blobs.
152
- * Must match the implementation in noir-protocol-circuits/crates/rollup-lib/src/tx_base/components/tx_blob_data.nr
153
- */ toBlobFields() {
154
- const flattened = [];
155
- // We reassign the first field at the end when we know the length of all effects to create the tx start marker.
156
- flattened.push(Fr.ZERO);
157
- flattened.push(this.txHash.hash);
158
- flattened.push(this.transactionFee);
159
- flattened.push(...this.noteHashes);
160
- flattened.push(...this.nullifiers);
161
- flattened.push(...this.l2ToL1Msgs);
162
- flattened.push(...this.publicDataWrites.flatMap((w)=>w.toBlobFields()));
163
- flattened.push(...this.privateLogs.flatMap((l)=>l.toBlobFields()));
164
- const flattenedPublicLogs = FlatPublicLogs.fromLogs(this.publicLogs);
165
- flattened.push(...flattenedPublicLogs.toBlobFields());
166
- flattened.push(...this.contractClassLogs.flatMap((l)=>l.toBlobFields()));
167
- flattened[0] = encodeTxStartMarker({
143
+ getNumBlobFields() {
144
+ return this.getTxStartMarker().numBlobFields;
145
+ }
146
+ toBlobFields() {
147
+ return encodeTxBlobData(this.toTxBlobData());
148
+ }
149
+ static fromBlobFields(fields) {
150
+ return TxEffect.fromTxBlobData(decodeTxBlobData(fields));
151
+ }
152
+ getTxStartMarker() {
153
+ const flatPublicLogs = FlatPublicLogs.fromLogs(this.publicLogs);
154
+ const partialTxStartMarker = {
168
155
  revertCode: this.revertCode.getCode(),
169
- numBlobFields: flattened.length,
170
156
  numNoteHashes: this.noteHashes.length,
171
157
  numNullifiers: this.nullifiers.length,
172
158
  numL2ToL1Msgs: this.l2ToL1Msgs.length,
173
159
  numPublicDataWrites: this.publicDataWrites.length,
174
160
  numPrivateLogs: this.privateLogs.length,
175
- publicLogsLength: flattenedPublicLogs.length,
161
+ privateLogsLength: this.privateLogs.reduce((acc, log)=>acc + log.emittedLength, 0),
162
+ publicLogsLength: flatPublicLogs.length,
176
163
  contractClassLogLength: this.contractClassLogs[0]?.emittedLength ?? 0
177
- });
178
- return flattened;
164
+ };
165
+ const numBlobFields = getNumTxBlobFields(partialTxStartMarker);
166
+ return {
167
+ ...partialTxStartMarker,
168
+ numBlobFields
169
+ };
170
+ }
171
+ /**
172
+ * Returns a flat packed array of fields of all tx effects, to be appended to blobs.
173
+ * Must match the implementation in noir-protocol-circuits/crates/rollup-lib/src/tx_base/components/tx_blob_data.nr
174
+ */ toTxBlobData() {
175
+ return {
176
+ txStartMarker: this.getTxStartMarker(),
177
+ txHash: this.txHash.hash,
178
+ transactionFee: this.transactionFee,
179
+ noteHashes: this.noteHashes,
180
+ nullifiers: this.nullifiers,
181
+ l2ToL1Msgs: this.l2ToL1Msgs,
182
+ publicDataWrites: this.publicDataWrites.map((w)=>w.toBlobFields()),
183
+ privateLogs: this.privateLogs.map((l)=>l.toBlobFields()),
184
+ publicLogs: FlatPublicLogs.fromLogs(this.publicLogs).toBlobFields(),
185
+ contractClassLog: this.contractClassLogs.map((l)=>l.toBlobFields()).flat()
186
+ };
179
187
  }
180
188
  /**
181
189
  * Decodes a flat packed array of fields to TxEffect.
182
- */ static fromBlobFields(fields) {
183
- const reader = FieldReader.asReader(fields);
184
- const totalFields = reader.remainingFields();
185
- if (!totalFields) {
186
- throw new Error('Cannot process empty blob fields.');
187
- }
188
- const txStartMarker = decodeTxStartMarker(reader.readField());
189
- if (!isValidTxStartMarker(txStartMarker)) {
190
- throw new Error('Invalid fields given to TxEffect.fromBlobFields(): invalid TxStartMarker');
191
- }
192
- const revertCode = RevertCode.fromField(new Fr(txStartMarker.revertCode));
193
- const txHash = new TxHash(reader.readField());
194
- const transactionFee = reader.readField();
195
- const noteHashes = reader.readFieldArray(txStartMarker.numNoteHashes);
196
- const nullifiers = reader.readFieldArray(txStartMarker.numNullifiers);
197
- const l2ToL1Msgs = reader.readFieldArray(txStartMarker.numL2ToL1Msgs);
198
- const publicDataWrites = Array.from({
199
- length: txStartMarker.numPublicDataWrites
200
- }, ()=>PublicDataWrite.fromBlobFields(reader));
201
- const privateLogs = Array.from({
202
- length: txStartMarker.numPrivateLogs
203
- }, ()=>PrivateLog.fromBlobFields(reader));
204
- const publicLogs = FlatPublicLogs.fromBlobFields(txStartMarker.publicLogsLength, reader).toLogs();
190
+ */ static fromTxBlobData(txBlobData) {
191
+ const txStartMarker = txBlobData.txStartMarker;
192
+ const revertCode = RevertCode.fromNumber(txStartMarker.revertCode);
193
+ const txHash = new TxHash(txBlobData.txHash);
194
+ const transactionFee = txBlobData.transactionFee;
195
+ const noteHashes = txBlobData.noteHashes;
196
+ const nullifiers = txBlobData.nullifiers;
197
+ const l2ToL1Msgs = txBlobData.l2ToL1Msgs;
198
+ const publicDataWrites = txBlobData.publicDataWrites.map((w)=>PublicDataWrite.fromBlobFields(w));
199
+ const privateLogs = txBlobData.privateLogs.map((l)=>PrivateLog.fromBlobFields(l.length, l));
200
+ const publicLogs = FlatPublicLogs.fromBlobFields(txStartMarker.publicLogsLength, txBlobData.publicLogs).toLogs();
205
201
  const contractClassLogs = txStartMarker.contractClassLogLength > 0 ? [
206
- ContractClassLog.fromBlobFields(txStartMarker.contractClassLogLength, reader)
202
+ ContractClassLog.fromBlobFields(txStartMarker.contractClassLogLength, txBlobData.contractClassLog)
207
203
  ] : [];
208
204
  return TxEffect.from({
209
205
  revertCode,
@@ -82,6 +82,7 @@ export declare class VerificationKeyAsFields {
82
82
  * @returns The VerificationKeyAsFields.
83
83
  */
84
84
  static fromBuffer(buffer: Buffer | BufferReader): VerificationKeyAsFields;
85
+ static fromFrBuffer(vkBytes: Buffer): Promise<VerificationKeyAsFields>;
85
86
  /**
86
87
  * Builds a fake verification key that should be accepted by circuits.
87
88
  * @returns A fake verification key.
@@ -165,6 +166,13 @@ export declare class VerificationKey {
165
166
  * @returns A fake verification key.
166
167
  */
167
168
  static makeFake(): VerificationKey;
169
+ /**
170
+ * Builds a fake MegaHonk verification key buffer for testing.
171
+ * Uses a real VK from a compiled contract to ensure proper format.
172
+ *
173
+ * @returns A valid MegaHonk VK buffer (4064 bytes)
174
+ */
175
+ static makeFakeMegaHonk(): Buffer;
168
176
  }
169
177
  export declare class VerificationKeyData {
170
178
  readonly keyAsFields: VerificationKeyAsFields;
@@ -183,6 +191,7 @@ export declare class VerificationKeyData {
183
191
  toBuffer(): Buffer<ArrayBufferLike>;
184
192
  toString(): `0x${string}`;
185
193
  static fromBuffer(buffer: Buffer | BufferReader): VerificationKeyData;
194
+ static fromFrBuffer(vkBytes: Buffer): Promise<VerificationKeyData>;
186
195
  static fromString(str: string): VerificationKeyData;
187
196
  clone(): VerificationKeyData;
188
197
  /** Returns a hex representation for JSON serialization. */
@@ -1 +1 @@
1
- {"version":3,"file":"verification_key.d.ts","sourceRoot":"","sources":["../../src/vks/verification_key.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,EAAE,EAAE,EAAE,EA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B;CACF"}
@@ -111,6 +111,12 @@ export const CIRCUIT_PUBLIC_INPUTS_INDEX = 1;
111
111
  const reader = BufferReader.asReader(buffer);
112
112
  return new VerificationKeyAsFields(reader.readVector(Fr), reader.readObject(Fr));
113
113
  }
114
+ static fromFrBuffer(vkBytes) {
115
+ const numFields = vkBytes.length / Fr.SIZE_IN_BYTES;
116
+ const reader = BufferReader.asReader(vkBytes);
117
+ const fields = reader.readArray(numFields, Fr);
118
+ return VerificationKeyAsFields.fromKey(fields);
119
+ }
114
120
  /**
115
121
  * Builds a fake verification key that should be accepted by circuits.
116
122
  * @returns A fake verification key.
@@ -182,6 +188,17 @@ export class VerificationKey {
182
188
  */ static makeFake() {
183
189
  return new VerificationKey(CircuitType.ULTRA, 2048, 116, {}, false, times(16, (i)=>i));
184
190
  }
191
+ /**
192
+ * Builds a fake MegaHonk verification key buffer for testing.
193
+ * Uses a real VK from a compiled contract to ensure proper format.
194
+ *
195
+ * @returns A valid MegaHonk VK buffer (4064 bytes)
196
+ */ static makeFakeMegaHonk() {
197
+ // This is a real MegaFlavor VK from token_contract, base64-encoded
198
+ // Size: 4064 bytes (127 fields × 32 bytes)
199
+ const vk = 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAANuAAAAAAAAAAAAAAAAAAAAP/2mLzBM1pS5uiSckb1BVHkAAAAAAAAAAAAAAAAAAAAAAAj416UaEYnPzn49IUFSXgAAAAAAAAAAAAAAAAAAAIXdwCJK3KYAoGKX4p6GfmryAAAAAAAAAAAAAAAAAAAAAAAokraNwSgFcpF48hQxNGkAAAAAAAAAAAAAAAAAAAC7oxlMkGNLFkB2hf+YZ3ZxbgAAAAAAAAAAAAAAAAAAAAAAJxTarsiWssfiDyt71jURAAAAAAAAAAAAAAAAAAAAXrNqIIwSwfoH9ohkDg7vOVkA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Zm7rhU1EjBVJa6+CsG3SwAAAAAAAAAAAAAAAAAAAAAADE3UV3HYY4to5MdMoyhzAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADR5j3OosE3DcjqfYFSVRVvhQAAAAAAAAAAAAAAAAAAAAAAIkOVicHIGw8ySdK6LLsSAAAAAAAAAAAAAAAAAAAAiUo00o971hiazvZDn4Ir9CsAAAAAAAAAAAAAAAAAAAAAADA8czfrc4+po12HYzzeswAAAAAAAAAAAAAAAAAAAGvMegX/lalrKJQkxfczZw2WAAAAAAAAAAAAAAAAAAAAAAAAxDcm91tv2g3iLODg36sAAAAAAAAAAAAAAAAAAAAdCgnXF47JO614WPluZPC0jQAAAAAAAAAAAAAAAAAAAAAAL5tuC04sAZaN5cMkgqp9AAAAAAAAAAAAAAAAAAAAjKmgRRlkp7urvZ42nbdVYlMAAAAAAAAAAAAAAAAAAAAAABRWfiw+hPwePmnYH2zlgAAAAAAAAAAAAAAAAAAAANYJxZ/uz4mfK5Wv9Rm78/s8AAAAAAAAAAAAAAAAAAAAAAADeJJvFQwwx2CWXfRprm4=';
200
+ return Buffer.from(vk, 'base64');
201
+ }
185
202
  }
186
203
  export class VerificationKeyData {
187
204
  keyAsFields;
@@ -224,6 +241,9 @@ export class VerificationKeyData {
224
241
  const bytes = reader.readBytes(length);
225
242
  return new VerificationKeyData(verificationKeyAsFields, bytes);
226
243
  }
244
+ static async fromFrBuffer(vkBytes) {
245
+ return new VerificationKeyData(await VerificationKeyAsFields.fromFrBuffer(vkBytes), vkBytes);
246
+ }
227
247
  static fromString(str) {
228
248
  return VerificationKeyData.fromBuffer(hexToBuffer(str));
229
249
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/stdlib",
3
- "version": "3.0.0-nightly.20251114",
3
+ "version": "3.0.0-nightly.20251118",
4
4
  "type": "module",
5
5
  "inherits": [
6
6
  "../package.common.json",
@@ -72,13 +72,13 @@
72
72
  },
73
73
  "dependencies": {
74
74
  "@aws-sdk/client-s3": "^3.892.0",
75
- "@aztec/bb.js": "3.0.0-nightly.20251114",
76
- "@aztec/blob-lib": "3.0.0-nightly.20251114",
77
- "@aztec/constants": "3.0.0-nightly.20251114",
78
- "@aztec/ethereum": "3.0.0-nightly.20251114",
79
- "@aztec/foundation": "3.0.0-nightly.20251114",
80
- "@aztec/l1-artifacts": "3.0.0-nightly.20251114",
81
- "@aztec/noir-noirc_abi": "3.0.0-nightly.20251114",
75
+ "@aztec/bb.js": "3.0.0-nightly.20251118",
76
+ "@aztec/blob-lib": "3.0.0-nightly.20251118",
77
+ "@aztec/constants": "3.0.0-nightly.20251118",
78
+ "@aztec/ethereum": "3.0.0-nightly.20251118",
79
+ "@aztec/foundation": "3.0.0-nightly.20251118",
80
+ "@aztec/l1-artifacts": "3.0.0-nightly.20251118",
81
+ "@aztec/noir-noirc_abi": "3.0.0-nightly.20251118",
82
82
  "@google-cloud/storage": "^7.15.0",
83
83
  "axios": "^1.12.0",
84
84
  "json-stringify-deterministic": "1.0.12",