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

Add gnark as bls-12-381 backend #551

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Conversation

Kubuxu
Copy link
Contributor

@Kubuxu Kubuxu commented Sep 18, 2024

Given that kilic is deprecated (and caused us some issues recently), I'm opening this PR with BLS-12-381 backend using https://github.com/Consensys/gnark-crypto/
The Gnark's BLS-12-381 code was audited in the past (but there have been changes to it since), and it is actively maintained.

Signing performance on G2 is comparable to kilic, while the signing on G1 and public key aggregation performance is better than both circl and kilic.
https://gist.github.com/Stebalien/d6268b5c1abc4aa29857cf7787b205e8

Signed-off-by: Jakub Sztandera <[email protected]>
Copy link

🔒 Could not start CI tests due to missing safe PR label. Please contact a DEDIS maintainer.

Errcheck was already not checking other impls

Signed-off-by: Jakub Sztandera <[email protected]>
Copy link

Stebalien added a commit to filecoin-project/go-f3 that referenced this pull request Sep 22, 2024
It's probably going to take a while for upstream to merge the changes so
we're importing just the changed package (BDN) and the new
package (Gnark) into this repo. That way we avoid forking the entire
repo but can still import our changes.

Any changes to these pacakges should be submitted as PRs to upstream
_first_, then backported to this repo.

Includes:

- dedis/kyber#546
- dedis/kyber#551
- dedis/kyber#553
Stebalien added a commit to filecoin-project/go-f3 that referenced this pull request Sep 22, 2024
It's probably going to take a while for upstream to merge the changes so
we're importing just the changed package (BDN) and the new
package (Gnark) into this repo. That way we avoid forking the entire
repo but can still import our changes.

Any changes to these pacakges should be submitted as PRs to upstream
_first_, then backported to this repo.

Includes:

- dedis/kyber#546
- dedis/kyber#551
- dedis/kyber#553
Stebalien added a commit to filecoin-project/go-f3 that referenced this pull request Sep 23, 2024
It's probably going to take a while for upstream to merge the changes so
we're importing just the changed package (BDN) and the new
package (Gnark) into this repo. That way we avoid forking the entire
repo but can still import our changes.

Any changes to these pacakges should be submitted as PRs to upstream
_first_, then backported to this repo.

Includes:

- dedis/kyber#546
- dedis/kyber#551
- dedis/kyber#553
Signed-off-by: Jakub Sztandera <[email protected]>
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
37.4% Duplication on New Code (required ≤ 10%)

See analysis details on SonarQube Cloud

Copy link

Please retry analysis of this Pull-Request directly on SonarQube Cloud

Copy link
Contributor

@AnomalRoil AnomalRoil left a comment

Choose a reason for hiding this comment

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

LGTM, one last question I guess

Comment on lines +99 to +112
p.inner.Set(&aa.inner)
p.inner.AddAssign(&bb.inner)
return p
}

func (p *G1Elt) Sub(a, b kyber.Point) kyber.Point {
aa, bb := a.(*G1Elt), b.(*G1Elt)
p.inner.Set(&aa.inner)
p.inner.SubAssign(&bb.inner)
return p
}

func (p *G1Elt) Neg(a kyber.Point) kyber.Point {
p.inner.Neg(&a.(*G1Elt).inner)
Copy link
Contributor

Choose a reason for hiding this comment

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

All of these are not safe for concurrent use since they aren't cloning p but setting it / overwriting it, right?
So I guess this might warrant a comment / require to open an issue about it.

Either that or p.inner should be cloned prior to modification if this wasn't the intention.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

None of them are thread-safe.
I wouldn't expect any thread safety, and the bigint semantics (which this resembles) in Go are that the struct will be clobbered.

The straightforward reason for this is that it gives options to either clone before or reuse and save on allocations.
I can add a note.


var _ kyber.Point = &GTElt{}

// GTElt is a wrapper around the Circl Gt point type.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// GTElt is a wrapper around the Circl Gt point type.
// GTElt is a wrapper around the gnark GT point type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants