Skip to content

Commit 75ce1ca

Browse files
authored
Pin vitest deps (#3688)
* update interface * update verkle crypto dep * fix types
1 parent 4aa4cef commit 75ce1ca

File tree

7 files changed

+852
-431
lines changed

7 files changed

+852
-431
lines changed

package-lock.json

Lines changed: 818 additions & 405 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434
"@types/tape": "4.13.2",
3535
"@typescript-eslint/eslint-plugin": "5.33.1",
3636
"@typescript-eslint/parser": "5.33.1",
37-
"@vitest/coverage-v8": "^2.1.0",
38-
"@vitest/ui": "^2.1.0",
37+
"@vitest/coverage-v8": "2.1.0",
38+
"@vitest/ui": "2.1.0",
3939
"c8": "7.12.0",
4040
"cspell": "^8.13.3",
4141
"embedme": "1.22.1",
@@ -62,7 +62,7 @@
6262
"vite-plugin-node-polyfills": "^0.21.0",
6363
"vite-plugin-top-level-await": "^1.4.1",
6464
"vite-plugin-wasm": "^3.3.0",
65-
"vitest": "^2.1.0"
65+
"vitest": "2.1.0"
6666
},
6767
"optionalDependencies": {
6868
"@rollup/rollup-linux-x64-gnu": "*"

packages/client/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
"memory-level": "^1.0.0",
9090
"prom-client": "^15.1.0",
9191
"rustbn-wasm": "^0.4.0",
92-
"verkle-cryptography-wasm": "^0.4.6",
92+
"verkle-cryptography-wasm": "^0.4.8",
9393
"winston": "^3.3.3",
9494
"winston-daily-rotate-file": "^4.5.5",
9595
"yargs": "^17.7.1"

packages/statemanager/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,6 @@
6565
"@ethereumjs/genesis": "^0.2.3",
6666
"@types/debug": "^4.1.9",
6767
"rustbn-wasm": "^0.4.0",
68-
"verkle-cryptography-wasm": "^0.4.6"
68+
"verkle-cryptography-wasm": "^0.4.8"
6969
}
7070
}

packages/util/src/verkle.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,20 @@ export interface VerkleCrypto {
3434
verifyExecutionWitnessPreState: (prestateRoot: string, execution_witness_json: string) => boolean
3535
hashCommitment: (commitment: Uint8Array) => Uint8Array
3636
serializeCommitment: (commitment: Uint8Array) => Uint8Array
37-
createProof: (bytes: Uint8Array) => Uint8Array
38-
verifyProof: (proof: Uint8Array) => boolean
37+
createProof: (bytes: ProverInput[]) => Uint8Array
38+
verifyProof: (proof: Uint8Array, verifierInput: VerifierInput[]) => boolean
3939
}
4040

41+
export interface ProverInput {
42+
serializedCommitment: Uint8Array // serialized node commitment we want a proof from i.e. verkleCrypto.serializeCommitment(commitment)
43+
vector: Uint8Array[] // Array of 256 children/values
44+
indices: number[] // Indices from the valuesArray we are proving existence of
45+
}
46+
47+
export interface VerifierInput {
48+
serializedCommitment: Uint8Array // serialized node commitment we want a proof from i.e. verkleCrypto.serializeCommitment(commitment)
49+
indexValuePairs: Array<{ index: number; value: Uint8Array }> // array of tuples of indices and values from node's children array being verified by proof
50+
}
4151
/**
4252
* @dev Returns the 31-bytes verkle tree stem for a given address and tree index.
4353
* @dev Assumes that the verkle node width = 256

packages/verkle/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
"dependencies": {
5656
"debug": "^4.3.4",
5757
"lru-cache": "10.1.0",
58-
"verkle-cryptography-wasm": "^0.4.6",
58+
"verkle-cryptography-wasm": "^0.4.8",
5959
"@ethereumjs/block": "^5.3.0",
6060
"@ethereumjs/rlp": "^5.0.2",
6161
"@ethereumjs/util": "^9.1.0"

packages/verkle/test/proof.spec.ts

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { MapDB, concatBytes, hexToBytes } from '@ethereumjs/util'
1+
import { MapDB, hexToBytes } from '@ethereumjs/util'
22
import { loadVerkleCrypto } from 'verkle-cryptography-wasm'
33
import { assert, beforeAll, describe, it } from 'vitest'
44

55
import { createVerkleTree } from '../src/constructors.js'
66

77
import type { LeafNode } from '../src/index.js'
8-
import type { PrefixedHexString, VerkleCrypto } from '@ethereumjs/util'
8+
import type { PrefixedHexString, ProverInput, VerifierInput, VerkleCrypto } from '@ethereumjs/util'
99

1010
describe('lets make proofs', () => {
1111
let verkleCrypto: VerkleCrypto
@@ -43,29 +43,27 @@ describe('lets make proofs', () => {
4343
const path = await trie.findPath(keys[0].slice(0, 31))
4444

4545
const leafNode = path.node! as LeafNode
46-
let valuesArray = new Uint8Array()
46+
const valuesArray = []
4747
for (let x = 0; x < 256; x++) {
4848
let value = leafNode.getValue(x)
4949
if (value === undefined) value = new Uint8Array(32)
50-
valuesArray = concatBytes(valuesArray, value)
50+
valuesArray.push(value)
5151
}
52-
const proofInput = concatBytes(
53-
verkleCrypto.serializeCommitment(leafNode.commitment), // serialized (not hashed!) node commitment
54-
valuesArray, // All values from node concatenated
55-
new Uint8Array(1).fill(1), // Position in values array (aka "z value")
56-
leafNode.getValue(1)!, // Value at position (aka "y value")
57-
)
58-
const proof = verkleCrypto.createProof(proofInput)
52+
const proofInput: ProverInput = {
53+
serializedCommitment: verkleCrypto.serializeCommitment(leafNode.commitment), // serialized (not hashed!) node commitment
54+
vector: valuesArray, // All values from node
55+
indices: [1], // Position in values array (aka "z value")
56+
}
57+
58+
const proof = verkleCrypto.createProof([proofInput])
5959

60-
const verificationInput = concatBytes(
61-
proof, // 576 byte proof
62-
verkleCrypto.serializeCommitment(leafNode.commitment), // serialized leafNode commitment
63-
new Uint8Array(1).fill(1), // Position in values array (aka "z value")
64-
leafNode.getValue(1)!, // Value at position (aka "y value")
65-
)
60+
const verificationInput: VerifierInput = {
61+
serializedCommitment: verkleCrypto.serializeCommitment(leafNode.commitment), // serialized leafNode commitment
62+
indexValuePairs: [{ index: 1, value: leafNode.getValue(1)! }], // Position in values array (aka "z value")
63+
}
6664

6765
try {
68-
const res = verkleCrypto.verifyProof(verificationInput)
66+
const res = verkleCrypto.verifyProof(proof, [verificationInput])
6967
assert.ok(res)
7068
} catch (err) {
7169
assert.fail(`Failed to verify proof: ${err}`)

0 commit comments

Comments
 (0)