diff --git a/go.mod b/go.mod index 9e35407bc..d737f6968 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.20 require ( github.com/BurntSushi/toml v1.2.1 - github.com/TBD54566975/ssi-sdk v0.0.4-alpha.0.20230526191213-380b671c2a1a + github.com/TBD54566975/ssi-sdk v0.0.4-alpha.0.20230601154259-07707db2c404 github.com/alicebob/miniredis/v2 v2.30.2 github.com/ardanlabs/conf v1.5.0 github.com/benbjohnson/clock v1.3.5 @@ -128,7 +128,7 @@ require ( github.com/multiformats/go-base36 v0.2.0 // indirect github.com/multiformats/go-multibase v0.2.0 // indirect github.com/multiformats/go-multicodec v0.9.0 // indirect - github.com/multiformats/go-multihash v0.2.1 // indirect + github.com/multiformats/go-multihash v0.2.2 // indirect github.com/multiformats/go-varint v0.0.7 // indirect github.com/ory/go-acc v0.2.6 // indirect github.com/ory/go-convenience v0.1.0 // indirect diff --git a/go.sum b/go.sum index ec6ee8788..a3a1e620b 100644 --- a/go.sum +++ b/go.sum @@ -37,6 +37,12 @@ github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWX github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= github.com/TBD54566975/ssi-sdk v0.0.4-alpha.0.20230526191213-380b671c2a1a h1:y8dmyhELNtnxolMNjBjddNVGeW0psdzCDoJJJwSBXJI= github.com/TBD54566975/ssi-sdk v0.0.4-alpha.0.20230526191213-380b671c2a1a/go.mod h1:jnnNbOc+tAYoN603vvY7ZGZZ9Kn3VFSu1XK8qUCVSbM= +github.com/TBD54566975/ssi-sdk v0.0.4-alpha.0.20230530142506-7878abde8732 h1:P77jCw/0EBbaFdBd6pnwGjF7ZF/fhGdM79NvzQ0Vl4w= +github.com/TBD54566975/ssi-sdk v0.0.4-alpha.0.20230530142506-7878abde8732/go.mod h1:Lbdhy8ASuiEuRRk/bKbNcwa5VOrejk/CXo+6HESlwxo= +github.com/TBD54566975/ssi-sdk v0.0.4-alpha.0.20230531200025-70d1269416c1 h1:iBKYaZd7dbvgQxRL19fr56MC9Fsyjpd7sw7oWnbeeXI= +github.com/TBD54566975/ssi-sdk v0.0.4-alpha.0.20230531200025-70d1269416c1/go.mod h1:Lbdhy8ASuiEuRRk/bKbNcwa5VOrejk/CXo+6HESlwxo= +github.com/TBD54566975/ssi-sdk v0.0.4-alpha.0.20230601154259-07707db2c404 h1:EwiJaa6rT7HciSJSK1cDhXbwW8jVln0nwm5X+6s0Lxs= +github.com/TBD54566975/ssi-sdk v0.0.4-alpha.0.20230601154259-07707db2c404/go.mod h1:Lbdhy8ASuiEuRRk/bKbNcwa5VOrejk/CXo+6HESlwxo= github.com/ajg/form v0.0.0-20160822230020-523a5da1a92f/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY= github.com/ajstarks/svgo v0.0.0-20180226025133-644b8db467af/go.mod h1:K08gAheRH3/J6wwsYMMT4xOr94bZjxIelGM0+d/wbFw= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= @@ -895,6 +901,8 @@ github.com/multiformats/go-multicodec v0.9.0 h1:pb/dlPnzee/Sxv/j4PmkDRxCOi3hXTz3 github.com/multiformats/go-multicodec v0.9.0/go.mod h1:L3QTQvMIaVBkXOXXtVmYE+LI16i14xuaojr/H7Ai54k= github.com/multiformats/go-multihash v0.2.1 h1:aem8ZT0VA2nCHHk7bPJ1BjUbHNciqZC/d16Vve9l108= github.com/multiformats/go-multihash v0.2.1/go.mod h1:WxoMcYG85AZVQUyRyo9s4wULvW5qrI9vb2Lt6evduFc= +github.com/multiformats/go-multihash v0.2.2 h1:Uu7LWs/PmWby1gkj1S1DXx3zyd3aVabA4FiMKn/2tAc= +github.com/multiformats/go-multihash v0.2.2/go.mod h1:dXgKXCXjBzdscBLk9JkjINiEsCKRVch90MdaGiKsvSM= github.com/multiformats/go-varint v0.0.7 h1:sWSGR+f/eu5ABZA2ZpYKBILXTTs9JWpdEM/nEGOHFS8= github.com/multiformats/go-varint v0.0.7/go.mod h1:r8PUYw/fD/SjBCiKOoDlGF6QawOELpZAu9eioSos/OU= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= diff --git a/internal/keyaccess/dataintegrity.go b/internal/keyaccess/dataintegrity.go index 9fe9696db..c12b4bbaa 100644 --- a/internal/keyaccess/dataintegrity.go +++ b/internal/keyaccess/dataintegrity.go @@ -6,6 +6,7 @@ import ( "github.com/TBD54566975/ssi-sdk/credential" "github.com/TBD54566975/ssi-sdk/crypto/jwx" "github.com/TBD54566975/ssi-sdk/cryptosuite" + "github.com/TBD54566975/ssi-sdk/cryptosuite/jws2020" "github.com/goccy/go-json" "github.com/pkg/errors" ) @@ -15,8 +16,8 @@ import ( // DataIntegrityKeyAccess represents a key access object for data integrity using the JsonWebSignature2020 suite: // https://w3c.github.io/vc-jws-2020/ type DataIntegrityKeyAccess struct { - Signer cryptosuite.JSONWebKeySigner - Verifier cryptosuite.JSONWebKeyVerifier + Signer jws2020.JSONWebKeySigner + Verifier jws2020.JSONWebKeyVerifier CryptoSuite cryptosuite.CryptoSuite } @@ -33,18 +34,18 @@ func NewDataIntegrityKeyAccess(id, kid string, key gocrypto.PrivateKey) (*DataIn if err != nil { return nil, errors.Wrapf(err, "could not convert private key to JWK: %s", kid) } - signer, err := cryptosuite.NewJSONWebKeySigner(id, *privateKeyJWK, cryptosuite.AssertionMethod) + signer, err := jws2020.NewJSONWebKeySigner(id, *privateKeyJWK, cryptosuite.AssertionMethod) if err != nil { return nil, errors.Wrapf(err, "could not create JWK signer: %s", kid) } - verifier, err := cryptosuite.NewJSONWebKeyVerifier(id, *publicKeyJWK) + verifier, err := jws2020.NewJSONWebKeyVerifier(id, *publicKeyJWK) if err != nil { return nil, errors.Wrapf(err, "could not create JWK verifier: %s", kid) } return &DataIntegrityKeyAccess{ Signer: *signer, Verifier: *verifier, - CryptoSuite: cryptosuite.GetJSONWebSignature2020Suite(), + CryptoSuite: jws2020.GetJSONWebSignature2020Suite(), }, nil } @@ -54,7 +55,7 @@ type DataIntegrityJSON struct { Data []byte `json:"data" validate:"required"` } -func (ka DataIntegrityKeyAccess) Sign(payload cryptosuite.Provable) (*DataIntegrityJSON, error) { +func (ka DataIntegrityKeyAccess) Sign(payload cryptosuite.WithEmbeddedProof) (*DataIntegrityJSON, error) { if payload == nil { return nil, errors.New("payload cannot be nil") } @@ -68,7 +69,7 @@ func (ka DataIntegrityKeyAccess) Sign(payload cryptosuite.Provable) (*DataIntegr return &DataIntegrityJSON{Data: signedJSONBytes}, nil } -func (ka DataIntegrityKeyAccess) Verify(payload cryptosuite.Provable) error { +func (ka DataIntegrityKeyAccess) Verify(payload cryptosuite.WithEmbeddedProof) error { if payload == nil { return errors.New("payload cannot be nil") } @@ -82,6 +83,6 @@ func (ka DataIntegrityKeyAccess) SignVerifiablePresentation(_ string, _ credenti return nil, errors.New("not implemented") } -func (ka DataIntegrityKeyAccess) VerifyVerifiablePresentation(_ cryptosuite.Provable) error { +func (ka DataIntegrityKeyAccess) VerifyVerifiablePresentation(_ cryptosuite.WithEmbeddedProof) error { return errors.New("not implemented") } diff --git a/pkg/service/did/web.go b/pkg/service/did/web.go index 5a44b118a..ad3996098 100644 --- a/pkg/service/did/web.go +++ b/pkg/service/did/web.go @@ -61,8 +61,9 @@ func (h *webHandler) CreateDID(ctx context.Context, request CreateDIDRequest) (* didWeb := web.DIDWeb(opts.DIDWebID) - if !didWeb.IsValid() { - return nil, fmt.Errorf("could not resolve did:web DID: %s", didWeb) + err := didWeb.Validate(ctx) + if err != nil { + return nil, errors.Wrap(err, "could not validate did:web") } pubKey, privKey, err := crypto.GenerateKeyByKeyType(request.KeyType)