From a640d11cc648e48746301aedba6733775b827817 Mon Sep 17 00:00:00 2001 From: acolytec3 <17355484+acolytec3@users.noreply.github.com> Date: Thu, 12 Sep 2024 13:08:27 -0400 Subject: [PATCH 1/6] Add commit to scalars to public API --- src.ts/index.ts | 3 +++ src.ts/verkleFFIBindings/index.ts | 2 ++ src.ts/verkleFFIBindings/verkleFFI.ts | 17 +++++++++++------ 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src.ts/index.ts b/src.ts/index.ts index 55f17fd..92ac8bf 100644 --- a/src.ts/index.ts +++ b/src.ts/index.ts @@ -7,6 +7,7 @@ import { verifyExecutionWitnessPreState as verifyExecutionWitnessPreStateBase, createProof as createProofBase, verifyProof as verifyProofBase, + commitToScalars as commitToScalarsBase, type ProverInput as ProverInputBase, type VerifierInput as VerifierInputBase, } from './verkleFFIBindings/index.js' @@ -43,7 +44,9 @@ export const loadVerkleCrypto = async () => { const createProof = (proverInputs: ProverInput[]) => createProofBase(verkleFFI, proverInputs) const verifyProof = (proof: Uint8Array, verifierInputs: VerifierInput[]) => verifyProofBase(verkleFFI, proof, verifierInputs) + const commitToScalars = (vector: Uint8Array[]) => commitToScalarsBase(verkleFFI, vector) return { + commitToScalars, getTreeKey, getTreeKeyHash, updateCommitment, diff --git a/src.ts/verkleFFIBindings/index.ts b/src.ts/verkleFFIBindings/index.ts index 549b18a..8e41b03 100644 --- a/src.ts/verkleFFIBindings/index.ts +++ b/src.ts/verkleFFIBindings/index.ts @@ -5,6 +5,7 @@ import { } from '../wasm/rust_verkle_wasm.js' import { + commitToScalars, getTreeKey, getTreeKeyHash, updateCommitment, @@ -15,6 +16,7 @@ import { } from './verkleFFI.js' export { + commitToScalars, initVerkleWasm, getTreeKey, getTreeKeyHash, diff --git a/src.ts/verkleFFIBindings/verkleFFI.ts b/src.ts/verkleFFIBindings/verkleFFI.ts index 41048b3..bc86589 100644 --- a/src.ts/verkleFFIBindings/verkleFFI.ts +++ b/src.ts/verkleFFIBindings/verkleFFI.ts @@ -136,12 +136,7 @@ export interface ProverInput { // The vector that we want to make proofs over vector: Uint8Array[] // The indices that we want to prove exist in the vector - indices: number[] -} - -function serializedProverInputs(proofInputs: ProverInput[]): Uint8Array { - const serializedProverInputs = proofInputs.flatMap(({ serializedCommitment, vector, indices }) => - indices.flatMap((index) => [ + inindices.flatMap((index) => [ serializedCommitment, ...vector, new Uint8Array([index]), @@ -178,3 +173,13 @@ function serializeVerifierInputs(proof: Uint8Array, verifierInputs: VerifierInpu return concatBytes(...serializedVerifierInputs) } + +/** + * + * @param verkleFFI The interface to the WASM verkle crypto object + * @param vector an array of Uint8Arrays to be committed to (must be 32 bytes each) + * @returns a 64 byte {@link Uint8Array} uncompressed commitment to the {@link vector} of values + */ +export const commitToScalars = (verkleFFI: VerkleFFI, vector: Uint8Array[]) => { + return verkleFFI.commitToScalars(vector) +} \ No newline at end of file From 99d69f621d263fa6298a319e000895e63d73f225 Mon Sep 17 00:00:00 2001 From: acolytec3 <17355484+acolytec3@users.noreply.github.com> Date: Thu, 12 Sep 2024 13:09:28 -0400 Subject: [PATCH 2/6] version bump --- .vscode/settings.json | 3 ++- package.json | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index cefe785..91b8f60 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -3,6 +3,7 @@ "source.fixAll.eslint": "explicit" }, "eslint.format.enable": true, - "eslint.workingDirectories": [{ "pattern": "./*" }] + "eslint.workingDirectories": [{ "pattern": "./*" }], + "rust-analyzer.procMacro.enable": true } \ No newline at end of file diff --git a/package.json b/package.json index c66df65..6b49c32 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "verkle-cryptography-wasm", - "version": "0.4.6", + "version": "0.4.7", "description": "Verkle Trie Crytography WASM/TypeScript Bindings", "keywords": [ "ethereum", From 884475db62cf91fdfe4b4a2f50cbb83136506036 Mon Sep 17 00:00:00 2001 From: acolytec3 <17355484+acolytec3@users.noreply.github.com> Date: Thu, 12 Sep 2024 13:09:46 -0400 Subject: [PATCH 3/6] changelog update --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e03562c..4a9a083 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) (modification: no type change headlines) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## 0.4.7 - 2024-09-12 + +- Expose `commitToScalars` in public API. #[57](https://github.com/ethereumjs/verkle-cryptography-wasm/pull/57) + ## 0.4.6 - 2024-09-08 - Expose `createProof` and `verifyProof` from verkle_ffi. #[56](https://github.com/ethereumjs/verkle-cryptography-wasm/pull/56) From da7f619fef304865dd84f8b9a6b06b50461fe12d Mon Sep 17 00:00:00 2001 From: acolytec3 <17355484+acolytec3@users.noreply.github.com> Date: Thu, 12 Sep 2024 13:12:14 -0400 Subject: [PATCH 4/6] right version bump --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 315e4ff..5c60b8f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "verkle-cryptography-wasm", - "version": "0.4.7", + "version": "0.4.8", "description": "Verkle Trie Crytography WASM/TypeScript Bindings", "keywords": [ "ethereum", From 803fb098879ec9143cbafc9356851ec62d4c7ad0 Mon Sep 17 00:00:00 2001 From: acolytec3 <17355484+acolytec3@users.noreply.github.com> Date: Thu, 12 Sep 2024 13:13:30 -0400 Subject: [PATCH 5/6] fix typos --- package-lock.json | 4 ++-- src.ts/verkleFFIBindings/verkleFFI.ts | 10 +--------- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/package-lock.json b/package-lock.json index fc2ff8b..550a4e1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "verkle-cryptography-wasm", - "version": "0.4.7", + "version": "0.4.8", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "verkle-cryptography-wasm", - "version": "0.4.7", + "version": "0.4.8", "license": "MIT/Apache", "dependencies": { "@scure/base": "^1.1.5" diff --git a/src.ts/verkleFFIBindings/verkleFFI.ts b/src.ts/verkleFFIBindings/verkleFFI.ts index bc86589..80f99a3 100644 --- a/src.ts/verkleFFIBindings/verkleFFI.ts +++ b/src.ts/verkleFFIBindings/verkleFFI.ts @@ -136,15 +136,7 @@ export interface ProverInput { // The vector that we want to make proofs over vector: Uint8Array[] // The indices that we want to prove exist in the vector - inindices.flatMap((index) => [ - serializedCommitment, - ...vector, - new Uint8Array([index]), - vector[index], - ]), - ) - - return concatBytes(...serializedProverInputs) + indices: number[] } export interface VerifierInput { From 76977c29faa402dd0541bdcb3c57a86d7670eb24 Mon Sep 17 00:00:00 2001 From: acolytec3 <17355484+acolytec3@users.noreply.github.com> Date: Thu, 12 Sep 2024 13:16:15 -0400 Subject: [PATCH 6/6] revert typo --- src.ts/verkleFFIBindings/verkleFFI.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src.ts/verkleFFIBindings/verkleFFI.ts b/src.ts/verkleFFIBindings/verkleFFI.ts index 80f99a3..daf6431 100644 --- a/src.ts/verkleFFIBindings/verkleFFI.ts +++ b/src.ts/verkleFFIBindings/verkleFFI.ts @@ -139,6 +139,19 @@ export interface ProverInput { indices: number[] } +function serializedProverInputs(proofInputs: ProverInput[]): Uint8Array { + const serializedProverInputs = proofInputs.flatMap(({ serializedCommitment, vector, indices }) => + indices.flatMap((index) => [ + serializedCommitment, + ...vector, + new Uint8Array([index]), + vector[index], + ]), + ) + + return concatBytes(...serializedProverInputs) +} + export interface VerifierInput { // A commitment to the vector that we want to verify // proofs over.