diff --git a/crypto/util/secp256k1.go b/crypto/util/secp256k1.go index c8adc31461..720e27e175 100644 --- a/crypto/util/secp256k1.go +++ b/crypto/util/secp256k1.go @@ -17,8 +17,9 @@ var oidNamedCurveP256k1 = asn1.ObjectIdentifier{1, 3, 132, 0, 10} var oidPublicKeyECDSA = asn1.ObjectIdentifier{1, 2, 840, 10045, 2, 1} type asn1PKCS8Container struct { - Algo pkix.AlgorithmIdentifier - Data []byte + Version int + Algo pkix.AlgorithmIdentifier + Data []byte } type asn1ECPrivateKey struct { diff --git a/vdr/api/v1/api.go b/vdr/api/v1/api.go index bfc8e7c6a1..2d9fbd68b1 100644 --- a/vdr/api/v1/api.go +++ b/vdr/api/v1/api.go @@ -95,7 +95,7 @@ func (a *Wrapper) AddNewVerificationMethod(ctx context.Context, request AddNewVe if request.Body.Type == nil { verificationMethodType = ssi.JsonWebKey2020 } else { - verificationMethodType = *request.Body.Type + verificationMethodType = ssi.KeyType(*request.Body.Type) } vm, err := a.DocManipulator.AddVerificationMethod(ctx, *d, opts.ToFlags(didnuts.DefaultCreationOptions().KeyFlags), verificationMethodType) if err != nil { @@ -136,6 +136,9 @@ func (a *Wrapper) CreateDID(ctx context.Context, request CreateDIDRequestObject) if request.Body.SelfControl != nil { options.SelfControl = *request.Body.SelfControl } + if request.Body.Type != nil { + options.VerificationMethodType = ssi.KeyType(*request.Body.Type) + } doc, _, err := a.VDR.Create(ctx, options) // if this operation leads to an error, it may return a 500 diff --git a/vdr/api/v1/types.go b/vdr/api/v1/types.go index 46fce4556c..e8c77bc1eb 100644 --- a/vdr/api/v1/types.go +++ b/vdr/api/v1/types.go @@ -16,7 +16,6 @@ package v1 import ( - ssi "github.com/nuts-foundation/go-did" "github.com/nuts-foundation/go-did/did" "github.com/nuts-foundation/nuts-node/vdr/management" "github.com/nuts-foundation/nuts-node/vdr/resolver" @@ -64,7 +63,7 @@ type VerificationMethodRelationship struct { KeyAgreement *bool `json:"keyAgreement,omitempty"` // KeyType is the type of key to generate. - Type *ssi.KeyType `json:"verificationMethodType,omitempty"` + Type *string `json:"verificationMethodType,omitempty"` } // ToFlags takes default key flags, and enabled/disables the flags which are set on the VerificationMethodRelationship, diff --git a/vdr/cmd/cmd.go b/vdr/cmd/cmd.go index 0b3a3134c7..8e1c2b5de7 100644 --- a/vdr/cmd/cmd.go +++ b/vdr/cmd/cmd.go @@ -71,6 +71,7 @@ func createCmd() *cobra.Command { CapabilityDelegation: new(bool), CapabilityInvocation: new(bool), KeyAgreement: new(bool), + Type: new(string), }, Controllers: new([]string), SelfControl: new(bool), @@ -107,6 +108,7 @@ func createCmd() *cobra.Command { result.Flags().BoolVar(createRequest.KeyAgreement, "keyAgreement", defs.KeyFlags.Is(management.KeyAgreementUsage), setUsage(defs.KeyFlags.Is(management.KeyAgreementUsage), "Pass '%t' to %s keyAgreement capabilities.")) result.Flags().BoolVar(createRequest.SelfControl, "selfControl", defs.SelfControl, setUsage(defs.SelfControl, "Pass '%t' to %s DID Document control.")) result.Flags().StringSliceVar(createRequest.Controllers, "controllers", []string{}, "Comma-separated list of DIDs that can control the generated DID Document.") + result.Flags().StringVar(createRequest.Type, "verificationMethodType", string(defs.VerificationMethodType), "The type of key to generate. Valid values are: JsonWebKey2020, EcdsaSecp256k1VerificationKey2019, Ed25519VerificationKey2018, RsaVerificationKey2018") return result } diff --git a/vdr/didnuts/creator.go b/vdr/didnuts/creator.go index cfc5110fd4..3fa0b84e59 100644 --- a/vdr/didnuts/creator.go +++ b/vdr/didnuts/creator.go @@ -68,9 +68,10 @@ type Creator struct { // DefaultCreationOptions returns the default DIDCreationOptions when creating DID Documents. func DefaultCreationOptions() management.DIDCreationOptions { return management.DIDCreationOptions{ - Controllers: []did.DID{}, - KeyFlags: management.AssertionMethodUsage | management.CapabilityInvocationUsage | management.KeyAgreementUsage, - SelfControl: true, + Controllers: []did.DID{}, + KeyFlags: management.AssertionMethodUsage | management.CapabilityInvocationUsage | management.KeyAgreementUsage, + SelfControl: true, + VerificationMethodType: ssi.JsonWebKey2020, } }