From 841e4bbf9d161cc4a70b52841b64c4b361672813 Mon Sep 17 00:00:00 2001 From: acolytec3 <17355484+acolytec3@users.noreply.github.com> Date: Thu, 19 Sep 2024 15:08:25 -0400 Subject: [PATCH] fix types --- packages/verkle/test/proof.spec.ts | 34 ++++++++++++++---------------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/packages/verkle/test/proof.spec.ts b/packages/verkle/test/proof.spec.ts index e0ecc3b707..8d4eb70dac 100644 --- a/packages/verkle/test/proof.spec.ts +++ b/packages/verkle/test/proof.spec.ts @@ -1,11 +1,11 @@ -import { MapDB, concatBytes, hexToBytes } from '@ethereumjs/util' +import { MapDB, hexToBytes } from '@ethereumjs/util' import { loadVerkleCrypto } from 'verkle-cryptography-wasm' import { assert, beforeAll, describe, it } from 'vitest' import { createVerkleTree } from '../src/constructors.js' import type { LeafNode } from '../src/index.js' -import type { PrefixedHexString, VerkleCrypto } from '@ethereumjs/util' +import type { PrefixedHexString, ProverInput, VerifierInput, VerkleCrypto } from '@ethereumjs/util' describe('lets make proofs', () => { let verkleCrypto: VerkleCrypto @@ -43,29 +43,27 @@ describe('lets make proofs', () => { const path = await trie.findPath(keys[0].slice(0, 31)) const leafNode = path.node! as LeafNode - let valuesArray = new Uint8Array() + const valuesArray = [] for (let x = 0; x < 256; x++) { let value = leafNode.getValue(x) if (value === undefined) value = new Uint8Array(32) - valuesArray = concatBytes(valuesArray, value) + valuesArray.push(value) } - const proofInput = concatBytes( - verkleCrypto.serializeCommitment(leafNode.commitment), // serialized (not hashed!) node commitment - valuesArray, // All values from node concatenated - new Uint8Array(1).fill(1), // Position in values array (aka "z value") - leafNode.getValue(1)!, // Value at position (aka "y value") - ) - const proof = verkleCrypto.createProof(proofInput) + const proofInput: ProverInput = { + serializedCommitment: verkleCrypto.serializeCommitment(leafNode.commitment), // serialized (not hashed!) node commitment + vector: valuesArray, // All values from node + indices: [1], // Position in values array (aka "z value") + } + + const proof = verkleCrypto.createProof([proofInput]) - const verificationInput = concatBytes( - proof, // 576 byte proof - verkleCrypto.serializeCommitment(leafNode.commitment), // serialized leafNode commitment - new Uint8Array(1).fill(1), // Position in values array (aka "z value") - leafNode.getValue(1)!, // Value at position (aka "y value") - ) + const verificationInput: VerifierInput = { + serializedCommitment: verkleCrypto.serializeCommitment(leafNode.commitment), // serialized leafNode commitment + indexValuePairs: [{ index: 1, value: leafNode.getValue(1)! }], // Position in values array (aka "z value") + } try { - const res = verkleCrypto.verifyProof(verificationInput) + const res = verkleCrypto.verifyProof(proof, [verificationInput]) assert.ok(res) } catch (err) { assert.fail(`Failed to verify proof: ${err}`)