-
Notifications
You must be signed in to change notification settings - Fork 133
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
Foreign curve and ECDSA #1007
Merged
Merged
Foreign curve and ECDSA #1007
Changes from 108 commits
Commits
Show all changes
113 commits
Select commit
Hold shift + click to select a range
a637e7c
fix example
mitschabaude 1febfbe
initial minimal foreign curve, doesn't work yet
mitschabaude e012ba6
initial work on test
mitschabaude addf84c
working bare bones ec with add
mitschabaude 578f444
make curve provable
mitschabaude 4fb98e6
expose common ec methods
mitschabaude 7a228c3
add remaining provable methods
mitschabaude e241042
correct comments
mitschabaude 6f0a888
minor tweaks
mitschabaude 44779a1
improve api
mitschabaude 26affb1
stub out ecdsa factory
mitschabaude 81b9118
expose ecdsa methods
mitschabaude 1dae1dc
from hex
mitschabaude 005a2aa
start writing test for eth signature
mitschabaude b237f9c
ecdsa test
mitschabaude 36ad895
minor
mitschabaude f4e59b2
Merge branch 'feature/foreign-field' into feature/ecdsa
mitschabaude 9b5cf28
bindings
mitschabaude b530803
renamings
mitschabaude afce065
add most constant curve impls
mitschabaude 6b43f92
scale
mitschabaude 5781049
constant subgroup check
mitschabaude 5ad6b49
getting non provable curve ops to run
mitschabaude 78c635b
start writing doc comments
mitschabaude bf9968a
more doc comments, unsafe parameter, proper check()
mitschabaude 61bb485
fox typo and foreign curve check
mitschabaude 499928d
ecdsa doc comments
mitschabaude f2460f1
implement ecdsa in ts for non-provable
mitschabaude 07a45f7
minor
mitschabaude 6c01efe
subgroup check in constant verification
mitschabaude 2dce057
web compatible benchmark
mitschabaude 3437479
foreign field benchmark
mitschabaude c033828
Merge branch 'feature/foreign-field' into feature/ecdsa
mitschabaude 45fb41f
Merge branch 'feature/ecdsa-new' into feature/ecdsa
mitschabaude 616e47a
Merge branch 'main' into feature/ecdsa
mitschabaude 5384087
make foreign field struct-friendly
mitschabaude b9205c4
bindings
mitschabaude c6989dd
fix foreign curve compilation except the class return
mitschabaude 321fca0
fixup foreign field
mitschabaude 8459851
delete duplicate curve params
mitschabaude 56795cf
foreign field: remove duplicate private method
mitschabaude bb61f3d
remove private
mitschabaude c0d8867
compiles
mitschabaude c85c5ea
tests compile
mitschabaude 6385b9a
Merge branch 'feature/foreign-field' into feature/ecdsa
mitschabaude d9353d4
remove unnecessary helper
mitschabaude 6f3413a
bindings
mitschabaude e9d17de
move foreign curve class outside class factory
mitschabaude 13081cc
minor
mitschabaude 190f3e3
negate
mitschabaude 8c09689
support message in foreign field assertMul
mitschabaude cd9193e
assert on curve
mitschabaude 722cfd6
scale gadget
mitschabaude a7fc887
Merge branch 'feature/foreign-field' into feature/ecdsa
mitschabaude e1fa376
Merge branch 'feature/ecdsa-new' into feature/ecdsa
mitschabaude da21b19
fixup merge
mitschabaude 132d879
support a!=0 in assert on curve
mitschabaude d953a70
implement subgroup check
mitschabaude d7707dc
fix assert on curve
mitschabaude ec7131e
not so slow anymore
mitschabaude 1f7e291
expose cs summary
mitschabaude 0122785
delete bad example
mitschabaude 4b5af0b
remove curve parameter limitations from foreign curve class
mitschabaude e1282d1
cleanup comments, move redundant unit test to example
mitschabaude 1348779
examples fixup
mitschabaude 6100817
make ecdsa class work
mitschabaude ecdeea7
move ecdsa class outside factory
mitschabaude 9fe6e59
bindings
mitschabaude 6290202
make type pure
mitschabaude 9dea77f
add ForeignField.random()
mitschabaude a3577b0
add Ecdsa.sign()
mitschabaude b35cc61
rewrite ecdsa example using high level API
mitschabaude 5095fac
fix constraint system test flakiness
mitschabaude 6ce500e
Merge branch 'feature/ecdsa-new' into feature/ecdsa
mitschabaude 3e2990c
collateral damage from using higher-level API
mitschabaude e4ffb48
Merge branch 'feature/ecdsa-new' into feature/ecdsa
mitschabaude e9c21b0
update benchmark
mitschabaude a668916
move ecdsa example to where it makes more sense
mitschabaude 8cc376f
doccomment tweaks
mitschabaude 4333762
revert unnecessary change
mitschabaude c6c39cc
save constraints
mitschabaude 9590840
add ec gadgets
mitschabaude 49b98c5
adapt constant case in multiscalarmul, remove the one in scale
mitschabaude cbd335f
remove testing code
mitschabaude 9ebd5f3
start writing ec gadgets tests
mitschabaude 07a1fde
simplify build scripts
mitschabaude 502a497
equivalent: add verbose option and onlyif combinator
mitschabaude 578a8ad
fix ec test
mitschabaude a7f997b
add assert on curve
mitschabaude 7e83c43
minor
mitschabaude 43eadf7
minor console formatting
mitschabaude 78e0c63
standardize ec gadgets inputs
mitschabaude d32ad75
make record forward provable
mitschabaude 24d3a32
add missing label
mitschabaude c07857f
verbose ecdsa test
mitschabaude 80d10a6
catch missing provable
mitschabaude d29a9b5
fix ecdsa unit test
mitschabaude 40cb374
remove use of build:node
mitschabaude ce82667
remove use of build:node
mitschabaude 81d0047
improve comments
mitschabaude 818046c
flesh out doccomments
mitschabaude 3d14a4e
move dangerous foreign field equals
mitschabaude dfc7e97
change to safe equals() methods in foreign field, rename assertCanonical
mitschabaude 0403912
add safe ec addition
mitschabaude abe4d56
signature to bigint
mitschabaude 3a3cce3
adapt unit test
mitschabaude 9bcb6fd
delete ec and ecdsa gadgets namespaces
mitschabaude 31282ea
changelog
mitschabaude db8f63a
Revert "remove ecdsa from vk test for now"
mitschabaude 120ae94
Merge branch 'tmp' into feature/ecdsa
mitschabaude 0a96141
Merge branch 'main' into feature/ecdsa
mitschabaude 62091b8
dump vks
mitschabaude 5430dc4
Merge branch 'main' into feature/ecdsa
mitschabaude File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Submodule bindings
updated
from 700639 to f9fc0b
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,31 @@ | ||
import { Crypto, Provable, createForeignField } from 'o1js'; | ||
|
||
class ForeignScalar extends createForeignField( | ||
Crypto.CurveParams.Secp256k1.modulus | ||
) {} | ||
|
||
function main() { | ||
let s = Provable.witness( | ||
ForeignScalar.Canonical.provable, | ||
ForeignScalar.random | ||
); | ||
let t = Provable.witness( | ||
ForeignScalar.Canonical.provable, | ||
ForeignScalar.random | ||
); | ||
s.mul(t); | ||
} | ||
|
||
console.time('running constant version'); | ||
main(); | ||
console.timeEnd('running constant version'); | ||
|
||
console.time('running witness generation & checks'); | ||
Provable.runAndCheck(main); | ||
console.timeEnd('running witness generation & checks'); | ||
|
||
console.time('creating constraint system'); | ||
let cs = Provable.constraintSystem(main); | ||
console.timeEnd('creating constraint system'); | ||
|
||
console.log(cs.summary()); |
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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this example was moved here from |
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,22 @@ | ||
import { ZkProgram, Crypto, createEcdsa, createForeignCurve, Bool } from 'o1js'; | ||
|
||
export { ecdsaProgram, Secp256k1, Ecdsa }; | ||
|
||
class Secp256k1 extends createForeignCurve(Crypto.CurveParams.Secp256k1) {} | ||
class Scalar extends Secp256k1.Scalar {} | ||
class Ecdsa extends createEcdsa(Secp256k1) {} | ||
|
||
const ecdsaProgram = ZkProgram({ | ||
name: 'ecdsa', | ||
publicInput: Scalar.provable, | ||
publicOutput: Bool, | ||
|
||
methods: { | ||
verifyEcdsa: { | ||
privateInputs: [Ecdsa.provable, Secp256k1.provable], | ||
method(msgHash: Scalar, signature: Ecdsa, publicKey: Secp256k1) { | ||
return signature.verify(msgHash, publicKey); | ||
}, | ||
}, | ||
}, | ||
}); |
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 was deleted.
Oops, something went wrong.
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I simplified the scripts as I was finding myself running
npm run build:test
everytime -- now bothnpm run dev
andnpm run build
include building test dependencies, and only the production build doesn't