hollowdb-prover
Version:
Zero-knowledge proof generator utiity for HollowDB
49 lines (47 loc) • 2.19 kB
TypeScript
/** A zero-knowledge prover utility to be used with HollowDB.
*
* You will need to provide paths to a WASM circuit, and a prover key.
* You can find these files [here](./circuits/) in the repository. it is up to you to decide where to place them for your application.
* For example, in a web-app you may place under the `public` directory.
*
* You can also choose to provide the protocol, which defaults to Groth16.
*/
export class Prover {
readonly protocol: 'groth16' | 'plonk';
constructor(wasmPath: string, proverKeyPath: string, protocol?: 'groth16' | 'plonk');
/** Generate a zero-knowledge proof.
*
* Calls {@link hashToGroup} on inputs, and then generates
* a proof with {@link proveHashed}.
*/
prove(preimage: bigint, curValue: unknown, nextValue: unknown): Promise<{
proof: object;
publicSignals: [curValueHash: string, nextValueHash: string, key: string];
}>;
/** Generate a zero-knowledge proof.
*
* Value inputs are expected to be results of {@link hashToGroup}. The
* incentive of using this function instead of {@link prove} is that the
* hash may be stored somewhere, and there is no need to hash the entire value
* again at a later time instead of using the existing hash.
*/
proveHashed(preimage: bigint, curValueHash: bigint, nextValueHash: bigint): Promise<{
proof: object;
publicSignals: [curValueHash: string, nextValueHash: string, key: string];
}>;
}
/** Given an input, stringifies and then hashes it and make sure the result is circuit-friendly for
* [BN254](https://docs.circom.io/background/background/#signals-of-a-circuit).
*
* Uses Ripemd160 for the hash where 160-bit output is guaranteed to be
* circuit-friendly (i.e. within the order of the curve's scalar field).
*
* If a given value is falsy, it will NOT be hashed but instead mapped to 0.
*/
export function hashToGroup(value: unknown): bigint;
/** Compute the key that is the Poseidon hash of some preimage.
*
* The returned key is a string in hexadecimal format with 0x prefix.
*/
export function computeKey(preimage: bigint): string;
//# sourceMappingURL=index.d.ts.map