This repository has been archived by the owner on Mar 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2261 from kdimak/issue-2221-vc
feat: BbsBlsSignature2020 LDP suite for VC
- Loading branch information
Showing
18 changed files
with
437 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
pkg/doc/signature/suite/bbsblssignature2020/public_key_verifier.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* | ||
Copyright SecureKey Technologies Inc. All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package bbsblssignature2020 | ||
|
||
import "github.com/hyperledger/aries-framework-go/pkg/doc/signature/verifier" | ||
|
||
const g2PubKeyType = "Bls12381G2Key2020" | ||
|
||
// NewG2PublicKeyVerifier creates a signature verifier that verifies a BbsBlsSignature2020 signature | ||
// taking Bls12381G2Key2020 public key bytes as input. | ||
func NewG2PublicKeyVerifier() *verifier.PublicKeyVerifier { | ||
return verifier.NewPublicKeyVerifier(verifier.NewBBSG2SignatureVerifier(), | ||
verifier.WithExactPublicKeyType(g2PubKeyType)) | ||
} |
59 changes: 59 additions & 0 deletions
59
pkg/doc/signature/suite/bbsblssignature2020/public_key_verifier_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
Copyright SecureKey Technologies Inc. All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package bbsblssignature2020 | ||
|
||
import ( | ||
"encoding/base64" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/hyperledger/aries-framework-go/pkg/doc/jose" | ||
sigverifier "github.com/hyperledger/aries-framework-go/pkg/doc/signature/verifier" | ||
) | ||
|
||
//nolint:lll | ||
func TestNewG2PublicKeyVerifier(t *testing.T) { | ||
verifier := NewG2PublicKeyVerifier() | ||
|
||
pkBase64 := "lOpN7uGZWivVIjs0325N/V0dAhoPomrgfXVpg7pZNdRWwFwJDVxoE7TvRyOx/Qr7GMtShNuS2Px/oScD+SMf08t8eAO78QRNErPzwNpfkP4ppcSTShStFDfFbsv9L9yb" | ||
pkBytes, err := base64.RawStdEncoding.DecodeString(pkBase64) | ||
require.NoError(t, err) | ||
|
||
sigBase64 := "hPbLkeMZZ6KKzkjWoTVHeMeuLJfYWjmdAU1Vg5fZ/VZnIXxxeXBB+q0/EL8XQmWkOMMwEGA/D2dCb4MDuntKZpvHEHlvaFR6l1A4bYj0t2Jd6bYwGwCwirNbmSeIoEmJeRzJ1cSvsL+jxvLixdDPnw==" | ||
sigBytes, err := base64.StdEncoding.DecodeString(sigBase64) | ||
require.NoError(t, err) | ||
|
||
msg := ` | ||
message1 | ||
message2 | ||
` | ||
|
||
err = verifier.Verify(&sigverifier.PublicKey{ | ||
Type: "Bls12381G2Key2020", | ||
Value: pkBytes, | ||
}, []byte(msg), sigBytes) | ||
require.NoError(t, err) | ||
|
||
err = verifier.Verify(&sigverifier.PublicKey{ | ||
Type: "NotBls12381G2Key2020", | ||
Value: pkBytes, | ||
}, []byte(msg), sigBytes) | ||
require.Error(t, err) | ||
require.EqualError(t, err, "a type of public key is not 'Bls12381G2Key2020'") | ||
|
||
// Failed as we do not support JWK for Bls12381G2Key2020. | ||
err = verifier.Verify(&sigverifier.PublicKey{ | ||
Type: "Bls12381G2Key2020", | ||
JWK: &jose.JWK{ | ||
Kty: "EC", | ||
Crv: "BLS12381_G2", | ||
}, | ||
}, []byte(msg), sigBytes) | ||
require.Error(t, err) | ||
require.EqualError(t, err, "verifier does not match JSON Web Key") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.