Skip to content
This repository has been archived by the owner on Mar 27, 2024. It is now read-only.

feat: BBS+ signer #2278

Merged
merged 1 commit into from
Oct 28, 2020
Merged

feat: BBS+ signer #2278

merged 1 commit into from
Oct 28, 2020

Conversation

kdimak
Copy link
Contributor

@kdimak kdimak commented Oct 27, 2020

This PR provides an implementation of BBS+ signer. It also provides a generator of public/private key pair. We can now generate a key pair, sing one or more messages, and verify the created signature (this functionality was already present).

Signed-off-by: Dmitriy Kinoshenko [email protected]

Relates to #2222 . To close this issue, in the follow-up PR we will use the BBS+ signer for VC.

@codecov
Copy link

codecov bot commented Oct 27, 2020

Codecov Report

Merging #2278 into master will decrease coverage by 0.03%.
The diff coverage is 81.81%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2278      +/-   ##
==========================================
- Coverage   89.90%   89.87%   -0.04%     
==========================================
  Files         226      227       +1     
  Lines       15239    15327      +88     
==========================================
+ Hits        13701    13775      +74     
- Misses        910      917       +7     
- Partials      628      635       +7     
Impacted Files Coverage Δ
pkg/doc/bbs/bbs12381g2pub/signature_message.go 66.66% <50.00%> (-17.34%) ⬇️
pkg/doc/bbs/bbs12381g2pub/bbs.go 82.75% <70.27%> (-3.76%) ⬇️
pkg/doc/bbs/bbs12381g2pub/keys.go 85.18% <85.18%> (ø)
pkg/doc/bbs/bbs12381g2pub/fr.go 87.09% <87.09%> (ø)
pkg/doc/bbs/bbs12381g2pub/signature.go 100.00% <100.00%> (+21.05%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4f03577...d1653bd. Read the comment docs.

for i := range messages {
messagesFr[i], err = ParseSignatureMessage(messages[i])
if err != nil {
return nil, fmt.Errorf("parse signature message: %w", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

add the index i in the error message to help troubleshoot errors

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Improved.

}

// SignWithKeyPair signs the one or more messages using BBS+ key pair.
func (bbs *BBSG2Pub) SignWithKeyPair(messages [][]byte, privKey *PrivateKey, pubKey *PublicKey) ([]byte, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

doesn't privKey include the public key as well ? can't we just pass privKey alone then do privKey.PublicKey() inside the function to fetch its public key?

what happens if someone passes a public key not matching the private one? I think its unnecessary to pass pubKey to this function.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree with this point. No need to pass a pubKey as it's created from privKey by a straightforward algorithm.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Corrected the API.

// returns:
// error in case of errors or nil if signature verification was successful
Verify(messages [][]byte, signature, pubKey []byte) error

// Sign will sign create signature of each message and aggregate it into a single signature using
// a matching signature primitive in kh key handle.
Copy link
Contributor

Choose a reason for hiding this comment

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

privKey is a raw key, not a handle

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Corrected.

Signed-off-by: Dmitriy Kinoshenko <[email protected]>
@llorllale llorllale merged commit 3e0d781 into hyperledger-archives:master Oct 28, 2020
@kdimak kdimak deleted the issue-2222 branch October 28, 2020 16:22
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants