From a32a542c0afc1df234455ee2cae7c1d0b7f5fdfd Mon Sep 17 00:00:00 2001 From: Gabe Cohen Date: Thu, 12 Dec 2024 15:06:27 -0800 Subject: [PATCH] update --- README.md | 12 ++- implementations/independent/go.mod | 5 +- implementations/independent/go.sum | 20 ++--- implementations/independent/issue.go | 35 ++++++-- implementations/independent/main.go | 5 +- implementations/independent/verify.go | 89 +++++++++++++++---- tests/README.md | 2 +- .../input/credential-issuer-match-signed.json | 1 + tests/input/credential-minimal-signed.json | 1 + tests/input/presentation-multiple-signed.json | 1 + tests/test-mapping.js | 28 +++--- 11 files changed, 139 insertions(+), 60 deletions(-) create mode 100644 tests/input/credential-issuer-match-signed.json create mode 100644 tests/input/credential-minimal-signed.json create mode 100644 tests/input/presentation-multiple-signed.json diff --git a/README.md b/README.md index 0bab51c..707eeb7 100644 --- a/README.md +++ b/README.md @@ -46,10 +46,16 @@ The suite makes use Digital Bazaar's [mocha-w3c-interop-reporter](https://github This file defines the structure of the test suite. It exports two main objects: 1. `TestResult`: An enum of possible test outcomes (success, failure, indeterminate, error). -2. `GenericTestMapping`: A mapping of test names to their configurations. Each test configuration includes: +2. `TestMapping`: A mapping of test names to their configurations. Each test configuration includes: - `number`: A unique identifier for the test - - `input_file`: The name of the input file to be used - - `config`: Configuration options for the test, including the `check` property which determines the feature being tested + - `input_file`: The name of the input file to be used, representing: + - For issuance, a JSON unsigned Verifiable Credential or Presentation + - For verification, a signed Verifiable Credential or Presentation, encoded as a JWT string (JOSE), + Base64 string (COSE), or SD-JWT string (Selective Disclosure JWT) + - `key_file`: The name of the key file to be used, representing a Verification Method + - `fn`: The function being tested either `issue` or `verify` + - `feature`: The function being tested, one of `credential_jose`, `credential_cose`, `credential_sdjwt`, + `presentation_jose`, `presentation_cose`, or `presentation_sdjwt` - `expected_result`: The expected outcome of the test ### test-runner.js diff --git a/implementations/independent/go.mod b/implementations/independent/go.mod index 57b533a..5f915c3 100644 --- a/implementations/independent/go.mod +++ b/implementations/independent/go.mod @@ -6,11 +6,13 @@ require ( github.com/decentralgabe/vc-jose-cose-go v0.0.0-20241210221305-008380bea39c github.com/goccy/go-json v0.10.3 github.com/lestrrat-go/jwx/v2 v2.1.3 + github.com/pkg/errors v0.9.1 ) require ( github.com/btcsuite/btcd/btcec/v2 v2.3.4 // indirect github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 // indirect + github.com/fxamacker/cbor/v2 v2.5.0 // indirect github.com/gabriel-vasile/mimetype v1.4.7 // indirect github.com/go-playground/locales v0.14.1 // indirect github.com/go-playground/universal-translator v0.18.1 // indirect @@ -21,8 +23,9 @@ require ( github.com/lestrrat-go/httprc v1.0.6 // indirect github.com/lestrrat-go/iter v1.0.2 // indirect github.com/lestrrat-go/option v1.0.1 // indirect - github.com/pkg/errors v0.9.1 // indirect github.com/segmentio/asm v1.2.0 // indirect + github.com/veraison/go-cose v1.3.0 // indirect + github.com/x448/float16 v0.8.4 // indirect golang.org/x/crypto v0.30.0 // indirect golang.org/x/net v0.32.0 // indirect golang.org/x/sys v0.28.0 // indirect diff --git a/implementations/independent/go.sum b/implementations/independent/go.sum index 248e3c4..c720679 100644 --- a/implementations/independent/go.sum +++ b/implementations/independent/go.sum @@ -7,8 +7,8 @@ github.com/decentralgabe/vc-jose-cose-go v0.0.0-20241210221305-008380bea39c h1:X github.com/decentralgabe/vc-jose-cose-go v0.0.0-20241210221305-008380bea39c/go.mod h1:ZOHYH9iQGJdawl1+iSfzrfQQxPHrDVL/rpZRc5z9okI= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 h1:rpfIENRNNilwHwZeG5+P150SMrnNEcHYvcCuK6dPZSg= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0= -github.com/gabriel-vasile/mimetype v1.4.5 h1:J7wGKdGu33ocBOhGy0z653k/lFKLFDPJMG8Gql0kxn4= -github.com/gabriel-vasile/mimetype v1.4.5/go.mod h1:ibHel+/kbxn9x2407k1izTA1S81ku1z/DlgOW2QE0M4= +github.com/fxamacker/cbor/v2 v2.5.0 h1:oHsG0V/Q6E/wqTS2O1Cozzsy69nqCiguo5Q1a1ADivE= +github.com/fxamacker/cbor/v2 v2.5.0/go.mod h1:TA1xS00nchWmaBnEIxPSE5oHLuJBAVvqrtAnWBwBCVo= github.com/gabriel-vasile/mimetype v1.4.7 h1:SKFKl7kD0RiPdbht0s7hFtjl489WcQ1VyPW8ZzUMYCA= github.com/gabriel-vasile/mimetype v1.4.7/go.mod h1:GDlAgAyIRT27BhFl53XNAFtfjzOkLaF35JdEG0P7LtU= github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= @@ -17,8 +17,6 @@ github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/o github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= -github.com/go-playground/validator/v10 v10.22.1 h1:40JcKH+bBNGFczGuoBYgX4I6m/i27HYW8P9FDk5PbgA= -github.com/go-playground/validator/v10 v10.22.1/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM= github.com/go-playground/validator/v10 v10.23.0 h1:/PwmTwZhS0dPkav3cdK9kV1FsAmrL8sThn8IHr/sO+o= github.com/go-playground/validator/v10 v10.23.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM= github.com/goccy/go-json v0.10.3 h1:KZ5WoDbxAIgm2HNbYckL0se1fHD6rz5j4ywS6ebzDqA= @@ -33,8 +31,6 @@ github.com/lestrrat-go/httprc v1.0.6 h1:qgmgIRhpvBqexMJjA/PmwSvhNk679oqD1RbovdCG github.com/lestrrat-go/httprc v1.0.6/go.mod h1:mwwz3JMTPBjHUkkDv/IGJ39aALInZLrhBp0X7KGUZlo= github.com/lestrrat-go/iter v1.0.2 h1:gMXo1q4c2pHmC3dn8LzRhJfP1ceCbgSiT9lUydIzltI= github.com/lestrrat-go/iter v1.0.2/go.mod h1:Momfcq3AnRlRjI5b5O8/G5/BvpzrhoFTZcn06fEOPt4= -github.com/lestrrat-go/jwx/v2 v2.1.1 h1:Y2ltVl8J6izLYFs54BVcpXLv5msSW4o8eXwnzZLI32E= -github.com/lestrrat-go/jwx/v2 v2.1.1/go.mod h1:4LvZg7oxu6Q5VJwn7Mk/UwooNRnTHUpXBj2C4j3HNx0= github.com/lestrrat-go/jwx/v2 v2.1.3 h1:Ud4lb2QuxRClYAmRleF50KrbKIoM1TddXgBrneT5/Jo= github.com/lestrrat-go/jwx/v2 v2.1.3/go.mod h1:q6uFgbgZfEmQrfJfrCo90QcQOcXFMfbI/fO0NqRtvZo= github.com/lestrrat-go/option v1.0.1 h1:oAzP2fvZGQKWkvHa1/SAcFolBEca1oN+mQ7eooNBEYU= @@ -50,20 +46,16 @@ github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw= -golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U= +github.com/veraison/go-cose v1.3.0 h1:2/H5w8kdSpQJyVtIhx8gmwPJ2uSz1PkyWFx0idbd7rk= +github.com/veraison/go-cose v1.3.0/go.mod h1:df09OV91aHoQWLmy1KsDdYiagtXgyAwAl8vFeFn1gMc= +github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM= +github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg= golang.org/x/crypto v0.30.0 h1:RwoQn3GkWiMkzlX562cLB7OxWvjH1L8xutO2WoJcRoY= golang.org/x/crypto v0.30.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk= -golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4= -golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU= golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= -golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo= -golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM= -golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/implementations/independent/issue.go b/implementations/independent/issue.go index 5ea1bdf..edd390d 100644 --- a/implementations/independent/issue.go +++ b/implementations/independent/issue.go @@ -1,8 +1,10 @@ package main import ( + "encoding/base64" "fmt" "github.com/decentralgabe/vc-jose-cose-go/cid" + "github.com/decentralgabe/vc-jose-cose-go/cose" "github.com/decentralgabe/vc-jose-cose-go/credential" "github.com/decentralgabe/vc-jose-cose-go/jose" "github.com/goccy/go-json" @@ -18,7 +20,9 @@ func Issue(inputFile, keyFile string, feature Feature) (*Result, error) { if err != nil { return nil, fmt.Errorf("error reading input file: %v", err) } - + if len(inputBytes) == 0 { + return nil, fmt.Errorf("input file is empty") + } fmt.Printf("Successfully read input file. Content length: %d bytes\n", len(inputBytes)) // Read and parse the key file @@ -26,7 +30,7 @@ func Issue(inputFile, keyFile string, feature Feature) (*Result, error) { if err != nil { return nil, fmt.Errorf("error reading key file: %v", err) } - if keyBytes == nil { + if len(keyBytes) == 0 { return nil, fmt.Errorf("key file is empty") } @@ -51,7 +55,6 @@ func IssueCredential(credBytes, keyBytes []byte, feature Feature) (*Result, erro if err := json.Unmarshal(keyBytes, &vm); err != nil { return nil, fmt.Errorf("error unmarshaling verifcation method: %v", err) } - fmt.Printf("%+v\n", vm) switch feature { case JOSECredential: @@ -107,7 +110,18 @@ func IssueJOSECredential(cred credential.VerifiableCredential, key jwk.Key) (*Re } func IssueCOSECredential(cred credential.VerifiableCredential, key jwk.Key) (*Result, error) { - return nil, nil + cs1, err := cose.SignVerifiableCredential(cred, key) + if err != nil { + fmt.Printf("error signing credential: %v", err) + return &Result{Result: Failure}, nil + } + if cs1 == nil { + return &Result{Result: Failure}, nil + } + return &Result{ + Result: Success, + Data: base64.RawStdEncoding.EncodeToString(cs1), + }, nil } func IssueSDJWTCredential(cred credential.VerifiableCredential, key jwk.Key) (*Result, error) { @@ -131,7 +145,18 @@ func IssueJOSEPresentation(pres credential.VerifiablePresentation, key jwk.Key) } func IssueCOSEPresentation(pres credential.VerifiablePresentation, key jwk.Key) (*Result, error) { - return nil, nil + cs1, err := cose.SignVerifiablePresentation(pres, key) + if err != nil { + fmt.Printf("error signing presentation: %v", err) + return &Result{Result: Failure}, nil + } + if cs1 == nil { + return &Result{Result: Failure}, nil + } + return &Result{ + Result: Success, + Data: base64.RawStdEncoding.EncodeToString(cs1), + }, nil } func IssueSDJWTPresentation(pres credential.VerifiablePresentation, key jwk.Key) (*Result, error) { diff --git a/implementations/independent/main.go b/implementations/independent/main.go index 6b61d9b..9ec2e78 100644 --- a/implementations/independent/main.go +++ b/implementations/independent/main.go @@ -81,15 +81,14 @@ func main() { validateFlags(input, key, feature, output) result, err := Verify(input, key, Feature(feature)) - if err != nil { + if err != nil || result == nil { fmt.Printf("error verifying %s: %s\n", feature, err.Error()) - // Write failure result to output file writeEmptyResult(Failure, output) os.Exit(1) } // Write the result to the output file - writeEmptyResult(*result, output) + writeResult(*result, output) fmt.Printf("Successfully wrote output to file\n") default: fmt.Println("expected 'issue' or 'verify' command") diff --git a/implementations/independent/verify.go b/implementations/independent/verify.go index c3b083b..d070662 100644 --- a/implementations/independent/verify.go +++ b/implementations/independent/verify.go @@ -1,11 +1,18 @@ package main import ( + "encoding/base64" "fmt" + "github.com/decentralgabe/vc-jose-cose-go/cid" + "github.com/decentralgabe/vc-jose-cose-go/cose" + "github.com/decentralgabe/vc-jose-cose-go/jose" + "github.com/goccy/go-json" + "github.com/lestrrat-go/jwx/v2/jwk" + "github.com/pkg/errors" "os" ) -func Verify(inputFile, keyFile string, feature Feature) (*Status, error) { +func Verify(inputFile, keyFile string, feature Feature) (*Result, error) { fmt.Printf("Attempting to read input file: %s\n", inputFile) // Read and parse the input file @@ -13,6 +20,10 @@ func Verify(inputFile, keyFile string, feature Feature) (*Status, error) { if err != nil { return nil, fmt.Errorf("error reading input file: %v", err) } + if len(inputBytes) == 0 { + return nil, fmt.Errorf("input file is empty") + } + inputStr := string(inputBytes) fmt.Printf("Successfully read input file. Content length: %d bytes\n", len(inputBytes)) @@ -25,46 +36,86 @@ func Verify(inputFile, keyFile string, feature Feature) (*Status, error) { return nil, fmt.Errorf("key file is empty") } + var vm cid.VerificationMethod + if err := json.Unmarshal(keyBytes, &vm); err != nil { + return nil, fmt.Errorf("error unmarshaling verifcation method: %v", err) + } + switch feature { case JOSECredential: - return VerifyJOSECredential(inputBytes, keyBytes) + return VerifyJOSECredential(inputStr, vm.PublicKeyJWK) case COSECredential: - return VerifyCOSECredential(inputBytes, keyBytes) + return VerifyCOSECredential(inputStr, vm.PublicKeyJWK) case SDJWTCredential: - return VerifySDJWTCredential(inputBytes, keyBytes) + return VerifySDJWTCredential(inputStr, vm.PublicKeyJWK) case JOSEPresentation: - return VerifyJOSEPresentation(inputBytes, keyBytes) + return VerifyJOSEPresentation(inputStr, vm.PublicKeyJWK) case COSEPresentation: - return VerifyCOSEPresentation(inputBytes, keyBytes) + return VerifyCOSEPresentation(inputStr, vm.PublicKeyJWK) case SDJWTPresentation: - return VerifySDJWTPresentation(inputBytes, keyBytes) + return VerifySDJWTPresentation(inputStr, vm.PublicKeyJWK) default: - i := Indeterminate fmt.Printf("unsupported feature: %s\n", feature) - return &i, nil + return &Result{Result: Indeterminate}, nil } } -func VerifyJOSECredential(credBytes, keyBytes []byte) (*Status, error) { - return nil, nil +func VerifyJOSECredential(credStr string, key jwk.Key) (*Result, error) { + cred, err := jose.VerifyVerifiableCredential(credStr, key) + if err != nil { + return &Result{Result: Failure, Data: fmt.Sprintf("error verifying JOSE credential: %v", err)}, nil + } + if cred == nil { + return &Result{Result: Failure, Data: "JOSE credential is invalid"}, nil + } + return &Result{Result: Success}, nil } -func VerifyCOSECredential(credBytes, keyBytes []byte) (*Status, error) { - return nil, nil +func VerifyCOSECredential(credStr string, key jwk.Key) (*Result, error) { + credBytes, err := base64.RawStdEncoding.DecodeString(credStr) + if err != nil { + return nil, errors.Wrap(err, "error decoding base64 encoded COSE credential") + } + cred, err := cose.VerifyVerifiableCredential(credBytes, key) + if err != nil { + return &Result{Result: Failure, Data: fmt.Sprintf("error verifying COSE credential: %v", err)}, nil + } + if cred == nil { + return &Result{Result: Failure, Data: "COSE credential is invalid"}, nil + } + return &Result{Result: Success}, nil } -func VerifySDJWTCredential(credBytes, keyBytes []byte) (*Status, error) { +func VerifySDJWTCredential(credStr string, key jwk.Key) (*Result, error) { return nil, nil } -func VerifyJOSEPresentation(presBytes, keyBytes []byte) (*Status, error) { - return nil, nil +func VerifyJOSEPresentation(presStr string, key jwk.Key) (*Result, error) { + pres, err := jose.VerifyVerifiablePresentation(presStr, key) + if err != nil { + return &Result{Result: Failure, Data: fmt.Sprintf("error verifying JOSE presentation: %v", err)}, nil + } + if pres == nil { + return &Result{Result: Failure, Data: "JOSE presentation is invalid"}, nil + } + return &Result{Result: Success}, nil } -func VerifyCOSEPresentation(presBytes, keyBytes []byte) (*Status, error) { - return nil, nil +func VerifyCOSEPresentation(presStr string, key jwk.Key) (*Result, error) { + presBytes, err := base64.RawStdEncoding.DecodeString(presStr) + if err != nil { + return nil, errors.Wrap(err, "error decoding base64 encoded COSE presentation") + } + pres, err := cose.VerifyVerifiablePresentation(presBytes, key) + if err != nil { + return &Result{Result: Failure, Data: fmt.Sprintf("error verifying COSE presentation: %v", err)}, nil + } + if pres == nil { + return &Result{Result: Failure, Data: "COSE presentation is invalid"}, nil + } + return &Result{Result: Success}, nil } -func VerifySDJWTPresentation(presBytes, keyBytes []byte) (*Status, error) { +func VerifySDJWTPresentation(presStr string, key jwk.Key) (*Result, error) { return nil, nil } diff --git a/tests/README.md b/tests/README.md index 5c553b0..5523863 100644 --- a/tests/README.md +++ b/tests/README.md @@ -195,4 +195,4 @@ Following, are a set of test cases which describe how the statements are to be t 21. Extension Processing * Input: Credentials of different formats with unknown extensions * Format: jose, cose, sd-jwt - * Covers: 26, 31, 33 \ No newline at end of file + * Covers: 26, 31, 33 diff --git a/tests/input/credential-issuer-match-signed.json b/tests/input/credential-issuer-match-signed.json new file mode 100644 index 0000000..bc1c0c7 --- /dev/null +++ b/tests/input/credential-issuer-match-signed.json @@ -0,0 +1 @@ +eyJhbGciOiJFZERTQSIsImN0eSI6InZjIiwia2lkIjoiMmFPSGFReHNXVlQ0bUxzVWtkdGxDblVWLWF1MEJCUi01eVBZYVBhQ2M1ayIsInR5cCI6InZjK2p3dCJ9.eyJAY29udGV4dCI6WyJodHRwczovL3d3dy53My5vcmcvbnMvY3JlZGVudGlhbHMvdjIiLCJodHRwczovL3d3dy53My5vcmcvbnMvY3JlZGVudGlhbHMvZXhhbXBsZXMvdjIiXSwiY3JlZGVudGlhbFNjaGVtYSI6eyJpZCI6Imh0dHBzOi8vZXhhbXBsZS5vcmcvZXhhbXBsZXMvZGVncmVlLmpzb24iLCJ0eXBlIjoiSnNvblNjaGVtYSJ9LCJjcmVkZW50aWFsU3ViamVjdCI6eyJkZWdyZWUiOnsibmFtZSI6IkJhY2hlbG9yIG9mIFNjaWVuY2UgYW5kIEFydHMiLCJ0eXBlIjoiQmFjaGVsb3JEZWdyZWUifSwiaWQiOiJkaWQ6ZXhhbXBsZToxMjMifSwiaWF0IjoiMjAxMC0wMS0wMVQxOToyMzoyNFoiLCJpZCI6Imh0dHA6Ly91bml2ZXJzaXR5LmV4YW1wbGUvY3JlZGVudGlhbHMvMTg3MiIsImlzcyI6Imh0dHBzOi8vZXhhbXBsZS5pc3N1ZXIvdmMtam9zZS1jb3NlIiwiaXNzdWVyIjoiaHR0cHM6Ly9leGFtcGxlLmlzc3Vlci92Yy1qb3NlLWNvc2UiLCJqdGkiOiJodHRwOi8vdW5pdmVyc2l0eS5leGFtcGxlL2NyZWRlbnRpYWxzLzE4NzIiLCJ0eXBlIjpbIlZlcmlmaWFibGVDcmVkZW50aWFsIiwiRXhhbXBsZUFsdW1uaUNyZWRlbnRpYWwiXSwidmFsaWRGcm9tIjoiMjAxMC0wMS0wMVQxOToyMzoyNFoifQ.Ar5J3jlPCjXpZy055JDSPGF6mF46XnNZ5QaqGvLrtHjI2pwbGU2j9X0W3KNiKs71n_mfFSghfuy-cPjIRu9CAw \ No newline at end of file diff --git a/tests/input/credential-minimal-signed.json b/tests/input/credential-minimal-signed.json new file mode 100644 index 0000000..0829f8d --- /dev/null +++ b/tests/input/credential-minimal-signed.json @@ -0,0 +1 @@ +eyJhbGciOiJFUzI1NiIsImN0eSI6InZjIiwia2lkIjoiNzN2b01YRk5tTmxPRXB1WUNTSmxoOGVOMGRzY3lrb082Z0J1a2dSUzF1VSIsInR5cCI6InZjK2p3dCJ9.eyJAY29udGV4dCI6WyJodHRwczovL3d3dy53My5vcmcvbnMvY3JlZGVudGlhbHMvdjIiLCJodHRwczovL3d3dy53My5vcmcvbnMvY3JlZGVudGlhbHMvZXhhbXBsZXMvdjIiXSwiY3JlZGVudGlhbFNjaGVtYSI6eyJpZCI6Imh0dHBzOi8vZXhhbXBsZS5vcmcvZXhhbXBsZXMvZGVncmVlLmpzb24iLCJ0eXBlIjoiSnNvblNjaGVtYSJ9LCJjcmVkZW50aWFsU3ViamVjdCI6eyJkZWdyZWUiOnsibmFtZSI6IkJhY2hlbG9yIG9mIFNjaWVuY2UgYW5kIEFydHMiLCJ0eXBlIjoiQmFjaGVsb3JEZWdyZWUifSwiaWQiOiJkaWQ6ZXhhbXBsZToxMjMifSwiaWF0IjoiMjAxMC0wMS0wMVQxOToyMzoyNFoiLCJpZCI6Imh0dHA6Ly91bml2ZXJzaXR5LmV4YW1wbGUvY3JlZGVudGlhbHMvMTg3MiIsImlzcyI6Imh0dHBzOi8vZXhhbXBsZS5pc3N1ZXIvdmMtam9zZS1jb3NlIiwiaXNzdWVyIjoiaHR0cHM6Ly9leGFtcGxlLmlzc3Vlci92Yy1qb3NlLWNvc2UiLCJqdGkiOiJodHRwOi8vdW5pdmVyc2l0eS5leGFtcGxlL2NyZWRlbnRpYWxzLzE4NzIiLCJ0eXBlIjpbIlZlcmlmaWFibGVDcmVkZW50aWFsIiwiRXhhbXBsZUFsdW1uaUNyZWRlbnRpYWwiXSwidmFsaWRGcm9tIjoiMjAxMC0wMS0wMVQxOToyMzoyNFoifQ.-X6A--TnCgeepna-dXn7j6_q2DfQzjiYdEc-pbaHR38JUIv5ubhjYp2Tb_LJuJInzI7qKfP-JcMlHdd6bDnOLw \ No newline at end of file diff --git a/tests/input/presentation-multiple-signed.json b/tests/input/presentation-multiple-signed.json new file mode 100644 index 0000000..c8b9011 --- /dev/null +++ b/tests/input/presentation-multiple-signed.json @@ -0,0 +1 @@ +eyJhbGciOiJFUzM4NCIsImN0eSI6InZwIiwia2lkIjoiOTZxQm5EcHZTNng4WVNDSF94bW5MbFhaTWtEaEhCcjhsajk5dTVhb2c3cyIsInR5cCI6InZwK2p3dCJ9.eyJAY29udGV4dCI6WyJodHRwczovL3d3dy53My5vcmcvbnMvY3JlZGVudGlhbHMvdjIiLCJodHRwczovL3d3dy53My5vcmcvbnMvY3JlZGVudGlhbHMvZXhhbXBsZXMvdjIiXSwiZXhwIjoxNzM0MTMwOTA4LCJob2xkZXIiOiJkaWQ6ZXhhbXBsZTplYmZlYjFmNzEyZWJjNmYxYzI3NmUxMmVjMjEiLCJpYXQiOjE3MzQwNDQ1MDgsImlkIjoidXJuOnV1aWQ6Mzk3ODM0NGYtODU5Ni00YzNhLWE5NzgtOGZjYWJhMzkwM2M1IiwiaXNzIjoiZGlkOmV4YW1wbGU6ZWJmZWIxZjcxMmViYzZmMWMyNzZlMTJlYzIxIiwianRpIjoidXJuOnV1aWQ6Mzk3ODM0NGYtODU5Ni00YzNhLWE5NzgtOGZjYWJhMzkwM2M1IiwidHlwZSI6IlZlcmlmaWFibGVQcmVzZW50YXRpb24iLCJ2ZXJpZmlhYmxlQ3JlZGVudGlhbCI6W3siQGNvbnRleHQiOiJodHRwczovL3d3dy53My5vcmcvbnMvY3JlZGVudGlhbHMvdjIiLCJpZCI6ImRhdGE6YXBwbGljYXRpb24vdmMrand0LGV5SmhiR2NpT2lKRlV6STFOaUo5LmV5SnBjM01pT2lKa2FXUTZaWGhoYlhCc1pUb3hNak1pZlEuLi4uIiwidHlwZSI6IkVudmVsb3BlZFZlcmlmaWFibGVDcmVkZW50aWFsIn0seyJAY29udGV4dCI6Imh0dHBzOi8vd3d3LnczLm9yZy9ucy9jcmVkZW50aWFscy92MiIsImlkIjoiZGF0YTphcHBsaWNhdGlvbi92YytzZC1qd3QsZXlKaGJHY2lPaUpGVXpJMU5pSjkuZXlKcGMzTWlPaUprYVdRNlpYaGhiWEJzWlRveE1qTWlmUS4uLi5-IiwidHlwZSI6IkVudmVsb3BlZFZlcmlmaWFibGVDcmVkZW50aWFsIn0seyJAY29udGV4dCI6Imh0dHBzOi8vd3d3LnczLm9yZy9ucy9jcmVkZW50aWFscy92MiIsImlkIjoiZGF0YTphcHBsaWNhdGlvbi92Yytjb3NlO2Jhc2U2NCwwb1JEb1FFbS4uLiIsInR5cGUiOiJFbnZlbG9wZWRWZXJpZmlhYmxlQ3JlZGVudGlhbCJ9XX0.WdfRJ69ALOItbkHFlCZuQ-JycvX9s-LZ2PebMo_LlXhm9Wgm3e7CUDq96Br3h8Ylg2PLmaGi8bqp_NfHaHP9QxgN5p_wo0lR5So16RMlsVJYZrdYS6xfEY_verp80CQl \ No newline at end of file diff --git a/tests/test-mapping.js b/tests/test-mapping.js index ede0971..3ee498c 100644 --- a/tests/test-mapping.js +++ b/tests/test-mapping.js @@ -38,7 +38,7 @@ export const TestError = { // See README.md for details export const JOSETestMapping = { - 'JWT Basic Credential Issuance': { + '1. JWT Basic Credential Issuance': { 'number': 1, 'input_file': 'credential-minimal.json', 'key_file': TestVerificationMethods.p256, @@ -53,7 +53,7 @@ export const JOSETestMapping = { // }, }, - 'JWT Complex Credential Issuance': { + '2. JWT Complex Credential Issuance': { 'number': 2, 'input_file': 'credential-full.json', 'key_file': TestVerificationMethods.p384, @@ -68,7 +68,7 @@ export const JOSETestMapping = { // }, }, - 'JWT Basic Presentation Issuance': { + '3. JWT Basic Presentation Issuance': { 'number': 3, 'input_file': 'presentation-single.json', 'key_file': TestVerificationMethods.p256, @@ -83,7 +83,7 @@ export const JOSETestMapping = { // }, }, - 'JWT Complex Presentation Issuance': { + '4. JWT Complex Presentation Issuance': { 'number': 4, 'input_file': 'presentation-multiple.json', 'key_file': TestVerificationMethods.p521, @@ -98,7 +98,7 @@ export const JOSETestMapping = { // }, }, - 'JWT Basic Credential Verification': { + '5. JWT Basic Credential Verification': { 'number': 5, 'input_file': 'credential-minimal-signed.json', 'key_file': TestVerificationMethods.p256, @@ -110,7 +110,7 @@ export const JOSETestMapping = { // }, }, - 'JWT Presentation Verification': { + '6. JWT Presentation Verification': { 'number': 6, 'input_file': 'presentation-multiple-signed.json', 'key_file': TestVerificationMethods.p384, @@ -122,9 +122,9 @@ export const JOSETestMapping = { // }, }, - 'JWT Issuer Match Verification': { + '7. JWT Issuer Match Verification': { 'number': 7, - 'input_file': 'credential-issuer-match.json', + 'input_file': 'credential-issuer-match-signed.json', 'key_file': TestVerificationMethods.ed25519, 'fn': TestFunction.verify, 'feature': TestFeature.credential_jose, @@ -137,7 +137,7 @@ export const JOSETestMapping = { }; export const SDJWTTestMapping = { - 'SD-JWT Basic Credential Issuance': { + '8. SD-JWT Basic Credential Issuance': { 'number': 9, 'input_file': 'credential-selective.json', 'key_file': TestVerificationMethods.p384, @@ -156,7 +156,7 @@ export const SDJWTTestMapping = { // }, }, - 'SD-JWT Complex Credential Issuance': { + '9. SD-JWT Complex Credential Issuance': { 'number': 10, 'input_file': 'credential-nested-selective.json', 'key_file': TestVerificationMethods.p521, @@ -181,9 +181,9 @@ export const SDJWTTestMapping = { }; export const COSETestMapping = { - 'COSE Basic Credential Issuance': { + '10. COSE Basic Credential Issuance': { 'number': 15, - 'input_file': 'credential-cose.json', + 'input_file': 'credential-minimal.json', 'key_file': TestVerificationMethods.p256, 'fn': TestFunction.issue, 'feature': TestFeature.credential_cose, @@ -196,9 +196,9 @@ export const COSETestMapping = { // }, }, - 'COSE Presentation': { + '11. COSE Presentation': { 'number': 18, - 'input_file': 'presentation-cose.json', + 'input_file': 'presentation-single.json', 'key_file': TestVerificationMethods.p384, 'fn': TestFunction.issue, 'feature': TestFeature.presentation_cose,