ZkFunction
ZkFunction: <Config>(config: Config & {
main: MainType<Get<Config, "publicInputType">>;
}) => {
analyzeMethod: Omit<ConstraintSystemSummary, "digest">;
compile: Promise<{
verificationKey: KimchiVerificationKey;
}>;
prove: Promise<KimchiProof>;
verify: Promise<boolean>;
} = ZkFunction_;
Defined in: index.ts:184
Type Parameters
Config
Config extends ZkFunctionConfig
Parameters
config
Config & {
main: MainType<Get<Config, "publicInputType">>;
}
Returns
analyzeMethod()
analyzeMethod(): Omit<ConstraintSystemSummary, "digest">;
Returns a low-level JSON representation of the constraint system (gates)
Returns
Omit<ConstraintSystemSummary, "digest">
Throws
If compile() has not been called yet.
Example
await zkf.compile();
const cs = zkf.analyzeMethod();
console.log(cs);
compile()
compile(): Promise<{
verificationKey: KimchiVerificationKey;
}>;
Generates and stores a proving key and a verification key for this circuit(ZkFunction).
Returns
Promise<{
verificationKey: KimchiVerificationKey;
}>
The generated verification key.
Example
const { verificationKey } = await zkf.compile();
Warning
Must be called before prove or analyzeMethod.
prove()
prove(...args: Parameters<ProveMethodType<Config>>): Promise<KimchiProof>;
Proves a statement using the public input and private inputs of the circuit(ZkFunction).
Parameters
args
...Parameters<ProveMethodType<Config>>
Returns
Promise<KimchiProof>
The generated proof.
Throws
If compile has not been called.
Example
const { verificationKey } = await zkf.compile();
const proof = await zkf.prove(publicInput, privateInput1, privateInput2);
verify()
verify(proof: KimchiProof, verificationKey: KimchiVerificationKey): Promise<boolean>;
Verifies a proof using the verification key of the circuit(ZkFunction).
Parameters
proof
KimchiProof
The proof to verify.
verificationKey
KimchiVerificationKey
The key to verify against.
Returns
Promise<boolean>
true if the proof is valid, otherwise false.
Example
const { verificationKey } = await zkf.compile();
const proof = await zkf.prove(publicInput, privateInput1, privateInput2);
const isValid = await zkf.verify(proof, verificationKey);