SecretKey -> PublicKey preconditions docs + fixes. #115
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fixes #114 and status-im/nimbus-eth2#2695
Overview
In BLSCurve, preconditions checks for:
are done at deserialization time.
nim-blscurve/blscurve/blst/bls_sig_io.nim
Lines 149 to 168 in 50dbaba
nim-blscurve/blscurve/blst/bls_sig_io.nim
Lines 81 to 99 in 50dbaba
This means that procedures that rely on those types, like
publicFromSecret
can assume that those preconditions are already respected.This has been clarified in a dedicated document https://github.com/status-im/nim-blscurve/blob/9b7366cdc7df14c87930c3ed0243ab551a5daf56/docs/bls_types_guarantees.md
Tests have been added to ensure that #114 was just a documentation issue and revealed that the MIRACL backend (not used in production) could actually deserialize an invalid secret key > r.
Furthermore, for defensive programming reason, an extra precondition check in
publicFromSecret
has been added to recheck that the input respects0 < SK < r
. That check should never fail.