@aztec/blob-lib 0.0.1-commit.b655e406 → 0.0.1-commit.b9865e97

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 (101) hide show
  1. package/dest/batched_blob.d.ts +31 -0
  2. package/dest/batched_blob.d.ts.map +1 -0
  3. package/dest/batched_blob.js +20 -0
  4. package/dest/blob.d.ts +14 -14
  5. package/dest/blob.d.ts.map +1 -1
  6. package/dest/blob.js +21 -20
  7. package/dest/blob_batching.d.ts +36 -73
  8. package/dest/blob_batching.d.ts.map +1 -1
  9. package/dest/blob_batching.js +90 -125
  10. package/dest/blob_utils.d.ts +22 -12
  11. package/dest/blob_utils.d.ts.map +1 -1
  12. package/dest/blob_utils.js +32 -23
  13. package/dest/circuit_types/blob_accumulator.d.ts +4 -2
  14. package/dest/circuit_types/blob_accumulator.d.ts.map +1 -1
  15. package/dest/circuit_types/blob_accumulator.js +5 -1
  16. package/dest/circuit_types/final_blob_accumulator.d.ts +3 -2
  17. package/dest/circuit_types/final_blob_accumulator.d.ts.map +1 -1
  18. package/dest/circuit_types/final_blob_accumulator.js +5 -2
  19. package/dest/circuit_types/final_blob_batching_challenges.d.ts +3 -2
  20. package/dest/circuit_types/final_blob_batching_challenges.d.ts.map +1 -1
  21. package/dest/circuit_types/final_blob_batching_challenges.js +2 -1
  22. package/dest/circuit_types/index.d.ts +1 -1
  23. package/dest/encoding/block_blob_data.d.ts +30 -0
  24. package/dest/encoding/block_blob_data.d.ts.map +1 -0
  25. package/dest/encoding/block_blob_data.js +75 -0
  26. package/dest/encoding/block_end_marker.d.ts +11 -0
  27. package/dest/encoding/block_end_marker.d.ts.map +1 -0
  28. package/dest/encoding/block_end_marker.js +41 -0
  29. package/dest/encoding/block_end_state_field.d.ts +12 -0
  30. package/dest/encoding/block_end_state_field.d.ts.map +1 -0
  31. package/dest/encoding/block_end_state_field.js +39 -0
  32. package/dest/encoding/checkpoint_blob_data.d.ts +15 -0
  33. package/dest/encoding/checkpoint_blob_data.d.ts.map +1 -0
  34. package/dest/encoding/checkpoint_blob_data.js +67 -0
  35. package/dest/encoding/checkpoint_end_marker.d.ts +8 -0
  36. package/dest/encoding/checkpoint_end_marker.d.ts.map +1 -0
  37. package/dest/encoding/checkpoint_end_marker.js +28 -0
  38. package/dest/encoding/fixtures.d.ts +41 -0
  39. package/dest/encoding/fixtures.d.ts.map +1 -0
  40. package/dest/encoding/fixtures.js +140 -0
  41. package/dest/encoding/index.d.ts +10 -0
  42. package/dest/encoding/index.d.ts.map +1 -0
  43. package/dest/encoding/index.js +9 -0
  44. package/dest/encoding/tx_blob_data.d.ts +19 -0
  45. package/dest/encoding/tx_blob_data.d.ts.map +1 -0
  46. package/dest/encoding/tx_blob_data.js +79 -0
  47. package/dest/encoding/tx_start_marker.d.ts +16 -0
  48. package/dest/encoding/tx_start_marker.d.ts.map +1 -0
  49. package/dest/{encoding.js → encoding/tx_start_marker.js} +14 -60
  50. package/dest/errors.d.ts +1 -1
  51. package/dest/errors.d.ts.map +1 -1
  52. package/dest/hash.d.ts +18 -9
  53. package/dest/hash.d.ts.map +1 -1
  54. package/dest/hash.js +33 -20
  55. package/dest/index.d.ts +4 -4
  56. package/dest/index.d.ts.map +1 -1
  57. package/dest/index.js +3 -3
  58. package/dest/interface.d.ts +1 -2
  59. package/dest/interface.d.ts.map +1 -1
  60. package/dest/kzg_context.d.ts +10 -4
  61. package/dest/kzg_context.d.ts.map +1 -1
  62. package/dest/kzg_context.js +29 -5
  63. package/dest/sponge_blob.d.ts +9 -13
  64. package/dest/sponge_blob.d.ts.map +1 -1
  65. package/dest/sponge_blob.js +21 -36
  66. package/dest/testing.d.ts +9 -17
  67. package/dest/testing.d.ts.map +1 -1
  68. package/dest/testing.js +35 -64
  69. package/dest/types.d.ts +2 -1
  70. package/dest/types.d.ts.map +1 -1
  71. package/dest/types.js +1 -0
  72. package/package.json +8 -7
  73. package/src/batched_blob.ts +26 -0
  74. package/src/blob.ts +21 -20
  75. package/src/blob_batching.ts +105 -137
  76. package/src/blob_utils.ts +38 -25
  77. package/src/circuit_types/blob_accumulator.ts +13 -1
  78. package/src/circuit_types/final_blob_accumulator.ts +2 -1
  79. package/src/circuit_types/final_blob_batching_challenges.ts +2 -1
  80. package/src/encoding/block_blob_data.ts +114 -0
  81. package/src/encoding/block_end_marker.ts +55 -0
  82. package/src/encoding/block_end_state_field.ts +59 -0
  83. package/src/encoding/checkpoint_blob_data.ts +102 -0
  84. package/src/encoding/checkpoint_end_marker.ts +40 -0
  85. package/src/encoding/fixtures.ts +210 -0
  86. package/src/encoding/index.ts +9 -0
  87. package/src/encoding/tx_blob_data.ts +116 -0
  88. package/src/{encoding.ts → encoding/tx_start_marker.ts} +20 -77
  89. package/src/hash.ts +36 -19
  90. package/src/index.ts +3 -3
  91. package/src/interface.ts +0 -1
  92. package/src/kzg_context.ts +39 -3
  93. package/src/sponge_blob.ts +23 -36
  94. package/src/testing.ts +48 -74
  95. package/src/types.ts +1 -0
  96. package/dest/deserialize.d.ts +0 -14
  97. package/dest/deserialize.d.ts.map +0 -1
  98. package/dest/deserialize.js +0 -33
  99. package/dest/encoding.d.ts +0 -26
  100. package/dest/encoding.d.ts.map +0 -1
  101. package/src/deserialize.ts +0 -38
