-
Notifications
You must be signed in to change notification settings - Fork 118
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 #1658 from o1-labs/fix/changelog-ecdsa-fix
Test recursion fix pointing to latest develop
- Loading branch information
Showing
4 changed files
with
69 additions
and
2 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
Submodule bindings
updated
4 files
+1 −1 | MINA_COMMIT | |
+1 −1 | compiled/node_bindings/o1js_node.bc.cjs | |
+1 −1 | compiled/node_bindings/o1js_node.bc.map | |
+1 −1 | compiled/web_bindings/o1js_web.bc.js |
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,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'); |