diff --git a/sdjwt/common/common.go b/sdjwt/common/common.go index 98f8264..a557408 100644 --- a/sdjwt/common/common.go +++ b/sdjwt/common/common.go @@ -82,9 +82,9 @@ type CombinedFormatForIssuance struct { // Serialize will assemble combined format for issuance. func (cf *CombinedFormatForIssuance) Serialize() string { - presentation := cf.SDJWT + presentation := cf.SDJWT + CombinedFormatSeparator for _, disclosure := range cf.Disclosures { - presentation += CombinedFormatSeparator + disclosure + presentation += disclosure + CombinedFormatSeparator } return presentation @@ -103,13 +103,9 @@ type CombinedFormatForPresentation struct { // Serialize will assemble combined format for presentation. func (cf *CombinedFormatForPresentation) Serialize() string { - presentation := cf.SDJWT + presentation := cf.SDJWT + CombinedFormatSeparator for _, disclosure := range cf.Disclosures { - presentation += CombinedFormatSeparator + disclosure - } - - if len(cf.Disclosures) > 0 || cf.HolderVerification != "" { - presentation += CombinedFormatSeparator + presentation += disclosure + CombinedFormatSeparator } presentation += cf.HolderVerification @@ -152,8 +148,8 @@ func ParseCombinedFormatForIssuance(combinedFormatForIssuance string) *CombinedF parts := strings.Split(combinedFormatForIssuance, CombinedFormatSeparator) var disclosures []string - if len(parts) > 1 { - disclosures = parts[1:] + if len(parts) > 2 { + disclosures = parts[1 : len(parts)-1] } sdJWT := parts[0] diff --git a/sdjwt/common/common_test.go b/sdjwt/common/common_test.go index ac3959e..0246a17 100644 --- a/sdjwt/common/common_test.go +++ b/sdjwt/common/common_test.go @@ -70,14 +70,14 @@ func TestParseCombinedFormatForIssuance(t *testing.T) { require.Equal(t, testSDJWT, cfi.SDJWT) require.Equal(t, 0, len(cfi.Disclosures)) - require.Equal(t, testSDJWT, cfi.Serialize()) + require.Equal(t, testSDJWT+CombinedFormatSeparator, cfi.Serialize()) }) } func TestParseCombinedFormatForPresentation(t *testing.T) { const testHolderBinding = "holder.binding.jwt" - testCombinedFormatForPresentation := testCombinedFormatForIssuance + CombinedFormatSeparator + testCombinedFormatForPresentation := testCombinedFormatForIssuance t.Run("success - AFG example", func(t *testing.T) { cfp := ParseCombinedFormatForPresentation(testCombinedFormatForPresentation) @@ -89,11 +89,11 @@ func TestParseCombinedFormatForPresentation(t *testing.T) { }) t.Run("success - spec example", func(t *testing.T) { - cfp := ParseCombinedFormatForPresentation(specCombinedFormatForIssuance + CombinedFormatSeparator) + cfp := ParseCombinedFormatForPresentation(specCombinedFormatForIssuance) require.Equal(t, 7, len(cfp.Disclosures)) require.Empty(t, cfp.HolderVerification) - require.Equal(t, specCombinedFormatForIssuance+CombinedFormatSeparator, cfp.Serialize()) + require.Equal(t, specCombinedFormatForIssuance, cfp.Serialize()) }) t.Run("success - AFG test with holder binding", func(t *testing.T) { @@ -112,7 +112,7 @@ func TestParseCombinedFormatForPresentation(t *testing.T) { require.Equal(t, 0, len(cfp.Disclosures)) require.Empty(t, cfp.HolderVerification) - require.Equal(t, testSDJWT, cfp.Serialize()) + require.Equal(t, testSDJWT+CombinedFormatSeparator, cfp.Serialize()) }) t.Run("success - SD-JWT + holder binding", func(t *testing.T) { @@ -127,7 +127,7 @@ func TestParseCombinedFormatForPresentation(t *testing.T) { }) t.Run("success - SD-JWT + multiple disclosures only", func(t *testing.T) { - specExample2bPresentation := fmt.Sprintf("%s%s", specExample2bJWT, specExample2bDisclosures) + specExample2bPresentation := fmt.Sprintf("%s~%s", specExample2bJWT, specExample2bDisclosures) cfp := ParseCombinedFormatForPresentation(specExample2bPresentation) require.Equal(t, specExample2bJWT, cfp.SDJWT) @@ -230,7 +230,7 @@ func TestGetDisclosureClaims(t *testing.T) { }) t.Run("error - invalid disclosure format (not encoded)", func(t *testing.T) { - sdJWT := ParseCombinedFormatForIssuance(testSDJWT + "~xyz") + sdJWT := ParseCombinedFormatForIssuance(testSDJWT + "~xyz~") require.Equal(t, 1, len(sdJWT.Disclosures)) token, _, err := afjwt.Parse(sdJWT.SDJWT) @@ -250,7 +250,7 @@ func TestGetDisclosureClaims(t *testing.T) { disclosureJSON, err := json.Marshal(disclosureArr) require.NoError(t, err) - sdJWT := ParseCombinedFormatForIssuance(fmt.Sprintf("%s~%s", testSDJWT, + sdJWT := ParseCombinedFormatForIssuance(fmt.Sprintf("%s~%s~", testSDJWT, base64.RawURLEncoding.EncodeToString(disclosureJSON))) require.Equal(t, 1, len(sdJWT.Disclosures)) @@ -271,7 +271,7 @@ func TestGetDisclosureClaims(t *testing.T) { disclosureJSON, err := json.Marshal(disclosureArr) require.NoError(t, err) - sdJWT := ParseCombinedFormatForIssuance(fmt.Sprintf("%s~%s", testSDJWT, + sdJWT := ParseCombinedFormatForIssuance(fmt.Sprintf("%s~%s~", testSDJWT, base64.RawURLEncoding.EncodeToString(disclosureJSON))) require.Equal(t, 1, len(sdJWT.Disclosures)) @@ -1039,14 +1039,14 @@ func (sv *NoopSignatureVerifier) CheckJWTProof(joseHeaders jose.Headers, payload const additionalSDDisclosure = `WyJfMjZiYzRMVC1hYzZxMktJNmNCVzVlcyIsICJmYW1pbHlfbmFtZSIsICJNw7ZiaXVzIl0` const additionalArrayElementDisclosure = `WyJjc3AteWZLWWNTYWlkUElUMHpyOFNRIiwiTWluYXMgVGlyaXRoIl0` -const testCombinedFormatForIssuance = `eyJhbGciOiJFZERTQSJ9.eyJfc2QiOlsicXF2Y3FuY3pBTWdZeDdFeWtJNnd3dHNweXZ5dks3OTBnZTdNQmJRLU51cyJdLCJfc2RfYWxnIjoic2hhLTI1NiIsImV4cCI6MTcwMzAyMzg1NSwiaWF0IjoxNjcxNDg3ODU1LCJpc3MiOiJodHRwczovL2V4YW1wbGUuY29tL2lzc3VlciIsIm5iZiI6MTY3MTQ4Nzg1NX0.vscuzfwcHGi04pWtJCadc4iDELug6NH6YK-qxhY1qacsciIHuoLELAfon1tGamHtuu8TSs6OjtLk3lHE16jqAQ~WyIzanFjYjY3ejl3a3MwOHp3aUs3RXlRIiwgImdpdmVuX25hbWUiLCAiSm9obiJd` // nolint: lll -const testCombinedFormatForIssuanceV5 = `eyJhbGciOiJFZERTQSJ9.eyJfc2RfYWxnIjoic2hhLTI1NiIsImF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reak6vvJVvjXpp-Wk6uxsdEEAKFspt_EYIvISFJhfTuQqyhCjnaW13X312MSQBPwjbHn74ylUqVLljDvqcemxeqjh42KWJq4C3RqNJ7anA2i3FU1kB4-KNZWsijY7-op49iL7BrnIBxdlAMrbHEkoGTbFWdl7Ki17GHtDxxa1jaxQg~WyJkcVR2WE14UzBHYTNEb2FHbmU5eDBRIiwgInN1YiIsICJqb2huX2RvZV80MiJd~WyIzanFjYjY3ejl3a3MwOHp3aUs3RXlRIiwgImdpdmVuX25hbWUiLCAiSm9obiJd~WyJxUVdtakpsMXMxUjRscWhFTkxScnJ3IiwgImZhbWlseV9uYW1lIiwgIkRvZSJd~WyJLVXhTNWhFX1hiVmFjckdBYzdFRnd3IiwgImVtYWlsIiwgImpvaG5kb2VAZXhhbXBsZS5jb20iXQ~WyIzcXZWSjFCQURwSERTUzkzOVEtUml3IiwgInBob25lX251bWJlciIsICIrMS0yMDItNTU1LTAxMDEiXQ~WyIweEd6bjNNaXFzY3RaSV9PcERsQWJRIiwgImFkZHJlc3MiLCB7InN0cmVldF9hZGRyZXNzIjogIjEyMyBNYWluIFN0IiwgImxvY2FsaXR5IjogIkFueXRvd24iLCAicmVnaW9uIjogIkFueXN0YXRlIiwgImNvdW50cnkiOiAiVVMifV0~WyJFUktNMENOZUZKa2FENW1UWFZfWDh3IiwgImJpcnRoZGF0ZSIsICIxOTQwLTAxLTAxIl0~` // Payload represents JWT payload. type payload struct { @@ -1057,7 +1057,7 @@ type payload struct { } const specExample2bJWT = `eyJhbGciOiAiRVMyNTYifQ.eyJfc2QiOiBbIjBsa1NjS2ppSk1IZWRKZnE3c0pCN0hRM3FvbUdmckVMYm81Z1podktSV28iLCAiMWgyOWdnUWkxeG91LV9OalZ5eW9DaEsyYXN3VXRvMlVqQ2ZGLTFMYWhBOCIsICIzQ29MVUxtRHh4VXdfTGR5WUVUanVkdVh1RXBHdUJ5NHJYSG90dUQ0MFg0IiwgIkFJRHlveHgxaXB5NDUtR0ZwS2d2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TUzM2EiXQ~WyJzNFhNSmxXQ2Eza3hDWk4wSVVrbnlBIiwgImNvdW50cnkiLCAiSlAiXQ~` // nolint:lll +const specExample2bDisclosures = `WyJSdHczZUFFUE5wWjIwTkhZSzNNRWNnIiwgImZhbWlseV9uYW1lIiwgIlx1NWM3MVx1NzUzMCJd~WyJicjgxenVSc0NUcXJuWEp4MHVqMkRRIiwgImdpdmVuX25hbWUiLCAiXHU1OTJhXHU5MGNlIl0~WyI1Z2NXRmxWSEM1VVEwbktrallybDlnIiwgImJpcnRoZGF0ZSIsICIxOTQwLTAxLTAxIl0~WyJJTms2bkx4WGFybDF4NmVabHdBOTV3IiwgImVtYWlsIiwgIlwidW51c3VhbCBlbWFpbCBhZGRyZXNzXCJAbmlob24uY29tIl0~WyJNOVY2N3V0UC1hTF9lR1B0UU5hM0RRIiwgInJlZ2lvbiIsICJcdTZlMmZcdTUzM2EiXQ~WyJzNFhNSmxXQ2Eza3hDWk4wSVVrbnlBIiwgImNvdW50cnkiLCAiSlAiXQ~` // nolint:lll const vcSample = ` { diff --git a/sdjwt/example_test.go b/sdjwt/example_test.go index 9281e20..0120d18 100644 --- a/sdjwt/example_test.go +++ b/sdjwt/example_test.go @@ -26,7 +26,7 @@ import ( "github.com/trustbloc/vc-go/sdjwt/verifier" ) -func ExampleSimpleClaims() { //nolint:govet +func SimpleClaims() { //nolint:govet signer, signatureVerifier, err := setUp() if err != nil { fmt.Println("failed to set-up test: %w", err.Error()) @@ -84,7 +84,7 @@ func ExampleSimpleClaims() { //nolint:govet // } } -func ExampleComplexClaimsWithHolderBinding() { //nolint:govet +func ComplexClaimsWithHolderBinding() { //nolint:govet signer, signatureVerifier, err := setUp() if err != nil { fmt.Println("failed to set-up test: %w", err.Error()) @@ -171,7 +171,7 @@ func ExampleComplexClaimsWithHolderBinding() { //nolint:govet // } } -func ExampleComplexObjectWithStructuredClaims() { //nolint:govet +func ComplexObjectWithStructuredClaims() { //nolint:govet signer, signatureVerifier, err := setUp() if err != nil { fmt.Println("failed to set-up test: %w", err.Error()) diff --git a/sdjwt/holder/holder_test.go b/sdjwt/holder/holder_test.go index 846404b..9d9de00 100644 --- a/sdjwt/holder/holder_test.go +++ b/sdjwt/holder/holder_test.go @@ -106,7 +106,7 @@ func TestParse(t *testing.T) { }) t.Run("error - additional disclosure", func(t *testing.T) { - claims, err := Parse(fmt.Sprintf("%s~%s", combinedFormatForIssuance, additionalDisclosure), + claims, err := Parse(fmt.Sprintf("%s%s~", combinedFormatForIssuance, additionalDisclosure), WithSignatureVerifier(verifier)) r.Error(err) r.Nil(claims) @@ -154,7 +154,7 @@ func TestParse(t *testing.T) { }) r.NoError(err) - cfp := specSDJWTV5 + common.CombinedFormatSeparator + holderVerification + cfp := specSDJWTV5 + holderVerification + common.CombinedFormatSeparator claims, err := Parse(cfp, WithSDJWTV5Validation(true), @@ -228,7 +228,7 @@ func TestCreatePresentation(t *testing.T) { combinedFormatForPresentation, err := CreatePresentation(combinedFormatForIssuance, claimsToDisclose) r.NoError(err) require.NotNil(t, combinedFormatForPresentation) - require.Equal(t, combinedFormatForIssuance+common.CombinedFormatSeparator, combinedFormatForPresentation) + require.Equal(t, combinedFormatForIssuance, combinedFormatForPresentation) }) t.Run("success - with holder verification", func(t *testing.T) { @@ -248,7 +248,7 @@ func TestCreatePresentation(t *testing.T) { })) r.NoError(err) r.NotEmpty(combinedFormatForPresentation) - r.Contains(combinedFormatForPresentation, combinedFormatForIssuance+common.CombinedFormatSeparator) + r.Contains(combinedFormatForPresentation, combinedFormatForIssuance) }) t.Run("error - failed to create holder verification due to signing error", func(t *testing.T) { @@ -368,10 +368,10 @@ func createComplexClaims() map[string]interface{} { const additionalDisclosure = `WyIzanFjYjY3ejl3a3MwOHp3aUs3RXlRIiwgImdpdmVuX25hbWUiLCAiSm9obiJd` // nolint: lll -const specSDJWTV2 = `eyJhbGciOiAiUlMyNTYiLCAia2lkIjogImNBRUlVcUowY21MekQxa3pHemhlaUJhZzBZUkF6VmRsZnhOMjg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XhhbXBsZS5lZHUvY3JlZGVudGlhbHMvMTg3MiIsImluZm8iOiJJbmZvIiwiaXNzdWFuY2VEYXRlIjoiMjAyMy0wMS0xN1QyMjozMjoyNy40NjgxMDk4MTcrMDI6MDAiLCJpc3N1ZXIiOiJkaWQ6ZXhhbXBsZTo3NmUxMmVjNzEyZWJjNmYxYzIyMWViZmViMWYiLCJsYXN0X25hbWUiOiJMYXN0IG5hbWUiLCJ0eXBlIjoiVmVyaWZpYWJsZUNyZWRlbnRpYWwifX0.GcfSA6NkONxdsm5Lxj9-988eWx1ZvMz5vJ1uh2x8UK1iKIeQLmhsWpA_34RbtAm2HnuoxW4_ZGeiHBzQ1GLTDQ~WyJFWkVDRVZ1YWVJOXhZWmlWb3VMQldBIiwidHlwZSIsIkJhY2hlbG9yRGVncmVlIl0~WyJyMno1UzZMa25FRTR3TWwteFB0VEx3IiwiZGVncmVlIiwiTUlUIl0~WyJ2VkhfaGhNQy1aSUt5WFdtdDUyOWpnIiwic3BvdXNlIiwiZGlkOmV4YW1wbGU6YzI3NmUxMmVjMjFlYmZlYjFmNzEyZWJjNmYxIl0~WyJrVzh0WVVwbVl1VmRoZktFT050TnFnIiwibmFtZSIsIkpheWRlbiBEb2UiXQ~` diff --git a/sdjwt/verifier/example_test.go b/sdjwt/verifier/example_test.go index 3b6a793..06c3a4c 100644 --- a/sdjwt/verifier/example_test.go +++ b/sdjwt/verifier/example_test.go @@ -15,7 +15,6 @@ import ( "github.com/trustbloc/vc-go/crypto-ext/testutil" "github.com/trustbloc/vc-go/proof/checker" "github.com/trustbloc/vc-go/proof/testsupport" - "github.com/trustbloc/vc-go/sdjwt/common" "github.com/trustbloc/vc-go/sdjwt/holder" "github.com/trustbloc/vc-go/sdjwt/issuer" ) @@ -49,7 +48,7 @@ func ExampleParse() { } // The Holder will disclose all claims. - combinedFormatForPresentation := combinedFormatForIssuance + common.CombinedFormatSeparator + combinedFormatForPresentation := combinedFormatForIssuance // Verifier will validate combined format for presentation and create verified claims. verifiedClaims, err := Parse(combinedFormatForPresentation, diff --git a/sdjwt/verifier/verifier_test.go b/sdjwt/verifier/verifier_test.go index ea1d283..58a92bf 100644 --- a/sdjwt/verifier/verifier_test.go +++ b/sdjwt/verifier/verifier_test.go @@ -70,7 +70,7 @@ func TestParse(t *testing.T) { combinedFormatForIssuance, e := token.Serialize(false) r.NoError(e) - combinedFormatForPresentation := combinedFormatForIssuance + common.CombinedFormatSeparator + combinedFormatForPresentation := combinedFormatForIssuance verifier := testsupport.NewEd25519Verifier(pubKey) @@ -118,7 +118,7 @@ func TestParse(t *testing.T) { rsaCombinedFormatForIssuance, err := rsaToken.Serialize(false) require.NoError(t, err) - cfp := fmt.Sprintf("%s%s", rsaCombinedFormatForIssuance, common.CombinedFormatSeparator) + cfp := rsaCombinedFormatForIssuance claims, err := Parse(cfp, WithSignatureVerifier(v), WithExpectedTypHeader("JWT")) r.NoError(err) @@ -141,7 +141,7 @@ func TestParse(t *testing.T) { cfIssuance, e := tokenWithTimes.Serialize(false) r.NoError(e) - cfPresentation := fmt.Sprintf("%s%s", cfIssuance, common.CombinedFormatSeparator) + cfPresentation := cfIssuance claims, err := Parse(cfPresentation, WithSignatureVerifier(verifier)) r.NoError(err) @@ -167,7 +167,7 @@ func TestParse(t *testing.T) { }) t.Run("error - additional disclosure", func(t *testing.T) { - claims, err := Parse(fmt.Sprintf("%s~%s~", combinedFormatForIssuance, additionalDisclosure), + claims, err := Parse(fmt.Sprintf("%s%s~", combinedFormatForIssuance, additionalDisclosure), WithSignatureVerifier(verifier)) r.Error(err) r.Nil(claims)