@aztec/foundation 0.75.0 → 0.76.0

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 (62) hide show
  1. package/dest/config/env_var.d.ts +1 -1
  2. package/dest/config/env_var.d.ts.map +1 -1
  3. package/dest/config/index.d.ts.map +1 -1
  4. package/dest/config/index.js +7 -2
  5. package/dest/index.d.ts +0 -1
  6. package/dest/index.d.ts.map +1 -1
  7. package/dest/index.js +1 -2
  8. package/dest/json-rpc/client/fetch.d.ts +6 -1
  9. package/dest/json-rpc/client/fetch.d.ts.map +1 -1
  10. package/dest/json-rpc/client/fetch.js +2 -2
  11. package/dest/json-rpc/client/safe_json_rpc_client.d.ts +14 -1
  12. package/dest/json-rpc/client/safe_json_rpc_client.d.ts.map +1 -1
  13. package/dest/json-rpc/client/safe_json_rpc_client.js +14 -8
  14. package/dest/json-rpc/test/integration.d.ts +4 -2
  15. package/dest/json-rpc/test/integration.d.ts.map +1 -1
  16. package/dest/json-rpc/test/integration.js +10 -7
  17. package/dest/log/log-filters.d.ts.map +1 -1
  18. package/dest/log/log-filters.js +12 -3
  19. package/dest/log/pino-logger.d.ts +1 -1
  20. package/dest/log/pino-logger.d.ts.map +1 -1
  21. package/dest/log/pino-logger.js +10 -3
  22. package/dest/queue/serial_queue.d.ts +1 -1
  23. package/dest/queue/serial_queue.d.ts.map +1 -1
  24. package/dest/queue/serial_queue.js +1 -1
  25. package/dest/serialize/field_reader.d.ts +6 -6
  26. package/dest/serialize/field_reader.d.ts.map +1 -1
  27. package/dest/serialize/field_reader.js +9 -9
  28. package/package.json +2 -3
  29. package/src/config/env_var.ts +5 -1
  30. package/src/config/index.ts +6 -1
  31. package/src/index.ts +0 -1
  32. package/src/json-rpc/client/fetch.ts +2 -2
  33. package/src/json-rpc/client/safe_json_rpc_client.ts +26 -11
  34. package/src/json-rpc/test/integration.ts +17 -6
  35. package/src/log/log-filters.ts +10 -2
  36. package/src/log/pino-logger.ts +15 -3
  37. package/src/queue/serial_queue.ts +1 -1
  38. package/src/serialize/field_reader.ts +9 -9
  39. package/dest/blob/blob.d.ts +0 -154
  40. package/dest/blob/blob.d.ts.map +0 -1
  41. package/dest/blob/blob.js +0 -264
  42. package/dest/blob/encoding.d.ts +0 -53
  43. package/dest/blob/encoding.d.ts.map +0 -1
  44. package/dest/blob/encoding.js +0 -87
  45. package/dest/blob/errors.d.ts +0 -4
  46. package/dest/blob/errors.d.ts.map +0 -1
  47. package/dest/blob/errors.js +0 -7
  48. package/dest/blob/index.d.ts +0 -6
  49. package/dest/blob/index.d.ts.map +0 -1
  50. package/dest/blob/index.js +0 -22
  51. package/dest/blob/interface.d.ts +0 -10
  52. package/dest/blob/interface.d.ts.map +0 -1
  53. package/dest/blob/interface.js +0 -2
  54. package/dest/blob/mocks.d.ts +0 -20
  55. package/dest/blob/mocks.d.ts.map +0 -1
  56. package/dest/blob/mocks.js +0 -42
  57. package/src/blob/blob.ts +0 -311
  58. package/src/blob/encoding.ts +0 -98
  59. package/src/blob/errors.ts +0 -6
  60. package/src/blob/index.ts +0 -22
  61. package/src/blob/interface.ts +0 -11
  62. package/src/blob/mocks.ts +0 -48
