@aztec/blob-lib 0.0.0-test.0 → 0.0.1-commit.21caa21

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 (107) hide show
  1. package/dest/batched_blob.d.ts +25 -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 +53 -100
  5. package/dest/blob.d.ts.map +1 -1
  6. package/dest/blob.js +83 -183
  7. package/dest/blob_batching.d.ts +105 -0
  8. package/dest/blob_batching.d.ts.map +1 -0
  9. package/dest/blob_batching.js +223 -0
  10. package/dest/blob_utils.d.ts +39 -0
  11. package/dest/blob_utils.d.ts.map +1 -0
  12. package/dest/blob_utils.js +69 -0
  13. package/dest/circuit_types/blob_accumulator.d.ts +22 -0
  14. package/dest/circuit_types/blob_accumulator.d.ts.map +1 -0
  15. package/dest/circuit_types/blob_accumulator.js +61 -0
  16. package/dest/circuit_types/final_blob_accumulator.d.ts +22 -0
  17. package/dest/circuit_types/final_blob_accumulator.d.ts.map +1 -0
  18. package/dest/circuit_types/final_blob_accumulator.js +63 -0
  19. package/dest/circuit_types/final_blob_batching_challenges.d.ts +15 -0
  20. package/dest/circuit_types/final_blob_batching_challenges.d.ts.map +1 -0
  21. package/dest/circuit_types/final_blob_batching_challenges.js +25 -0
  22. package/dest/circuit_types/index.d.ts +4 -0
  23. package/dest/circuit_types/index.d.ts.map +1 -0
  24. package/dest/circuit_types/index.js +4 -0
  25. package/dest/encoding/block_blob_data.d.ts +22 -0
  26. package/dest/encoding/block_blob_data.d.ts.map +1 -0
  27. package/dest/encoding/block_blob_data.js +65 -0
  28. package/dest/encoding/block_end_marker.d.ts +10 -0
  29. package/dest/encoding/block_end_marker.d.ts.map +1 -0
  30. package/dest/encoding/block_end_marker.js +40 -0
  31. package/dest/encoding/block_end_state_field.d.ts +12 -0
  32. package/dest/encoding/block_end_state_field.d.ts.map +1 -0
  33. package/dest/encoding/block_end_state_field.js +39 -0
  34. package/dest/encoding/checkpoint_blob_data.d.ts +15 -0
  35. package/dest/encoding/checkpoint_blob_data.d.ts.map +1 -0
  36. package/dest/encoding/checkpoint_blob_data.js +67 -0
  37. package/dest/encoding/checkpoint_end_marker.d.ts +8 -0
  38. package/dest/encoding/checkpoint_end_marker.d.ts.map +1 -0
  39. package/dest/encoding/checkpoint_end_marker.js +28 -0
  40. package/dest/encoding/fixtures.d.ts +41 -0
  41. package/dest/encoding/fixtures.d.ts.map +1 -0
  42. package/dest/encoding/fixtures.js +139 -0
  43. package/dest/encoding/index.d.ts +10 -0
  44. package/dest/encoding/index.d.ts.map +1 -0
  45. package/dest/encoding/index.js +9 -0
  46. package/dest/encoding/tx_blob_data.d.ts +19 -0
  47. package/dest/encoding/tx_blob_data.d.ts.map +1 -0
  48. package/dest/encoding/tx_blob_data.js +79 -0
  49. package/dest/encoding/tx_start_marker.d.ts +16 -0
  50. package/dest/encoding/tx_start_marker.d.ts.map +1 -0
  51. package/dest/encoding/tx_start_marker.js +77 -0
  52. package/dest/errors.d.ts +1 -1
  53. package/dest/errors.d.ts.map +1 -1
  54. package/dest/hash.d.ts +42 -0
  55. package/dest/hash.d.ts.map +1 -0
  56. package/dest/hash.js +79 -0
  57. package/dest/index.d.ts +7 -4
  58. package/dest/index.d.ts.map +1 -1
  59. package/dest/index.js +6 -16
  60. package/dest/interface.d.ts +2 -3
  61. package/dest/interface.d.ts.map +1 -1
  62. package/dest/kzg_context.d.ts +4 -0
  63. package/dest/kzg_context.d.ts.map +1 -0
  64. package/dest/kzg_context.js +5 -0
  65. package/dest/sponge_blob.d.ts +13 -17
  66. package/dest/sponge_blob.d.ts.map +1 -1
  67. package/dest/sponge_blob.js +24 -28
  68. package/dest/testing.d.ts +13 -25
  69. package/dest/testing.d.ts.map +1 -1
  70. package/dest/testing.js +37 -53
  71. package/dest/types.d.ts +17 -0
  72. package/dest/types.d.ts.map +1 -0
  73. package/dest/types.js +4 -0
  74. package/package.json +20 -15
  75. package/src/batched_blob.ts +25 -0
  76. package/src/blob.ts +82 -221
  77. package/src/blob_batching.ts +293 -0
  78. package/src/blob_utils.ts +81 -0
  79. package/src/circuit_types/blob_accumulator.ts +95 -0
  80. package/src/circuit_types/final_blob_accumulator.ts +75 -0
  81. package/src/circuit_types/final_blob_batching_challenges.ts +29 -0
  82. package/src/circuit_types/index.ts +4 -0
  83. package/src/encoding/block_blob_data.ts +102 -0
  84. package/src/encoding/block_end_marker.ts +54 -0
  85. package/src/encoding/block_end_state_field.ts +59 -0
  86. package/src/encoding/checkpoint_blob_data.ts +95 -0
  87. package/src/encoding/checkpoint_end_marker.ts +40 -0
  88. package/src/encoding/fixtures.ts +209 -0
  89. package/src/encoding/index.ts +9 -0
  90. package/src/encoding/tx_blob_data.ts +116 -0
  91. package/src/encoding/tx_start_marker.ts +97 -0
  92. package/src/hash.ts +87 -0
  93. package/src/index.ts +6 -20
  94. package/src/interface.ts +1 -4
  95. package/src/kzg_context.ts +5 -0
  96. package/src/sponge_blob.ts +26 -29
  97. package/src/testing.ts +48 -50
  98. package/src/trusted_setup_bit_reversed.json +4100 -0
  99. package/src/types.ts +17 -0
  100. package/dest/blob_public_inputs.d.ts +0 -50
  101. package/dest/blob_public_inputs.d.ts.map +0 -1
  102. package/dest/blob_public_inputs.js +0 -146
  103. package/dest/encoding.d.ts +0 -66
  104. package/dest/encoding.d.ts.map +0 -1
  105. package/dest/encoding.js +0 -113
  106. package/src/blob_public_inputs.ts +0 -157
  107. package/src/encoding.ts +0 -138
