@aztec/stdlib 5.0.0-nightly.20260324 → 5.0.0-nightly.20260331
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.
- package/dest/abi/decoder.d.ts +5 -44
- package/dest/abi/decoder.d.ts.map +1 -1
- package/dest/abi/decoder.js +12 -67
- package/dest/abi/function_selector.js +1 -1
- package/dest/abi/function_signature_decoder.d.ts +43 -0
- package/dest/abi/function_signature_decoder.d.ts.map +1 -0
- package/dest/abi/function_signature_decoder.js +66 -0
- package/dest/abi/index.d.ts +2 -1
- package/dest/abi/index.d.ts.map +1 -1
- package/dest/abi/index.js +1 -0
- package/dest/block/l2_block_source.d.ts +80 -3
- package/dest/block/l2_block_source.d.ts.map +1 -1
- package/dest/block/l2_block_source.js +1 -0
- package/dest/block/l2_block_stream/l2_tips_store_base.d.ts +1 -1
- package/dest/block/l2_block_stream/l2_tips_store_base.d.ts.map +1 -1
- package/dest/block/l2_block_stream/l2_tips_store_base.js +17 -4
- package/dest/block/test/l2_tips_store_test_suite.d.ts +1 -1
- package/dest/block/test/l2_tips_store_test_suite.d.ts.map +1 -1
- package/dest/block/test/l2_tips_store_test_suite.js +3 -2
- package/dest/checkpoint/checkpoint.d.ts +7 -1
- package/dest/checkpoint/checkpoint.d.ts.map +1 -1
- package/dest/checkpoint/checkpoint.js +9 -1
- package/dest/checkpoint/checkpoint_data.d.ts +71 -5
- package/dest/checkpoint/checkpoint_data.d.ts.map +1 -1
- package/dest/checkpoint/checkpoint_data.js +10 -0
- package/dest/epoch-helpers/index.d.ts +5 -1
- package/dest/epoch-helpers/index.d.ts.map +1 -1
- package/dest/epoch-helpers/index.js +6 -0
- package/dest/file-store/factory.d.ts +4 -3
- package/dest/file-store/factory.d.ts.map +1 -1
- package/dest/file-store/factory.js +2 -2
- package/dest/file-store/http.d.ts +9 -2
- package/dest/file-store/http.d.ts.map +1 -1
- package/dest/file-store/http.js +20 -9
- package/dest/file-store/index.d.ts +2 -1
- package/dest/file-store/index.d.ts.map +1 -1
- package/dest/hash/hash.d.ts +4 -1
- package/dest/hash/hash.d.ts.map +1 -1
- package/dest/hash/hash.js +5 -0
- package/dest/interfaces/archiver.d.ts +1 -1
- package/dest/interfaces/archiver.d.ts.map +1 -1
- package/dest/interfaces/archiver.js +3 -1
- package/dest/interfaces/aztec-node-admin.d.ts +1 -4
- package/dest/interfaces/aztec-node-admin.d.ts.map +1 -1
- package/dest/interfaces/validator.d.ts +2 -10
- package/dest/interfaces/validator.d.ts.map +1 -1
- package/dest/interfaces/validator.js +0 -1
- package/dest/logs/message_context.d.ts +4 -7
- package/dest/logs/message_context.d.ts.map +1 -1
- package/dest/logs/message_context.js +23 -9
- package/dest/logs/pending_tagged_log.d.ts +2 -3
- package/dest/logs/pending_tagged_log.d.ts.map +1 -1
- package/dest/logs/pending_tagged_log.js +2 -2
- package/dest/logs/shared_secret_derivation.d.ts +11 -10
- package/dest/logs/shared_secret_derivation.d.ts.map +1 -1
- package/dest/logs/shared_secret_derivation.js +15 -9
- package/dest/logs/siloed_tag.d.ts +4 -1
- package/dest/logs/siloed_tag.d.ts.map +1 -1
- package/dest/logs/siloed_tag.js +7 -3
- package/dest/messaging/l1_to_l2_message.d.ts +3 -2
- package/dest/messaging/l1_to_l2_message.d.ts.map +1 -1
- package/dest/messaging/l1_to_l2_message.js +11 -13
- package/dest/note/note_dao.d.ts +1 -1
- package/dest/note/note_dao.d.ts.map +1 -1
- package/dest/note/note_dao.js +1 -4
- package/dest/proofs/chonk_proof.d.ts +46 -2
- package/dest/proofs/chonk_proof.d.ts.map +1 -1
- package/dest/proofs/chonk_proof.js +85 -10
- package/dest/tests/factories.d.ts +1 -1
- package/dest/tests/factories.d.ts.map +1 -1
- package/dest/tests/factories.js +10 -0
- package/dest/tx/capsule.d.ts +6 -2
- package/dest/tx/capsule.d.ts.map +1 -1
- package/dest/tx/capsule.js +9 -3
- package/dest/tx/global_variable_builder.d.ts +14 -2
- package/dest/tx/global_variable_builder.d.ts.map +1 -1
- package/package.json +8 -8
- package/src/abi/decoder.ts +23 -78
- package/src/abi/function_selector.ts +1 -1
- package/src/abi/function_signature_decoder.ts +77 -0
- package/src/abi/index.ts +1 -0
- package/src/block/l2_block_source.ts +10 -2
- package/src/block/l2_block_stream/l2_tips_store_base.ts +24 -12
- package/src/block/test/l2_tips_store_test_suite.ts +8 -1
- package/src/checkpoint/checkpoint.ts +11 -1
- package/src/checkpoint/checkpoint_data.ts +40 -4
- package/src/epoch-helpers/index.ts +13 -0
- package/src/file-store/factory.ts +13 -4
- package/src/file-store/http.ts +29 -10
- package/src/file-store/index.ts +1 -0
- package/src/hash/hash.ts +5 -0
- package/src/interfaces/archiver.ts +3 -1
- package/src/interfaces/validator.ts +1 -5
- package/src/logs/message_context.ts +17 -7
- package/src/logs/pending_tagged_log.ts +1 -3
- package/src/logs/shared_secret_derivation.ts +21 -10
- package/src/logs/siloed_tag.ts +7 -2
- package/src/messaging/l1_to_l2_message.ts +12 -9
- package/src/note/note_dao.ts +1 -4
- package/src/proofs/chonk_proof.ts +91 -5
- package/src/tests/factories.ts +4 -0
- package/src/tx/capsule.ts +10 -2
- package/src/tx/global_variable_builder.ts +15 -0
|
@@ -1,21 +1,41 @@
|
|
|
1
|
+
import { BarretenbergSync, flattenChonkProofFields } from '@aztec/bb.js';
|
|
1
2
|
import { CHONK_PROOF_LENGTH } from '@aztec/constants';
|
|
2
3
|
import { times } from '@aztec/foundation/collection';
|
|
3
4
|
import { randomBytes } from '@aztec/foundation/crypto/random';
|
|
4
5
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
5
6
|
import { bufferSchemaFor } from '@aztec/foundation/schemas';
|
|
6
|
-
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
7
|
+
import { BufferReader, numToUInt32BE, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Serialization format detection for ChonkProof is size-based:
|
|
11
|
+
* - UNCOMPRESSED (legacy): [field_count=1632: uint32] [fields...] → total ≈ 52KB (>= 40KB)
|
|
12
|
+
* - COMPRESSED: [byte_count: uint32] [compressed_bytes] → total ≈ 35KB (< 40KB)
|
|
13
|
+
*
|
|
14
|
+
* Detection: if the first uint32 equals CHONK_PROOF_LENGTH (1632), it's legacy format
|
|
15
|
+
* (field count). Otherwise, it's compressed format (byte count). The old uncompressed
|
|
16
|
+
* format is never smaller than 40KB; compressed proofs are always smaller than 40KB.
|
|
17
|
+
*/
|
|
7
18
|
|
|
8
19
|
// CHONK: "Client Honk" - An UltraHonk variant with incremental folding and delayed non-native arithmetic.
|
|
9
20
|
export class ChonkProof {
|
|
21
|
+
/**
|
|
22
|
+
* Optional compressed proof bytes from chonk compression (point compression + u256 encoding).
|
|
23
|
+
* When set, toBuffer() will serialize in compressed format (~1.7x smaller).
|
|
24
|
+
* When reading from compressed format, this is populated and fields are decompressed on demand.
|
|
25
|
+
*/
|
|
26
|
+
public compressedProof?: Buffer;
|
|
27
|
+
|
|
10
28
|
constructor(
|
|
11
29
|
// The proof fields.
|
|
12
30
|
// For native verification, attach public inputs via `attachPublicInputs(publicInputs)`.
|
|
13
31
|
// Not using Tuple here due to the length being too high.
|
|
14
32
|
public fields: Fr[],
|
|
33
|
+
compressedProof?: Buffer,
|
|
15
34
|
) {
|
|
16
35
|
if (fields.length !== CHONK_PROOF_LENGTH) {
|
|
17
36
|
throw new Error(`Invalid ChonkProof length: ${fields.length}`);
|
|
18
37
|
}
|
|
38
|
+
this.compressedProof = compressedProof;
|
|
19
39
|
}
|
|
20
40
|
|
|
21
41
|
public attachPublicInputs(publicInputs: Fr[]) {
|
|
@@ -53,19 +73,84 @@ export class ChonkProof {
|
|
|
53
73
|
return this.toBuffer();
|
|
54
74
|
}
|
|
55
75
|
|
|
76
|
+
/**
|
|
77
|
+
* Deserialize a ChonkProof from a buffer.
|
|
78
|
+
* Supports both legacy (field elements) and compressed (chonk compression) formats.
|
|
79
|
+
*
|
|
80
|
+
* Size-based format detection:
|
|
81
|
+
* - First uint32 == CHONK_PROOF_LENGTH (1632): legacy format, read field elements
|
|
82
|
+
* Total proof data ≈ 52KB (always >= 40KB)
|
|
83
|
+
* - Otherwise: compressed format, first uint32 is byte count of compressed data
|
|
84
|
+
* Total proof data ≈ 35KB (always < 40KB)
|
|
85
|
+
*/
|
|
56
86
|
static fromBuffer(buffer: Buffer | BufferReader): ChonkProof {
|
|
57
87
|
const reader = BufferReader.asReader(buffer);
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
88
|
+
const firstUint32 = reader.readNumber();
|
|
89
|
+
|
|
90
|
+
if (firstUint32 === CHONK_PROOF_LENGTH) {
|
|
91
|
+
// Legacy format: firstUint32 is the field count (1632)
|
|
92
|
+
// Widen to `number` to prevent TS from narrowing to literal 1632,
|
|
93
|
+
// which would cause Tuple<Fr, 1632> to exceed the recursion limit.
|
|
94
|
+
const fieldCount: number = firstUint32;
|
|
95
|
+
const proof = reader.readArray(fieldCount, Fr);
|
|
96
|
+
return new ChonkProof(proof);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// Compressed format: firstUint32 is the compressed byte count
|
|
100
|
+
const compressedBytes = reader.readBytes(firstUint32);
|
|
101
|
+
return ChonkProof.fromCompressedBytes(Buffer.from(compressedBytes));
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Create a ChonkProof from compressed bytes by decompressing via the BarretenbergSync API.
|
|
106
|
+
* The compressed format uses point compression and u256 encoding (from PR #20645).
|
|
107
|
+
*
|
|
108
|
+
* @param compressed - Compressed proof bytes from chonk compression
|
|
109
|
+
* @returns ChonkProof with both fields and compressed bytes populated
|
|
110
|
+
*/
|
|
111
|
+
static fromCompressedBytes(compressed: Buffer): ChonkProof {
|
|
112
|
+
const api = BarretenbergSync.getSingleton();
|
|
113
|
+
const result = api.chonkDecompressProof({ compressedProof: new Uint8Array(compressed) });
|
|
114
|
+
|
|
115
|
+
// Flatten the structured bb.js ChonkProof into flat Fr[] field elements
|
|
116
|
+
const flatFields = flattenChonkProofFields(result.proof);
|
|
117
|
+
const fields = flatFields.map(f => Fr.fromBuffer(Buffer.from(f)));
|
|
118
|
+
|
|
119
|
+
// The decompressed proof includes public inputs in hidingOinkProof.
|
|
120
|
+
// Since ChonkProof stores fields WITHOUT public inputs, strip them.
|
|
121
|
+
// The number of public inputs = total fields - CHONK_PROOF_LENGTH
|
|
122
|
+
if (fields.length > CHONK_PROOF_LENGTH) {
|
|
123
|
+
const numPubInputs = fields.length - CHONK_PROOF_LENGTH;
|
|
124
|
+
const proofFields = fields.slice(numPubInputs);
|
|
125
|
+
return new ChonkProof(proofFields, compressed);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return new ChonkProof(fields, compressed);
|
|
61
129
|
}
|
|
62
130
|
|
|
131
|
+
/**
|
|
132
|
+
* Serialize the proof to a buffer.
|
|
133
|
+
* If compressed bytes are available, uses the compressed format (~1.7x smaller).
|
|
134
|
+
* Otherwise falls back to legacy field element format.
|
|
135
|
+
*/
|
|
63
136
|
public toBuffer() {
|
|
137
|
+
if (this.compressedProof) {
|
|
138
|
+
// Compressed format: [compressed_byte_count: uint32] [compressed_bytes]
|
|
139
|
+
return Buffer.concat([numToUInt32BE(this.compressedProof.length), this.compressedProof]);
|
|
140
|
+
}
|
|
141
|
+
// Legacy format: [field_count=1632: uint32] [fields...]
|
|
64
142
|
return serializeToBuffer(this.fields.length, this.fields);
|
|
65
143
|
}
|
|
66
144
|
}
|
|
67
145
|
|
|
68
146
|
export class ChonkProofWithPublicInputs {
|
|
147
|
+
/**
|
|
148
|
+
* Optional compressed proof bytes (covers the full proof WITH public inputs).
|
|
149
|
+
* Set by the prover when using chonk compression. Flows through to ChonkProof
|
|
150
|
+
* via removePublicInputs() so the Tx can serialize in compressed format.
|
|
151
|
+
*/
|
|
152
|
+
public compressedProof?: Buffer;
|
|
153
|
+
|
|
69
154
|
constructor(
|
|
70
155
|
// The proof fields with public inputs.
|
|
71
156
|
// For recursive verification, use without public inputs via `removePublicInputs()`.
|
|
@@ -83,7 +168,8 @@ export class ChonkProofWithPublicInputs {
|
|
|
83
168
|
|
|
84
169
|
public removePublicInputs() {
|
|
85
170
|
const numPublicInputs = this.fieldsWithPublicInputs.length - CHONK_PROOF_LENGTH;
|
|
86
|
-
|
|
171
|
+
// Flow compressed proof bytes through so the ChonkProof can serialize efficiently
|
|
172
|
+
return new ChonkProof(this.fieldsWithPublicInputs.slice(numPublicInputs), this.compressedProof);
|
|
87
173
|
}
|
|
88
174
|
|
|
89
175
|
public isEmpty() {
|
package/src/tests/factories.ts
CHANGED
|
@@ -1715,6 +1715,10 @@ export function makeL2Tips(
|
|
|
1715
1715
|
block: { number: bn, hash },
|
|
1716
1716
|
checkpoint: { number: cpn, hash: cph },
|
|
1717
1717
|
},
|
|
1718
|
+
proposedCheckpoint: {
|
|
1719
|
+
block: { number: bn, hash },
|
|
1720
|
+
checkpoint: { number: cpn, hash: cph },
|
|
1721
|
+
},
|
|
1718
1722
|
proven: {
|
|
1719
1723
|
block: { number: bn, hash },
|
|
1720
1724
|
checkpoint: { number: cpn, hash: cph },
|
package/src/tx/capsule.ts
CHANGED
|
@@ -19,6 +19,8 @@ export class Capsule {
|
|
|
19
19
|
public readonly storageSlot: Fr,
|
|
20
20
|
/** Data passed to the contract */
|
|
21
21
|
public readonly data: Fr[],
|
|
22
|
+
/** Optional namespace for the capsule contents */
|
|
23
|
+
public readonly scope?: AztecAddress,
|
|
22
24
|
) {}
|
|
23
25
|
|
|
24
26
|
static get schema() {
|
|
@@ -30,12 +32,18 @@ export class Capsule {
|
|
|
30
32
|
}
|
|
31
33
|
|
|
32
34
|
toBuffer() {
|
|
33
|
-
return
|
|
35
|
+
return this.scope
|
|
36
|
+
? serializeToBuffer(this.contractAddress, this.storageSlot, new Vector(this.data), true, this.scope)
|
|
37
|
+
: serializeToBuffer(this.contractAddress, this.storageSlot, new Vector(this.data), false);
|
|
34
38
|
}
|
|
35
39
|
|
|
36
40
|
static fromBuffer(buffer: Buffer | BufferReader): Capsule {
|
|
37
41
|
const reader = BufferReader.asReader(buffer);
|
|
38
|
-
|
|
42
|
+
const contractAddress = AztecAddress.fromBuffer(reader);
|
|
43
|
+
const storageSlot = Fr.fromBuffer(reader);
|
|
44
|
+
const data = reader.readVector(Fr);
|
|
45
|
+
const hasScope = reader.readBoolean();
|
|
46
|
+
return new Capsule(contractAddress, storageSlot, data, hasScope ? AztecAddress.fromBuffer(reader) : undefined);
|
|
39
47
|
}
|
|
40
48
|
|
|
41
49
|
toString() {
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { FeeHeader } from '@aztec/ethereum/contracts';
|
|
2
|
+
import type { CheckpointNumber } from '@aztec/foundation/branded-types';
|
|
1
3
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
4
|
import type { SlotNumber } from '@aztec/foundation/schemas';
|
|
3
5
|
|
|
@@ -6,6 +8,18 @@ import type { GasFees } from '../gas/gas_fees.js';
|
|
|
6
8
|
import type { UInt32 } from '../types/index.js';
|
|
7
9
|
import type { CheckpointGlobalVariables, GlobalVariables } from './global_variables.js';
|
|
8
10
|
|
|
11
|
+
/** Fee header fields needed for pipelining overrides. */
|
|
12
|
+
export type ForceProposedFeeHeader = {
|
|
13
|
+
checkpointNumber: CheckpointNumber;
|
|
14
|
+
feeHeader: FeeHeader;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/** Options for building checkpoint global variables during pipelining. */
|
|
18
|
+
export type BuildCheckpointGlobalVariablesOpts = {
|
|
19
|
+
forcePendingCheckpointNumber?: CheckpointNumber;
|
|
20
|
+
forceProposedFeeHeader?: ForceProposedFeeHeader;
|
|
21
|
+
};
|
|
22
|
+
|
|
9
23
|
/**
|
|
10
24
|
* Interface for building global variables for Aztec blocks.
|
|
11
25
|
*/
|
|
@@ -32,5 +46,6 @@ export interface GlobalVariableBuilder {
|
|
|
32
46
|
coinbase: EthAddress,
|
|
33
47
|
feeRecipient: AztecAddress,
|
|
34
48
|
slotNumber: SlotNumber,
|
|
49
|
+
opts?: BuildCheckpointGlobalVariablesOpts,
|
|
35
50
|
): Promise<CheckpointGlobalVariables>;
|
|
36
51
|
}
|