package/src/blob/blob.ts DELETED
@@ -1,311 +0,0 @@
1
- // Importing directly from 'c-kzg' does not work, ignoring import/no-named-as-default-member err:
2
- import cKzg from 'c-kzg';
3
- import type { Blob as BlobBuffer } from 'c-kzg';
4
-
5
- import { poseidon2Hash, sha256 } from '../crypto/index.js';
6
- import { Fr } from '../fields/index.js';
7
- import { BufferReader, serializeToBuffer } from '../serialize/index.js';
8
- import { deserializeEncodedBlobToFields, extractBlobFieldsFromBuffer } from './encoding.js';
9
- import { BlobDeserializationError } from './errors.js';
10
- import { type BlobJson } from './interface.js';
11
-
12
- /* eslint-disable import/no-named-as-default-member */
13
- const { BYTES_PER_BLOB, FIELD_ELEMENTS_PER_BLOB, blobToKzgCommitment, computeKzgProof, verifyKzgProof } = cKzg;
14
-
15
- // The prefix to the EVM blobHash, defined here: https://eips.ethereum.org/EIPS/eip-4844#specification
16
- export const VERSIONED_HASH_VERSION_KZG = 0x01;
17
-
18
- /**
19
- * A class to create, manage, and prove EVM blobs.
20
- */
21
- export class Blob {
22
- constructor(
23
- /** The blob to be broadcast on L1 in bytes form. */
24
- public readonly data: BlobBuffer,
25
- /** The hash of all tx effects inside the blob. Used in generating the challenge z and proving that we have included all required effects. */
26
- public readonly fieldsHash: Fr,
27
- /** Challenge point z (= H(H(tx_effects), kzgCommmitment). Used such that p(z) = y. */
28
- public readonly challengeZ: Fr,
29
- /** Evaluation y = p(z), where p() is the blob polynomial. BLS12 field element, rep. as BigNum in nr, bigint in ts. */
30
- public readonly evaluationY: Buffer,
31
- /** Commitment to the blob C. Used in compressed BLS12 point format (48 bytes). */
32
- public readonly commitment: Buffer,
33
- /** KZG opening proof for y = p(z). The commitment to quotient polynomial Q, used in compressed BLS12 point format (48 bytes). */
34
- public readonly proof: Buffer,
35
- ) {}
36
-
37
- /**
38
- * The encoded version of the blob will determine the end of the blob based on the transaction encoding.
39
- * This is required when the fieldsHash of a blob will contain trailing zeros.
40
- *
41
- * See `./encoding.ts` for more details.
42
- *
43
- * This method is used to create a Blob from a buffer.
44
- * @param blob - The buffer to create the Blob from.
45
- * @param multiBlobFieldsHash - The fields hash to use for the Blob.
46
- * @returns A Blob created from the buffer.
47
- *
48
- * @throws If unable to deserialize the blob.
49
- */
50
- static fromEncodedBlobBuffer(blob: BlobBuffer, multiBlobFieldsHash?: Fr): Promise<Blob> {
51
- try {
52
- const fields: Fr[] = deserializeEncodedBlobToFields(blob);
53
- return Blob.fromFields(fields, multiBlobFieldsHash);
54
- } catch (err) {
55
- throw new BlobDeserializationError(
56
- `Failed to create Blob from encoded blob buffer, this blob was likely not created by us`,
57
- );
58
- }
59
- }
60
-
61
- /**
62
- * Create a Blob from an array of fields.
63
- *
64
- * @param fields - The array of fields to create the Blob from.
65
- * @param multiBlobFieldsHash - The fields hash to use for the Blob.
66
- * @returns A Blob created from the array of fields.
67
- */
68
- static async fromFields(fields: Fr[], multiBlobFieldsHash?: Fr): Promise<Blob> {
69
- if (fields.length > FIELD_ELEMENTS_PER_BLOB) {
70
- throw new Error(
71
- `Attempted to overfill blob with ${fields.length} elements. The maximum is ${FIELD_ELEMENTS_PER_BLOB}`,
72
- );
73
- }
74
-
75
- const data = Buffer.concat([serializeToBuffer(fields)], BYTES_PER_BLOB);
76
-
77
- // This matches the output of SpongeBlob.squeeze() in the blob circuit
78
- const fieldsHash = multiBlobFieldsHash ? multiBlobFieldsHash : await poseidon2Hash(fields);
79
- const commitment = Buffer.from(blobToKzgCommitment(data));
80
- const challengeZ = await poseidon2Hash([fieldsHash, ...commitmentToFields(commitment)]);
81
- const res = computeKzgProof(data, challengeZ.toBuffer());
82
- if (!verifyKzgProof(commitment, challengeZ.toBuffer(), res[1], res[0])) {
83
- throw new Error(`KZG proof did not verify.`);
84
- }
85
- const proof = Buffer.from(res[0]);
86
- const evaluationY = Buffer.from(res[1]);
87
-
88
- return new Blob(data, fieldsHash, challengeZ, evaluationY, commitment, proof);
89
- }
90
-
91
- /**
92
- * Create a Blob from a JSON object.
93
- *
94
- * Blobs will be in this form when requested from the blob sink, or from
95
- * the beacon chain via `getBlobSidecars`
96
- * https://ethereum.github.io/beacon-APIs/?urls.primaryName=dev#/Beacon/getBlobSidecars
97
- *
98
- * @dev WARNING: by default json deals with encoded buffers
99
- *
100
- * @param json - The JSON object to create the Blob from.
101
- * @returns A Blob created from the JSON object.
102
- */
103
- static async fromJson(json: BlobJson): Promise<Blob> {
104
- const blobBuffer = Buffer.from(json.blob.slice(2), 'hex');
105
-
106
- const blob = await Blob.fromEncodedBlobBuffer(blobBuffer);
107
-
108
- if (blob.commitment.toString('hex') !== json.kzg_commitment.slice(2)) {
109
- throw new Error('KZG commitment does not match');
110
- }
111
-
112
- // We do not check the proof, as it will be different if the challenge is shared
113
- // across multiple blobs
114
-
115
- return blob;
116
- }
117
-
118
- /**
119
- * Get the JSON representation of the blob.
120
- *
121
- * @dev WARNING: by default json deals with encoded buffers
122
- * @param index - optional - The index of the blob in the block.
123
- * @returns The JSON representation of the blob.
124
- */
125
- toJson(index?: number): BlobJson {
126
- return {
127
- blob: `0x${Buffer.from(this.data).toString('hex')}`,
128
- index,
129
- // eslint-disable-next-line camelcase
130
- kzg_commitment: `0x${this.commitment.toString('hex')}`,
131
- // eslint-disable-next-line camelcase
132
- kzg_proof: `0x${this.proof.toString('hex')}`,
133
- };
134
- }
135
-
136
- /**
137
- * Get the fields from the blob.
138
- *
139
- * @dev WARNING: this method does not take into account trailing zeros
140
- *
141
- * @returns The fields from the blob.
142
- */
143
- toFields(): Fr[] {
144
- return extractBlobFieldsFromBuffer(this.data);
145
- }
146
-
147
- /**
148
- * Get the encoded fields from the blob.
149
- *
150
- * @dev This method takes into account trailing zeros
151
- *
152
- * @returns The encoded fields from the blob.
153
- *
154
- * @throws If unable to deserialize the blob.
155
- */
156
- toEncodedFields(): Fr[] {
157
- try {
158
- return deserializeEncodedBlobToFields(this.data);
159
- } catch (err) {
160
- throw new BlobDeserializationError(
161
- `Failed to deserialize encoded blob fields, this blob was likely not created by us`,
162
- );
163
- }
164
- }
165
-
166
- /**
167
- * Get the commitment fields from the blob.
168
- *
169
- * The 48-byte commitment is encoded into two field elements:
170
- * +------------------+------------------+
171
- * | Field Element 1 | Field Element 2 |
172
- * | [bytes 0-31] | [bytes 32-47] |
173
- * +------------------+------------------+
174
- * | 32 bytes | 16 bytes |
175
- * +------------------+------------------+
176
- * @returns The commitment fields from the blob.
177
- */
178
- commitmentToFields(): [Fr, Fr] {
179
- return commitmentToFields(this.commitment);
180
- }
181
-
182
- // Returns ethereum's versioned blob hash, following kzg_to_versioned_hash: https://eips.ethereum.org/EIPS/eip-4844#helpers
183
- getEthVersionedBlobHash(): Buffer {
184
- const hash = sha256(this.commitment);
185
- hash[0] = VERSIONED_HASH_VERSION_KZG;
186
- return hash;
187
- }
188
-
189
- static getEthVersionedBlobHash(commitment: Buffer): Buffer {
190
- const hash = sha256(commitment);
191
- hash[0] = VERSIONED_HASH_VERSION_KZG;
192
- return hash;
193
- }
194
-
195
- /**
196
- * Get the buffer representation of the ENTIRE blob.
197
- *
198
- * @dev WARNING: this buffer contains all metadata aswell as the data itself
199
- *
200
- * @returns The buffer representation of the blob.
201
- */
202
- toBuffer(): Buffer {
203
- return Buffer.from(
204
- serializeToBuffer(
205
- this.data.length,
206
- this.data,
207
- this.fieldsHash,
208
- this.challengeZ,
209
- this.evaluationY.length,
210
- this.evaluationY,
211
- this.commitment.length,
212
- this.commitment,
213
- this.proof.length,
214
- this.proof,
215
- ),
216
- );
217
- }
218
-
219
- /**
220
- * Create a Blob from a buffer.
221
- *
222
- * @dev WARNING: this method contains all metadata aswell as the data itself
223
- *
224
- * @param buf - The buffer to create the Blob from.
225
- * @returns A Blob created from the buffer.
226
- */
227
- static fromBuffer(buf: Buffer | BufferReader): Blob {
228
- const reader = BufferReader.asReader(buf);
229
- return new Blob(
230
- reader.readUint8Array(),
231
- reader.readObject(Fr),
232
- reader.readObject(Fr),
233
- reader.readBuffer(),
234
- reader.readBuffer(),
235
- reader.readBuffer(),
236
- );
237
- }
238
-
239
- /**
240
- * Get the size of the blob in bytes
241
- */
242
- getSize() {
243
- return this.data.length;
244
- }
245
-
246
- /**
247
- * Returns a proof of opening of the blob to verify on L1 using the point evaluation precompile:
248
- *
249
- * input[:32] - versioned_hash
250
- * input[32:64] - z
251
- * input[64:96] - y
252
- * input[96:144] - commitment C
253
- * input[144:192] - proof (a commitment to the quotient polynomial q(X))
254
- *
255
- * See https://eips.ethereum.org/EIPS/eip-4844#point-evaluation-precompile
256
- */
257
- getEthBlobEvaluationInputs(): `0x${string}` {
258
- const buf = Buffer.concat([
259
- this.getEthVersionedBlobHash(),
260
- this.challengeZ.toBuffer(),
261
- this.evaluationY,
262
- this.commitment,
263
- this.proof,
264
- ]);
265
- return `0x${buf.toString('hex')}`;
266
- }
267
-
268
- static getEthBlobEvaluationInputs(blobs: Blob[]): `0x${string}` {
269
- let buf = Buffer.alloc(0);
270
- blobs.forEach(blob => {
271
- buf = Buffer.concat([
272
- buf,
273
- blob.getEthVersionedBlobHash(),
274
- blob.challengeZ.toBuffer(),
275
- blob.evaluationY,
276
- blob.commitment,
277
- blob.proof,
278
- ]);
279
- });
280
- // For multiple blobs, we prefix the number of blobs:
281
- const lenBuf = Buffer.alloc(1);
282
- lenBuf.writeUint8(blobs.length);
283
- buf = Buffer.concat([lenBuf, buf]);
284
- return `0x${buf.toString('hex')}`;
285
- }
286
-
287
- static getViemKzgInstance() {
288
- return {
289
- blobToKzgCommitment: cKzg.blobToKzgCommitment,
290
- computeBlobKzgProof: cKzg.computeBlobKzgProof,
291
- };
292
- }
293
-
294
- // Returns as many blobs as we require to broadcast the given fields
295
- // Assumes we share the fields hash between all blobs
296
- static async getBlobs(fields: Fr[]): Promise<Blob[]> {
297
- const numBlobs = Math.max(Math.ceil(fields.length / FIELD_ELEMENTS_PER_BLOB), 1);
298
- const multiBlobFieldsHash = await poseidon2Hash(fields);
299
- const res = [];
300
- for (let i = 0; i < numBlobs; i++) {
301
- const end = fields.length < (i + 1) * FIELD_ELEMENTS_PER_BLOB ? fields.length : (i + 1) * FIELD_ELEMENTS_PER_BLOB;
302
- res.push(await Blob.fromFields(fields.slice(i * FIELD_ELEMENTS_PER_BLOB, end), multiBlobFieldsHash));
303
- }
304
- return res;
305
- }
306
- }
307
-
308
- // 48 bytes encoded in fields as [Fr, Fr] = [0->31, 31->48]
309
- function commitmentToFields(commitment: Buffer): [Fr, Fr] {
310
- return [new Fr(commitment.subarray(0, 31)), new Fr(commitment.subarray(31, 48))];
311
- }
@@ -1,98 +0,0 @@
1
- import { Fr } from '@aztec/foundation/fields';
2
- import { BufferReader, FieldReader } from '@aztec/foundation/serialize';
3
-
4
- import type { Blob as BlobBuffer } from 'c-kzg';
5
-
6
- // This will appear as 0x74785f7374617274 in logs
7
- export const TX_START_PREFIX = 8392562855083340404n;
8
- // These are helper constants to decode tx effects from blob encoded fields
9
- export const TX_START_PREFIX_BYTES_LENGTH = TX_START_PREFIX.toString(16).length / 2;
10
- // 7 bytes for: | 0 | txlen[0] | txlen[1] | 0 | REVERT_CODE_PREFIX | 0 | revertCode |
11
- export const TX_EFFECT_PREFIX_BYTE_LENGTH = TX_START_PREFIX_BYTES_LENGTH + 7;
12
-
13
- /**
14
- * Deserializes a blob buffer into an array of field elements.
15
- *
16
- * Blobs are converted into BN254 fields to perform a poseidon2 hash on them (fieldHash).
17
- * This method is sparse, meaning it does not include trailing zeros at the end of the blob.
18
- *
19
- * However, we cannot simply trim the zero's from the end of the blob, as some logs may include zero's
20
- * within them.
21
- * If we end on a set of zeros, such as the log below:
22
- * length 7: [ a, b, c, d, e, 0, 0]
23
- *
24
- * we will end up with the incorrect hash if we trim the zeros from the end.
25
- *
26
- * Each transactions logs contains a TX start prefix, which includes a string followed
27
- * by the length ( in field elements ) of the transaction's log.
28
- *
29
- * This function finds the end of the last transaction's logs, and returns the array up to this point.
30
- *
31
- * We search for a series of Tx Prefixes progressing the cursor in the field reader until we hit
32
- * a field that is not a Tx Prefix, this indicates that we have reached the end of the last transaction's logs.
33
- *
34
- * +------------------+------------------+------------------+------------------+
35
- * | TX1 Start Prefix | TX1 Log Fields | TX2 Start Prefix | Padded zeros |
36
- * | [3 a,b,c] | [3, a, b, c] | [5 d,e,f,0,0] | [0, 0, 0, .., 0] |
37
- * +------------------+------------------+------------------+------------------+
38
- * ^
39
- * |
40
- * Function reads until here --------------------------------
41
- *
42
- * @param blob - The blob buffer to deserialize.
43
- * @returns An array of field elements.
44
- */
45
- export function deserializeEncodedBlobToFields(blob: BlobBuffer): Fr[] {
46
- // Convert blob buffer to array of field elements
47
- const reader = BufferReader.asReader(blob);
48
- const array = reader.readArray(blob.length >> 5, Fr); // >> 5 = / 32 (bytes per field)
49
- const fieldReader = FieldReader.asReader(array);
50
-
51
- // Read fields until we hit zeros at the end
52
- while (!fieldReader.isFinished()) {
53
- const currentField = fieldReader.peekField();
54
-
55
- // Stop when we hit a zero field
56
- if (!currentField || currentField.isZero()) {
57
- break;
58
- }
59
-
60
- // Skip the remaining fields in this transaction
61
- const len = getLengthFromFirstField(currentField);
62
- fieldReader.skip(len);
63
- }
64
-
65
- // Return array up to last non-zero field
66
- return array.slice(0, fieldReader.cursor);
67
- }
68
-
69
- export function getLengthFromFirstField(firstField: Fr): number {
70
- const buf = firstField.toBuffer().subarray(-TX_EFFECT_PREFIX_BYTE_LENGTH);
71
- return new Fr(buf.subarray(TX_START_PREFIX_BYTES_LENGTH + 1, TX_START_PREFIX_BYTES_LENGTH + 3)).toNumber();
72
- }
73
-
74
- /**
75
- * Extract the fields from a blob buffer, but do not take into account encoding
76
- * that will include trailing zeros.
77
- *
78
- * +------------------+------------------+------------------+------------------+
79
- * | | | | Padded zeros |
80
- * | [3 a,b,c] | [3, a, b, c] | [5 d,e,f,0,0] | [0, 0, 0, .., 0] |
81
- * +------------------+------------------+------------------+------------------+
82
- * ^
83
- * |
84
- * Function reads until here ----------------------
85
- */
86
- export function extractBlobFieldsFromBuffer(blob: BlobBuffer): Fr[] {
87
- const reader = BufferReader.asReader(blob);
88
- const array = reader.readArray(blob.length >> 5, Fr);
89
-
90
- // Find the index of the last non-zero field
91
- let lastNonZeroIndex = array.length - 1;
92
- while (lastNonZeroIndex >= 0 && array[lastNonZeroIndex].isZero()) {
93
- lastNonZeroIndex--;
94
- }
95
-
96
- // Return the trimmed array
97
- return array.slice(0, lastNonZeroIndex + 1);
98
- }
@@ -1,6 +0,0 @@
1
- export class BlobDeserializationError extends Error {
2
- constructor(message: string) {
3
- super(message);
4
- this.name = 'BlobDeserializationError';
5
- }
6
- }
package/src/blob/index.ts DELETED
@@ -1,22 +0,0 @@
1
- import cKzg from 'c-kzg';
2
-
3
- /* eslint-disable import/no-named-as-default-member */
4
- const { loadTrustedSetup } = cKzg;
5
-
6
- export * from './blob.js';
7
- export * from './mocks.js';
8
- export * from './encoding.js';
9
- export * from './interface.js';
10
- export * from './errors.js';
11
-
12
- try {
13
- loadTrustedSetup();
14
- } catch (error: any) {
15
- if (error.message.includes('trusted setup is already loaded')) {
16
- // NB: The c-kzg lib has no way of checking whether the setup is loaded or not,
17
- // and it throws an error if it's already loaded, even though nothing is wrong.
18
- // This is a rudimentary way of ensuring we load the trusted setup if we need it.
19
- } else {
20
- throw new Error(error);
21
- }
22
- }
@@ -1,11 +0,0 @@
1
- /**
2
- * The relevant parts of a response from https://ethereum.github.io/beacon-APIs/?urls.primaryName=dev#/Beacon/getBlobSidecars
3
- */
4
- export interface BlobJson {
5
- blob: string;
6
- index?: number;
7
- // eslint-disable-next-line camelcase
8
- kzg_commitment: string;
9
- // eslint-disable-next-line camelcase
10
- kzg_proof: string;
11
- }
package/src/blob/mocks.ts DELETED
@@ -1,48 +0,0 @@
1
- import { toBufferBE } from '@aztec/foundation/bigint-buffer';
2
- import { Fr } from '@aztec/foundation/fields';
3
-
4
- import { Blob } from './blob.js';
5
- import { TX_START_PREFIX, TX_START_PREFIX_BYTES_LENGTH } from './encoding.js';
6
-
7
- // TODO: copied form circuit-types tx effect
8
- function encodeFirstField(length: number): Fr {
9
- const lengthBuf = Buffer.alloc(2);
10
- lengthBuf.writeUInt16BE(length, 0);
11
- return new Fr(
12
- Buffer.concat([
13
- toBufferBE(TX_START_PREFIX, TX_START_PREFIX_BYTES_LENGTH),
14
- Buffer.alloc(1),
15
- lengthBuf,
16
- Buffer.alloc(1),
17
- Buffer.from([1]),
18
- Buffer.alloc(1),
19
- Buffer.alloc(1),
20
- ]),
21
- );
22
- }
23
-
24
- /**
25
- * Make an encoded blob with the given length
26
- *
27
- * This will deserialise correctly in the archiver
28
- * @param length
29
- * @returns
30
- */
31
- export function makeEncodedBlob(length: number): Promise<Blob> {
32
- return Blob.fromFields([encodeFirstField(length + 1), ...Array.from({ length: length }, () => Fr.random())]);
33
- }
34
-
35
- /**
36
- * Make an unencoded blob with the given length
37
- *
38
- * This will fail deserialisation in the archiver
39
- * @param length
40
- * @returns
41
- */
42
- export function makeUnencodedBlob(length: number): Promise<Blob> {
43
- return Blob.fromFields([...Array.from({ length: length }, () => Fr.random())]);
44
- }
45
-
46
- export function makeEncodedBlobFields(fields: Fr[]): Promise<Blob> {
47
- return Blob.fromFields([encodeFirstField(fields.length + 1), ...fields]);
48
- }