bls12381: Add support for point at infinity for G1 adds #37
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 PR adds some initial point at infinity handling for G1 points. (G2 points will be similar, but come in a future PR).
identity()
method that returns(0, 0)
alloc_elem
: the native bls12_381 representation is(0, 1)
instead of(0, 0)
, so we need to map italloc_is_identity()
that checks whether the point is(0, 0)
assert_collinear
intoassert_addition
that can handle points at infinity. Function is called withassert_addition(a, b, c)
and checks whethera + b = c
is valida == 0
orb == 0
, to support checking whethera + b = c
: usually only one ofa
orb
is0
, and in this case thenc == 0
as well and the function works properly. The function only breaks ifb == -a
andc == 0
.add_unified
(~3800 vs ~5000 constraints per operation), so it makes sense to have it for certain applications for now.add_unified
implementation that supports all input values. (p = 0
,q = 0
,p = q
are all supported)conditionally_select
implementation forG1Point