@aztec/blob-lib 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 (51) hide show
  1. package/dest/blob_utils.d.ts +5 -8
  2. package/dest/blob_utils.d.ts.map +1 -1
  3. package/dest/blob_utils.js +7 -10
  4. package/dest/encoding/block_blob_data.d.ts +22 -0
  5. package/dest/encoding/block_blob_data.d.ts.map +1 -0
  6. package/dest/encoding/block_blob_data.js +65 -0
  7. package/dest/encoding/block_end_marker.d.ts +10 -0
  8. package/dest/encoding/block_end_marker.d.ts.map +1 -0
  9. package/dest/encoding/block_end_marker.js +40 -0
  10. package/dest/encoding/block_end_state_field.d.ts +12 -0
  11. package/dest/encoding/block_end_state_field.d.ts.map +1 -0
  12. package/dest/encoding/block_end_state_field.js +39 -0
  13. package/dest/encoding/checkpoint_blob_data.d.ts +13 -0
  14. package/dest/encoding/checkpoint_blob_data.d.ts.map +1 -0
  15. package/dest/encoding/checkpoint_blob_data.js +54 -0
  16. package/dest/encoding/fixtures.d.ts +41 -0
  17. package/dest/encoding/fixtures.d.ts.map +1 -0
  18. package/dest/encoding/fixtures.js +137 -0
  19. package/dest/encoding/index.d.ts +8 -0
  20. package/dest/encoding/index.d.ts.map +1 -0
  21. package/dest/encoding/index.js +7 -0
  22. package/dest/encoding/tx_blob_data.d.ts +19 -0
  23. package/dest/encoding/tx_blob_data.d.ts.map +1 -0
  24. package/dest/encoding/tx_blob_data.js +79 -0
  25. package/dest/encoding/tx_start_marker.d.ts +16 -0
  26. package/dest/encoding/tx_start_marker.d.ts.map +1 -0
  27. package/dest/{encoding.js → encoding/tx_start_marker.js} +12 -58
  28. package/dest/index.d.ts +1 -2
  29. package/dest/index.d.ts.map +1 -1
  30. package/dest/index.js +1 -2
  31. package/dest/testing.d.ts +1 -13
  32. package/dest/testing.d.ts.map +1 -1
  33. package/dest/testing.js +1 -60
  34. package/package.json +4 -4
  35. package/src/blob_utils.ts +7 -10
  36. package/src/encoding/block_blob_data.ts +102 -0
  37. package/src/encoding/block_end_marker.ts +54 -0
  38. package/src/encoding/block_end_state_field.ts +59 -0
  39. package/src/encoding/checkpoint_blob_data.ts +75 -0
  40. package/src/encoding/fixtures.ts +209 -0
  41. package/src/encoding/index.ts +7 -0
  42. package/src/encoding/tx_blob_data.ts +116 -0
  43. package/src/{encoding.ts → encoding/tx_start_marker.ts} +18 -75
  44. package/src/index.ts +1 -2
  45. package/src/testing.ts +2 -64
  46. package/dest/deserialize.d.ts +0 -14
  47. package/dest/deserialize.d.ts.map +0 -1
  48. package/dest/deserialize.js +0 -33
  49. package/dest/encoding.d.ts +0 -26
  50. package/dest/encoding.d.ts.map +0 -1
  51. package/src/deserialize.ts +0 -38
