Documentation ¶
Index ¶
Constants ¶
const ( // Prefix did:key prefix Prefix = "did:key" // Expansion options EnableEncryptionKeyDerivationOption = "EnableEncryptionKeyDerivation" PublicKeyFormatOption = "PublicKeyFormat" )
Variables ¶
var ( EnableEncryptionKeyDerivation = Option{ Name: EnableEncryptionKeyDerivationOption, Value: true, } DisableEncryptionKeyDerivation = Option{ Name: EnableEncryptionKeyDerivationOption, Value: false, } PublicKeyFormatJSONWebKey2020 = Option{ Name: PublicKeyFormatOption, Value: cryptosuite.JSONWebKey2020Type, } PublicKeyFormatMultibase = Option{ Name: PublicKeyFormatOption, Value: cryptosuite.MultikeyType, } )
Functions ¶
func GetSupportedDIDKeyTypes ¶
func IsSupportedDIDKeyType ¶
Types ¶
type DIDKey ¶
type DIDKey string
func CreateDIDKey ¶
CreateDIDKey constructs a did:key from a specific key type and its corresponding public key This method does not attempt to validate that the provided public key is of the specified key type. A safer method is `GenerateDIDKey` which handles key generation based on the provided key type.
func GenerateDIDKey ¶
GenerateDIDKey takes in a key type value that this library supports and constructs a conformant did:key identifier. The function returns the associated private key value cast to the generic golang crypto.PrivateKey interface. To use the private key, it is recommended to re-cast to the associated type. For example, called with the input for a secp256k1 key: privKey, didKey, err := GenerateDIDKey(SECP256k1) if err != nil { ... } // where secp is an import alias to the secp256k1 library we use "github.com/decred/dcrd/dcrec/secp256k1/v4" secpPrivKey, ok := privKey.(secp.PrivateKey) if !ok { ... }
func (DIDKey) Decode ¶
Decode takes a did:key and returns the underlying public key value as bytes, the key type, and a possible error https://w3c-ccg.github.io/did-method-key/#document-creation-algorithm