Skip to content

Commit

Permalink
Merge pull request #1658 from o1-labs/fix/changelog-ecdsa-fix
Browse files Browse the repository at this point in the history
Test recursion fix pointing to latest develop
  • Loading branch information
mitschabaude authored May 18, 2024
2 parents 750ffd5 + fd0ad52 commit e7fa35d
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

- Fix type inference for `method.returns(Type)`, to require a matching return signature https://github.com/o1-labs/o1js/pull/1653
- Fix `Struct.empty()` returning a garbage object when one of the base types doesn't support `empty()` https://github.com/o1-labs/o1js/pull/1657
- Fix `Option.value_exn None` error when using certain custom gates in combination with recursion https://github.com/o1-labs/o1js/issues/1336 https://github.com/MinaProtocol/mina/pull/15588

## [1.2.0](https://github.com/o1-labs/o1js/compare/4a17de857...6a1012162) - 2024-05-14

Expand Down
66 changes: 66 additions & 0 deletions src/lib/provable/test/custom-gates-recursion.unit-test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/**
* This tests that we can use optional custom gates plus recursion in the same zkprogram proof.
*/
import { Bool } from '../wrapped.js';
import { ZkProgram } from '../../proof-system/zkprogram.js';
import { Provable } from '../provable.js';
import { assert } from '../gadgets/common.js';
import { Ecdsa, Point } from '../gadgets/elliptic-curve.js';
import { Field3 } from '../gadgets/foreign-field.js';
import { Crypto } from '../crypto/crypto.js';

const Secp256k1 = Crypto.createCurve(Crypto.CurveParams.Secp256k1);

let publicKey = Point.from({
x: 49781623198970027997721070672560275063607048368575198229673025608762959476014n,
y: 44999051047832679156664607491606359183507784636787036192076848057884504239143n,
});

let signature = Ecdsa.Signature.fromHex(
'0x82de9950cc5aac0dca7210cb4b77320ac9e844717d39b1781e9d941d920a12061da497b3c134f50b2fce514d66e20c5e43f9615f097395a5527041d14860a52f1b'
);

let msgHash =
Field3.from(
0x3e91cd8bd233b3df4e4762b329e2922381da770df1b31276ec77d0557be7fcefn
);

let emptyProgram = ZkProgram({
name: 'empty',
methods: { run: { privateInputs: [], async method() {} } },
});
class EmptyProof extends ZkProgram.Proof(emptyProgram) {}

let program = ZkProgram({
name: 'ecdsa',
publicOutput: Bool,
methods: {
ecdsa: {
privateInputs: [EmptyProof],
async method(proof: EmptyProof) {
proof.verify();
let signature_ = Provable.witness(
Ecdsa.Signature.provable,
() => signature
);
let msgHash_ = Provable.witness(Field3.provable, () => msgHash);
let publicKey_ = Provable.witness(Point.provable, () => publicKey);

return Ecdsa.verify(Secp256k1, signature_, msgHash_, publicKey_);
},
},
},
});

console.time('ecdsa verify (compile)');
await emptyProgram.compile();
await program.compile();
console.timeEnd('ecdsa verify (compile)');

console.time('ecdsa verify (prove)');
let emptyProof = await emptyProgram.run();
let proof = await program.ecdsa(emptyProof);
console.timeEnd('ecdsa verify (prove)');

assert(await program.verify(proof), 'proof verifies');
proof.publicOutput.assertTrue('signature verifies');
2 changes: 1 addition & 1 deletion src/mina
Submodule mina updated 420 files

0 comments on commit e7fa35d

Please sign in to comment.