-
Notifications
You must be signed in to change notification settings - Fork 35
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
Bugfix/eip 196 edge case #185
Bugfix/eip 196 edge case #185
Conversation
d308b8d
to
df3a53c
Compare
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'm not sure about the edge case. For me it does not make sense and we should try to find out whether that is the right behaviour.
@@ -100,7 +121,17 @@ func eip196altbn128G1Mul(javaInputBuf, javaOutputBuf, javaErrorBuf *C.char, cInp | |||
errorBuf := castErrorBuffer(javaErrorBuf, errorLen) | |||
|
|||
if inputLen < EIP196PreallocateForG1 { | |||
// if we do not have complete input, return 0 | |||
|
|||
// check the X point and return an error if it is in the field, edge case |
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.
// check the X point and return an error if it is in the field, edge case | |
// check the X point and return an error if it is not in the field, edge case |
// check we have input size sufficient for a G1Affine | ||
if inputLen < EIP196PreallocateForG1 { | ||
|
||
// if not, check the X point and return an error if it is in the field, edge case |
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.
// if not, check the X point and return an error if it is in the field, edge case | |
// if not, check the X point and return an error if it is not in the field, edge case |
This PR to resolve a reference test failure. I agree it is weird behavior. IMO all malformed inputs should return an error. reference test fail: |
…t case, make tests pickier about expected errors Signed-off-by: garyschulte <garyschulte@gmail.com>
df3a53c
to
f8dfeab
Compare
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.
LGTM
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 understand the math, but the change in error case handling is sound.
fix for a weird (imo) EIP-196 expectation that a malformed/incomplete g1 point should return an error if the X value is readable, but not in the field; whereas a malformed/incomplete g1 point will otherwise return 0