|
1 | | -import { initializeBindings, withThreadPool } from '../../snarky.js'; |
| 1 | +import { |
| 2 | + areBindingsInitialized, |
| 3 | + initializeBindings, |
| 4 | + withThreadPool, |
| 5 | +} from '../../snarky.js'; |
2 | 6 | import { Pickles } from '../../snarky.js'; |
3 | 7 | import { Field, Bool } from '../provable/wrapped.js'; |
4 | 8 | import type { |
@@ -92,6 +96,15 @@ class ProofBase<Input = any, Output = any> { |
92 | 96 | publicFields() { |
93 | 97 | return (this.constructor as typeof ProofBase).publicFields(this); |
94 | 98 | } |
| 99 | + |
| 100 | + static _proofFromBase64(proofString: string, maxProofsVerified: 0 | 1 | 2) { |
| 101 | + assertBindingsInitialized(); |
| 102 | + return Pickles.proofOfBase64(proofString, maxProofsVerified)[1]; |
| 103 | + } |
| 104 | + static _proofToBase64(proof: Pickles.Proof, maxProofsVerified: 0 | 1 | 2) { |
| 105 | + assertBindingsInitialized(); |
| 106 | + return Pickles.proofToBase64([maxProofsVerified, proof]); |
| 107 | + } |
95 | 108 | } |
96 | 109 |
|
97 | 110 | class Proof<Input, Output> extends ProofBase<Input, Output> { |
@@ -428,3 +441,10 @@ function extractProofTypes(type: ProvableType) { |
428 | 441 | let proofValues = extractProofs(value); |
429 | 442 | return proofValues.map((proof) => proof.constructor as typeof ProofBase); |
430 | 443 | } |
| 444 | + |
| 445 | +function assertBindingsInitialized() { |
| 446 | + assert( |
| 447 | + areBindingsInitialized, |
| 448 | + 'Bindings are not initialized. Try calling `await initializeBindings()` first.' |
| 449 | + ); |
| 450 | +} |
0 commit comments