-
Notifications
You must be signed in to change notification settings - Fork 517
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
Add inline test for signature consistency #10650
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
(library | ||
(name signature_lib_tests) | ||
(libraries | ||
random_oracle_input | ||
signature_lib | ||
snark_params) | ||
(instrumentation (backend bisect_ppx)) | ||
(inline_tests) | ||
(preprocess | ||
(pps | ||
ppx_inline_test | ||
ppx_version))) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
open Signature_lib | ||
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. my understanding is that there is no global 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.
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. ah I was wrong then |
||
|
||
let%test_module "Signatures are unchanged test" = | ||
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 is a great test to add! Would it be possible to quickly make it use our standard set of signature test vectors? |
||
( module struct | ||
let privkey = | ||
Private_key.of_base58_check_exn | ||
"EKE2M5q5afTtdzZTzyKu89Pzc7274BD6fm2fsDLgLt5zy34TAN5N" | ||
|
||
let signature_expected = | ||
( Snark_params.Tick.Field.of_string | ||
"22392589120931543014785073787084416773963960016576902579504636013984435243005" | ||
, Snark_params.Tock.Field.of_string | ||
"21219227048859428590456415944357352158328885122224477074004768710152393114331" | ||
) | ||
|
||
let%test "signature of empty random oracle input matches" = | ||
let signature_got = | ||
Schnorr.sign privkey (Random_oracle_input.field_elements [||]) | ||
in | ||
Snark_params.Tick.Field.equal (fst signature_expected) (fst signature_got) | ||
&& Snark_params.Tock.Field.equal (snd signature_expected) | ||
(snd signature_got) | ||
|
||
let%test "signature of signature matches" = | ||
let signature_got = | ||
Schnorr.sign privkey | ||
(Random_oracle_input.field_elements [| fst signature_expected |]) | ||
in | ||
let signature_expected = | ||
( Snark_params.Tick.Field.of_string | ||
"7379148532947400206038414977119655575287747480082205647969258483647762101030" | ||
, Snark_params.Tock.Field.of_string | ||
"26901815964642131149392134713980873704065643302140817442239336405283236628658" | ||
) | ||
in | ||
Snark_params.Tick.Field.equal (fst signature_expected) (fst signature_got) | ||
&& Snark_params.Tock.Field.equal (snd signature_expected) | ||
(snd signature_got) | ||
end ) |
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.
why create a separate module for inline tests? Why not inline these in the library itself? (or the caller if we want to keep the library out of scope for this test)
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.
Inline tests get compiled into the Mina binary. We've been starting to move them out, to avoid executable bloat.
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.
dang, that's a pretty good reason not to use inline tests at all :D