Skip to content
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

secp256k1: Add overflow check to field val set. #2147

Merged
merged 1 commit into from
Apr 6, 2020

Conversation

davecgh
Copy link
Member

@davecgh davecgh commented Apr 1, 2020

This is rebased on #2145.

This modifies the SetBytes and SetByteSlice methods of the FieldVal type to return whether or not the provided value was greater than or equal to the field prime and adds tests to ensure it works as expected.

This allows callers to easily check if a given uint256 value will fit within the field element without modular reduction and makes it more consistent with the ModNScalar type.

Finally, it updates all of the callers in the repository accordingly.

@davecgh davecgh added this to the 1.6.0 milestone Apr 1, 2020
@davecgh davecgh force-pushed the secp256k1_fieldval_overflow_check branch from 3547308 to 3571781 Compare April 1, 2020 19:17
dcrec/secp256k1/field_test.go Outdated Show resolved Hide resolved
@davecgh davecgh force-pushed the secp256k1_fieldval_overflow_check branch 2 times, most recently from ecffd1f to 2c770ab Compare April 3, 2020 03:06
dcrec/secp256k1/field.go Outdated Show resolved Hide resolved
@davecgh davecgh force-pushed the secp256k1_fieldval_overflow_check branch 2 times, most recently from 935932b to cdb3f06 Compare April 5, 2020 04:20
This modifies the SetBytes and SetByteSlice methods of the FieldVal type
to return whether or not the provided value was greater than or equal to
the field prime and adds tests to ensure  it works as expected.

This allows callers to easily check if a given uint256 value will fit
within the field element without modular reduction and makes it more
consistent with the ModNScalar type.

Finally, it updates all of the callers in the repository accordingly.
@davecgh davecgh force-pushed the secp256k1_fieldval_overflow_check branch from cdb3f06 to 8c6b52d Compare April 6, 2020 21:25
@davecgh davecgh merged commit 8c6b52d into decred:master Apr 6, 2020
@davecgh davecgh deleted the secp256k1_fieldval_overflow_check branch April 6, 2020 21:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants