Skip to content

Commit

Permalink
feat: add data integrity signature types (#1825)
Browse files Browse the repository at this point in the history
Signed-off-by: Andrii Holovko <andriy.holovko@gmail.com>
  • Loading branch information
aholovko authored Dec 20, 2024
1 parent c3888ab commit 8d5b3bf
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 1 deletion.
7 changes: 7 additions & 0 deletions pkg/doc/verifiable/signaturetype.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (

"github.com/samber/lo"
"github.com/trustbloc/kms-go/spi/kms"
"github.com/trustbloc/vc-go/dataintegrity/suite/ecdsa2019"
"github.com/trustbloc/vc-go/dataintegrity/suite/eddsa2022"
)

// SignatureType type of signature used to sign vc.
Expand Down Expand Up @@ -70,6 +72,11 @@ var signatureTypes = []signatureTypeDesc{
kms.ECDSASecp256k1TypeIEEEP1363, kms.ECDSAP256TypeDER, kms.ECDSAP384TypeDER, kms.RSAPS256Type,
}},

{ecdsa2019.SuiteType, Ldp, []kms.KeyType{kms.ECDSAP256TypeIEEEP1363, kms.ECDSAP384TypeIEEEP1363}},
{ecdsa2019.SuiteTypeNew, Ldp, []kms.KeyType{kms.ECDSAP256TypeIEEEP1363, kms.ECDSAP384TypeIEEEP1363}},
{eddsa2022.SuiteType, Ldp, []kms.KeyType{kms.ED25519Type}},
{eddsa2022.SuiteType2, Ldp, []kms.KeyType{kms.ED25519Type}},

{EdDSA, Jwt, []kms.KeyType{kms.ED25519Type}},
{ES256K, Jwt, []kms.KeyType{kms.ECDSASecp256k1TypeIEEEP1363,
kms.ECDSASecp256k1DER}},
Expand Down
2 changes: 1 addition & 1 deletion pkg/doc/verifiable/signaturetype_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func TestGetSignatureTypesByKeyTypeFormat(t *testing.T) {
require.Equal(t, EdDSA, sigTypes[0])

sigTypes = GetSignatureTypesByKeyTypeFormat(kms.ED25519Type, Ldp)
require.Len(t, sigTypes, 3)
require.Len(t, sigTypes, 5)
require.Contains(t, sigTypes, Ed25519Signature2018)
require.Contains(t, sigTypes, Ed25519Signature2020)
require.Contains(t, sigTypes, JSONWebSignature2020)
Expand Down
56 changes: 56 additions & 0 deletions pkg/service/oidc4vp/oidc4vp_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1938,11 +1938,15 @@ func Test_GetSupportedVPFormats(t *testing.T) {
"Ed25519Signature2018",
"Ed25519Signature2020",
"JsonWebSignature2020",
"eddsa-rdfc-2022",
"eddsa-2022",
}},
LdpVP: &presexch.LdpType{ProofType: []string{
"Ed25519Signature2018",
"Ed25519Signature2020",
"JsonWebSignature2020",
"eddsa-rdfc-2022",
"eddsa-2022",
}},
},
},
Expand Down Expand Up @@ -1974,6 +1978,58 @@ func Test_GetSupportedVPFormats(t *testing.T) {
LdpVP: nil,
},
},
{
name: "Ldp VC and VP with ECDSA P-256",
args: args{
kmsSupportedKeyTypes: []kms.KeyType{
kms.ECDSAP256TypeIEEEP1363,
},
supportedVPFormats: []vcsverifiable.Format{
vcsverifiable.Ldp,
},
supportedVCFormats: []vcsverifiable.Format{
vcsverifiable.Ldp,
},
},
want: &presexch.Format{
JwtVC: nil,
JwtVP: nil,
LdpVC: &presexch.LdpType{ProofType: []string{
"ecdsa-2019",
"ecdsa-rdfc-2019",
}},
LdpVP: &presexch.LdpType{ProofType: []string{
"ecdsa-2019",
"ecdsa-rdfc-2019",
}},
},
},
{
name: "Ldp VC and VP with ECDSA P-384",
args: args{
kmsSupportedKeyTypes: []kms.KeyType{
kms.ECDSAP384TypeIEEEP1363,
},
supportedVPFormats: []vcsverifiable.Format{
vcsverifiable.Ldp,
},
supportedVCFormats: []vcsverifiable.Format{
vcsverifiable.Ldp,
},
},
want: &presexch.Format{
JwtVC: nil,
JwtVP: nil,
LdpVC: &presexch.LdpType{ProofType: []string{
"ecdsa-2019",
"ecdsa-rdfc-2019",
}},
LdpVP: &presexch.LdpType{ProofType: []string{
"ecdsa-2019",
"ecdsa-rdfc-2019",
}},
},
},
}

for _, tt := range tests {
Expand Down

0 comments on commit 8d5b3bf

Please sign in to comment.