@@ -1,33 +0,0 @@
1
- import { Fr } from '@aztec/foundation/fields';
2
- import { BufferReader } from '@aztec/foundation/serialize';
3
- import { checkBlobFieldsEncoding } from './encoding.js';
4
- import { BlobDeserializationError } from './errors.js';
5
- /**
6
- * Deserializes a buffer into an array of field elements.
7
- *
8
- * This function returns the fields that were actually added in a checkpoint. The number of fields is specified by the
9
- * first field.
10
- *
11
- * @param buf - The buffer to deserialize.
12
- * @param checkEncoding - Whether to check if the encoding is correct. If false, it will still check the checkpoint
13
- * prefix and throw if there's not enough fields.
14
- * @returns An array of field elements.
15
- */ export function deserializeEncodedBlobToFields(buf, checkEncoding = false) {
16
- const reader = BufferReader.asReader(buf);
17
- const firstField = reader.readObject(Fr);
18
- // Use toBigInt instead of toNumber so that we can catch it and throw a more descriptive error below if the first
19
- // field is larger than a javascript integer.
20
- const numFields = firstField.toBigInt();
21
- const totalFieldsInBuffer = BigInt(buf.length / Fr.SIZE_IN_BYTES);
22
- if (numFields > totalFieldsInBuffer) {
23
- throw new BlobDeserializationError(`Failed to deserialize blob fields, this blob was likely not created by us`);
24
- }
25
- const numFieldsWithoutPrefix = Number(numFields) - 1;
26
- const blobFields = [
27
- firstField
28
- ].concat(reader.readArray(numFieldsWithoutPrefix, Fr));
29
- if (checkEncoding && !checkBlobFieldsEncoding(blobFields)) {
30
- throw new BlobDeserializationError(`Incorrect encoding of blob fields, this blob was likely not created by us`);
31
- }
32
- return blobFields;
33
- }
@@ -1,26 +0,0 @@
1
- import { Fr } from '@aztec/foundation/fields';
2
- export interface TxStartMarker {
3
- prefix: bigint;
4
- numBlobFields: number;
5
- revertCode: number;
6
- numNoteHashes: number;
7
- numNullifiers: number;
8
- numL2ToL1Msgs: number;
9
- numPublicDataWrites: number;
10
- numPrivateLogs: number;
11
- publicLogsLength: number;
12
- contractClassLogLength: number;
13
- }
14
- export declare function encodeTxStartMarker(txStartMarker: Omit<TxStartMarker, 'prefix'>): Fr;
15
- export declare function decodeTxStartMarker(field: Fr): TxStartMarker;
16
- export declare function getNumBlobFieldsFromTxStartMarker(field: Fr): number;
17
- export declare function isValidTxStartMarker(txStartMarker: TxStartMarker): boolean;
18
- export declare function createBlockEndMarker(numTxs: number): Fr;
19
- export declare function getNumTxsFromBlockEndMarker(field: Fr): number;
20
- export declare function isBlockEndMarker(field: Fr): boolean;
21
- /**
22
- * Check that the fields are emitted from the circuits and conform to the encoding.
23
- * @param blobFields - The concatenated fields from all blobs of an L1 block.
24
- */
25
- export declare function checkBlobFieldsEncoding(blobFields: Fr[]): boolean;
26
- //# sourceMappingURL=encoding.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"encoding.d.ts","sourceRoot":"","sources":["../src/encoding.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAa9C,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,cAAc,EAAE,MAAM,CAAC;IACvB,gBAAgB,EAAE,MAAM,CAAC;IACzB,sBAAsB,EAAE,MAAM,CAAC;CAChC;AAGD,wBAAgB,mBAAmB,CAAC,aAAa,EAAE,IAAI,CAAC,aAAa,EAAE,QAAQ,CAAC,MAqB/E;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,EAAE,GAAG,aAAa,CAmC5D;AAED,wBAAgB,iCAAiC,CAAC,KAAK,EAAE,EAAE,UAE1D;AAED,wBAAgB,oBAAoB,CAAC,aAAa,EAAE,aAAa,WAEhE;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,MAGlD;AAED,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,EAAE,UAEpD;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,EAAE,WAIzC;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,UAAU,EAAE,EAAE,EAAE,WAsCvD"}
@@ -1,38 +0,0 @@
1
- import { Fr } from '@aztec/foundation/fields';
2
- import { BufferReader } from '@aztec/foundation/serialize';
3
-
4
- import { checkBlobFieldsEncoding } from './encoding.js';
5
- import { BlobDeserializationError } from './errors.js';
6
-
7
- /**
8
- * Deserializes a buffer into an array of field elements.
9
- *
10
- * This function returns the fields that were actually added in a checkpoint. The number of fields is specified by the
11
- * first field.
12
- *
13
- * @param buf - The buffer to deserialize.
14
- * @param checkEncoding - Whether to check if the encoding is correct. If false, it will still check the checkpoint
15
- * prefix and throw if there's not enough fields.
16
- * @returns An array of field elements.
17
- */
18
- export function deserializeEncodedBlobToFields(buf: Uint8Array, checkEncoding = false): Fr[] {
19
- const reader = BufferReader.asReader(buf);
20
- const firstField = reader.readObject(Fr);
21
-
22
- // Use toBigInt instead of toNumber so that we can catch it and throw a more descriptive error below if the first
23
- // field is larger than a javascript integer.
24
- const numFields = firstField.toBigInt();
25
- const totalFieldsInBuffer = BigInt(buf.length / Fr.SIZE_IN_BYTES);
26
- if (numFields > totalFieldsInBuffer) {
27
- throw new BlobDeserializationError(`Failed to deserialize blob fields, this blob was likely not created by us`);
28
- }
29
-
30
- const numFieldsWithoutPrefix = Number(numFields) - 1;
31
- const blobFields = [firstField].concat(reader.readArray(numFieldsWithoutPrefix, Fr));
32
-
33
- if (checkEncoding && !checkBlobFieldsEncoding(blobFields)) {
34
- throw new BlobDeserializationError(`Incorrect encoding of blob fields, this blob was likely not created by us`);
35
- }
36
-
37
- return blobFields;
38
- }