Skip to content

Commit a640d11

Browse files
committed
Add commit to scalars to public API
1 parent 43a3b76 commit a640d11

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

src.ts/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
verifyExecutionWitnessPreState as verifyExecutionWitnessPreStateBase,
88
createProof as createProofBase,
99
verifyProof as verifyProofBase,
10+
commitToScalars as commitToScalarsBase,
1011
type ProverInput as ProverInputBase,
1112
type VerifierInput as VerifierInputBase,
1213
} from './verkleFFIBindings/index.js'
@@ -43,7 +44,9 @@ export const loadVerkleCrypto = async () => {
4344
const createProof = (proverInputs: ProverInput[]) => createProofBase(verkleFFI, proverInputs)
4445
const verifyProof = (proof: Uint8Array, verifierInputs: VerifierInput[]) =>
4546
verifyProofBase(verkleFFI, proof, verifierInputs)
47+
const commitToScalars = (vector: Uint8Array[]) => commitToScalarsBase(verkleFFI, vector)
4648
return {
49+
commitToScalars,
4750
getTreeKey,
4851
getTreeKeyHash,
4952
updateCommitment,

src.ts/verkleFFIBindings/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
} from '../wasm/rust_verkle_wasm.js'
66

77
import {
8+
commitToScalars,
89
getTreeKey,
910
getTreeKeyHash,
1011
updateCommitment,
@@ -15,6 +16,7 @@ import {
1516
} from './verkleFFI.js'
1617

1718
export {
19+
commitToScalars,
1820
initVerkleWasm,
1921
getTreeKey,
2022
getTreeKeyHash,

src.ts/verkleFFIBindings/verkleFFI.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,12 +136,7 @@ export interface ProverInput {
136136
// The vector that we want to make proofs over
137137
vector: Uint8Array[]
138138
// The indices that we want to prove exist in the vector
139-
indices: number[]
140-
}
141-
142-
function serializedProverInputs(proofInputs: ProverInput[]): Uint8Array {
143-
const serializedProverInputs = proofInputs.flatMap(({ serializedCommitment, vector, indices }) =>
144-
indices.flatMap((index) => [
139+
inindices.flatMap((index) => [
145140
serializedCommitment,
146141
...vector,
147142
new Uint8Array([index]),
@@ -178,3 +173,13 @@ function serializeVerifierInputs(proof: Uint8Array, verifierInputs: VerifierInpu
178173

179174
return concatBytes(...serializedVerifierInputs)
180175
}
176+
177+
/**
178+
*
179+
* @param verkleFFI The interface to the WASM verkle crypto object
180+
* @param vector an array of Uint8Arrays to be committed to (must be 32 bytes each)
181+
* @returns a 64 byte {@link Uint8Array} uncompressed commitment to the {@link vector} of values
182+
*/
183+
export const commitToScalars = (verkleFFI: VerkleFFI, vector: Uint8Array[]) => {
184+
return verkleFFI.commitToScalars(vector)
185+
}

0 commit comments

Comments
 (0)