@@ -0,0 +1,79 @@
1
+ import { chunk } from '@aztec/foundation/collection';
2
+ import { Fr } from '@aztec/foundation/curves/bn254';
3
+ import { FieldReader } from '@aztec/foundation/serialize';
4
+ import { BlobDeserializationError } from '../errors.js';
5
+ import { decodeTxStartMarker, encodeTxStartMarker } from './tx_start_marker.js';
6
+ export function encodeTxBlobData(txBlobData) {
7
+ return [
8
+ encodeTxStartMarker(txBlobData.txStartMarker),
9
+ txBlobData.txHash,
10
+ txBlobData.transactionFee,
11
+ ...txBlobData.noteHashes,
12
+ ...txBlobData.nullifiers,
13
+ ...txBlobData.l2ToL1Msgs,
14
+ ...txBlobData.publicDataWrites.flat(),
15
+ ...txBlobData.privateLogs.map((log)=>[
16
+ new Fr(log.length),
17
+ ...log
18
+ ]).flat(),
19
+ ...txBlobData.publicLogs,
20
+ ...txBlobData.contractClassLog
21
+ ];
22
+ }
23
+ export function decodeTxBlobData(fields) {
24
+ const reader = FieldReader.asReader(fields);
25
+ if (reader.isFinished()) {
26
+ throw new BlobDeserializationError(`Incorrect encoding of blob fields: not enough fields for tx blob data.`);
27
+ }
28
+ const txStartMarker = decodeTxStartMarker(reader.readField());
29
+ const checkRemainingFields = (requiredFields, type)=>{
30
+ if (requiredFields > reader.remainingFields()) {
31
+ throw new BlobDeserializationError(`Incorrect encoding of blob fields: not enough fields for ${type}. Expected ${requiredFields} fields, only ${reader.remainingFields()} remaining.`);
32
+ }
33
+ };
34
+ const numTxEffectFields = txStartMarker.numBlobFields - 1; // -1 because we already read the tx start marker.
35
+ checkRemainingFields(numTxEffectFields, 'tx effect');
36
+ const txHash = reader.readField();
37
+ const transactionFee = reader.readField();
38
+ checkRemainingFields(txStartMarker.numNoteHashes, 'note hashes');
39
+ const noteHashes = reader.readFieldArray(txStartMarker.numNoteHashes);
40
+ checkRemainingFields(txStartMarker.numNullifiers, 'nullifiers');
41
+ const nullifiers = reader.readFieldArray(txStartMarker.numNullifiers);
42
+ checkRemainingFields(txStartMarker.numL2ToL1Msgs, 'l2-to-l1 messages');
43
+ const l2ToL1Msgs = reader.readFieldArray(txStartMarker.numL2ToL1Msgs);
44
+ checkRemainingFields(txStartMarker.numPublicDataWrites * 2, 'public data writes'); // *2 for leaf slot and value
45
+ const publicDataWrites = chunk(reader.readFieldArray(txStartMarker.numPublicDataWrites * 2), 2);
46
+ const privateLogs = Array.from({
47
+ length: txStartMarker.numPrivateLogs
48
+ }, ()=>{
49
+ const length = reader.readU32();
50
+ checkRemainingFields(length, 'private log');
51
+ return reader.readFieldArray(length);
52
+ });
53
+ checkRemainingFields(txStartMarker.publicLogsLength, 'public logs');
54
+ const publicLogs = reader.readFieldArray(txStartMarker.publicLogsLength);
55
+ const contractClassLogBlobDataLength = txStartMarker.contractClassLogLength > 0 ? txStartMarker.contractClassLogLength + 1 : 0; // If the log exists, +1 for the contract address
56
+ checkRemainingFields(contractClassLogBlobDataLength, 'contract class logs');
57
+ const contractClassLog = reader.readFieldArray(contractClassLogBlobDataLength);
58
+ return {
59
+ txStartMarker,
60
+ txHash,
61
+ transactionFee,
62
+ noteHashes,
63
+ nullifiers,
64
+ l2ToL1Msgs,
65
+ publicDataWrites,
66
+ privateLogs,
67
+ publicLogs,
68
+ contractClassLog
69
+ };
70
+ }
71
+ export function getNumTxBlobFields(txStartMarker) {
72
+ return 1 + // tx start marker
73
+ 1 + // tx hash
74
+ 1 + // transaction fee
75
+ txStartMarker.numNoteHashes + txStartMarker.numNullifiers + txStartMarker.numL2ToL1Msgs + txStartMarker.numPublicDataWrites * 2 + // *2 for leaf slot and value per public data write
76
+ txStartMarker.numPrivateLogs + // +1 length field for each private log
77
+ txStartMarker.privateLogsLength + txStartMarker.publicLogsLength + txStartMarker.contractClassLogLength + (txStartMarker.contractClassLogLength > 0 ? 1 : 0 // +1 for contract address of the contract class log
78
+ );
79
+ }
@@ -0,0 +1,16 @@
1
+ import { Fr } from '@aztec/foundation/curves/bn254';
2
+ export interface TxStartMarker {
3
+ numBlobFields: number;
4
+ revertCode: number;
5
+ numNoteHashes: number;
6
+ numNullifiers: number;
7
+ numL2ToL1Msgs: number;
8
+ numPublicDataWrites: number;
9
+ numPrivateLogs: number;
10
+ privateLogsLength: number;
11
+ publicLogsLength: number;
12
+ contractClassLogLength: number;
13
+ }
14
+ export declare function encodeTxStartMarker(txStartMarker: TxStartMarker): Fr;
15
+ export declare function decodeTxStartMarker(field: Fr): TxStartMarker;
16
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHhfc3RhcnRfbWFya2VyLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvZW5jb2RpbmcvdHhfc3RhcnRfbWFya2VyLnRzIl0sIm5hbWVzIj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AAC;CAChC;AAED,wBAAgB,mBAAmB,CAAC,aAAa,EAAE,aAAa,GAAG,EAAE,CAuBpE;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,EAAE,GAAG,aAAa,CAwC5D"}
@@ -1,6 +1,7 @@
1
- import { BLOCK_END_PREFIX, TX_START_PREFIX } from '@aztec/constants';
2
- import { Fr } from '@aztec/foundation/fields';
3
- import { FieldReader } from '@aztec/foundation/serialize';
1
+ import { TX_START_PREFIX } from '@aztec/constants';
2
+ import { Fr } from '@aztec/foundation/curves/bn254';
3
+ import { BlobDeserializationError } from '../errors.js';
4
+ // Must match the implementation in `noir-protocol-circuits/crates/types/src/blob_data/tx_blob_data.nr`.
4
5
  const NUM_BLOB_FIELDS_BIT_SIZE = 32n;