package/src/hash.ts ADDED
@@ -0,0 +1,87 @@
1
+ import { poseidon2Hash, sha256, sha256ToField } from '@aztec/foundation/crypto';
2
+ import { BLS12Fr, Fr } from '@aztec/foundation/fields';
3
+
4
+ import { BYTES_PER_BLOB, BYTES_PER_COMMITMENT, kzg } from './kzg_context.js';
5
+ import { SpongeBlob } from './sponge_blob.js';
6
+
7
+ const VERSIONED_HASH_VERSION_KZG = 0x01;
8
+
9
+ /**
10
+ * Returns ethereum's versioned blob hash, following kzg_to_versioned_hash: https://eips.ethereum.org/EIPS/eip-4844#helpers
11
+ */
12
+ export function computeEthVersionedBlobHash(commitment: Buffer): Buffer {
13
+ const hash = sha256(commitment);
14
+ hash[0] = VERSIONED_HASH_VERSION_KZG;
15
+ return hash;
16
+ }
17
+
18
+ // TODO(#13430): The blobsHash is confusingly similar to blobCommitmentsHash, calculated from below blobCommitments:
19
+ // - blobsHash := sha256([blobhash_0, ..., blobhash_m]) = a hash of all blob hashes in a block with m+1 blobs inserted into the header, exists so a user can cross check blobs.
20
+ // - blobCommitmentsHash := sha256( ...sha256(sha256(C_0), C_1) ... C_n) = iteratively calculated hash of all blob commitments in an epoch with n+1 blobs (see calculateBlobCommitmentsHash()),
21
+ // exists so we can validate injected commitments to the rollup circuits correspond to the correct real blobs.
22
+ // We may be able to combine these values e.g. blobCommitmentsHash := sha256( ...sha256(sha256(blobshash_0), blobshash_1) ... blobshash_l) for an epoch with l+1 blocks.
23
+ export function computeBlobsHash(evmVersionedBlobHashes: Buffer[]): Fr {
24
+ return sha256ToField(evmVersionedBlobHashes);
25
+ }
26
+
27
+ /**
28
+ * Computes a non-standard Poseidon2 hash over the provided fields.
29
+ *
30
+ * This function is used to compute:
31
+ * - `blobFieldsHash` of a checkpoint:
32
+ * Verified in the circuit against all fields absorbed into the blob sponge over the entire checkpoint.
33
+ * The exact number of fields is encoded in the checkpoint end marker (the last field).
34
+ * This hash is used when generating the challenge `z` for all blobs in the checkpoint.
35
+ * - `spongeBlobHash` of a block:
36
+ * Computed from the block's tx effects, its end-state, and the blob fields of all prior blocks in the same checkpoint.
37
+ * This hash is included in the block header.
38
+ */
39
+ export async function computeBlobFieldsHash(fields: Fr[]): Promise<Fr> {
40
+ const sponge = SpongeBlob.init();
41
+ await sponge.absorb(fields);
42
+ return sponge.squeeze();
43
+ }
44
+
45
+ export function computeBlobCommitment(data: Uint8Array): Buffer {
46
+ if (data.length !== BYTES_PER_BLOB) {
47
+ throw new Error(`Expected ${BYTES_PER_BLOB} bytes per blob. Got ${data.length}.`);
48
+ }
49
+
50
+ return Buffer.from(kzg.blobToKzgCommitment(data));
51
+ }
52
+
53
+ /**
54
+ * Get the commitment fields of the blob, to compute the challenge z.
55
+ *
56
+ * The 48-byte commitment is encoded into two field elements:
57
+ * +-------------------+------------------------+
58
+ * | 31 bytes | 17 bytes |
59
+ * +-------------------+------------------------+
60
+ * | Field Element 1 | Field Element 2 |
61
+ * | [0][bytes 0-30] | [0...0][bytes 31-47] |
62
+ * +-------------------+------------------------+
63
+ *
64
+ * @param commitment - The commitment to convert to fields. Computed from `computeBlobCommitment`.
65
+ * @returns The fields representing the commitment buffer.
66
+ */
67
+ export function commitmentToFields(commitment: Buffer): [Fr, Fr] {
68
+ if (commitment.length !== BYTES_PER_COMMITMENT) {
69
+ throw new Error(`Expected ${BYTES_PER_COMMITMENT} bytes for blob commitment. Got ${commitment.length}.`);
70
+ }
71
+
72
+ return [new Fr(commitment.subarray(0, 31)), new Fr(commitment.subarray(31, BYTES_PER_COMMITMENT))];
73
+ }
74
+
75
+ export async function computeChallengeZ(blobFieldsHash: Fr, commitment: Buffer): Promise<Fr> {
76
+ const commitmentFields = commitmentToFields(commitment);
77
+ return await poseidon2Hash([blobFieldsHash, commitmentFields[0], commitmentFields[1]]);
78
+ }
79
+
80
+ /**
81
+ * Hash each u128 limb of the noir bignum struct representing the BLS field, to mimic the hash accumulation in the
82
+ * rollup circuits.
83
+ */
84
+ export async function hashNoirBigNumLimbs(field: BLS12Fr): Promise<Fr> {
85
+ const num = field.toNoirBigNum();
86
+ return await poseidon2Hash(num.limbs.map(Fr.fromHexString));
87
+ }
package/src/index.ts CHANGED
@@ -1,23 +1,9 @@
1
- import cKzg from 'c-kzg';
2
-
3
- /* eslint-disable import/no-named-as-default-member */
4
- const { loadTrustedSetup } = cKzg;
5
-
1
+ export * from './batched_blob.js';
6
2
  export * from './blob.js';
