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 161
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: BbsBlsSignatureProof2020 LDP suite for VC
Signed-off-by: Dmitriy Kinoshenko <[email protected]>
- Loading branch information
Showing
23 changed files
with
1,782 additions
and
13 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/bbsblssignatureproof2020/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 bbsblssignatureproof2020 | ||
|
||
import "github.com/hyperledger/aries-framework-go/pkg/doc/signature/verifier" | ||
|
||
const g2PubKeyType = "Bls12381G2Key2020" | ||
|
||
// NewG2PublicKeyVerifier creates a signature verifier that verifies a BbsBlsSignatureProof2020 signature | ||
// taking Bls12381G2Key2020 public key bytes as input. | ||
func NewG2PublicKeyVerifier(nonce []byte) *verifier.PublicKeyVerifier { | ||
return verifier.NewPublicKeyVerifier(verifier.NewBBSG2SignatureProofVerifier(nonce), | ||
verifier.WithExactPublicKeyType(g2PubKeyType)) | ||
} |
60 changes: 60 additions & 0 deletions
60
pkg/doc/signature/suite/bbsblssignatureproof2020/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,60 @@ | ||
/* | ||
Copyright SecureKey Technologies Inc. All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package bbsblssignatureproof2020_test | ||
|
||
import ( | ||
"encoding/base64" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/hyperledger/aries-framework-go/pkg/doc/jose" | ||
"github.com/hyperledger/aries-framework-go/pkg/doc/signature/suite/bbsblssignatureproof2020" | ||
sigverifier "github.com/hyperledger/aries-framework-go/pkg/doc/signature/verifier" | ||
) | ||
|
||
//nolint:lll | ||
func TestNewG2PublicKeyVerifier(t *testing.T) { | ||
verifier := bbsblssignatureproof2020.NewG2PublicKeyVerifier([]byte("nonce")) | ||
|
||
pkBase64 := "sVEbbh9jDPGSBK/oT/EeXQwFvNuC+47rgq9cxXKrwo6G7k4JOY/vEcfgZw9Vf/TpArbIdIAJCFMDyTd7l2atS5zExAKX0B/9Z3E/mgIZeQJ81iZ/1HUnUCT2Om239KFx" | ||
pkBytes, err := base64.RawStdEncoding.DecodeString(pkBase64) | ||
require.NoError(t, err) | ||
|
||
sigBase64 := "AAIBiN4EL9psRsIUlwQah7a5VROD369PPt09Z+jfzamP+/114a5RfWVMju3NCUl2Yv6ahyIdHGdEfxhC985ShlGQrRPLa+crFRiu2pfnAk+L6QMNooVMQhzJc2yYgktHen4QhsKV3IGoRRUs42zqPTP3BdqIPQeLgjDVi1d1LXEnP+WFQGEQmTKWTja4u1MsERdmAAAAdIb6HuFznhE3OByXN0Xp3E4hWQlocCdpExyNlSLh3LxK5duCI/WMM7ETTNS0Ozxe3gAAAAIuALkiwplgKW6YmvrEcllWSkG3H+uHEZzZGL6wq6Ac0SuktQ4n84tZPtMtR9vC1Rsu8f7Kwtbq1Kv4v02ct9cvj7LGcitzg3u/ZO516qLz+iitKeGeJhtFB8ggALcJOEsebPFl12cYwkieBbIHCBt4AAAAAxgEHt3iqKIyIQbTYJvtrMjGjT4zuimiZbtE3VXnqFmGaxVTeR7dh89PbPtsBI8LLMrCvFFpks9D/oTzxnw13RBmMgMlc1bcfQOmE9DZBGB7NCdwOnT7q4TVKhswOITKTQ==" | ||
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") | ||
} |
Oops, something went wrong.