Skip to content

Commit

Permalink
test: BSS+ signature suite interop tests (with Mattr)
Browse files Browse the repository at this point in the history
closes hyperledger-archives#2223

Signed-off-by: Dmitriy Kinoshenko <[email protected]>
  • Loading branch information
kdimak committed Nov 18, 2020
1 parent 5cb023b commit 6e813b7
Show file tree
Hide file tree
Showing 20 changed files with 9,356 additions and 0 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/bbs-interop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#
# Copyright SecureKey Technologies Inc. All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0
#
name: bbs-interop
on:
push:
branches-ignore:
- 'dependabot/**'
paths:
- 'pkg/doc/verifiable/**'
- 'pkg/doc/bbs/**'
- 'pkg/doc/signature/suite/bbsblssignature2020/**'
- 'scripts/check_bbs_interop.sh'
- '.github/workflows/bbs-interop.yml'
- 'Makefile'
pull_request:
paths:
- 'pkg/doc/verifiable/**'
- 'pkg/doc/bbs/**'
- 'pkg/doc/signature/suite/bbsblssignature2020/**'
- 'scripts/check_bbs_interop.sh'
- '.github/workflows/bbs-interop.yml'
- 'Makefile'
jobs:
vcTestSuite:
name: VC test suite
runs-on: ubuntu-18.04
timeout-minutes: 10
steps:

- name: Setup Go 1.15
uses: actions/setup-go@v2
with:
go-version: 1.15
id: go

- name: Setup node
uses: actions/[email protected]
with:
node-version: '10.x'

- name: Setup mocha
timeout-minutes: 10
run: npm install -g mocha

- uses: actions/checkout@v2

- name: Run test suite
timeout-minutes: 10
run: make bbs-interop-test
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ bdd-test-js-local:
vc-test-suite: clean
@scripts/run_vc_test_suite.sh

.PHONY: bbs-interop-test
bbs-interop-test:
@scripts/check_bbs_interop.sh

generate-test-keys: clean
@mkdir -p -p test/bdd/fixtures/keys/tls
@docker run -i --rm \
Expand Down
18 changes: 18 additions & 0 deletions pkg/doc/bbs/bbs12381g2pub/keys_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"crypto/sha256"
"testing"

"github.com/btcsuite/btcutil/base58"
"github.com/stretchr/testify/require"

bbs "github.com/hyperledger/aries-framework-go/pkg/doc/bbs/bbs12381g2pub"
Expand Down Expand Up @@ -75,6 +76,23 @@ func TestPublicKey_Marshal(t *testing.T) {
require.Equal(t, pubKey, pubKeyUnmarshalled)
}

func TestParseMattrKeys(t *testing.T) {
privKeyB58 := "5D6Pa8dSwApdnfg7EZR8WnGfvLDCZPZGsZ5Y1ELL9VDj"
privKeyBytes := base58.Decode(privKeyB58)
t.Logf("priv key bytes length: %d", len(privKeyBytes))

pubKeyB58 := "oqpWYKaZD9M1Kbe94BVXpr8WTdFBNZyKv48cziTiQUeuhm7sBhCABMyYG4kcMrseC68YTFFgyhiNeBKjzdKk9MiRWuLv5H4FFujQsQK2KTAtzU8qTBiZqBHMmnLF4PL7Ytu" //nolint:lll
pubKeyBytes := base58.Decode(pubKeyB58)
t.Logf("pub key bytes length: %d", len(pubKeyBytes))

messagesBytes := [][]byte{[]byte("message1"), []byte("message2")}
signatureBytes, err := bbs.New().Sign(messagesBytes, privKeyBytes)
require.NoError(t, err)

err = bbs.New().Verify(messagesBytes, signatureBytes, pubKeyBytes)
require.NoError(t, err)
}

