Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make proof provable #1457

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions src/examples/zkprogram/witness-proof-2.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import {
SelfProof,
Field,
ZkProgram,
verify,
isReady,
Proof,
JsonProof,
Provable,
Empty,
} from 'o1js';

await isReady;

let MyProgram = ZkProgram({
name: 'example-with-output',
publicOutput: Field,

methods: {
baseCase: {
privateInputs: [],
method() {
return Field(0);
},
},
},
});

class ProgramProof extends ZkProgram.Proof(MyProgram) {}

await MyProgram.compile();

let proof = await MyProgram.baseCase();

let MyProgram2 = ZkProgram({
name: 'example-with-output2',

methods: {
baseCase: {
privateInputs: [ProgramProof],
method(p: ProgramProof) {
p.verify();

// should say 0 and fail verification
Provable.log(proof.publicOutput);
},
},
},
});
console.log('GOING INTO SECOND ZKPROGRAM');
await MyProgram2.compile();
console.log('PROVING');

await MyProgram2.baseCase(proof);
58 changes: 58 additions & 0 deletions src/examples/zkprogram/witness-proof.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import {
SelfProof,
Field,
ZkProgram,
verify,
isReady,
Proof,
JsonProof,
Provable,
Empty,
} from 'o1js';

await isReady;

let MyProgram = ZkProgram({
name: 'example-with-output',
publicOutput: Field,

methods: {
baseCase: {
privateInputs: [],
method() {
return Field(0);
},
},
},
});

class ProgramProof extends ZkProgram.Proof(MyProgram) {}

await MyProgram.compile();

let proof = await MyProgram.baseCase();

let MyProgram2 = ZkProgram({
name: 'example-with-output2',

methods: {
baseCase: {
privateInputs: [],
method() {
let p = Provable.witness(ProgramProof.provable, () => {
proof.publicOutput = Field(5);
return proof;
});

ProgramProof.declare(p);
p.verify();
// should say 0 and fail verification
Provable.log(proof.publicOutput);
},
},
},
});
console.log('GOING INTO SECOND ZKPROGRAM');
await MyProgram2.compile();
console.log('PROVING');
await MyProgram2.baseCase();
2 changes: 1 addition & 1 deletion src/lib/gadgets/ecdsa.unit-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ Provable.runAndCheck(program.rawMethods.ecdsa);
console.timeEnd('ecdsa verify (witness gen / check)');

console.time('ecdsa verify (build constraint system)');
let cs = program.analyzeMethods().ecdsa;
let cs = program.analyzeMethods().ecdsa.cs;
console.timeEnd('ecdsa verify (build constraint system)');

console.log(cs.summary());
Expand Down
Loading
Loading