@aztec/blob-lib 3.0.0-canary.a9708bd → 3.0.0-devnet.2
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/blob.d.ts +52 -95
- package/dest/blob.d.ts.map +1 -1
- package/dest/blob.js +73 -165
- package/dest/blob_batching.d.ts +15 -48
- package/dest/blob_batching.d.ts.map +1 -1
- package/dest/blob_batching.js +81 -120
- package/dest/blob_utils.d.ts +30 -0
- package/dest/blob_utils.d.ts.map +1 -0
- package/dest/blob_utils.js +60 -0
- package/dest/circuit_types/blob_accumulator.d.ts +21 -0
- package/dest/circuit_types/blob_accumulator.d.ts.map +1 -0
- package/dest/circuit_types/blob_accumulator.js +58 -0
- package/dest/circuit_types/final_blob_accumulator.d.ts +22 -0
- package/dest/circuit_types/final_blob_accumulator.d.ts.map +1 -0
- package/dest/circuit_types/final_blob_accumulator.js +63 -0
- package/dest/circuit_types/final_blob_batching_challenges.d.ts +15 -0
- package/dest/circuit_types/final_blob_batching_challenges.d.ts.map +1 -0
- package/dest/circuit_types/final_blob_batching_challenges.js +25 -0
- package/dest/circuit_types/index.d.ts +4 -0
- package/dest/circuit_types/index.d.ts.map +1 -0
- package/dest/circuit_types/index.js +4 -0
- package/dest/deserialize.d.ts +14 -0
- package/dest/deserialize.d.ts.map +1 -0
- package/dest/deserialize.js +33 -0
- package/dest/encoding.d.ts +22 -62
- package/dest/encoding.d.ts.map +1 -1
- package/dest/encoding.js +114 -104
- package/dest/hash.d.ts +35 -0
- package/dest/hash.d.ts.map +1 -0
- package/dest/hash.js +69 -0
- package/dest/index.d.ts +5 -2
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +5 -15
- package/dest/kzg_context.d.ts +4 -0
- package/dest/kzg_context.d.ts.map +1 -0
- package/dest/kzg_context.js +5 -0
- package/dest/sponge_blob.d.ts +13 -9
- package/dest/sponge_blob.d.ts.map +1 -1
- package/dest/sponge_blob.js +28 -17
- package/dest/testing.d.ts +7 -12
- package/dest/testing.d.ts.map +1 -1
- package/dest/testing.js +54 -41
- package/dest/types.d.ts +16 -0
- package/dest/types.d.ts.map +1 -0
- package/dest/types.js +3 -0
- package/package.json +6 -4
- package/src/blob.ts +76 -191
- package/src/blob_batching.ts +109 -137
- package/src/blob_utils.ts +71 -0
- package/src/circuit_types/blob_accumulator.ts +84 -0
- package/src/circuit_types/final_blob_accumulator.ts +75 -0
- package/src/circuit_types/final_blob_batching_challenges.ts +29 -0
- package/src/circuit_types/index.ts +4 -0
- package/src/deserialize.ts +38 -0
- package/src/encoding.ts +136 -120
- package/src/hash.ts +77 -0
- package/src/index.ts +5 -18
- package/src/kzg_context.ts +5 -0
- package/src/sponge_blob.ts +24 -14
- package/src/testing.ts +55 -40
- package/src/types.ts +16 -0
- package/dest/blob_batching_public_inputs.d.ts +0 -71
- package/dest/blob_batching_public_inputs.d.ts.map +0 -1
- package/dest/blob_batching_public_inputs.js +0 -168
- package/src/blob_batching_public_inputs.ts +0 -252
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { BLS12Fr, BLS12Point, Fr } from '@aztec/foundation/fields';
|
|
2
|
-
import { BufferReader, FieldReader } from '@aztec/foundation/serialize';
|
|
3
|
-
import { inspect } from 'util';
|
|
4
|
-
import { Blob } from './blob.js';
|
|
5
|
-
import { BatchedBlob, BatchedBlobAccumulator, FinalBlobBatchingChallenges } from './blob_batching.js';
|
|
6
|
-
/**
|
|
7
|
-
* See nr BlobAccumulatorPublicInputs and ts BatchedBlobAccumulator for documentation.
|
|
8
|
-
*/
|
|
9
|
-
export declare class BlobAccumulatorPublicInputs {
|
|
10
|
-
blobCommitmentsHashAcc: Fr;
|
|
11
|
-
zAcc: Fr;
|
|
12
|
-
yAcc: BLS12Fr;
|
|
13
|
-
cAcc: BLS12Point;
|
|
14
|
-
gammaAcc: Fr;
|
|
15
|
-
gammaPowAcc: BLS12Fr;
|
|
16
|
-
constructor(blobCommitmentsHashAcc: Fr, zAcc: Fr, yAcc: BLS12Fr, cAcc: BLS12Point, gammaAcc: Fr, gammaPowAcc: BLS12Fr);
|
|
17
|
-
static empty(): BlobAccumulatorPublicInputs;
|
|
18
|
-
equals(other: BlobAccumulatorPublicInputs): boolean;
|
|
19
|
-
static fromBuffer(buffer: Buffer | BufferReader): BlobAccumulatorPublicInputs;
|
|
20
|
-
toBuffer(): Buffer<ArrayBufferLike>;
|
|
21
|
-
/**
|
|
22
|
-
* Given blobs, accumulate all public inputs state.
|
|
23
|
-
* We assume the input blobs have not been evaluated at z.
|
|
24
|
-
* NOTE: Does NOT accumulate non circuit values including Q. This exists to simulate/check exactly what the circuit is doing
|
|
25
|
-
* and is unsafe for other use. For that reason, a toBatchedBlobAccumulator does not exist. See evaluateBlobs() oracle for usage.
|
|
26
|
-
* @returns An updated blob accumulator.
|
|
27
|
-
*/
|
|
28
|
-
accumulateBlobs(blobs: Blob[], finalBlobChallenges: FinalBlobBatchingChallenges): Promise<BlobAccumulatorPublicInputs>;
|
|
29
|
-
toFields(): Fr[];
|
|
30
|
-
static fromFields(fields: Fr[] | FieldReader): BlobAccumulatorPublicInputs;
|
|
31
|
-
/**
|
|
32
|
-
* Converts from an accumulator to a struct for the public inputs of our rollup circuits.
|
|
33
|
-
* @returns A BlobAccumulatorPublicInputs instance.
|
|
34
|
-
*/
|
|
35
|
-
static fromBatchedBlobAccumulator(accumulator: BatchedBlobAccumulator): BlobAccumulatorPublicInputs;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* See nr FinalBlobAccumulatorPublicInputs and ts BatchedBlobAccumulator for documentation.
|
|
39
|
-
*/
|
|
40
|
-
export declare class FinalBlobAccumulatorPublicInputs {
|
|
41
|
-
blobCommitmentsHash: Fr;
|
|
42
|
-
z: Fr;
|
|
43
|
-
y: BLS12Fr;
|
|
44
|
-
c: BLS12Point;
|
|
45
|
-
constructor(blobCommitmentsHash: Fr, z: Fr, y: BLS12Fr, c: BLS12Point);
|
|
46
|
-
static empty(): FinalBlobAccumulatorPublicInputs;
|
|
47
|
-
static fromBuffer(buffer: Buffer | BufferReader): FinalBlobAccumulatorPublicInputs;
|
|
48
|
-
toBuffer(): Buffer<ArrayBufferLike>;
|
|
49
|
-
static fromBatchedBlob(blob: BatchedBlob): FinalBlobAccumulatorPublicInputs;
|
|
50
|
-
toFields(): Fr[];
|
|
51
|
-
toString(): string;
|
|
52
|
-
equals(other: FinalBlobAccumulatorPublicInputs): boolean;
|
|
53
|
-
static random(): FinalBlobAccumulatorPublicInputs;
|
|
54
|
-
static fromBatchedBlobAccumulator(accumulator: BatchedBlobAccumulator): FinalBlobAccumulatorPublicInputs;
|
|
55
|
-
[inspect.custom](): string;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* startBlobAccumulator: Accumulated opening proofs for all blobs before this block range.
|
|
59
|
-
* endBlobAccumulator: Accumulated opening proofs for all blobs after adding this block range.
|
|
60
|
-
* finalBlobChallenges: Final values z and gamma, shared across the epoch.
|
|
61
|
-
*/
|
|
62
|
-
export declare class BlockBlobPublicInputs {
|
|
63
|
-
startBlobAccumulator: BlobAccumulatorPublicInputs;
|
|
64
|
-
endBlobAccumulator: BlobAccumulatorPublicInputs;
|
|
65
|
-
finalBlobChallenges: FinalBlobBatchingChallenges;
|
|
66
|
-
constructor(startBlobAccumulator: BlobAccumulatorPublicInputs, endBlobAccumulator: BlobAccumulatorPublicInputs, finalBlobChallenges: FinalBlobBatchingChallenges);
|
|
67
|
-
static empty(): BlockBlobPublicInputs;
|
|
68
|
-
static fromBuffer(buffer: Buffer | BufferReader): BlockBlobPublicInputs;
|
|
69
|
-
toBuffer(): Buffer<ArrayBufferLike>;
|
|
70
|
-
}
|
|
71
|
-
//# sourceMappingURL=blob_batching_public_inputs.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"blob_batching_public_inputs.d.ts","sourceRoot":"","sources":["../src/blob_batching_public_inputs.ts"],"names":[],"mappings":"AACA,OAAO,EAAW,OAAO,EAAE,UAAU,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,WAAW,EAAqB,MAAM,6BAA6B,CAAC;AAE3F,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAE/B,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,sBAAsB,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAC;AAEtG;;GAEG;AACH,qBAAa,2BAA2B;IAE7B,sBAAsB,EAAE,EAAE;IAC1B,IAAI,EAAE,EAAE;IACR,IAAI,EAAE,OAAO;IACb,IAAI,EAAE,UAAU;IAChB,QAAQ,EAAE,EAAE;IACZ,WAAW,EAAE,OAAO;gBALpB,sBAAsB,EAAE,EAAE,EAC1B,IAAI,EAAE,EAAE,EACR,IAAI,EAAE,OAAO,EACb,IAAI,EAAE,UAAU,EAChB,QAAQ,EAAE,EAAE,EACZ,WAAW,EAAE,OAAO;IAG7B,MAAM,CAAC,KAAK,IAAI,2BAA2B;IAI3C,MAAM,CAAC,KAAK,EAAE,2BAA2B;IAWzC,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,GAAG,2BAA2B;IAY7E,QAAQ;IAWR;;;;;;OAMG;IACG,eAAe,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,mBAAmB,EAAE,2BAA2B;IAsBrF,QAAQ;IAaR,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,EAAE,EAAE,GAAG,WAAW,GAAG,2BAA2B;IAgB1E;;;OAGG;IACH,MAAM,CAAC,0BAA0B,CAAC,WAAW,EAAE,sBAAsB;CAUtE;AAED;;GAEG;AACH,qBAAa,gCAAgC;IAElC,mBAAmB,EAAE,EAAE;IACvB,CAAC,EAAE,EAAE;IACL,CAAC,EAAE,OAAO;IACV,CAAC,EAAE,UAAU;gBAHb,mBAAmB,EAAE,EAAE,EACvB,CAAC,EAAE,EAAE,EACL,CAAC,EAAE,OAAO,EACV,CAAC,EAAE,UAAU;IAGtB,MAAM,CAAC,KAAK,IAAI,gCAAgC;IAIhD,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,GAAG,gCAAgC;IAUlF,QAAQ;IAIR,MAAM,CAAC,eAAe,CAAC,IAAI,EAAE,WAAW;IAIxC,QAAQ;IAUR,QAAQ;IAQR,MAAM,CAAC,KAAK,EAAE,gCAAgC;IAU9C,MAAM,CAAC,MAAM;IAKb,MAAM,CAAC,0BAA0B,CAAC,WAAW,EAAE,sBAAsB;IASrE,CAAC,OAAO,CAAC,MAAM,CAAC;CAQjB;AAED;;;;GAIG;AACH,qBAAa,qBAAqB;IAEvB,oBAAoB,EAAE,2BAA2B;IACjD,kBAAkB,EAAE,2BAA2B;IAC/C,mBAAmB,EAAE,2BAA2B;gBAFhD,oBAAoB,EAAE,2BAA2B,EACjD,kBAAkB,EAAE,2BAA2B,EAC/C,mBAAmB,EAAE,2BAA2B;IAGzD,MAAM,CAAC,KAAK,IAAI,qBAAqB;IAQrC,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,GAAG,qBAAqB;IASvE,QAAQ;CAGT"}
|
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
import { BLS12_FQ_LIMBS, BLS12_FR_LIMBS } from '@aztec/constants';
|
|
2
|
-
import { BLS12Fq, BLS12Fr, BLS12Point, Fr } from '@aztec/foundation/fields';
|
|
3
|
-
import { BufferReader, FieldReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
4
|
-
import { inspect } from 'util';
|
|
5
|
-
import { BatchedBlobAccumulator, FinalBlobBatchingChallenges } from './blob_batching.js';
|
|
6
|
-
/**
|
|
7
|
-
* See nr BlobAccumulatorPublicInputs and ts BatchedBlobAccumulator for documentation.
|
|
8
|
-
*/ export class BlobAccumulatorPublicInputs {
|
|
9
|
-
blobCommitmentsHashAcc;
|
|
10
|
-
zAcc;
|
|
11
|
-
yAcc;
|
|
12
|
-
cAcc;
|
|
13
|
-
gammaAcc;
|
|
14
|
-
gammaPowAcc;
|
|
15
|
-
constructor(blobCommitmentsHashAcc, zAcc, yAcc, cAcc, gammaAcc, gammaPowAcc){
|
|
16
|
-
this.blobCommitmentsHashAcc = blobCommitmentsHashAcc;
|
|
17
|
-
this.zAcc = zAcc;
|
|
18
|
-
this.yAcc = yAcc;
|
|
19
|
-
this.cAcc = cAcc;
|
|
20
|
-
this.gammaAcc = gammaAcc;
|
|
21
|
-
this.gammaPowAcc = gammaPowAcc;
|
|
22
|
-
}
|
|
23
|
-
static empty() {
|
|
24
|
-
return new BlobAccumulatorPublicInputs(Fr.ZERO, Fr.ZERO, BLS12Fr.ZERO, BLS12Point.ZERO, Fr.ZERO, BLS12Fr.ZERO);
|
|
25
|
-
}
|
|
26
|
-
equals(other) {
|
|
27
|
-
return this.blobCommitmentsHashAcc.equals(other.blobCommitmentsHashAcc) && this.zAcc.equals(other.zAcc) && this.yAcc.equals(other.yAcc) && this.cAcc.equals(other.cAcc) && this.gammaAcc.equals(other.gammaAcc) && this.gammaPowAcc.equals(other.gammaPowAcc);
|
|
28
|
-
}
|
|
29
|
-
static fromBuffer(buffer) {
|
|
30
|
-
const reader = BufferReader.asReader(buffer);
|
|
31
|
-
return new BlobAccumulatorPublicInputs(Fr.fromBuffer(reader), Fr.fromBuffer(reader), BLS12Fr.fromBuffer(reader), BLS12Point.fromBuffer(reader), Fr.fromBuffer(reader), BLS12Fr.fromBuffer(reader));
|
|
32
|
-
}
|
|
33
|
-
toBuffer() {
|
|
34
|
-
return serializeToBuffer(this.blobCommitmentsHashAcc, this.zAcc, this.yAcc, this.cAcc, this.gammaAcc, this.gammaPowAcc);
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Given blobs, accumulate all public inputs state.
|
|
38
|
-
* We assume the input blobs have not been evaluated at z.
|
|
39
|
-
* NOTE: Does NOT accumulate non circuit values including Q. This exists to simulate/check exactly what the circuit is doing
|
|
40
|
-
* and is unsafe for other use. For that reason, a toBatchedBlobAccumulator does not exist. See evaluateBlobs() oracle for usage.
|
|
41
|
-
* @returns An updated blob accumulator.
|
|
42
|
-
*/ async accumulateBlobs(blobs, finalBlobChallenges) {
|
|
43
|
-
let acc = new BatchedBlobAccumulator(this.blobCommitmentsHashAcc, this.zAcc, this.yAcc, this.cAcc, BLS12Point.ZERO, this.gammaAcc, this.gammaPowAcc, finalBlobChallenges);
|
|
44
|
-
acc = await acc.accumulateBlobs(blobs);
|
|
45
|
-
return new BlobAccumulatorPublicInputs(acc.blobCommitmentsHashAcc, acc.zAcc, acc.yAcc, acc.cAcc, acc.gammaAcc, acc.gammaPow);
|
|
46
|
-
}
|
|
47
|
-
toFields() {
|
|
48
|
-
return [
|
|
49
|
-
this.blobCommitmentsHashAcc,
|
|
50
|
-
this.zAcc,
|
|
51
|
-
...this.yAcc.toNoirBigNum().limbs.map(Fr.fromString),
|
|
52
|
-
...this.cAcc.x.toNoirBigNum().limbs.map(Fr.fromString),
|
|
53
|
-
...this.cAcc.y.toNoirBigNum().limbs.map(Fr.fromString),
|
|
54
|
-
new Fr(this.cAcc.isInfinite),
|
|
55
|
-
this.gammaAcc,
|
|
56
|
-
...this.gammaPowAcc.toNoirBigNum().limbs.map(Fr.fromString)
|
|
57
|
-
];
|
|
58
|
-
}
|
|
59
|
-
static fromFields(fields) {
|
|
60
|
-
const reader = FieldReader.asReader(fields);
|
|
61
|
-
return new BlobAccumulatorPublicInputs(reader.readField(), reader.readField(), BLS12Fr.fromNoirBigNum({
|
|
62
|
-
limbs: reader.readFieldArray(BLS12_FR_LIMBS).map((f)=>f.toString())
|
|
63
|
-
}), new BLS12Point(BLS12Fq.fromNoirBigNum({
|
|
64
|
-
limbs: reader.readFieldArray(BLS12_FQ_LIMBS).map((f)=>f.toString())
|
|
65
|
-
}), BLS12Fq.fromNoirBigNum({
|
|
66
|
-
limbs: reader.readFieldArray(BLS12_FQ_LIMBS).map((f)=>f.toString())
|
|
67
|
-
}), reader.readBoolean()), reader.readField(), BLS12Fr.fromNoirBigNum({
|
|
68
|
-
limbs: reader.readFieldArray(BLS12_FR_LIMBS).map((f)=>f.toString())
|
|
69
|
-
}));
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Converts from an accumulator to a struct for the public inputs of our rollup circuits.
|
|
73
|
-
* @returns A BlobAccumulatorPublicInputs instance.
|
|
74
|
-
*/ static fromBatchedBlobAccumulator(accumulator) {
|
|
75
|
-
return new BlobAccumulatorPublicInputs(accumulator.blobCommitmentsHashAcc, accumulator.zAcc, accumulator.yAcc, accumulator.cAcc, accumulator.gammaAcc, accumulator.gammaPow);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* See nr FinalBlobAccumulatorPublicInputs and ts BatchedBlobAccumulator for documentation.
|
|
80
|
-
*/ export class FinalBlobAccumulatorPublicInputs {
|
|
81
|
-
blobCommitmentsHash;
|
|
82
|
-
z;
|
|
83
|
-
y;
|
|
84
|
-
c;
|
|
85
|
-
constructor(blobCommitmentsHash, z, y, c){
|
|
86
|
-
this.blobCommitmentsHash = blobCommitmentsHash;
|
|
87
|
-
this.z = z;
|
|
88
|
-
this.y = y;
|
|
89
|
-
this.c = c;
|
|
90
|
-
}
|
|
91
|
-
static empty() {
|
|
92
|
-
return new FinalBlobAccumulatorPublicInputs(Fr.ZERO, Fr.ZERO, BLS12Fr.ZERO, BLS12Point.ZERO);
|
|
93
|
-
}
|
|
94
|
-
static fromBuffer(buffer) {
|
|
95
|
-
const reader = BufferReader.asReader(buffer);
|
|
96
|
-
return new FinalBlobAccumulatorPublicInputs(Fr.fromBuffer(reader), Fr.fromBuffer(reader), BLS12Fr.fromBuffer(reader), BLS12Point.fromBuffer(reader));
|
|
97
|
-
}
|
|
98
|
-
toBuffer() {
|
|
99
|
-
return serializeToBuffer(this.blobCommitmentsHash, this.z, this.y, this.c);
|
|
100
|
-
}
|
|
101
|
-
static fromBatchedBlob(blob) {
|
|
102
|
-
return new FinalBlobAccumulatorPublicInputs(blob.blobCommitmentsHash, blob.z, blob.y, blob.commitment);
|
|
103
|
-
}
|
|
104
|
-
toFields() {
|
|
105
|
-
return [
|
|
106
|
-
this.blobCommitmentsHash,
|
|
107
|
-
this.z,
|
|
108
|
-
...this.y.toNoirBigNum().limbs.map(Fr.fromString),
|
|
109
|
-
...this.c.toBN254Fields()
|
|
110
|
-
];
|
|
111
|
-
}
|
|
112
|
-
// The below is used to send to L1 for proof verification
|
|
113
|
-
toString() {
|
|
114
|
-
// We prepend 32 bytes for the (unused) 'blobHash' slot. This is not read or required by getEpochProofPublicInputs() on L1, but
|
|
115
|
-
// is expected since we usually pass the full precompile inputs via verifyEpochRootProof() to getEpochProofPublicInputs() to ensure
|
|
116
|
-
// we use calldata rather than a slice in memory:
|
|
117
|
-
const buf = Buffer.concat([
|
|
118
|
-
Buffer.alloc(32),
|
|
119
|
-
this.z.toBuffer(),
|
|
120
|
-
this.y.toBuffer(),
|
|
121
|
-
this.c.compress()
|
|
122
|
-
]);
|
|
123
|
-
return buf.toString('hex');
|
|
124
|
-
}
|
|
125
|
-
equals(other) {
|
|
126
|
-
return this.blobCommitmentsHash.equals(other.blobCommitmentsHash) && this.z.equals(other.z) && this.y.equals(other.y) && this.c.equals(other.c);
|
|
127
|
-
}
|
|
128
|
-
// Creates a random instance. Used for testing only - will not prove/verify.
|
|
129
|
-
static random() {
|
|
130
|
-
return new FinalBlobAccumulatorPublicInputs(Fr.random(), Fr.random(), BLS12Fr.random(), BLS12Point.random());
|
|
131
|
-
}
|
|
132
|
-
// Warning: MUST be final accumulator state.
|
|
133
|
-
static fromBatchedBlobAccumulator(accumulator) {
|
|
134
|
-
return new FinalBlobAccumulatorPublicInputs(accumulator.blobCommitmentsHashAcc, accumulator.zAcc, accumulator.yAcc, accumulator.cAcc);
|
|
135
|
-
}
|
|
136
|
-
[inspect.custom]() {
|
|
137
|
-
return `FinalBlobAccumulatorPublicInputs {
|
|
138
|
-
blobCommitmentsHash: ${inspect(this.blobCommitmentsHash)},
|
|
139
|
-
z: ${inspect(this.z)},
|
|
140
|
-
y: ${inspect(this.y)},
|
|
141
|
-
c: ${inspect(this.c)},
|
|
142
|
-
}`;
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* startBlobAccumulator: Accumulated opening proofs for all blobs before this block range.
|
|
147
|
-
* endBlobAccumulator: Accumulated opening proofs for all blobs after adding this block range.
|
|
148
|
-
* finalBlobChallenges: Final values z and gamma, shared across the epoch.
|
|
149
|
-
*/ export class BlockBlobPublicInputs {
|
|
150
|
-
startBlobAccumulator;
|
|
151
|
-
endBlobAccumulator;
|
|
152
|
-
finalBlobChallenges;
|
|
153
|
-
constructor(startBlobAccumulator, endBlobAccumulator, finalBlobChallenges){
|
|
154
|
-
this.startBlobAccumulator = startBlobAccumulator;
|
|
155
|
-
this.endBlobAccumulator = endBlobAccumulator;
|
|
156
|
-
this.finalBlobChallenges = finalBlobChallenges;
|
|
157
|
-
}
|
|
158
|
-
static empty() {
|
|
159
|
-
return new BlockBlobPublicInputs(BlobAccumulatorPublicInputs.empty(), BlobAccumulatorPublicInputs.empty(), FinalBlobBatchingChallenges.empty());
|
|
160
|
-
}
|
|
161
|
-
static fromBuffer(buffer) {
|
|
162
|
-
const reader = BufferReader.asReader(buffer);
|
|
163
|
-
return new BlockBlobPublicInputs(reader.readObject(BlobAccumulatorPublicInputs), reader.readObject(BlobAccumulatorPublicInputs), reader.readObject(FinalBlobBatchingChallenges));
|
|
164
|
-
}
|
|
165
|
-
toBuffer() {
|
|
166
|
-
return serializeToBuffer(this.startBlobAccumulator, this.endBlobAccumulator, this.finalBlobChallenges);
|
|
167
|
-
}
|
|
168
|
-
}
|
|
@@ -1,252 +0,0 @@
|
|
|
1
|
-
import { BLS12_FQ_LIMBS, BLS12_FR_LIMBS } from '@aztec/constants';
|
|
2
|
-
import { BLS12Fq, BLS12Fr, BLS12Point, Fr } from '@aztec/foundation/fields';
|
|
3
|
-
import { BufferReader, FieldReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
4
|
-
|
|
5
|
-
import { inspect } from 'util';
|
|
6
|
-
|
|
7
|
-
import { Blob } from './blob.js';
|
|
8
|
-
import { BatchedBlob, BatchedBlobAccumulator, FinalBlobBatchingChallenges } from './blob_batching.js';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* See nr BlobAccumulatorPublicInputs and ts BatchedBlobAccumulator for documentation.
|
|
12
|
-
*/
|
|
13
|
-
export class BlobAccumulatorPublicInputs {
|
|
14
|
-
constructor(
|
|
15
|
-
public blobCommitmentsHashAcc: Fr,
|
|
16
|
-
public zAcc: Fr,
|
|
17
|
-
public yAcc: BLS12Fr,
|
|
18
|
-
public cAcc: BLS12Point,
|
|
19
|
-
public gammaAcc: Fr,
|
|
20
|
-
public gammaPowAcc: BLS12Fr,
|
|
21
|
-
) {}
|
|
22
|
-
|
|
23
|
-
static empty(): BlobAccumulatorPublicInputs {
|
|
24
|
-
return new BlobAccumulatorPublicInputs(Fr.ZERO, Fr.ZERO, BLS12Fr.ZERO, BLS12Point.ZERO, Fr.ZERO, BLS12Fr.ZERO);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
equals(other: BlobAccumulatorPublicInputs) {
|
|
28
|
-
return (
|
|
29
|
-
this.blobCommitmentsHashAcc.equals(other.blobCommitmentsHashAcc) &&
|
|
30
|
-
this.zAcc.equals(other.zAcc) &&
|
|
31
|
-
this.yAcc.equals(other.yAcc) &&
|
|
32
|
-
this.cAcc.equals(other.cAcc) &&
|
|
33
|
-
this.gammaAcc.equals(other.gammaAcc) &&
|
|
34
|
-
this.gammaPowAcc.equals(other.gammaPowAcc)
|
|
35
|
-
);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
static fromBuffer(buffer: Buffer | BufferReader): BlobAccumulatorPublicInputs {
|
|
39
|
-
const reader = BufferReader.asReader(buffer);
|
|
40
|
-
return new BlobAccumulatorPublicInputs(
|
|
41
|
-
Fr.fromBuffer(reader),
|
|
42
|
-
Fr.fromBuffer(reader),
|
|
43
|
-
BLS12Fr.fromBuffer(reader),
|
|
44
|
-
BLS12Point.fromBuffer(reader),
|
|
45
|
-
Fr.fromBuffer(reader),
|
|
46
|
-
BLS12Fr.fromBuffer(reader),
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
toBuffer() {
|
|
51
|
-
return serializeToBuffer(
|
|
52
|
-
this.blobCommitmentsHashAcc,
|
|
53
|
-
this.zAcc,
|
|
54
|
-
this.yAcc,
|
|
55
|
-
this.cAcc,
|
|
56
|
-
this.gammaAcc,
|
|
57
|
-
this.gammaPowAcc,
|
|
58
|
-
);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Given blobs, accumulate all public inputs state.
|
|
63
|
-
* We assume the input blobs have not been evaluated at z.
|
|
64
|
-
* NOTE: Does NOT accumulate non circuit values including Q. This exists to simulate/check exactly what the circuit is doing
|
|
65
|
-
* and is unsafe for other use. For that reason, a toBatchedBlobAccumulator does not exist. See evaluateBlobs() oracle for usage.
|
|
66
|
-
* @returns An updated blob accumulator.
|
|
67
|
-
*/
|
|
68
|
-
async accumulateBlobs(blobs: Blob[], finalBlobChallenges: FinalBlobBatchingChallenges) {
|
|
69
|
-
let acc = new BatchedBlobAccumulator(
|
|
70
|
-
this.blobCommitmentsHashAcc,
|
|
71
|
-
this.zAcc,
|
|
72
|
-
this.yAcc,
|
|
73
|
-
this.cAcc,
|
|
74
|
-
BLS12Point.ZERO,
|
|
75
|
-
this.gammaAcc,
|
|
76
|
-
this.gammaPowAcc,
|
|
77
|
-
finalBlobChallenges,
|
|
78
|
-
);
|
|
79
|
-
acc = await acc.accumulateBlobs(blobs);
|
|
80
|
-
return new BlobAccumulatorPublicInputs(
|
|
81
|
-
acc.blobCommitmentsHashAcc,
|
|
82
|
-
acc.zAcc,
|
|
83
|
-
acc.yAcc,
|
|
84
|
-
acc.cAcc,
|
|
85
|
-
acc.gammaAcc,
|
|
86
|
-
acc.gammaPow,
|
|
87
|
-
);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
toFields() {
|
|
91
|
-
return [
|
|
92
|
-
this.blobCommitmentsHashAcc,
|
|
93
|
-
this.zAcc,
|
|
94
|
-
...this.yAcc.toNoirBigNum().limbs.map(Fr.fromString),
|
|
95
|
-
...this.cAcc.x.toNoirBigNum().limbs.map(Fr.fromString),
|
|
96
|
-
...this.cAcc.y.toNoirBigNum().limbs.map(Fr.fromString),
|
|
97
|
-
new Fr(this.cAcc.isInfinite),
|
|
98
|
-
this.gammaAcc,
|
|
99
|
-
...this.gammaPowAcc.toNoirBigNum().limbs.map(Fr.fromString),
|
|
100
|
-
];
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
static fromFields(fields: Fr[] | FieldReader): BlobAccumulatorPublicInputs {
|
|
104
|
-
const reader = FieldReader.asReader(fields);
|
|
105
|
-
return new BlobAccumulatorPublicInputs(
|
|
106
|
-
reader.readField(),
|
|
107
|
-
reader.readField(),
|
|
108
|
-
BLS12Fr.fromNoirBigNum({ limbs: reader.readFieldArray(BLS12_FR_LIMBS).map(f => f.toString()) }),
|
|
109
|
-
new BLS12Point(
|
|
110
|
-
BLS12Fq.fromNoirBigNum({ limbs: reader.readFieldArray(BLS12_FQ_LIMBS).map(f => f.toString()) }),
|
|
111
|
-
BLS12Fq.fromNoirBigNum({ limbs: reader.readFieldArray(BLS12_FQ_LIMBS).map(f => f.toString()) }),
|
|
112
|
-
reader.readBoolean(),
|
|
113
|
-
),
|
|
114
|
-
reader.readField(),
|
|
115
|
-
BLS12Fr.fromNoirBigNum({ limbs: reader.readFieldArray(BLS12_FR_LIMBS).map(f => f.toString()) }),
|
|
116
|
-
);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Converts from an accumulator to a struct for the public inputs of our rollup circuits.
|
|
121
|
-
* @returns A BlobAccumulatorPublicInputs instance.
|
|
122
|
-
*/
|
|
123
|
-
static fromBatchedBlobAccumulator(accumulator: BatchedBlobAccumulator) {
|
|
124
|
-
return new BlobAccumulatorPublicInputs(
|
|
125
|
-
accumulator.blobCommitmentsHashAcc,
|
|
126
|
-
accumulator.zAcc,
|
|
127
|
-
accumulator.yAcc,
|
|
128
|
-
accumulator.cAcc,
|
|
129
|
-
accumulator.gammaAcc,
|
|
130
|
-
accumulator.gammaPow,
|
|
131
|
-
);
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* See nr FinalBlobAccumulatorPublicInputs and ts BatchedBlobAccumulator for documentation.
|
|
137
|
-
*/
|
|
138
|
-
export class FinalBlobAccumulatorPublicInputs {
|
|
139
|
-
constructor(
|
|
140
|
-
public blobCommitmentsHash: Fr,
|
|
141
|
-
public z: Fr,
|
|
142
|
-
public y: BLS12Fr,
|
|
143
|
-
public c: BLS12Point,
|
|
144
|
-
) {}
|
|
145
|
-
|
|
146
|
-
static empty(): FinalBlobAccumulatorPublicInputs {
|
|
147
|
-
return new FinalBlobAccumulatorPublicInputs(Fr.ZERO, Fr.ZERO, BLS12Fr.ZERO, BLS12Point.ZERO);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
static fromBuffer(buffer: Buffer | BufferReader): FinalBlobAccumulatorPublicInputs {
|
|
151
|
-
const reader = BufferReader.asReader(buffer);
|
|
152
|
-
return new FinalBlobAccumulatorPublicInputs(
|
|
153
|
-
Fr.fromBuffer(reader),
|
|
154
|
-
Fr.fromBuffer(reader),
|
|
155
|
-
BLS12Fr.fromBuffer(reader),
|
|
156
|
-
BLS12Point.fromBuffer(reader),
|
|
157
|
-
);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
toBuffer() {
|
|
161
|
-
return serializeToBuffer(this.blobCommitmentsHash, this.z, this.y, this.c);
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
static fromBatchedBlob(blob: BatchedBlob) {
|
|
165
|
-
return new FinalBlobAccumulatorPublicInputs(blob.blobCommitmentsHash, blob.z, blob.y, blob.commitment);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
toFields() {
|
|
169
|
-
return [
|
|
170
|
-
this.blobCommitmentsHash,
|
|
171
|
-
this.z,
|
|
172
|
-
...this.y.toNoirBigNum().limbs.map(Fr.fromString),
|
|
173
|
-
...this.c.toBN254Fields(),
|
|
174
|
-
];
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
// The below is used to send to L1 for proof verification
|
|
178
|
-
toString() {
|
|
179
|
-
// We prepend 32 bytes for the (unused) 'blobHash' slot. This is not read or required by getEpochProofPublicInputs() on L1, but
|
|
180
|
-
// is expected since we usually pass the full precompile inputs via verifyEpochRootProof() to getEpochProofPublicInputs() to ensure
|
|
181
|
-
// we use calldata rather than a slice in memory:
|
|
182
|
-
const buf = Buffer.concat([Buffer.alloc(32), this.z.toBuffer(), this.y.toBuffer(), this.c.compress()]);
|
|
183
|
-
return buf.toString('hex');
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
equals(other: FinalBlobAccumulatorPublicInputs) {
|
|
187
|
-
return (
|
|
188
|
-
this.blobCommitmentsHash.equals(other.blobCommitmentsHash) &&
|
|
189
|
-
this.z.equals(other.z) &&
|
|
190
|
-
this.y.equals(other.y) &&
|
|
191
|
-
this.c.equals(other.c)
|
|
192
|
-
);
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
// Creates a random instance. Used for testing only - will not prove/verify.
|
|
196
|
-
static random() {
|
|
197
|
-
return new FinalBlobAccumulatorPublicInputs(Fr.random(), Fr.random(), BLS12Fr.random(), BLS12Point.random());
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
// Warning: MUST be final accumulator state.
|
|
201
|
-
static fromBatchedBlobAccumulator(accumulator: BatchedBlobAccumulator) {
|
|
202
|
-
return new FinalBlobAccumulatorPublicInputs(
|
|
203
|
-
accumulator.blobCommitmentsHashAcc,
|
|
204
|
-
accumulator.zAcc,
|
|
205
|
-
accumulator.yAcc,
|
|
206
|
-
accumulator.cAcc,
|
|
207
|
-
);
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
[inspect.custom]() {
|
|
211
|
-
return `FinalBlobAccumulatorPublicInputs {
|
|
212
|
-
blobCommitmentsHash: ${inspect(this.blobCommitmentsHash)},
|
|
213
|
-
z: ${inspect(this.z)},
|
|
214
|
-
y: ${inspect(this.y)},
|
|
215
|
-
c: ${inspect(this.c)},
|
|
216
|
-
}`;
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
/**
|
|
221
|
-
* startBlobAccumulator: Accumulated opening proofs for all blobs before this block range.
|
|
222
|
-
* endBlobAccumulator: Accumulated opening proofs for all blobs after adding this block range.
|
|
223
|
-
* finalBlobChallenges: Final values z and gamma, shared across the epoch.
|
|
224
|
-
*/
|
|
225
|
-
export class BlockBlobPublicInputs {
|
|
226
|
-
constructor(
|
|
227
|
-
public startBlobAccumulator: BlobAccumulatorPublicInputs,
|
|
228
|
-
public endBlobAccumulator: BlobAccumulatorPublicInputs,
|
|
229
|
-
public finalBlobChallenges: FinalBlobBatchingChallenges,
|
|
230
|
-
) {}
|
|
231
|
-
|
|
232
|
-
static empty(): BlockBlobPublicInputs {
|
|
233
|
-
return new BlockBlobPublicInputs(
|
|
234
|
-
BlobAccumulatorPublicInputs.empty(),
|
|
235
|
-
BlobAccumulatorPublicInputs.empty(),
|
|
236
|
-
FinalBlobBatchingChallenges.empty(),
|
|
237
|
-
);
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
static fromBuffer(buffer: Buffer | BufferReader): BlockBlobPublicInputs {
|
|
241
|
-
const reader = BufferReader.asReader(buffer);
|
|
242
|
-
return new BlockBlobPublicInputs(
|
|
243
|
-
reader.readObject(BlobAccumulatorPublicInputs),
|
|
244
|
-
reader.readObject(BlobAccumulatorPublicInputs),
|
|
245
|
-
reader.readObject(FinalBlobBatchingChallenges),
|
|
246
|
-
);
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
toBuffer() {
|
|
250
|
-
return serializeToBuffer(this.startBlobAccumulator, this.endBlobAccumulator, this.finalBlobChallenges);
|
|
251
|
-
}
|
|
252
|
-
}
|