7
- export * from './encoding.js';
3
+ export * from './blob_batching.js';
4
+ export * from './blob_utils.js';
5
+ export * from './circuit_types/index.js';
6
+ export * from './encoding/index.js';
7
+ export * from './hash.js';
8
8
  export * from './interface.js';
9
- export * from './errors.js';
10
- export * from './blob_public_inputs.js';
11
9
  export * from './sponge_blob.js';
12
-
13
- try {
14
- loadTrustedSetup();
15
- } catch (error: any) {
16
- if (error.message.includes('trusted setup is already loaded')) {
17
- // NB: The c-kzg lib has no way of checking whether the setup is loaded or not,
18
- // and it throws an error if it's already loaded, even though nothing is wrong.
19
- // This is a rudimentary way of ensuring we load the trusted setup if we need it.
20
- } else {
21
- throw new Error(error);
22
- }
23
- }
package/src/interface.ts CHANGED
@@ -3,9 +3,6 @@
3
3
  */
4
4
  export interface BlobJson {
5
5
  blob: string;
6
- index?: number;
7
- // eslint-disable-next-line camelcase
6
+ index: string;
8
7
  kzg_commitment: string;
9
- // eslint-disable-next-line camelcase
10
- kzg_proof: string;
11
8
  }
@@ -0,0 +1,5 @@
1
+ import { DasContextJs } from '@crate-crypto/node-eth-kzg';
2
+
3
+ export * from '@crate-crypto/node-eth-kzg';
4
+
5
+ export const kzg = DasContextJs.create({ usePrecomp: true });
@@ -1,3 +1,4 @@
1
+ import { BLOBS_PER_CHECKPOINT, FIELDS_PER_BLOB, TWO_POW_64 } from '@aztec/constants';
1
2
  import { type FieldsOf, makeTuple } from '@aztec/foundation/array';
