forked from o1-labs/o1js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request o1-labs#1847 from o1-labs/feature/provable-proofs-2
Proof as Provable
- Loading branch information
Showing
6 changed files
with
285 additions
and
226 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { expect } from 'expect'; | ||
import { Provable } from '../provable/provable.js'; | ||
import { Field } from '../provable/wrapped.js'; | ||
import { Proof } from './proof.js'; | ||
import { Void } from './zkprogram.js'; | ||
import test from 'node:test'; | ||
|
||
test('Proof provable', async () => { | ||
class MyProof extends Proof<Field, Void> { | ||
static publicInputType = Field; | ||
static publicOutputType = Void; | ||
} | ||
|
||
expect(MyProof.provable.sizeInFields()).toEqual(1); | ||
|
||
let proof = await MyProof.dummy(Field(1n), undefined, 0); | ||
|
||
expect(MyProof.provable.toFields(proof)).toEqual([Field(1n)]); | ||
expect(MyProof.provable.toAuxiliary(proof)).toEqual([ | ||
[], | ||
[], | ||
[proof.proof, 0], | ||
]); | ||
|
||
async function circuit() { | ||
let publicInput = Provable.witness(Field, () => 5n); | ||
|
||
let proof = await Provable.witnessAsync(MyProof, () => { | ||
return MyProof.dummy(publicInput, undefined, 0); | ||
}); | ||
|
||
expect(proof).toBeInstanceOf(MyProof); | ||
expect(proof.publicOutput).toBeUndefined(); | ||
expect(proof.maxProofsVerified).toEqual(0); | ||
|
||
Provable.asProver(() => { | ||
expect(proof.publicInput.toBigInt()).toEqual(5n); | ||
|
||
let value = MyProof.provable.toValue(proof); | ||
expect(value.publicInput).toEqual(5n); | ||
expect(value.proof).toBe(proof.proof); | ||
}); | ||
} | ||
|
||
await Provable.runAndCheck(circuit); | ||
}); |
Oops, something went wrong.