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

src|cmake: Fix some FromBytes decoding issues, add more test cases #253

Merged
merged 5 commits into from
Jul 21, 2021

Conversation

xdustinface
Copy link
Contributor

This is a (i think the proper) fix for #251 which basically has been introduced by a bug-fix in relic, see relic-toolkit/relic@c7177c8 and relic-toolkit/relic#206. Please also have a look here @dfaranha :)

a90d56a expands the test case to cover the issue detected in #251 and e9f60d1 is the actual fix.

Copy link
Member

@hoffmang9 hoffmang9 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@wjblanke wjblanke requested a review from mariano54 July 20, 2021 03:28
@xdustinface xdustinface marked this pull request as draft July 20, 2021 12:20
@xdustinface xdustinface changed the title elements|test|util: Throw an error in FromBytes for non-infinity zero only buffers elements|test|util|cmake: Fix some FromBytes decoding issues, add more test cases Jul 20, 2021
@xdustinface xdustinface changed the title elements|test|util|cmake: Fix some FromBytes decoding issues, add more test cases src|cmake: Fix some FromBytes decoding issues, add more test cases Jul 20, 2021
@xdustinface
Copy link
Contributor Author

xdustinface commented Jul 20, 2021

Okay, turned out that there are more "first byte values" where it should pass because the 5 lower bits of the first byte are also used as data. I adjusted the test and fixed an issue in the zero bytes check.. now it should have the same behavior like before the relic bug-fix which introduced the change of the behavior. But at the end i guess this should also be fixed in relic itself @dfaranha?

Another thing i realized is that with this commit relic-toolkit/relic@1620a03 we get more invalid cases, see 1fa53dc which is required after that commit . I miss some background here to judge if all of the values in here

0x85, 0x86, 0x87, 0x88, 0x89, 0x8C, 0x8F, 0x91, 0x93, 0x94, 0x96, 0x98, 0x99, 0x9A, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAC, 0xAF, 0xB1, 0xB3, 0xB4, 0xB6, 0xB8, 0xB9, 0xBA

with zeroes appended should be decoded to valid G1 elements. Can either of you @mariano54 or @dfaranha share your thoughts?

Also just for the record, this PR now bumps relic to relic-toolkit/relic@b7b2266. If someone has any objections let me know, i can then drop 1fa53dc and 896e33c.

@xdustinface xdustinface marked this pull request as ready for review July 20, 2021 14:53
@dfaranha
Copy link
Contributor

Currently on holidays, but will catch-up tonight!

@wjblanke wjblanke merged commit 2716e68 into Chia-Network:main Jul 21, 2021
@mariano54
Copy link
Contributor

I have not reviewed this yet

@wjblanke
Copy link
Contributor

ah i saw gene's review and thought it had gone through

@hoffmang9
Copy link
Member

Sorry - however it did pass Guido's testing and it looked otherwise correct - which is why I approved.

Copy link
Contributor

@mariano54 mariano54 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

UdjinM6 pushed a commit to UdjinM6/bls-signatures that referenced this pull request Dec 1, 2021
…hia-Network#253)

* test: Expand invalid G1/G2 element test cases

Test all prefix values, not only 0-10.

* util: Introduce `HasOnlyZeros` to check a `Bytes` object for zero bytes

* elements: Don't accept zero only buffer with valid prefix in `FromBytes`

* test: Drop cases which become invalid with relic commit 1620a03b388e50acd68ed9c88d7cd82ec5490ce4

* cmake: Pin relic to b7b2266a0e4ee6f628f61d3ab638f524a18b52f1

Which is currently the latest `main`
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.

5 participants