Skip to content

Commit 57d2ce9

Browse files
committed
PR comments
1 parent fc4e8fa commit 57d2ce9

File tree

3 files changed

+28
-12
lines changed

3 files changed

+28
-12
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
1919

2020
### Added
2121
- `setFee` and `setFeePerSnarkCost` for `Transaction` and `PendingTransaction` https://github.com/o1-labs/o1js/pull/1968
22-
- Doc comments for ZkProgram, verify, SelfProof...https://github.com/o1-labs/o1js/pull/1974
22+
- Doc comments for various ZkProgram methods https://github.com/o1-labs/o1js/pull/1974
2323

2424
### Changed
2525
- Sort order for actions now includes the transaction sequence number and the exact account id sequence https://github.com/o1-labs/o1js/pull/1917

src/lib/proof-system/zkprogram.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { EmptyUndefined, EmptyVoid } from '../../bindings/lib/generic.js';
22
import {
33
Base64ProofString,
4+
Base64VerificationKeyString,
45
Snarky,
56
initializeBindings,
67
withThreadPool,
@@ -124,15 +125,15 @@ function createProgramState() {
124125
}
125126

126127
/**
127-
* Initializes {@link Pickles} bindings, serializes the input proof and VK for use in Ocaml, then calls into {@link Pickles.verify} to verify the proof.
128+
* Initializes Pickles bindings, serializes the input proof and verification key for use in OCaml, then calls into the Pickles verify function and returns the result.
128129
*
129-
* @param proof Either a Proof instance or a JSON proof which gets converted into an {@link MlPair} of {@link FieldConst} arrays for use in the bindings.
130-
* @param verificationKey Either a string containing a base64 serialized verification key or a VerificationKey which gets converted into a string for use in the bindings.
130+
* @param proof Either a `Proof` instance or a serialized JSON proof
131+
* @param verificationKey Either a base64 serialized verification key or a `VerificationKey` instance which will be base64 serialized for use in the bindings.
131132
* @returns A promise that resolves to a boolean indicating whether the proof is valid.
132133
*/
133134
async function verify(
134135
proof: ProofBase<any, any> | JsonProof,
135-
verificationKey: string | VerificationKey
136+
verificationKey: Base64VerificationKeyString | VerificationKey
136137
) {
137138
await initializeBindings();
138139
let picklesProof: Pickles.Proof;
@@ -171,9 +172,9 @@ async function verify(
171172
* Serializeable representation of a Pickles proof, useful for caching compiled proofs.
172173
*/
173174
type JsonProof = {
174-
/** Array of string, where each string is a {@link Field} in the publicInput of this proof */
175+
/** Array of string, where each string is a `Field` in the publicInput of this proof */
175176
publicInput: string[];
176-
/** Array of string, where each string is a {@link Field} in the publicOutput of this proof */
177+
/** Array of string, where each string is a `Field` in the publicOutput of this proof */
177178
publicOutput: string[];
178179
maxProofsVerified: 0 | 1 | 2;
179180
proof: Base64ProofString;

src/snarky.d.ts

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,21 @@ export {
4949
MlFeatureFlags,
5050
areBindingsInitialized,
5151
Base64ProofString,
52+
Base64VerificationKeyString,
5253
};
5354

5455
declare let areBindingsInitialized: boolean;
5556

5657
/**
57-
* A string representation of a {@link Pickles.Proof} in base64 encoding, used for communication between Ocaml and TypeScript and for JSON serialization.
58+
* A string representation of a Pickles proof in base64 encoding, used for communication between OCaml and TypeScript and for JSON serialization.
5859
*/
5960
type Base64ProofString = string;
6061

62+
/**
63+
* A string representation of a constraint system's verification key in base64 encoding, used for communication between OCaml and TypeScript and for JSON serialization.
64+
*/
65+
type Base64VerificationKeyString = string;
66+
6167
type WasmModule = typeof wasm;
6268

6369
type MlGroup = MlPair<FieldVar, FieldVar>;
@@ -706,13 +712,15 @@ declare const Pickles: {
706712
/**
707713
* @returns (base64 vk, hash)
708714
*/
709-
getVerificationKey: () => Promise<[_: 0, data: string, hash: FieldConst]>;
715+
getVerificationKey: () => Promise<
716+
[_: 0, data: Base64VerificationKeyString, hash: FieldConst]
717+
>;
710718
};
711719

712720
verify(
713721
statement: Pickles.Statement<FieldConst>,
714722
proof: Pickles.Proof,
715-
verificationKey: string
723+
verificationKey: Base64VerificationKeyString
716724
): Promise<boolean>;
717725

718726
loadSrsFp(): WasmFpSrs;
@@ -726,7 +734,11 @@ declare const Pickles: {
726734
/**
727735
* @returns (base64 vk, hash)
728736
*/
729-
dummyVerificationKey: () => [_: 0, data: string, hash: FieldConst];
737+
dummyVerificationKey: () => [
738+
_: 0,
739+
data: Base64VerificationKeyString,
740+
hash: FieldConst
741+
];
730742

731743
encodeVerificationKey: (vk: MlWrapVerificationKey) => string;
732744
decodeVerificationKey: (vk: string) => MlWrapVerificationKey;
@@ -751,7 +763,10 @@ declare const Pickles: {
751763
// Instantiate the verification key inside the circuit (required).
752764
inCircuit: (tag: unknown, verificationKey: unknown) => undefined;
753765
// Instantiate the verification key in prover-only logic (also required).
754-
inProver: (tag: unknown, verificationKey: string) => undefined;
766+
inProver: (
767+
tag: unknown,
768+
verificationKey: Base64VerificationKeyString
769+
) => undefined;
755770
// Create an in-circuit representation of a verification key
756771
vkToCircuit: (
757772
verificationKey: () => string

0 commit comments

Comments
 (0)