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 BLS signatures over BLS12-381 #446

Merged
merged 6 commits into from
Feb 14, 2024
Merged

Add BLS signatures over BLS12-381 #446

merged 6 commits into from
Feb 14, 2024

Conversation

armfazh
Copy link
Contributor

@armfazh armfazh commented Jun 22, 2023

Implements the basic version of BLS as in IETF draft.
https://github.com/cfrg/draft-irtf-cfrg-bls-signature

@armfazh armfazh added the new feature New functionality or module label Jun 22, 2023
@armfazh armfazh self-assigned this Jun 22, 2023
ecc/bls12381/g2.go Outdated Show resolved Hide resolved
Copy link
Contributor

@thibmeu thibmeu left a comment

Choose a reason for hiding this comment

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

Tests are passing. Mostly documentation related comments.

I think the code should be better documented. This could be with one big comment at the start with reference to the source algorithm/paper/document, or via multiple inline comments.

sign/bls/bls.go Outdated
k.pub = new(PublicKey[K])
switch (interface{})(k).(type) {
case *PrivateKey[G1]:
kk := (interface{})(&k.pub.key).(*G1)
Copy link
Contributor

Choose a reason for hiding this comment

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

question on the naming scheme: what is the reason behind naming inner variables with one additional duplicated letter?
For instance, inner variable of k becomes kk, for x it becomes xx and then xxx?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it obey to conversions between interfaces to specific structs. The pattern of repeating a letter hints about the origin of the variable.

sign/bls/bls.go Show resolved Hide resolved
sign/bls/bls.go Show resolved Hide resolved
sign/bls/bls.go Show resolved Hide resolved
sign/bls/bls.go Show resolved Hide resolved
sign/bls/bls.go Outdated Show resolved Hide resolved
sign/bls/bls.go Outdated Show resolved Hide resolved
@armfazh armfazh force-pushed the blsSig branch 2 times, most recently from a796343 to c8d23eb Compare June 26, 2023 23:16
Copy link
Contributor

@thibmeu thibmeu left a comment

Choose a reason for hiding this comment

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

Good codewise for me.

sign/bls/bls.go Outdated Show resolved Hide resolved
sign/bls/bls.go Outdated Show resolved Hide resolved
ss.SetBytes(OKM)

if ss.IsZero() == 1 {
digest := sha256.Sum256(salt)
Copy link
Member

Choose a reason for hiding this comment

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

Do we have a test that covers this branch?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no, this branch happens when HKDF outputs all-zeros, or a multiple of a prime.

sign/bls/bls.go Show resolved Hide resolved
var Q GG.G1
Q.Hash(msg, []byte(dstG1))
Q.ScalarMult(&k.key, &Q)
return Q.BytesCompressed()
Copy link
Member

Choose a reason for hiding this comment

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

The compression matches the spec also in the corner cases?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

all the points have fixed-size length. or do you mean something different?

Copy link
Member

Choose a reason for hiding this comment

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

Case of point at infinity.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tests for serialization here depend only on the unique ciphersuite: BLS12-381 curve
The encoding format is tested in the ecc/bls12381 package, see: https://github.com/cloudflare/circl/blob/main/ecc/bls12381/encoding_test.go#L73

sign/bls/bls.go Outdated Show resolved Hide resolved
sign/bls/bls.go Show resolved Hide resolved
sign/bls/bls.go Show resolved Hide resolved
sign/bls/bls.go Show resolved Hide resolved
sign/bls/bls.go Outdated Show resolved Hide resolved
@armfazh armfazh requested a review from bwesterb July 14, 2023 20:27
Copy link
Member

@bwesterb bwesterb left a comment

Choose a reason for hiding this comment

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

Please address the test for point for infinity. Otherwise it's ok.

@armfazh
Copy link
Contributor Author

armfazh commented Jan 23, 2024

Please address the test for point for infinity. Otherwise it's ok.

Tests for the point at infinity are checked in the ecc/bls12831 package

the other case happens when the signing key is zero.
and this case is checked here:
https://github.com/cloudflare/circl/pull/446/files#diff-45bd7b7f5e0dd32f5ee9e14fdb3b1c8cb2fff157c8a99f9667c9029781e69090R111-R112

@armfazh armfazh merged commit 59e26d0 into cloudflare:main Feb 14, 2024
10 checks passed
@armfazh armfazh deleted the blsSig branch February 14, 2024 19:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature New functionality or module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants