Skip to content
This repository has been archived by the owner on Dec 12, 2024. It is now read-only.

Commit

Permalink
update to a newer ssi-sdk revision
Browse files Browse the repository at this point in the history
  • Loading branch information
vlad-tim committed Jun 6, 2023
1 parent e20946d commit b41f27a
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 12 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down Expand Up @@ -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=
Expand Down
17 changes: 9 additions & 8 deletions internal/keyaccess/dataintegrity.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -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
}

Expand All @@ -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
}

Expand All @@ -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")
}
Expand All @@ -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")
}
Expand All @@ -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")
}
5 changes: 3 additions & 2 deletions pkg/service/did/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit b41f27a

Please sign in to comment.