@aztec/blob-lib 0.0.1-commit.f295ac2 → 0.0.1-commit.f8ca9b2f3

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.
@@ -1,4 +1,4 @@
1
- import { AZTEC_MAX_EPOCH_DURATION, BLOBS_PER_CHECKPOINT } from '@aztec/constants';
1
+ import { BLOBS_PER_CHECKPOINT, MAX_CHECKPOINTS_PER_EPOCH } from '@aztec/constants';
2
2
  import { poseidon2Hash } from '@aztec/foundation/crypto/poseidon';
3
3
  import { sha256ToField } from '@aztec/foundation/crypto/sha256';
4
4
  import { BLS12Fr, BLS12Point } from '@aztec/foundation/curves/bls12';
@@ -56,8 +56,8 @@ import { getKzg } from './kzg_context.js';
56
56
  * @returns A batched blob.
57
57
  */ static async batch(blobFieldsPerCheckpoint, verifyProof = false) {
58
58
  const numCheckpoints = blobFieldsPerCheckpoint.length;
59
- if (numCheckpoints > AZTEC_MAX_EPOCH_DURATION) {
60
- throw new Error(`Too many checkpoints sent to batch(). The maximum is ${AZTEC_MAX_EPOCH_DURATION}. Got ${numCheckpoints}.`);
59
+ if (numCheckpoints > MAX_CHECKPOINTS_PER_EPOCH) {
60
+ throw new Error(`Too many checkpoints sent to batch(). The maximum is ${MAX_CHECKPOINTS_PER_EPOCH}. Got ${numCheckpoints}.`);
61
61
  }
62
62
  // Precalculate the values (z and gamma) and initialize the accumulator:
63
63
  let acc = await this.fromBlobFields(blobFieldsPerCheckpoint);
@@ -7,7 +7,7 @@ const BLOCK_NUMBER_BIT_SIZE = 32n;
7
7
  const TIMESTAMP_BIT_SIZE = 64n;
8
8
  const NUM_TXS_BIT_SIZE = 16n;
9
9
  export function encodeBlockEndMarker(blockEndMarker) {
10
- let value = BLOCK_END_PREFIX;
10
+ let value = BigInt(BLOCK_END_PREFIX);
11
11
  value <<= TIMESTAMP_BIT_SIZE;
12
12
  value += blockEndMarker.timestamp;
13
13
  value <<= BLOCK_NUMBER_BIT_SIZE;
@@ -25,7 +25,7 @@ export function decodeBlockEndMarker(field) {
25
25
  const timestamp = value & 2n ** TIMESTAMP_BIT_SIZE - 1n;
26
26
  value >>= TIMESTAMP_BIT_SIZE;
27
27
  const prefix = value;
28
- if (prefix !== BLOCK_END_PREFIX) {
28
+ if (prefix !== BigInt(BLOCK_END_PREFIX)) {
29
29
  throw new BlobDeserializationError(`Incorrect encoding of blob fields: invalid block end marker.`);
30
30
  }
31
31
  return {
@@ -37,5 +37,5 @@ export function decodeBlockEndMarker(field) {
37
37
  // Check if a field is a block end marker. Used before decoding to check if it has reached the end of the block.
38
38
  export function isBlockEndMarker(field) {
39
39
  const prefix = field.toBigInt() >> NUM_TXS_BIT_SIZE + BLOCK_NUMBER_BIT_SIZE + TIMESTAMP_BIT_SIZE;
40
- return prefix === BLOCK_END_PREFIX;
40
+ return prefix === BigInt(BLOCK_END_PREFIX);
41
41
  }
@@ -4,7 +4,7 @@ import { BlobDeserializationError } from '../errors.js';
4
4
  // Must match the implementation in `noir-protocol-circuits/crates/types/src/blob_data/checkpoint_blob_data.nr`.
5
5
  const NUM_BLOB_FIELDS_BIT_SIZE = 32n;
6
6
  export function encodeCheckpointEndMarker(checkpointEndMarker) {
7
- let value = CHECKPOINT_END_PREFIX;
7
+ let value = BigInt(CHECKPOINT_END_PREFIX);
8
8
  value <<= NUM_BLOB_FIELDS_BIT_SIZE;
9
9
  value += BigInt(checkpointEndMarker.numBlobFields);
10
10
  return new Fr(value);
@@ -14,7 +14,7 @@ export function decodeCheckpointEndMarker(field) {
14
14
  const numBlobFields = Number(value & 2n ** NUM_BLOB_FIELDS_BIT_SIZE - 1n);
15
15
  value >>= NUM_BLOB_FIELDS_BIT_SIZE;
16
16
  const prefix = value;
17
- if (prefix !== CHECKPOINT_END_PREFIX) {
17
+ if (prefix !== BigInt(CHECKPOINT_END_PREFIX)) {
18
18
  throw new BlobDeserializationError(`Incorrect encoding of blob fields: invalid checkpoint end marker.`);
19
19
  }
20
20
  return {
@@ -24,5 +24,5 @@ export function decodeCheckpointEndMarker(field) {
24
24
  // Check if a field is a checkpoint end marker. Used to check if it has reached the end of the blob fields.
25
25
  export function isCheckpointEndMarker(field) {
26
26
  const prefix = field.toBigInt() >> NUM_BLOB_FIELDS_BIT_SIZE;
27
- return prefix === CHECKPOINT_END_PREFIX;
27
+ return prefix === BigInt(CHECKPOINT_END_PREFIX);
28
28
  }
@@ -13,7 +13,7 @@ const PRIVATE_LOGS_LENGTH_BIT_SIZE = 16n;
13
13
  const PUBLIC_LOGS_LENGTH_BIT_SIZE = 32n;
14
14
  const CONTRACT_CLASS_LOG_LENGTH_BIT_SIZE = 16n;
15
15
  export function encodeTxStartMarker(txStartMarker) {
16
- let value = TX_START_PREFIX;
16
+ let value = BigInt(TX_START_PREFIX);
17
17
  value <<= NUM_NOTE_HASH_BIT_SIZE;
18
18
  value += BigInt(txStartMarker.numNoteHashes);
19
19
  value <<= NUM_NULLIFIER_BIT_SIZE;
@@ -59,7 +59,7 @@ export function decodeTxStartMarker(field) {
59
59
  const numNoteHashes = Number(value & 2n ** NUM_NOTE_HASH_BIT_SIZE - 1n);
60
60
  value >>= NUM_NOTE_HASH_BIT_SIZE;
61
61
  const prefix = value;
62
- if (prefix !== TX_START_PREFIX) {
62
+ if (prefix !== BigInt(TX_START_PREFIX)) {
63
63
  throw new BlobDeserializationError(`Incorrect encoding of blob fields: invalid tx start marker.`);
64
64
  }
65
65
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/blob-lib",
3
- "version": "0.0.1-commit.f295ac2",
3
+ "version": "0.0.1-commit.f8ca9b2f3",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./dest/index.js",
@@ -27,8 +27,8 @@
27
27
  "../package.common.json"
28
28
  ],
29
29
  "dependencies": {
30
- "@aztec/constants": "0.0.1-commit.f295ac2",
31
- "@aztec/foundation": "0.0.1-commit.f295ac2",
30
+ "@aztec/constants": "0.0.1-commit.f8ca9b2f3",
31
+ "@aztec/foundation": "0.0.1-commit.f8ca9b2f3",
32
32
  "@crate-crypto/node-eth-kzg": "^0.10.0",
33
33
  "tslib": "^2.4.0"
34
34
  },
@@ -1,4 +1,4 @@
1
- import { AZTEC_MAX_EPOCH_DURATION, BLOBS_PER_CHECKPOINT } from '@aztec/constants';
1
+ import { BLOBS_PER_CHECKPOINT, MAX_CHECKPOINTS_PER_EPOCH } from '@aztec/constants';
2
2
  import { poseidon2Hash } from '@aztec/foundation/crypto/poseidon';
3
3
  import { sha256ToField } from '@aztec/foundation/crypto/sha256';
4
4
  import { BLS12Fr, BLS12Point } from '@aztec/foundation/curves/bls12';
@@ -75,9 +75,9 @@ export class BatchedBlobAccumulator {
75
75
  */
76
76
  static async batch(blobFieldsPerCheckpoint: Fr[][], verifyProof = false): Promise<BatchedBlob> {
77
77
  const numCheckpoints = blobFieldsPerCheckpoint.length;
78
- if (numCheckpoints > AZTEC_MAX_EPOCH_DURATION) {
78
+ if (numCheckpoints > MAX_CHECKPOINTS_PER_EPOCH) {
79
79
  throw new Error(
80
- `Too many checkpoints sent to batch(). The maximum is ${AZTEC_MAX_EPOCH_DURATION}. Got ${numCheckpoints}.`,
80
+ `Too many checkpoints sent to batch(). The maximum is ${MAX_CHECKPOINTS_PER_EPOCH}. Got ${numCheckpoints}.`,
81
81
  );
82
82
  }
83
83
 
@@ -17,7 +17,7 @@ export interface BlockEndMarker {
17
17
  }
18
18
 
19
19
  export function encodeBlockEndMarker(blockEndMarker: BlockEndMarker) {
20
- let value = BLOCK_END_PREFIX;
20
+ let value = BigInt(BLOCK_END_PREFIX);
21
21
  value <<= TIMESTAMP_BIT_SIZE;
22
22
  value += blockEndMarker.timestamp;
23
23
  value <<= BLOCK_NUMBER_BIT_SIZE;
@@ -37,7 +37,7 @@ export function decodeBlockEndMarker(field: Fr): BlockEndMarker {
37
37
  value >>= TIMESTAMP_BIT_SIZE;
38
38
 
39
39
  const prefix = value;
40
- if (prefix !== BLOCK_END_PREFIX) {
40
+ if (prefix !== BigInt(BLOCK_END_PREFIX)) {
41
41
  throw new BlobDeserializationError(`Incorrect encoding of blob fields: invalid block end marker.`);
42
42
  }
43
43
 
@@ -51,5 +51,5 @@ export function decodeBlockEndMarker(field: Fr): BlockEndMarker {
51
51
  // Check if a field is a block end marker. Used before decoding to check if it has reached the end of the block.
52
52
  export function isBlockEndMarker(field: Fr): boolean {
53
53
  const prefix = field.toBigInt() >> (NUM_TXS_BIT_SIZE + BLOCK_NUMBER_BIT_SIZE + TIMESTAMP_BIT_SIZE);
54
- return prefix === BLOCK_END_PREFIX;
54
+ return prefix === BigInt(BLOCK_END_PREFIX);
55
55
  }
@@ -12,7 +12,7 @@ export interface CheckpointEndMarker {
12
12
  }
13
13
 
14
14
  export function encodeCheckpointEndMarker(checkpointEndMarker: CheckpointEndMarker) {
15
- let value = CHECKPOINT_END_PREFIX;
15
+ let value = BigInt(CHECKPOINT_END_PREFIX);
16
16
  value <<= NUM_BLOB_FIELDS_BIT_SIZE;
17
17
  value += BigInt(checkpointEndMarker.numBlobFields);
18
18
  return new Fr(value);
@@ -24,7 +24,7 @@ export function decodeCheckpointEndMarker(field: Fr): CheckpointEndMarker {
24
24
  value >>= NUM_BLOB_FIELDS_BIT_SIZE;
25
25
 
26
26
  const prefix = value;
27
- if (prefix !== CHECKPOINT_END_PREFIX) {
27
+ if (prefix !== BigInt(CHECKPOINT_END_PREFIX)) {
28
28
  throw new BlobDeserializationError(`Incorrect encoding of blob fields: invalid checkpoint end marker.`);
29
29
  }
30
30
 
@@ -36,5 +36,5 @@ export function decodeCheckpointEndMarker(field: Fr): CheckpointEndMarker {
36
36
  // Check if a field is a checkpoint end marker. Used to check if it has reached the end of the blob fields.
37
37
  export function isCheckpointEndMarker(field: Fr): boolean {
38
38
  const prefix = field.toBigInt() >> NUM_BLOB_FIELDS_BIT_SIZE;
39
- return prefix === CHECKPOINT_END_PREFIX;
39
+ return prefix === BigInt(CHECKPOINT_END_PREFIX);
40
40
  }
@@ -30,7 +30,7 @@ export interface TxStartMarker {
30
30
  }
31
31
 
32
32
  export function encodeTxStartMarker(txStartMarker: TxStartMarker): Fr {
33
- let value = TX_START_PREFIX;
33
+ let value = BigInt(TX_START_PREFIX);
34
34
  value <<= NUM_NOTE_HASH_BIT_SIZE;
35
35
  value += BigInt(txStartMarker.numNoteHashes);
36
36
  value <<= NUM_NULLIFIER_BIT_SIZE;
@@ -78,7 +78,7 @@ export function decodeTxStartMarker(field: Fr): TxStartMarker {
78
78
  value >>= NUM_NOTE_HASH_BIT_SIZE;
79
79
 
80
80
  const prefix = value;
81
- if (prefix !== TX_START_PREFIX) {
81
+ if (prefix !== BigInt(TX_START_PREFIX)) {
82
82
  throw new BlobDeserializationError(`Incorrect encoding of blob fields: invalid tx start marker.`);
83
83
  }
84
84