5
6
  const REVERT_CODE_BIT_SIZE = 8n;
6
7
  const NUM_NOTE_HASH_BIT_SIZE = 16n;
@@ -8,11 +9,11 @@ const NUM_NULLIFIER_BIT_SIZE = 16n;
8
9
  const NUM_L2_TO_L1_MSG_BIT_SIZE = 16n;
9
10
  const NUM_PUBLIC_DATA_WRITE_BIT_SIZE = 16n;
10
11
  const NUM_PRIVATE_LOG_BIT_SIZE = 16n;
12
+ const PRIVATE_LOGS_LENGTH_BIT_SIZE = 16n;
11
13
  const PUBLIC_LOGS_LENGTH_BIT_SIZE = 32n;
12
14
  const CONTRACT_CLASS_LOG_LENGTH_BIT_SIZE = 16n;
13
- // Must match the implementation in `noir-protocol-circuits/crates/rollup-lib/src/tx_base/components/tx_blob_data.nr`.
14
15
  export function encodeTxStartMarker(txStartMarker) {
15
- let value = TX_START_PREFIX;
16
+ let value = BigInt(TX_START_PREFIX);
16
17
  value <<= NUM_NOTE_HASH_BIT_SIZE;
17
18
  value += BigInt(txStartMarker.numNoteHashes);
18
19
  value <<= NUM_NULLIFIER_BIT_SIZE;
@@ -23,6 +24,8 @@ export function encodeTxStartMarker(txStartMarker) {
23
24
  value += BigInt(txStartMarker.numPublicDataWrites);
24
25
  value <<= NUM_PRIVATE_LOG_BIT_SIZE;
25
26
  value += BigInt(txStartMarker.numPrivateLogs);
27
+ value <<= PRIVATE_LOGS_LENGTH_BIT_SIZE;
28
+ value += BigInt(txStartMarker.privateLogsLength);
26
29
  value <<= PUBLIC_LOGS_LENGTH_BIT_SIZE;
27
30
  value += BigInt(txStartMarker.publicLogsLength);
28
31
  value <<= CONTRACT_CLASS_LOG_LENGTH_BIT_SIZE;
@@ -43,6 +46,8 @@ export function decodeTxStartMarker(field) {
43
46
  value >>= CONTRACT_CLASS_LOG_LENGTH_BIT_SIZE;
44
47
  const publicLogsLength = Number(value & 2n ** PUBLIC_LOGS_LENGTH_BIT_SIZE - 1n);
45
48
  value >>= PUBLIC_LOGS_LENGTH_BIT_SIZE;
49
+ const privateLogsLength = Number(value & 2n ** PRIVATE_LOGS_LENGTH_BIT_SIZE - 1n);
50
+ value >>= PRIVATE_LOGS_LENGTH_BIT_SIZE;
46
51
  const numPrivateLogs = Number(value & 2n ** NUM_PRIVATE_LOG_BIT_SIZE - 1n);
47
52
  value >>= NUM_PRIVATE_LOG_BIT_SIZE;
48
53
  const numPublicDataWrites = Number(value & 2n ** NUM_PUBLIC_DATA_WRITE_BIT_SIZE - 1n);
@@ -53,11 +58,11 @@ export function decodeTxStartMarker(field) {
53
58
  value >>= NUM_NULLIFIER_BIT_SIZE;
54
59
  const numNoteHashes = Number(value & 2n ** NUM_NOTE_HASH_BIT_SIZE - 1n);
55
60
  value >>= NUM_NOTE_HASH_BIT_SIZE;
56
- // Do not throw if the prefix doesn't match.
57
- // The caller function can check it by calling `isValidTxStartMarker`, and decide what to do if it's incorrect.
58
61
  const prefix = value;
62
+ if (prefix !== BigInt(TX_START_PREFIX)) {
63
+ throw new BlobDeserializationError(`Incorrect encoding of blob fields: invalid tx start marker.`);
64
+ }
59
65
  return {
60
- prefix,
61
66
  numBlobFields,
62
67
  revertCode,
63
68
  numNoteHashes,
@@ -65,59 +70,8 @@ export function decodeTxStartMarker(field) {
65
70
  numL2ToL1Msgs,
66
71
  numPublicDataWrites,
67
72
  numPrivateLogs,
73
+ privateLogsLength,
68
74
  publicLogsLength,
69
75
  contractClassLogLength
70
76
  };
71
77
  }
72
- export function getNumBlobFieldsFromTxStartMarker(field) {
73
- return Number(field.toBigInt() & 2n ** NUM_BLOB_FIELDS_BIT_SIZE - 1n);
74
- }
75
- export function isValidTxStartMarker(txStartMarker) {
76
- return txStartMarker.prefix === TX_START_PREFIX;
77
- }
78
- export function createBlockEndMarker(numTxs) {
79
- // Must match the implementation in `block_rollup_public_inputs_composer.nr > create_block_end_marker`.
80
- return new Fr(BLOCK_END_PREFIX * 256n * 256n + BigInt(numTxs));
81
- }
82
- export function getNumTxsFromBlockEndMarker(field) {
83
- return Number(field.toBigInt() & 0xffffn);
84
- }
85
- export function isBlockEndMarker(field) {
86
- const value = field.toBigInt();
87
- const numTxs = value & 0xffffn;
88
- return value - numTxs === BLOCK_END_PREFIX * 256n * 256n;
89
- }
90
- /**
91
- * Check that the fields are emitted from the circuits and conform to the encoding.
92
- * @param blobFields - The concatenated fields from all blobs of an L1 block.
93
- */ export function checkBlobFieldsEncoding(blobFields) {
94
- const reader = FieldReader.asReader(blobFields);
95
- const checkpointPrefix = reader.readField();
96
- if (checkpointPrefix.toBigInt() !== BigInt(blobFields.length)) {
97
- return false;
98
- }
99
- const numFieldsInCheckpoint = checkpointPrefix.toNumber();
100
- let seenNumTxs = 0;
101
- while(reader.cursor < numFieldsInCheckpoint){
102
- const currentField = reader.readField();
103
- if (isBlockEndMarker(currentField)) {
104
- // Found a block end marker. Confirm that the number of txs in this block is correct.
105
- const numTxs = getNumTxsFromBlockEndMarker(currentField);
106
- if (numTxs !== seenNumTxs) {
107
- return false;
108
- }
109
- seenNumTxs = 0;
110
- continue;
111
- }
112
- // If the field is not a block end marker, it must be a tx start marker.
113
- const txStartMarker = decodeTxStartMarker(currentField);
114
- if (!isValidTxStartMarker(txStartMarker)) {
115
- return false;
116
- }
117
- seenNumTxs += 1;
118
- // Skip the remaining fields in this tx. -1 because we already read the tx start marker.
119
- reader.skip(txStartMarker.numBlobFields - 1);
120
- // TODO: Check the encoding of the tx if we want to be more strict.
121
- }
122
- return true;
123
- }
package/dest/errors.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  export declare class BlobDeserializationError extends Error {
2
2
  constructor(message: string);
3
3
  }
4
- //# sourceMappingURL=errors.d.ts.map
4
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXJyb3JzLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvZXJyb3JzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLHFCQUFhLHdCQUF5QixTQUFRLEtBQUs7SUFDakQsWUFBWSxPQUFPLEVBQUUsTUFBTSxFQUcxQjtDQUNGIn0=
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,wBAAyB,SAAQ,KAAK;gBACrC,OAAO,EAAE,MAAM;CAI5B"}
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,wBAAyB,SAAQ,KAAK;IACjD,YAAY,OAAO,EAAE,MAAM,EAG1B;CACF"}
package/dest/hash.d.ts CHANGED
@@ -1,16 +1,24 @@
1
- import { BLS12Fr, Fr } from '@aztec/foundation/fields';
1
+ import { BLS12Fr } from '@aztec/foundation/curves/bls12';
2
+ import { Fr } from '@aztec/foundation/curves/bn254';
2
3
  /**
3
4
  * Returns ethereum's versioned blob hash, following kzg_to_versioned_hash: https://eips.ethereum.org/EIPS/eip-4844#helpers
4
5
  */
5
6
  export declare function computeEthVersionedBlobHash(commitment: Buffer): Buffer;
6
7
  export declare function computeBlobsHash(evmVersionedBlobHashes: Buffer[]): Fr;
7
8
  /**
8
- * The hash of the fields added throughout the checkpoint. The exact number of fields is specified by the checkpoint
9
- * prefix (the first field). It's verified in the circuit against the fields absorbed into the sponge blob.
10
- * This hash is used in generating the challenge z for all blobs in the same checkpoint.
9
+ * Computes a non-standard Poseidon2 hash over the provided fields.
10
+ *
11
+ * This function is used to compute:
12
+ * - `blobFieldsHash` of a checkpoint:
13
+ * Verified in the circuit against all fields absorbed into the blob sponge over the entire checkpoint.
14
+ * The exact number of fields is encoded in the checkpoint end marker (the last field).
15
+ * This hash is used when generating the challenge `z` for all blobs in the checkpoint.
16
+ * - `spongeBlobHash` of a block:
17
+ * Computed from the block's tx effects, its end-state, and the blob fields of all prior blocks in the same checkpoint.
18
+ * This hash is included in the block header.
11
19
  */
12
20
  export declare function computeBlobFieldsHash(fields: Fr[]): Promise<Fr>;
13
- export declare function computeBlobCommitment(data: Uint8Array): Buffer;
21
+ export declare function computeBlobCommitment(data: Uint8Array): Promise<Buffer>;
14
22
  /**
15
23
  * Get the commitment fields of the blob, to compute the challenge z.
16
24
  *
@@ -28,8 +36,9 @@ export declare function computeBlobCommitment(data: Uint8Array): Buffer;
28
36
  export declare function commitmentToFields(commitment: Buffer): [Fr, Fr];
29
37
  export declare function computeChallengeZ(blobFieldsHash: Fr, commitment: Buffer): Promise<Fr>;
30
38
  /**
31
- * Hash each u128 limb of the noir bignum struct representing the BLS field, to mimic the hash accumulation in the
32
- * rollup circuits.
39
+ * Hash the u128 limbs of a BLS field's noir bignum representation under the `BLOB_HASHED_Y_LIMBS` separator.
40
+ * Used to commit to blob evaluation values `y_i` before folding them into the gamma accumulator; mirrors the
41
+ * hash accumulation performed in the rollup circuits.
33
42
  */
34
- export declare function hashNoirBigNumLimbs(field: BLS12Fr): Promise<Fr>;
35
- //# sourceMappingURL=hash.d.ts.map
43
+ export declare function hashBlobYLimbs(field: BLS12Fr): Promise<Fr>;
44
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaGFzaC5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZX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C,UAAU,EAAE,MAAM,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,CAM/D;AAED,wBAAsB,iBAAiB,CAAC,cAAc,EAAE,EAAE,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,EAAE,CAAC,CAM3F;AAED;;;;GAIG;AACH,wBAAsB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,EAAE,CAAC,CAGhE"}
package/dest/hash.js CHANGED
@@ -1,6 +1,9 @@
1
- import { poseidon2Hash, sha256, sha256ToField } from '@aztec/foundation/crypto';
2
- import { Fr } from '@aztec/foundation/fields';
3
- import { BYTES_PER_BLOB, BYTES_PER_COMMITMENT, kzg } from './kzg_context.js';
1
+ import { DomainSeparator } from '@aztec/constants';
2
+ import { poseidon2HashWithSeparator } from '@aztec/foundation/crypto/poseidon';
3
+ import { sha256, sha256ToField } from '@aztec/foundation/crypto/sha256';
4
+ import { Fr } from '@aztec/foundation/curves/bn254';
5
+ import { getBytesPerBlob, getBytesPerCommitment, getKzg } from './kzg_context.js';
6
+ import { SpongeBlob } from './sponge_blob.js';
4
7
  const VERSIONED_HASH_VERSION_KZG = 0x01;
5
8
  /**
6
9
  * Returns ethereum's versioned blob hash, following kzg_to_versioned_hash: https://eips.ethereum.org/EIPS/eip-4844#helpers
@@ -18,17 +21,26 @@ export function computeBlobsHash(evmVersionedBlobHashes) {
18
21
  return sha256ToField(evmVersionedBlobHashes);
19
22
  }
20
23
  /**
21
- * The hash of the fields added throughout the checkpoint. The exact number of fields is specified by the checkpoint
22
- * prefix (the first field). It's verified in the circuit against the fields absorbed into the sponge blob.
23
- * This hash is used in generating the challenge z for all blobs in the same checkpoint.
24
+ * Computes a non-standard Poseidon2 hash over the provided fields.
25
+ *
26
+ * This function is used to compute:
27
+ * - `blobFieldsHash` of a checkpoint:
28
+ * Verified in the circuit against all fields absorbed into the blob sponge over the entire checkpoint.
29
+ * The exact number of fields is encoded in the checkpoint end marker (the last field).
30
+ * This hash is used when generating the challenge `z` for all blobs in the checkpoint.
31
+ * - `spongeBlobHash` of a block:
32
+ * Computed from the block's tx effects, its end-state, and the blob fields of all prior blocks in the same checkpoint.
33
+ * This hash is included in the block header.
24
34
  */ export async function computeBlobFieldsHash(fields) {
25
- return await poseidon2Hash(fields);
35
+ const sponge = SpongeBlob.init();
36
+ await sponge.absorb(fields);
37
+ return sponge.squeeze();
26
38
  }
27
- export function computeBlobCommitment(data) {
28
- if (data.length !== BYTES_PER_BLOB) {
29
- throw new Error(`Expected ${BYTES_PER_BLOB} bytes per blob. Got ${data.length}.`);
39
+ export async function computeBlobCommitment(data) {
40
+ if (data.length !== getBytesPerBlob()) {
41
+ throw new Error(`Expected ${getBytesPerBlob()} bytes per blob. Got ${data.length}.`);
30
42
  }
31
- return Buffer.from(kzg.blobToKzgCommitment(data));
43
+ return Buffer.from(await getKzg().asyncBlobToKzgCommitment(data));
32
44
  }
33
45
  /**
34
46
  * Get the commitment fields of the blob, to compute the challenge z.
@@ -44,26 +56,27 @@ export function computeBlobCommitment(data) {
44
56
  * @param commitment - The commitment to convert to fields. Computed from `computeBlobCommitment`.
45
57
  * @returns The fields representing the commitment buffer.
46
58
  */ export function commitmentToFields(commitment) {
47
- if (commitment.length !== BYTES_PER_COMMITMENT) {
48
- throw new Error(`Expected ${BYTES_PER_COMMITMENT} bytes for blob commitment. Got ${commitment.length}.`);
59
+ if (commitment.length !== getBytesPerCommitment()) {
60
+ throw new Error(`Expected ${getBytesPerCommitment()} bytes for blob commitment. Got ${commitment.length}.`);
49
61
  }
50
62
  return [
51
63
  new Fr(commitment.subarray(0, 31)),
52
- new Fr(commitment.subarray(31, BYTES_PER_COMMITMENT))
64
+ new Fr(commitment.subarray(31, getBytesPerCommitment()))
53
65
  ];
54
66
  }
55
67
  export async function computeChallengeZ(blobFieldsHash, commitment) {
56
68
  const commitmentFields = commitmentToFields(commitment);
57
- return await poseidon2Hash([
69
+ return await poseidon2HashWithSeparator([
58
70
  blobFieldsHash,
59
71
  commitmentFields[0],
60
72
  commitmentFields[1]
61
- ]);
73
+ ], DomainSeparator.BLOB_CHALLENGE_Z);
62
74
  }
63
75
  /**
64
- * Hash each u128 limb of the noir bignum struct representing the BLS field, to mimic the hash accumulation in the
65
- * rollup circuits.
66
- */ export async function hashNoirBigNumLimbs(field) {
76
+ * Hash the u128 limbs of a BLS field's noir bignum representation under the `BLOB_HASHED_Y_LIMBS` separator.
77
+ * Used to commit to blob evaluation values `y_i` before folding them into the gamma accumulator; mirrors the
78
+ * hash accumulation performed in the rollup circuits.
79
+ */ export async function hashBlobYLimbs(field) {
67
80
  const num = field.toNoirBigNum();
68
- return await poseidon2Hash(num.limbs.map(Fr.fromHexString));
81
+ return await poseidon2HashWithSeparator(num.limbs.map(Fr.fromHexString), DomainSeparator.BLOB_HASHED_Y_LIMBS);
69
82
  }
package/dest/index.d.ts CHANGED
@@ -1,11 +1,11 @@
1
+ export * from './batched_blob.js';
1
2
  export * from './blob.js';
2
3
  export * from './blob_batching.js';
3
4
  export * from './blob_utils.js';
4
5
  export * from './circuit_types/index.js';
5
- export * from './deserialize.js';
6
- export * from './encoding.js';
7
- export * from './errors.js';
6
+ export * from './encoding/index.js';
8
7
  export * from './hash.js';
9
8
  export * from './interface.js';
10
9
  export * from './sponge_blob.js';
11
- //# sourceMappingURL=index.d.ts.map
10
+ export * from './kzg_context.js';
11
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxjQUFjLG1CQUFtQixDQUFDO0FBQ2xDLGNBQWMsV0FBVyxDQUFDO0FBQzFCLGNBQWMsb0JBQW9CLENBQUM7QUFDbkMsY0FBYyxpQkFBaUIsQ0FBQztBQUNoQyxjQUFjLDBCQUEwQixDQUFDO0FBQ3pDLGNBQWMscUJBQXFCLENBQUM7QUFDcEMsY0FBYyxXQUFXLENBQUM7QUFDMUIsY0FBYyxnQkFBZ0IsQ0FBQztBQUMvQixjQUFjLGtCQUFrQixDQUFDO0FBQ2pDLGNBQWMsa0JBQWtCLENBQUMifQ==
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,0BAA0B,CAAC;AACzC,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,WAAW,CAAC;AAC1B,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AACpC,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC"}
package/dest/index.js CHANGED
@@ -1,10 +1,10 @@
1
+ export * from './batched_blob.js';
1
2
  export * from './blob.js';
2
3
  export * from './blob_batching.js';
3
4
  export * from './blob_utils.js';
4
5
  export * from './circuit_types/index.js';
5
- export * from './deserialize.js';
6
- export * from './encoding.js';
7
- export * from './errors.js';
6
+ export * from './encoding/index.js';
8
7
  export * from './hash.js';
9
8
  export * from './interface.js';
10
9
  export * from './sponge_blob.js';
10
+ export * from './kzg_context.js';
@@ -3,7 +3,6 @@
3
3
  */
4
4
  export interface BlobJson {
5
5
  blob: string;
6
- index: string;
7
6
  kzg_commitment: string;
8
7
  }
9
- //# sourceMappingURL=interface.d.ts.map
8
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW50ZXJmYWNlLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvaW50ZXJmYWNlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOztHQUVHO0FBQ0gsTUFBTSxXQUFXLFFBQVE7SUFDdkIsSUFBSSxFQUFFLE1BQU0sQ0FBQztJQUNiLGNBQWMsRUFBRSxNQUFNLENBQUM7Q0FDeEIifQ==
@@ -1 +1 @@
1
- {"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../src/interface.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,cAAc,EAAE,MAAM,CAAC;CACxB"}
1
+ {"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../src/interface.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,MAAM,CAAC;CACxB"}
@@ -1,4 +1,10 @@
1
- import { DasContextJs } from '@crate-crypto/node-eth-kzg';
2
- export * from '@crate-crypto/node-eth-kzg';
3
- export declare const kzg: DasContextJs;
4
- //# sourceMappingURL=kzg_context.d.ts.map
1
+ import type { DasContextJs } from '@crate-crypto/node-eth-kzg';
2
+ export type { DasContextJs } from '@crate-crypto/node-eth-kzg';
3
+ export declare function getBytesPerBlob(): number;
4
+ export declare function getBytesPerCommitment(): number;
5
+ /**
6
+ * Returns the lazily-initialized KZG context.
7
+ * The first call takes ~3 seconds to initialize the precomputation tables.
8
+ */
9
+ export declare function getKzg(): DasContextJs;
10
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoia3pnX2NvbnRleHQuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9remdfY29udGV4dC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsTUFBTSw0QkFBNEIsQ0FBQztBQU0vRCxZQUFZLEVBQUUsWUFBWSxFQUFFLE1BQU0sNEJBQTRCLENBQUM7QUFlL0Qsd0JBQWdCLGVBQWUsSUFBSSxNQUFNLENBRXhDO0FBRUQsd0JBQWdCLHFCQUFxQixJQUFJLE1BQU0sQ0FFOUM7QUFJRDs7O0dBR0c7QUFDSCx3QkFBZ0IsTUFBTSxJQUFJLFlBQVksQ0FLckMifQ==
@@ -1 +1 @@
1
- {"version":3,"file":"kzg_context.d.ts","sourceRoot":"","sources":["../src/kzg_context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE1D,cAAc,4BAA4B,CAAC;AAE3C,eAAO,MAAM,GAAG,cAA4C,CAAC"}
1
+ {"version":3,"file":"kzg_context.d.ts","sourceRoot":"","sources":["../src/kzg_context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAM/D,YAAY,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAe/D,wBAAgB,eAAe,IAAI,MAAM,CAExC;AAED,wBAAgB,qBAAqB,IAAI,MAAM,CAE9C;AAID;;;GAGG;AACH,wBAAgB,MAAM,IAAI,YAAY,CAKrC"}
@@ -1,5 +1,29 @@
1
- import { DasContextJs } from '@crate-crypto/node-eth-kzg';
2
- export * from '@crate-crypto/node-eth-kzg';
3
- export const kzg = DasContextJs.create({
4
- usePrecomp: true
5
- });
1
+ import { createRequire } from 'module';
2
+ let nativeModule;
3
+ /** Lazily loads the @crate-crypto/node-eth-kzg native module. */ function loadNativeModule() {
4
+ if (!nativeModule) {
5
+ const require = createRequire(import.meta.url);
6
+ nativeModule = require('@crate-crypto/node-eth-kzg');
7
+ }
8
+ return nativeModule;
9
+ }
10
+ // Ethereum blob constants, loaded lazily from the native module.
11
+ // Values: BYTES_PER_BLOB=131072, BYTES_PER_COMMITMENT=48
12
+ export function getBytesPerBlob() {
13
+ return loadNativeModule().BYTES_PER_BLOB;
14
+ }
15
+ export function getBytesPerCommitment() {
16
+ return loadNativeModule().BYTES_PER_COMMITMENT;
17
+ }
18
+ let kzgInstance;
19
+ /**
20
+ * Returns the lazily-initialized KZG context.
21
+ * The first call takes ~3 seconds to initialize the precomputation tables.
22
+ */ export function getKzg() {
23
+ if (!kzgInstance) {
24
+ kzgInstance = loadNativeModule().DasContextJs.create({
25
+ usePrecomp: true
26
+ });
27
+ }
28
+ return kzgInstance;
29
+ }
@@ -1,5 +1,5 @@
1
1
  import { type FieldsOf } from '@aztec/foundation/array';
2
- import { Fr } from '@aztec/foundation/fields';
2
+ import { Fr } from '@aztec/foundation/curves/bn254';
3
3
  import { BufferReader, FieldReader, type Tuple } from '@aztec/foundation/serialize';
4
4
  /**
5
5
  * A Poseidon2 sponge used to accumulate data that will be added to blobs.
@@ -10,15 +10,16 @@ export declare class SpongeBlob {
10
10
  readonly sponge: Poseidon2Sponge;
11
11
  /** Number of effects absorbed so far. */
12
12
  numAbsorbedFields: number;
13
- /** Number of effects that will be absorbed. */
14
- readonly numExpectedFields: number;
13
+ static MAX_FIELDS: number;
15
14
  constructor(
16
15
  /** Sponge with absorbed fields that will go into one or more blobs. */
17
16
  sponge: Poseidon2Sponge,
18
17
  /** Number of effects absorbed so far. */
19
- numAbsorbedFields: number,
20
- /** Number of effects that will be absorbed. */
21
- numExpectedFields: number);
18
+ numAbsorbedFields: number);
19
+ /**
20
+ * Initialize the sponge blob to absorb data for a checkpoint.
21
+ */
22
+ static init(): SpongeBlob;
22
23
  static fromBuffer(buffer: Buffer | BufferReader): SpongeBlob;
23
24
  toBuffer(): Buffer<ArrayBufferLike>;
24
25
  static getFields(fields: FieldsOf<SpongeBlob>): (number | Poseidon2Sponge)[];
@@ -28,11 +29,6 @@ export declare class SpongeBlob {
28
29
  absorb(fields: Fr[]): Promise<void>;
29
30
  squeeze(): Promise<Fr>;
30
31
  static empty(): SpongeBlob;
31
- /**
32
- * Initialize the sponge blob with the number of expected fields in the checkpoint and absorb it as the first field.
33
- * Note: `numExpectedFields` includes the first field absorbed in this method.
34
- */
35
- static init(numExpectedFields: number): Promise<SpongeBlob>;
36
32
  }
37
33
  export declare class Poseidon2Sponge {
38
34
  cache: Tuple<Fr, 3>;
@@ -46,9 +42,9 @@ export declare class Poseidon2Sponge {
46
42
  toFields(): Fr[];
47
43
  static fromFields(fields: Fr[] | FieldReader): Poseidon2Sponge;
48
44
  static empty(): Poseidon2Sponge;
49
- static init(numExpectedFields: number): Poseidon2Sponge;
45
+ static init(iv: Fr): Poseidon2Sponge;
50
46
  performDuplex(): Promise<void>;
51
47
  absorb(fields: Fr[]): Promise<void>;
52
48
  squeeze(): Promise<Fr>;
53
49
  }
54
- //# sourceMappingURL=sponge_blob.d.ts.map
50
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3BvbmdlX2Jsb2IuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9zcG9uZ2VfYmxvYi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFDQSxPQUFPLEVBQUUsS0FBSyxRQUFRLEVBQWEsTUFBTSx5QkFBeUIsQ0FBQztBQUVuRSxPQUFPLEVBQUUsRUFBRSxFQUFFLE1BQU0sZ0NBQWdDLENBQUM7QUFDcEQsT0FBTyxFQUNMLFlBQVksRUFDWixXQUFXLEVBQ1gsS0FBSyxLQUFLLEVBR1gsTUFBTSw2QkFBNkIsQ0FBQztBQUVyQzs7O0dBR0c7QUFDSCxxQkFBYSxVQUFVO0lBSW5CLHVFQUF1RTthQUN2RCxNQUFNLEVBQUUsZUFBZTtJQUN2Qyx5Q0FBeUM7SUF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