func generateKeyPairRandom() (*bbs.PublicKey, *bbs.PrivateKey, error) {
seed := make([]byte, 32)

Expand Down
26 changes: 26 additions & 0 deletions scripts/check_bbs_interop.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash
#
# Copyright SecureKey Technologies Inc. All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0
#
set -e

ROOT=`pwd`

echo ""
echo "Running BBS+ interoperability tests..."
cd $ROOT/test/bbs
command=$1
if [ -z "$command" ]; then
command=test
fi
# capture exit code if it fails
npm run test || code=$?
if [ -z ${code+x} ]; then
# set exit code because it did not fail
code=0
fi
echo ""
cd $ROOT
exit $code
7 changes: 7 additions & 0 deletions test/bbs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#
# Copyright SecureKey Technologies Inc. All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0
#

node_modules/
54 changes: 54 additions & 0 deletions test/bbs/data/context/citizenship.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"@context": {
"@version": 1.1,
"@protected": true,

"name": "http://schema.org/name",
"description": "http://schema.org/description",
"identifier": "http://schema.org/identifier",
"image": {"@id": "http://schema.org/image", "@type": "@id"},

"PermanentResidentCard": {
"@id": "https://w3id.org/citizenship#PermanentResidentCard",
"@context": {
"@version": 1.1,
"@protected": true,

"id": "@id",
"type": "@type",

"description": "http://schema.org/description",
"name": "http://schema.org/name",
"identifier": "http://schema.org/identifier",
"image": {"@id": "http://schema.org/image", "@type": "@id"}
}
},

"PermanentResident": {
"@id": "https://w3id.org/citizenship#PermanentResident",
"@context": {
"@version": 1.1,
"@protected": true,

"id": "@id",
"type": "@type",

"ctzn": "https://w3id.org/citizenship#",
"schema": "http://schema.org/",
"xsd": "http://www.w3.org/2001/XMLSchema#",

"birthCountry": "ctzn:birthCountry",
"birthDate": {"@id": "schema:birthDate", "@type": "xsd:dateTime"},
"commuterClassification": "ctzn:commuterClassification",
"familyName": "schema:familyName",
"gender": "schema:gender",
"givenName": "schema:givenName",
"lprCategory": "ctzn:lprCategory",
"lprNumber": "ctzn:lprNumber",
"residentSince": {"@id": "ctzn:residentSince", "@type": "xsd:dateTime"}
}
},

"Person": "http://schema.org/Person"
}
}
98 changes: 98 additions & 0 deletions test/bbs/data/context/ldp-bbs2020.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@

