zkp-ecdsa
This is a TypeScript library for Zero-Knowledge proof for ECDSA.
It enables proving knowledge of a signature under one of many keys.
Specification
See branch paper of this repository.
Functional Spec.
Hello World
const keyPair = await crypto.subtle.generateKey(
{ name: 'ECDSA', namedCurve: 'P-256' },
true,
[ 'sign', 'verify']),
enc = new TextEncoder(),
msg = enc.encode('kilroy was here'),
msgHash = new Uint8Array(await crypto.subtle.digest('SHA-256', msg)),
signature = new Uint8Array(
await crypto.subtle.sign({ name: 'ECDSA', hash: 'SHA-256' }, keyPair.privateKey, msg)
),
{ system: params, accumulator: initAcc } = generateParams(),
{ j, acc, witness } = await addKeyToAccumulator(params, initAcc, keyPair.publicKey),
proof = await proveSignature(
params,
msgHash,
signature,
keyPair.publicKey,
j,
witness,
acc
),
res = await verifySignature(params, msgHash, acc, proof)
Building
$ npm ci
$ npm run build
Testing
$ npm ci
$ npm run build
$ npm run test
Future Work / Possible enhancements
- Accelerate verification in another language.
- Consider Groth-Kohlweisse proofs.
- Use private key so accumulator doesn't change and invalidate older witnesses.
Development Environment
Benchmark
$ npm ci
$ npm run bench
Flamegraph
$ npm ci
$ npm run flame
Webpack
This package compiles to ESModules (instead of CommonJS). More info about ESModules.
Requires to have webpack installed.
$ npm ci
$ npm run build
$ webpack --config webpack.config.cjs
Linter & Formatter
$ npm ci
$ npm run lint
$ npm run lint:fix
$ npm run format