/ bindings / node.js / test / kzg.test.ts
kzg.test.ts
  1  import {randomBytes} from "crypto";
  2  import {readFileSync, existsSync} from "fs";
  3  import {resolve} from "path";
  4  import {globSync} from "glob";
  5  
  6  const yaml = require("js-yaml");
  7  
  8  interface TestMeta<I extends Record<string, any>, O extends boolean | string | string[] | Record<string, any>> {
  9    input: I;
 10    output: O;
 11  }
 12  
 13  import kzg from "../lib/kzg";
 14  import type {ProofResult} from "../lib/kzg";
 15  const {
 16    loadTrustedSetup,
 17    blobToKzgCommitment,
 18    computeKzgProof,
 19    computeBlobKzgProof,
 20    verifyKzgProof,
 21    verifyBlobKzgProof,
 22    verifyBlobKzgProofBatch,
 23    BYTES_PER_BLOB,
 24    BYTES_PER_COMMITMENT,
 25    BYTES_PER_PROOF,
 26    BYTES_PER_FIELD_ELEMENT,
 27  } = kzg;
 28  // not exported by types, only exported for testing purposes
 29  const getTrustedSetupFilepath = (kzg as any).getTrustedSetupFilepath as (filePath?: string) => string;
 30  const DEFAULT_TRUSTED_SETUP_PATH = (kzg as any).DEFAULT_TRUSTED_SETUP_PATH as string;
 31  
 32  const TEST_SETUP_FILE_PATH_JSON = resolve(__dirname, "__fixtures__", "trusted_setup.json");
 33  const TEST_SETUP_FILE_PATH_TXT = resolve(__dirname, "__fixtures__", "trusted_setup.txt");
 34  
 35  const MAX_TOP_BYTE = 114;
 36  
 37  const BLOB_TO_KZG_COMMITMENT_TESTS = "../../tests/blob_to_kzg_commitment/*/*/data.yaml";
 38  const COMPUTE_KZG_PROOF_TESTS = "../../tests/compute_kzg_proof/*/*/data.yaml";
 39  const COMPUTE_BLOB_KZG_PROOF_TESTS = "../../tests/compute_blob_kzg_proof/*/*/data.yaml";
 40  const VERIFY_KZG_PROOF_TESTS = "../../tests/verify_kzg_proof/*/*/data.yaml";
 41  const VERIFY_BLOB_KZG_PROOF_TESTS = "../../tests/verify_blob_kzg_proof/*/*/data.yaml";
 42  const VERIFY_BLOB_KZG_PROOF_BATCH_TESTS = "../../tests/verify_blob_kzg_proof_batch/*/*/data.yaml";
 43  
 44  type BlobToKzgCommitmentTest = TestMeta<{blob: string}, string>;
 45  type ComputeKzgProofTest = TestMeta<{blob: string; z: string}, string[]>;
 46  type ComputeBlobKzgProofTest = TestMeta<{blob: string; commitment: string}, string>;
 47  type VerifyKzgProofTest = TestMeta<{commitment: string; y: string; z: string; proof: string}, boolean>;
 48  type VerifyBlobKzgProofTest = TestMeta<{blob: string; commitment: string; proof: string}, boolean>;
 49  type VerifyBatchKzgProofTest = TestMeta<{blobs: string[]; commitments: string[]; proofs: string[]}, boolean>;
 50  
 51  const blobValidLength = randomBytes(BYTES_PER_BLOB);
 52  const blobBadLength = randomBytes(BYTES_PER_BLOB - 1);
 53  const commitmentValidLength = randomBytes(BYTES_PER_COMMITMENT);
 54  const commitmentBadLength = randomBytes(BYTES_PER_COMMITMENT - 1);
 55  const proofValidLength = randomBytes(BYTES_PER_PROOF);
 56  const proofBadLength = randomBytes(BYTES_PER_PROOF - 1);
 57  const fieldElementValidLength = randomBytes(BYTES_PER_FIELD_ELEMENT);
 58  const fieldElementBadLength = randomBytes(BYTES_PER_FIELD_ELEMENT - 1);
 59  
 60  /**
 61   * Generates a random blob of the correct length for the KZG library
 62   *
 63   * @return {Uint8Array}
 64   */
 65  function generateRandomBlob(): Uint8Array {
 66    return new Uint8Array(
 67      randomBytes(BYTES_PER_BLOB).map((x, i) => {
 68        // Set the top byte to be low enough that the field element doesn't overflow the BLS modulus
 69        if (x > MAX_TOP_BYTE && i % BYTES_PER_FIELD_ELEMENT == 0) {
 70          return Math.floor(Math.random() * MAX_TOP_BYTE);
 71        }
 72        return x;
 73      })
 74    );
 75  }
 76  
 77  /**
 78   * Converts hex string to binary Uint8Array
 79   *
 80   * @param {string} hexString Hex string to convert
 81   *
 82   * @return {Uint8Array}
 83   */
 84  function bytesFromHex(hexString: string): Uint8Array {
 85    if (hexString.startsWith("0x")) {
 86      hexString = hexString.slice(2);
 87    }
 88    return Uint8Array.from(Buffer.from(hexString, "hex"));
 89  }
 90  
 91  /**
 92   * Verifies that two Uint8Arrays are bitwise equivalent
 93   *
 94   * @param {Uint8Array} a
 95   * @param {Uint8Array} b
 96   *
 97   * @return {void}
 98   *
 99   * @throws {Error} If arrays are not equal length or byte values are unequal
100   */
101  function assertBytesEqual(a: Uint8Array | Buffer, b: Uint8Array | Buffer): void {
102    if (a.length !== b.length) {
103      throw new Error("unequal Uint8Array lengths");
104    }
105    for (let i = 0; i < a.length; i++) {
106      if (a[i] !== b[i]) throw new Error(`unequal Uint8Array byte at index ${i}`);
107    }
108  }
109  
110  /**
111   * Finds a valid test under a glob path to test files. Filters out tests with
112   * "invalid", "incorrect", or "different" in the file name.
113   *
114   * @param {string} testDir Glob path to test files
115   *
116   * @return {any} Test object with valid input and output. Must strongly type
117   *               results at calling location
118   *
119   * @throws {Error} If no valid test is found
120   */
121  function getValidTest(testDir: string): any {
122    const tests = globSync(testDir);
123    const validTest = tests.find(
124      (testFile: string) =>
125        !testFile.includes("invalid") && !testFile.includes("incorrect") && !testFile.includes("different")
126    );
127    if (!validTest) throw new Error("Could not find valid test");
128    return yaml.load(readFileSync(validTest, "ascii"));
129  }
130  
131  /**
132   * Runs a suite of tests for the passed function and arguments. Will test base
133   * case to ensure a valid set of arguments was passed with the function being
134   * tested.  Will then test the same function with an extra, invalid, argument
135   * at the end of the argument list to verify extra args are ignored. Checks
136   * validity of the extra argument case against the base case. Finally, will
137   * check that if an argument is removed that an error is thrown.
138   *
139   * @param {(...args: any[]) => any} fn Function to be tested
140   * @param {any[]} validArgs Valid arguments to be passed as base case to fn
141   *
142   * @return {void}
143   *
144   * @throws {Error} If no valid test is found
145   */
146  function testArgCount(fn: (...args: any[]) => any, validArgs: any[]): void {
147    const lessArgs = validArgs.slice(0, -1);
148    const moreArgs = validArgs.concat("UNKNOWN_ARGUMENT");
149  
150    it("should test for different argument lengths", () => {
151      expect(lessArgs.length).toBeLessThan(validArgs.length);
152      expect(moreArgs.length).toBeGreaterThan(validArgs.length);
153    });
154  
155    it("should run for expected argument count", () => {
156      expect(() => fn(...validArgs)).not.toThrowError();
157    });
158  
159    it("should ignore extra arguments", () => {
160      expect(() => fn(...moreArgs)).not.toThrowError();
161    });
162  
163    it("should give same result with extra args", () => {
164      expect(fn(...validArgs)).toEqual(fn(...moreArgs));
165    });
166  
167    it("should throw for less than expected argument count", () => {
168      expect(() => fn(...lessArgs)).toThrowError();
169    });
170  }
171  
172  describe("C-KZG", () => {
173    beforeAll(async () => {
174      loadTrustedSetup(TEST_SETUP_FILE_PATH_JSON);
175    });
176  
177    describe("locating trusted setup file", () => {
178      it("should return a txt path if a json file is provided and exists", () => {
179        expect(getTrustedSetupFilepath(TEST_SETUP_FILE_PATH_JSON)).toEqual(TEST_SETUP_FILE_PATH_TXT);
180      });
181      /**
182       * No guarantee that the test above runs first, however the json file should
183       * have already been loaded by the beforeAll so a valid .txt test setup
184       * should be available to expect
185       */
186      it("should return the same txt path if provided and exists", () => {
187        expect(getTrustedSetupFilepath(TEST_SETUP_FILE_PATH_TXT)).toEqual(TEST_SETUP_FILE_PATH_TXT);
188      });
189      describe("default setups", () => {
190        beforeAll(() => {
191          if (!existsSync(DEFAULT_TRUSTED_SETUP_PATH)) {
192            throw new Error("Default deps/c-kzg/trusted_setup.txt not found for testing");
193          }
194        });
195        it("should return default trusted_setup filepath", () => {
196          expect(getTrustedSetupFilepath()).toEqual(DEFAULT_TRUSTED_SETUP_PATH);
197        });
198      });
199    });
200  
201    describe("reference tests should pass", () => {
202      it("reference tests for blobToKzgCommitment should pass", () => {
203        const tests = globSync(BLOB_TO_KZG_COMMITMENT_TESTS);
204        expect(tests.length).toBeGreaterThan(0);
205  
206        tests.forEach((testFile: string) => {
207          const test: BlobToKzgCommitmentTest = yaml.load(readFileSync(testFile, "ascii"));
208  
209          let commitment: Uint8Array;
210          const blob = bytesFromHex(test.input.blob);
211  
212          try {
213            commitment = blobToKzgCommitment(blob);
214          } catch (err) {
215            expect(test.output).toBeNull();
216            return;
217          }
218  
219          expect(test.output).not.toBeNull();
220          const expectedCommitment = bytesFromHex(test.output);
221          expect(assertBytesEqual(commitment, expectedCommitment));
222        });
223      });
224  
225      it("reference tests for computeKzgProof should pass", () => {
226        const tests = globSync(COMPUTE_KZG_PROOF_TESTS);
227        expect(tests.length).toBeGreaterThan(0);
228  
229        tests.forEach((testFile: string) => {
230          const test: ComputeKzgProofTest = yaml.load(readFileSync(testFile, "ascii"));
231  
232          let proof: ProofResult;
233          const blob = bytesFromHex(test.input.blob);
234          const z = bytesFromHex(test.input.z);
235  
236          try {
237            proof = computeKzgProof(blob, z);
238          } catch (err) {
239            expect(test.output).toBeNull();
240            return;
241          }
242  
243          expect(test.output).not.toBeNull();
244  
245          const [proofBytes, yBytes] = proof;
246          const [expectedProofBytes, expectedYBytes] = test.output.map((out) => bytesFromHex(out));
247  
248          expect(assertBytesEqual(proofBytes, expectedProofBytes));
249          expect(assertBytesEqual(yBytes, expectedYBytes));
250        });
251      });
252  
253      it("reference tests for computeBlobKzgProof should pass", () => {
254        const tests = globSync(COMPUTE_BLOB_KZG_PROOF_TESTS);
255        expect(tests.length).toBeGreaterThan(0);
256  
257        tests.forEach((testFile: string) => {
258          const test: ComputeBlobKzgProofTest = yaml.load(readFileSync(testFile, "ascii"));
259  
260          let proof: Uint8Array;
261          const blob = bytesFromHex(test.input.blob);
262          const commitment = bytesFromHex(test.input.commitment);
263  
264          try {
265            proof = computeBlobKzgProof(blob, commitment);
266          } catch (err) {
267            expect(test.output).toBeNull();
268            return;
269          }
270  
271          expect(test.output).not.toBeNull();
272          const expectedProof = bytesFromHex(test.output);
273          expect(assertBytesEqual(proof, expectedProof));
274        });
275      });
276  
277      it("reference tests for verifyKzgProof should pass", () => {
278        const tests = globSync(VERIFY_KZG_PROOF_TESTS);
279        expect(tests.length).toBeGreaterThan(0);
280  
281        tests.forEach((testFile: string) => {
282          const test: VerifyKzgProofTest = yaml.load(readFileSync(testFile, "ascii"));
283  
284          let valid;
285          const commitment = bytesFromHex(test.input.commitment);
286          const z = bytesFromHex(test.input.z);
287          const y = bytesFromHex(test.input.y);
288          const proof = bytesFromHex(test.input.proof);
289  
290          try {
291            valid = verifyKzgProof(commitment, z, y, proof);
292          } catch (err) {
293            expect(test.output).toBeNull();
294            return;
295          }
296  
297          expect(valid).toEqual(test.output);
298        });
299      });
300  
301      it("reference tests for verifyBlobKzgProof should pass", () => {
302        const tests = globSync(VERIFY_BLOB_KZG_PROOF_TESTS);
303        expect(tests.length).toBeGreaterThan(0);
304  
305        tests.forEach((testFile: string) => {
306          const test: VerifyBlobKzgProofTest = yaml.load(readFileSync(testFile, "ascii"));
307  
308          let valid;
309          const blob = bytesFromHex(test.input.blob);
310          const commitment = bytesFromHex(test.input.commitment);
311          const proof = bytesFromHex(test.input.proof);
312  
313          try {
314            valid = verifyBlobKzgProof(blob, commitment, proof);
315          } catch (err) {
316            expect(test.output).toBeNull();
317            return;
318          }
319  
320          expect(valid).toEqual(test.output);
321        });
322      });
323  
324      it("reference tests for verifyBlobKzgProofBatch should pass", () => {
325        const tests = globSync(VERIFY_BLOB_KZG_PROOF_BATCH_TESTS);
326        expect(tests.length).toBeGreaterThan(0);
327  
328        tests.forEach((testFile: string) => {
329          const test: VerifyBatchKzgProofTest = yaml.load(readFileSync(testFile, "ascii"));
330  
331          let valid;
332          const blobs = test.input.blobs.map(bytesFromHex);
333          const commitments = test.input.commitments.map(bytesFromHex);
334          const proofs = test.input.proofs.map(bytesFromHex);
335  
336          try {
337            valid = verifyBlobKzgProofBatch(blobs, commitments, proofs);
338          } catch (err) {
339            expect(test.output).toBeNull();
340            return;
341          }
342  
343          expect(valid).toEqual(test.output);
344        });
345      });
346    });
347  
348    describe("edge cases for blobToKzgCommitment", () => {
349      describe("check argument count", () => {
350        const test: BlobToKzgCommitmentTest = getValidTest(BLOB_TO_KZG_COMMITMENT_TESTS);
351        const blob = bytesFromHex(test.input.blob);
352        testArgCount(blobToKzgCommitment, [blob]);
353      });
354  
355      it("throws as expected when given an argument of invalid type", () => {
356        // eslint-disable-next-line @typescript-eslint/ban-ts-comment
357        // @ts-expect-error
358        expect(() => blobToKzgCommitment("wrong type")).toThrowError("Expected blob to be a Uint8Array");
359      });
360  
361      it("throws as expected when given an argument of invalid length", () => {
362        expect(() => blobToKzgCommitment(blobBadLength)).toThrowError("Expected blob to be 131072 bytes");
363      });
364    });
365  
366    // TODO: add more tests for this function.
367    describe("edge cases for computeKzgProof", () => {
368      describe("check argument count", () => {
369        const test: ComputeKzgProofTest = getValidTest(COMPUTE_KZG_PROOF_TESTS);
370        const blob = bytesFromHex(test.input.blob);
371        const z = bytesFromHex(test.input.z);
372        testArgCount(computeKzgProof, [blob, z]);
373      });
374  
375      it("computes a proof from blob/field element", () => {
376        const blob = generateRandomBlob();
377        const zBytes = new Uint8Array(BYTES_PER_FIELD_ELEMENT).fill(0);
378        computeKzgProof(blob, zBytes);
379      });
380  
381      it("throws as expected when given an argument of invalid length", () => {
382        expect(() => computeKzgProof(blobBadLength, fieldElementValidLength)).toThrowError(
383          "Expected blob to be 131072 bytes"
384        );
385        expect(() => computeKzgProof(blobValidLength, fieldElementBadLength)).toThrowError(
386          "Expected zBytes to be 32 bytes"
387        );
388      });
389    });
390  
391    // TODO: add more tests for this function.
392    describe("edge cases for computeBlobKzgProof", () => {
393      describe("check argument count", () => {
394        const test: ComputeBlobKzgProofTest = getValidTest(COMPUTE_BLOB_KZG_PROOF_TESTS);
395        const blob = bytesFromHex(test.input.blob);
396        const commitment = bytesFromHex(test.input.commitment);
397        testArgCount(computeBlobKzgProof, [blob, commitment]);
398      });
399  
400      it("computes a proof from blob", () => {
401        const blob = generateRandomBlob();
402        const commitment = blobToKzgCommitment(blob);
403        computeBlobKzgProof(blob, commitment);
404      });
405  
406      it("throws as expected when given an argument of invalid length", () => {
407        expect(() => computeBlobKzgProof(blobBadLength, blobToKzgCommitment(generateRandomBlob()))).toThrowError(
408          "Expected blob to be 131072 bytes"
409        );
410      });
411    });
412  
413    describe("edge cases for verifyKzgProof", () => {
414      describe("check argument count", () => {
415        const test: VerifyKzgProofTest = getValidTest(VERIFY_KZG_PROOF_TESTS);
416        const commitment = bytesFromHex(test.input.commitment);
417        const z = bytesFromHex(test.input.z);
418        const y = bytesFromHex(test.input.y);
419        const proof = bytesFromHex(test.input.proof);
420        testArgCount(verifyKzgProof, [commitment, z, y, proof]);
421      });
422  
423      it("valid proof should result in true", () => {
424        const commitment = new Uint8Array(BYTES_PER_COMMITMENT).fill(0);
425        commitment[0] = 0xc0;
426        const z = new Uint8Array(BYTES_PER_FIELD_ELEMENT).fill(0);
427        const y = new Uint8Array(BYTES_PER_FIELD_ELEMENT).fill(0);
428        const proof = new Uint8Array(BYTES_PER_PROOF).fill(0);
429        proof[0] = 0xc0;
430        expect(verifyKzgProof(commitment, z, y, proof)).toBe(true);
431      });
432  
433      it("invalid proof should result in false", () => {
434        const commitment = new Uint8Array(BYTES_PER_COMMITMENT).fill(0);
435        commitment[0] = 0xc0;
436        const z = new Uint8Array(BYTES_PER_FIELD_ELEMENT).fill(1);
437        const y = new Uint8Array(BYTES_PER_FIELD_ELEMENT).fill(1);
438        const proof = new Uint8Array(BYTES_PER_PROOF).fill(0);
439        proof[0] = 0xc0;
440        expect(verifyKzgProof(commitment, z, y, proof)).toBe(false);
441      });
442  
443      it("throws as expected when given an argument of invalid length", () => {
444        expect(() =>
445          verifyKzgProof(commitmentBadLength, fieldElementValidLength, fieldElementValidLength, proofValidLength)
446        ).toThrowError("Expected commitmentBytes to be 48 bytes");
447        expect(() =>
448          verifyKzgProof(commitmentValidLength, fieldElementBadLength, fieldElementValidLength, proofValidLength)
449        ).toThrowError("Expected zBytes to be 32 bytes");
450        expect(() =>
451          verifyKzgProof(commitmentValidLength, fieldElementValidLength, fieldElementBadLength, proofValidLength)
452        ).toThrowError("Expected yBytes to be 32 bytes");
453        expect(() =>
454          verifyKzgProof(commitmentValidLength, fieldElementValidLength, fieldElementValidLength, proofBadLength)
455        ).toThrowError("Expected proofBytes to be 48 bytes");
456      });
457    });
458  
459    describe("edge cases for verifyBlobKzgProof", () => {
460      describe("check argument count", () => {
461        const test: VerifyBlobKzgProofTest = getValidTest(VERIFY_BLOB_KZG_PROOF_TESTS);
462        const blob = bytesFromHex(test.input.blob);
463        const commitment = bytesFromHex(test.input.commitment);
464        const proof = bytesFromHex(test.input.proof);
465        testArgCount(verifyBlobKzgProof, [blob, commitment, proof]);
466      });
467  
468      it("correct blob/commitment/proof should verify as true", () => {
469        const blob = generateRandomBlob();
470        const commitment = blobToKzgCommitment(blob);
471        const proof = computeBlobKzgProof(blob, commitment);
472        expect(verifyBlobKzgProof(blob, commitment, proof)).toBe(true);
473      });
474  
475      it("incorrect commitment should verify as false", () => {
476        const blob = generateRandomBlob();
477        const commitment = blobToKzgCommitment(generateRandomBlob());
478        const proof = computeBlobKzgProof(blob, commitment);
479        expect(verifyBlobKzgProof(blob, commitment, proof)).toBe(false);
480      });
481  
482      it("incorrect proof should verify as false", () => {
483        const blob = generateRandomBlob();
484        const commitment = blobToKzgCommitment(blob);
485        const randomBlob = generateRandomBlob();
486        const randomCommitment = blobToKzgCommitment(randomBlob);
487        const proof = computeBlobKzgProof(randomBlob, randomCommitment);
488        expect(verifyBlobKzgProof(blob, commitment, proof)).toBe(false);
489      });
490  
491      it("throws as expected when given an argument of invalid length", () => {
492        expect(() => verifyBlobKzgProof(blobBadLength, commitmentValidLength, proofValidLength)).toThrowError(
493          "Expected blob to be 131072 bytes"
494        );
495        expect(() => verifyBlobKzgProof(blobValidLength, commitmentBadLength, proofValidLength)).toThrowError(
496          "Expected commitmentBytes to be 48 bytes"
497        );
498        expect(() => verifyBlobKzgProof(blobValidLength, commitmentValidLength, proofBadLength)).toThrowError(
499          "Expected proofBytes to be 48 bytes"
500        );
501      });
502    });
503  
504    describe("edge cases for verifyBlobKzgProofBatch", () => {
505      describe("check argument count", () => {
506        const test: VerifyBatchKzgProofTest = getValidTest(VERIFY_BLOB_KZG_PROOF_BATCH_TESTS);
507        const blobs = test.input.blobs.map(bytesFromHex);
508        const commitments = test.input.commitments.map(bytesFromHex);
509        const proofs = test.input.proofs.map(bytesFromHex);
510        testArgCount(verifyBlobKzgProofBatch, [blobs, commitments, proofs]);
511      });
512  
513      it("should reject non-array args", () => {
514        expect(() =>
515          verifyBlobKzgProofBatch(
516            2 as unknown as Uint8Array[],
517            [commitmentValidLength, commitmentValidLength],
518            [proofValidLength, proofValidLength]
519          )
520        ).toThrowError("Blobs, commitments, and proofs must all be arrays");
521      });
522  
523      it("should reject non-bytearray blob", () => {
524        expect(() =>
525          verifyBlobKzgProofBatch(
526            ["foo", "bar"] as unknown as Uint8Array[],
527            [commitmentValidLength, commitmentValidLength],
528            [proofValidLength, proofValidLength]
529          )
530        ).toThrowError("Expected blob to be a Uint8Array");
531      });
532  
533      it("throws as expected when given an argument of invalid length", () => {
534        expect(() =>
535          verifyBlobKzgProofBatch(
536            [blobBadLength, blobValidLength],
537            [commitmentValidLength, commitmentValidLength],
538            [proofValidLength, proofValidLength]
539          )
540        ).toThrowError("Expected blob to be 131072 bytes");
541        expect(() =>
542          verifyBlobKzgProofBatch(
543            [blobValidLength, blobValidLength],
544            [commitmentBadLength, commitmentValidLength],
545            [proofValidLength, proofValidLength]
546          )
547        ).toThrowError("Expected commitmentBytes to be 48 bytes");
548        expect(() =>
549          verifyBlobKzgProofBatch(
550            [blobValidLength, blobValidLength],
551            [commitmentValidLength, commitmentValidLength],
552            [proofValidLength, proofBadLength]
553          )
554        ).toThrowError("Expected proofBytes to be 48 bytes");
555      });
556  
557      it("zero blobs/commitments/proofs should verify as true", () => {
558        expect(verifyBlobKzgProofBatch([], [], [])).toBe(true);
559      });
560  
561      it("mismatching blobs/commitments/proofs should throw error", () => {
562        const count = 3;
563        const blobs = new Array(count);
564        const commitments = new Array(count);
565        const proofs = new Array(count);
566        for (const [i] of blobs.entries()) {
567          blobs[i] = generateRandomBlob();
568          commitments[i] = blobToKzgCommitment(blobs[i]);
569          proofs[i] = computeBlobKzgProof(blobs[i], commitments[i]);
570        }
571        expect(verifyBlobKzgProofBatch(blobs, commitments, proofs)).toBe(true);
572        expect(() => verifyBlobKzgProofBatch(blobs.slice(0, 1), commitments, proofs)).toThrowError(
573          "Requires equal number of blobs/commitments/proofs"
574        );
575        expect(() => verifyBlobKzgProofBatch(blobs, commitments.slice(0, 1), proofs)).toThrowError(
576          "Requires equal number of blobs/commitments/proofs"
577        );
578        expect(() => verifyBlobKzgProofBatch(blobs, commitments, proofs.slice(0, 1))).toThrowError(
579          "Requires equal number of blobs/commitments/proofs"
580        );
581      });
582    });
583  });