-
Notifications
You must be signed in to change notification settings - Fork 519
crypto: add a couple of tests for ed25519 signatures before/after verification #3783
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
Conversation
56f0852 to
e50e8a7
Compare
id-ms
left a comment
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.
From my understanding, the purpose of those tests is to check ed25519verify TEAL opcode under specially crafted public keys, right?
if so, what is the difference between those two tests? (I do understand that they have different logic, but this is not the focus of the test)
Is there a way to break one test without the other?
jannotti
left a comment
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.
Seems good, willing to merge as is, let me know if you want to make any of the changes I mentioned. (the sb trace is probably the most worthwhile)
| var txn transactions.SignedTxn | ||
| txn.Lsig.Logic = ops.Program | ||
| txn.Lsig.Args = [][]byte{data[:], vec[2], vec[1]} | ||
| sb := strings.Builder{} |
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 don't see where you're putting sb in to trace. But you shouldn't have to anyway. defaultEvalParams inserts a string.Builder for you, so just change to evalParams.Trace.
| evalParams.Proto.EnableBatchVerification = tc.enableBatchVerification | ||
| pass, err := EvalSignature(0, evalParams) | ||
| require.Equal(t, tc.valid, pass, "trace %s", sb.String()) | ||
| t.Log(sb.String()) |
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.
It would be nice to Log the trace only if the test is about to fail, so the output is less cluttered when something else fails.
| (== (txn Amount) 2000000)) | ||
| ) | ||
| */ | ||
| ops, err := AssembleStringWithVersion(`arg 0 |
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 like to use testProg for assembling in tests. It checks the error for you and does not return it, it disassembles and reassembles to check equality giving us more tests for free, and does some logging if things don't work out.
There is no difference between the tests from the POV of the ed25519verify opcode operation, in the second one I was working on a transaction that would result in an account balance change, but it is not necessary if we want to just assert the new ed25519 behavior. |
|
Unnecessary after #3781 merged |
Summary
Now that the consensus upgrade for #3031 is complete this pushes a couple of unit tests related to signatures that were not valid before the batch verification upgrade, but are valid now.
Related: #3781
Test Plan
Adds two new tests.