From 99c45971f5a779134da1d156040ecddf6a9ad648 Mon Sep 17 00:00:00 2001 From: Rein Krul Date: Mon, 20 Nov 2023 13:02:14 +0100 Subject: [PATCH] wip --- vdr/didnuts/creator.go | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/vdr/didnuts/creator.go b/vdr/didnuts/creator.go index 72c413b358..19bccff74f 100644 --- a/vdr/didnuts/creator.go +++ b/vdr/didnuts/creator.go @@ -30,7 +30,7 @@ import ( "github.com/lestrrat-go/jwx/v2/jwk" "github.com/nuts-foundation/go-did/did" - crypto2 "github.com/nuts-foundation/nuts-node/crypto" + nutsCrypto "github.com/nuts-foundation/nuts-node/crypto" ) // MethodName is the DID method name used by Nuts @@ -62,7 +62,7 @@ func CreateDocument() did.Document { // Creator implements the DocCreator interface and can create Nuts DID Documents. type Creator struct { // KeyStore is used for getting a fresh key and use it to generate the Nuts DID - KeyStore crypto2.KeyCreator + KeyStore nutsCrypto.KeyCreator } // DefaultCreationOptions returns the default DIDCreationOptions when creating DID Documents. @@ -77,14 +77,14 @@ func DefaultCreationOptions() management.DIDCreationOptions { // didKIDNamingFunc is a function used to name a key used in newly generated DID Documents. func didKIDNamingFunc(pKey crypto.PublicKey) (string, error) { - return getKIDName(pKey, crypto2.Thumbprint) + return getKIDName(pKey, nutsCrypto.Thumbprint) } // didSubKIDNamingFunc returns a KIDNamingFunc that can be used as param in the KeyStore.New function. // It wraps the KIDNamingFunc with the context of the DID of the document. // It returns a keyID in the form of the documents DID with the new keys thumbprint as fragment. // E.g. for a assertionMethod key that differs from the key the DID document was created with. -func didSubKIDNamingFunc(owningDID did.DID) crypto2.KIDNamingFunc { +func didSubKIDNamingFunc(owningDID did.DID) nutsCrypto.KIDNamingFunc { return func(pKey crypto.PublicKey) (string, error) { return getKIDName(pKey, func(_ jwk.Key) (string, error) { return owningDID.ID, nil @@ -127,14 +127,14 @@ var ErrInvalidOptions = errors.New("create request has invalid combination of op // Create creates a Nuts DID Document with a valid DID id based on a freshly generated keypair. // The key is added to the verificationMethod list and referred to from the Authentication list -func (n Creator) Create(ctx context.Context, options management.DIDCreationOptions) (*did.Document, crypto2.Key, error) { +func (n Creator) Create(ctx context.Context, options management.DIDCreationOptions) (*did.Document, nutsCrypto.Key, error) { // Validate verification method type and derive key type keyType, err := cryptoKeyType(options.VerificationMethodType) if err != nil { return nil, nil, err } - var key crypto2.Key + var key nutsCrypto.Key if options.SelfControl && !options.KeyFlags.Is(management.CapabilityInvocationUsage) { return nil, nil, ErrInvalidOptions @@ -215,17 +215,17 @@ func applyKeyUsage(document *did.Document, keyToAdd *did.VerificationMethod, int } } -func cryptoKeyType(verificationMethodType ssi.KeyType) (crypto2.KeyType, error) { - var keyType crypto2.KeyType +func cryptoKeyType(verificationMethodType ssi.KeyType) (nutsCrypto.KeyType, error) { + var keyType nutsCrypto.KeyType switch verificationMethodType { case ssi.JsonWebKey2020: - keyType = crypto2.ECP256Key + keyType = nutsCrypto.ECP256Key case ssi.ECDSASECP256K1VerificationKey2019: - keyType = crypto2.ECP256k1Key + keyType = nutsCrypto.ECP256k1Key case ssi.ED25519VerificationKey2018: - keyType = crypto2.Ed25519Key + keyType = nutsCrypto.Ed25519Key case ssi.RSAVerificationKey2018: - keyType = crypto2.RSA2048Key + keyType = nutsCrypto.RSA2048Key default: return "", fmt.Errorf("unsupported verification method type: %s", verificationMethodType) }