{
"@context": {
"@version": 1.1,
"id": "@id",
"type": "@type",
"ldssk": "https://w3c-ccg.github.io/ldp-bbs2020/context/v1#",
"BbsBlsSignature2020": {
"@id": "https://w3c-ccg.github.io/ldp-bbs2020/context/v1#BbsBlsSignature2020",
"@context": {
"@version": 1.1,
"@protected": true,
"id": "@id",
"type": "@type",
"sec": "https://w3id.org/security#",
"xsd": "http://www.w3.org/2001/XMLSchema#",
"challenge": "sec:challenge",
"created": {
"@id": "http://purl.org/dc/terms/created",
"@type": "xsd:dateTime"
},
"domain": "sec:domain",
"proofValue": "sec:proofValue",
"nonce": "sec:nonce",
"proofPurpose": {
"@id": "sec:proofPurpose",
"@type": "@vocab",
"@context": {
"@version": 1.1,
"@protected": true,
"id": "@id",
"type": "@type",
"sec": "https://w3id.org/security#",
"assertionMethod": {
"@id": "sec:assertionMethod",
"@type": "@id",
"@container": "@set"
},
"authentication": {
"@id": "sec:authenticationMethod",
"@type": "@id",
"@container": "@set"
}
}
},
"verificationMethod": {
"@id": "sec:verificationMethod",
"@type": "@id"
}
}
},
"BbsBlsSignatureProof2020": {
"@id": "https://w3c-ccg.github.io/ldp-bbs2020/context/v1#BbsBlsSignatureProof2020",
"@context": {
"@version": 1.1,
"@protected": true,
"id": "@id",
"type": "@type",
"sec": "https://w3id.org/security#",
"xsd": "http://www.w3.org/2001/XMLSchema#",
"challenge": "sec:challenge",
"created": {
"@id": "http://purl.org/dc/terms/created",
"@type": "xsd:dateTime"
},
"domain": "sec:domain",
"nonce": "sec:nonce",
"proofPurpose": {
"@id": "sec:proofPurpose",
"@type": "@vocab",
"@context": {
"@version": 1.1,
"@protected": true,
"id": "@id",
"type": "@type",
"sec": "https://w3id.org/security#",
"assertionMethod": {
"@id": "sec:assertionMethod",
"@type": "@id",
"@container": "@set"
},
"authentication": {
"@id": "sec:authenticationMethod",
"@type": "@id",
"@container": "@set"
}
}
},
"proofValue": "sec:proofValue",
"verificationMethod": {
"@id": "sec:verificationMethod",
"@type": "@id"
}
}
},
"Bls12381G2Key2020": "ldssk:Bls12381G2Key2020"
}
}
50 changes: 50 additions & 0 deletions test/bbs/data/context/security_v1.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"@context": {
"id": "@id",
"type": "@type",

"dc": "http://purl.org/dc/terms/",
"sec": "https://w3id.org/security#",
"xsd": "http://www.w3.org/2001/XMLSchema#",

"EcdsaKoblitzSignature2016": "sec:EcdsaKoblitzSignature2016",
"Ed25519Signature2018": "sec:Ed25519Signature2018",
"EncryptedMessage": "sec:EncryptedMessage",
"GraphSignature2012": "sec:GraphSignature2012",
"LinkedDataSignature2015": "sec:LinkedDataSignature2015",
"LinkedDataSignature2016": "sec:LinkedDataSignature2016",
"CryptographicKey": "sec:Key",

"authenticationTag": "sec:authenticationTag",
"canonicalizationAlgorithm": "sec:canonicalizationAlgorithm",
"cipherAlgorithm": "sec:cipherAlgorithm",
"cipherData": "sec:cipherData",
"cipherKey": "sec:cipherKey",
"created": {"@id": "dc:created", "@type": "xsd:dateTime"},
"creator": {"@id": "dc:creator", "@type": "@id"},
"digestAlgorithm": "sec:digestAlgorithm",
"digestValue": "sec:digestValue",
"domain": "sec:domain",
"encryptionKey": "sec:encryptionKey",
"expiration": {"@id": "sec:expiration", "@type": "xsd:dateTime"},
"expires": {"@id": "sec:expiration", "@type": "xsd:dateTime"},
"initializationVector": "sec:initializationVector",
"iterationCount": "sec:iterationCount",
"nonce": "sec:nonce",
"normalizationAlgorithm": "sec:normalizationAlgorithm",
"owner": {"@id": "sec:owner", "@type": "@id"},
"password": "sec:password",
"privateKey": {"@id": "sec:privateKey", "@type": "@id"},
"privateKeyPem": "sec:privateKeyPem",
"publicKey": {"@id": "sec:publicKey", "@type": "@id"},
"publicKeyBase58": "sec:publicKeyBase58",
"publicKeyPem": "sec:publicKeyPem",
"publicKeyWif": "sec:publicKeyWif",
"publicKeyService": {"@id": "sec:publicKeyService", "@type": "@id"},
"revoked": {"@id": "sec:revoked", "@type": "xsd:dateTime"},
"salt": "sec:salt",
"signature": "sec:signature",
"signatureAlgorithm": "sec:signingAlgorithm",
"signatureValue": "sec:signatureValue"
}
}
59 changes: 59 additions & 0 deletions test/bbs/data/context/security_v2.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"@context": [{
"@version": 1.1
}, "https://w3id.org/security/v1", {
"AesKeyWrappingKey2019": "sec:AesKeyWrappingKey2019",
"DeleteKeyOperation": "sec:DeleteKeyOperation",
"DeriveSecretOperation": "sec:DeriveSecretOperation",
"EcdsaSecp256k1Signature2019": "sec:EcdsaSecp256k1Signature2019",
"EcdsaSecp256r1Signature2019": "sec:EcdsaSecp256r1Signature2019",
"EcdsaSecp256k1VerificationKey2019": "sec:EcdsaSecp256k1VerificationKey2019",
"EcdsaSecp256r1VerificationKey2019": "sec:EcdsaSecp256r1VerificationKey2019",
"Ed25519Signature2018": "sec:Ed25519Signature2018",
"Ed25519VerificationKey2018": "sec:Ed25519VerificationKey2018",
"EquihashProof2018": "sec:EquihashProof2018",
"ExportKeyOperation": "sec:ExportKeyOperation",
"GenerateKeyOperation": "sec:GenerateKeyOperation",
"KmsOperation": "sec:KmsOperation",
"RevokeKeyOperation": "sec:RevokeKeyOperation",
"RsaSignature2018": "sec:RsaSignature2018",
"RsaVerificationKey2018": "sec:RsaVerificationKey2018",
"Sha256HmacKey2019": "sec:Sha256HmacKey2019",
"SignOperation": "sec:SignOperation",
"UnwrapKeyOperation": "sec:UnwrapKeyOperation",
"VerifyOperation": "sec:VerifyOperation",
"WrapKeyOperation": "sec:WrapKeyOperation",
"X25519KeyAgreementKey2019": "sec:X25519KeyAgreementKey2019",

"allowedAction": "sec:allowedAction",
"assertionMethod": {"@id": "sec:assertionMethod", "@type": "@id", "@container": "@set"},
"authentication": {"@id": "sec:authenticationMethod", "@type": "@id", "@container": "@set"},
"capability": {"@id": "sec:capability", "@type": "@id"},
"capabilityAction": "sec:capabilityAction",
"capabilityChain": {"@id": "sec:capabilityChain", "@type": "@id", "@container": "@list"},
"capabilityDelegation": {"@id": "sec:capabilityDelegationMethod", "@type": "@id", "@container": "@set"},
"capabilityInvocation": {"@id": "sec:capabilityInvocationMethod", "@type": "@id", "@container": "@set"},
"caveat": {"@id": "sec:caveat", "@type": "@id", "@container": "@set"},
"challenge": "sec:challenge",
"ciphertext": "sec:ciphertext",
"controller": {"@id": "sec:controller", "@type": "@id"},
"delegator": {"@id": "sec:delegator", "@type": "@id"},
"equihashParameterK": {"@id": "sec:equihashParameterK", "@type": "xsd:integer"},
"equihashParameterN": {"@id": "sec:equihashParameterN", "@type": "xsd:integer"},
"invocationTarget": {"@id": "sec:invocationTarget", "@type": "@id"},
"invoker": {"@id": "sec:invoker", "@type": "@id"},
"jws": "sec:jws",
"keyAgreement": {"@id": "sec:keyAgreementMethod", "@type": "@id", "@container": "@set"},
"kmsModule": {"@id": "sec:kmsModule"},
"parentCapability": {"@id": "sec:parentCapability", "@type": "@id"},
"plaintext": "sec:plaintext",
"proof": {"@id": "sec:proof", "@type": "@id", "@container": "@graph"},
"proofPurpose": {"@id": "sec:proofPurpose", "@type": "@vocab"},
"proofValue": "sec:proofValue",
"referenceId": "sec:referenceId",
"unwrappedKey": "sec:unwrappedKey",
"verificationMethod": {"@id": "sec:verificationMethod", "@type": "@id"},
"verifyData": "sec:verifyData",
"wrappedKey": "sec:wrappedKey"
}]
}
Loading

0 comments on commit 6e813b7

Please sign in to comment.