2
3
  import { poseidon2Permutation } from '@aztec/foundation/crypto';
3
4
  import { Fr } from '@aztec/foundation/fields';
@@ -10,30 +11,40 @@ import {
10
11
  } from '@aztec/foundation/serialize';
11
12
 
12
13
  /**
13
- * A Poseidon2 sponge used to accumulate data that will be added to a blob.
14
+ * A Poseidon2 sponge used to accumulate data that will be added to blobs.
14
15
  * See noir-projects/noir-protocol-circuits/crates/types/src/abis/sponge_blob.nr.
15
16
  */
16
17
  export class SpongeBlob {
18
+ static MAX_FIELDS = BLOBS_PER_CHECKPOINT * FIELDS_PER_BLOB;
19
+
17
20
  constructor(
18
- /** Sponge with absorbed tx effects that will go into a blob. */
21
+ /** Sponge with absorbed fields that will go into one or more blobs. */
19
22
  public readonly sponge: Poseidon2Sponge,
20
23
  /** Number of effects absorbed so far. */
21
- public fields: number,
22
- /** Number of effects that will be absorbed. */
23
- public readonly expectedFields: number,
24
+ public numAbsorbedFields: number,
24
25
  ) {}
25
26
 
27
+ /**
28
+ * Initialize the sponge blob to absorb data for a checkpoint.
29
+ */
30
+ static init(): SpongeBlob {
31
+ // This must match the implementation in noir-projects/noir-protocol-circuits/types/src/abis/sponge_blob.nr
32
+ const iv = new Fr(BigInt(SpongeBlob.MAX_FIELDS) * TWO_POW_64);
33
+ const sponge = Poseidon2Sponge.init(iv);
34
+ return new SpongeBlob(sponge, 0);
35
+ }
36
+
26
37
  static fromBuffer(buffer: Buffer | BufferReader): SpongeBlob {
27
38
  const reader = BufferReader.asReader(buffer);
28
- return new SpongeBlob(reader.readObject(Poseidon2Sponge), reader.readNumber(), reader.readNumber());
39
+ return new SpongeBlob(reader.readObject(Poseidon2Sponge), reader.readNumber());
29
40
  }
30
41
 
31
42
  toBuffer() {
32
- return serializeToBuffer(this.sponge, this.fields, this.expectedFields);
43
+ return serializeToBuffer(...SpongeBlob.getFields(this));
33
44
  }
34
45
 
35
46
  static getFields(fields: FieldsOf<SpongeBlob>) {
36
- return [fields.sponge, fields.fields, fields.expectedFields];
47
+ return [fields.sponge, fields.numAbsorbedFields];
37
48
  }
38
49
 
39
50
  toFields(): Fr[] {
@@ -42,11 +53,7 @@ export class SpongeBlob {
42
53
 
43
54
  static fromFields(fields: Fr[] | FieldReader): SpongeBlob {
44
55
  const reader = FieldReader.asReader(fields);
45
- return new SpongeBlob(
46
- reader.readObject(Poseidon2Sponge),
47
- reader.readField().toNumber(),
48
- reader.readField().toNumber(),
49
- );
56
+ return new SpongeBlob(reader.readObject(Poseidon2Sponge), reader.readField().toNumber());
50
57
  }
51
58
 
52
59
  clone() {
@@ -54,30 +61,21 @@ export class SpongeBlob {
54
61
  }
55
62
 
56
63
  async absorb(fields: Fr[]) {
57
- if (this.fields + fields.length > this.expectedFields) {
64
+ if (this.numAbsorbedFields + fields.length > SpongeBlob.MAX_FIELDS) {
58
65
  throw new Error(
59
- `Attempted to fill spongeblob with ${this.fields + fields.length}, but it has a max of ${this.expectedFields}`,
66
+ `Attempted to fill spongeBlob with ${this.numAbsorbedFields + fields.length}, but it has a max of ${SpongeBlob.MAX_FIELDS}`,
60
67
  );
61
68
  }
62
69
  await this.sponge.absorb(fields);
63
- this.fields += fields.length;
70
+ this.numAbsorbedFields += fields.length;
64
71
  }
65
72
 
66
73
  async squeeze(): Promise<Fr> {
67
- // If the blob sponge is not 'full', we append 1 to match Poseidon2::hash_internal()
68
- // NB: There is currently no use case in which we don't 'fill' a blob sponge, but adding for completeness
69
- if (this.fields != this.expectedFields) {
70
- await this.sponge.absorb([Fr.ONE]);
71
- }
72
- return this.sponge.squeeze();
74
+ return await this.sponge.squeeze();
73
75
  }
74
76
 
75
77
  static empty(): SpongeBlob {
76
- return new SpongeBlob(Poseidon2Sponge.empty(), 0, 0);
77
- }
78
-
79
- static init(expectedFields: number): SpongeBlob {
80
- return new SpongeBlob(Poseidon2Sponge.init(expectedFields), 0, expectedFields);
78
+ return new SpongeBlob(Poseidon2Sponge.empty(), 0);
81
79
  }
82
80
  }
83
81
 
@@ -131,8 +129,7 @@ export class Poseidon2Sponge {
131
129
  );
132
130
  }
133
131
 
134
- static init(expectedFields: number): Poseidon2Sponge {
135
- const iv = new Fr(expectedFields).mul(new Fr(BigInt('18446744073709551616')));
132
+ static init(iv: Fr): Poseidon2Sponge {
136
133
  const sponge = Poseidon2Sponge.empty();
137
134
  sponge.state[3] = iv;
138
135
  return sponge;
package/src/testing.ts CHANGED
@@ -1,13 +1,14 @@
1
- import { BLOBS_PER_BLOCK } from '@aztec/constants';
2
1
  import { makeTuple } from '@aztec/foundation/array';
3
- import { toBufferBE } from '@aztec/foundation/bigint-buffer';
4
- import { Fr } from '@aztec/foundation/fields';
2
+ import { BLS12Fq, BLS12Fr, BLS12Point, BLSPointNotOnCurveError, Fr } from '@aztec/foundation/fields';
5
3
 
6
4
  import { Blob } from './blob.js';
7
- import { BlobPublicInputs, BlockBlobPublicInputs } from './blob_public_inputs.js';
8
- import { TX_START_PREFIX, TX_START_PREFIX_BYTES_LENGTH } from './encoding.js';
5
+ import { BlobAccumulator } from './circuit_types/blob_accumulator.js';
6
+ import { FinalBlobAccumulator } from './circuit_types/final_blob_accumulator.js';
7
+ import { FinalBlobBatchingChallenges } from './circuit_types/final_blob_batching_challenges.js';
9
8
  import { Poseidon2Sponge, SpongeBlob } from './sponge_blob.js';
10
9
 
10
+ export * from './encoding/fixtures.js';
11
+
11
12
  /**
12
13
  * Makes arbitrary poseidon sponge for blob inputs.
13
14
  * Note: will not verify inside the circuit.
@@ -23,73 +24,70 @@ export function makeSpongeBlob(seed = 1): SpongeBlob {
23
24
  false,
24
25
  ),
25
26
  seed,
26
- seed + 1,
27
27
  );
28
28
  }
29
29
 
30
30
  /**
31
- * Makes arbitrary blob public inputs.
32
- * Note: will not verify inside the circuit.
33
- * @param seed - The seed to use for generating the blob inputs.
34
- * @returns A blob public inputs instance.
31
+ * Makes an arbitrary but valid BLS12 point. The value is deterministic for a given seed.
32
+ * @param seed - The seed to use for generating the point.
33
+ * @returns A BLS12 point instance.
35
34
  */
36
- export function makeBlobPublicInputs(seed = 1): BlobPublicInputs {
37
- return new BlobPublicInputs(
38
- new Fr(seed),
39
- BigInt(seed + 1),
40
- makeTuple(2, i => new Fr(i)),
41
- );
35
+ function makeBLS12Point(seed = 1): BLS12Point {
36
+ let accum = 0;
37
+ while (true) {
38
+ try {
39
+ const x = new BLS12Fq(seed + accum);
40
+ const y = BLS12Point.YFromX(x);
41
+ if (y) {
42
+ return new BLS12Point(x, y, false);
43
+ }
44
+ accum++;
45
+ } catch (e: any) {
46
+ if (!(e instanceof BLSPointNotOnCurveError)) {
47
+ throw e;
48
+ }
49
+ // The point is not on the curve - try again
50
+ }
51
+ }
42
52
  }
43
53
 
44
54
  /**
45
- * Makes arbitrary block blob public inputs.
55
+ * Makes arbitrary blob public accumulator.
46
56
  * Note: will not verify inside the circuit.
47
- * @param seed - The seed to use for generating the blob inputs.
48
- * @returns A block blob public inputs instance.
57
+ * @param seed - The seed to use for generating the blob accumulator.
58
+ * @returns A blob accumulator instance.
49
59
  */
50
- export function makeBlockBlobPublicInputs(seed = 1): BlockBlobPublicInputs {
51
- return new BlockBlobPublicInputs(makeTuple(BLOBS_PER_BLOCK, () => makeBlobPublicInputs(seed)));
60
+ export function makeBlobAccumulator(seed = 1): BlobAccumulator {
61
+ return new BlobAccumulator(
62
+ new Fr(seed),
63
+ new Fr(seed + 0x10),
64
+ new BLS12Fr(seed + 0x20),
65
+ makeBLS12Point(seed + 0x30),
66
+ new Fr(seed + 0x50),
67
+ new BLS12Fr(seed + 0x60),
68
+ );
52
69
  }
53
70
 
54
- // TODO: copied form stdlib tx effect
55
- function encodeFirstField(length: number): Fr {
56
- const lengthBuf = Buffer.alloc(2);
57
- lengthBuf.writeUInt16BE(length, 0);
58
- return new Fr(
59
- Buffer.concat([
60
- toBufferBE(TX_START_PREFIX, TX_START_PREFIX_BYTES_LENGTH),
61
- Buffer.alloc(1),
62
- lengthBuf,
63
- Buffer.alloc(1),
64
- Buffer.from([1]),
65
- Buffer.alloc(1),
66
- Buffer.alloc(1),
67
- ]),
71
+ export function makeFinalBlobAccumulator(seed = 1) {
72
+ return new FinalBlobAccumulator(
73
+ new Fr(seed),
74
+ new Fr(seed + 0x10),
75
+ new BLS12Fr(seed + 0x20),
76
+ makeBLS12Point(seed + 0x30),
68
77
  );
69
78
  }
70
79
 
71
- /**
72
- * Make an encoded blob with the given length
73
- *
74
- * This will deserialise correctly in the archiver
75
- * @param length
76
- * @returns
77
- */
78
- export function makeEncodedBlob(length: number): Promise<Blob> {
79
- return Blob.fromFields([encodeFirstField(length + 1), ...Array.from({ length: length }, () => Fr.random())]);
80
+ export function makeFinalBlobBatchingChallenges(seed = 1) {
81
+ return new FinalBlobBatchingChallenges(new Fr(seed), new BLS12Fr(seed + 0x10));
80
82
  }
81
83
 
82
84
  /**
83
- * Make an unencoded blob with the given length
85
+ * Make a blob with random fields.
84
86
  *
85
87
  * This will fail deserialisation in the archiver
86
88
  * @param length
87
89
  * @returns
88
90
  */
89
- export function makeUnencodedBlob(length: number): Promise<Blob> {
91
+ export function makeRandomBlob(length: number): Blob {
90
92
  return Blob.fromFields([...Array.from({ length: length }, () => Fr.random())]);
91
93
  }
92
-
93
- export function makeEncodedBlobFields(fields: Fr[]): Promise<Blob> {
94
- return Blob.fromFields([encodeFirstField(fields.length + 1), ...fields]);
95
- }