Documentation ¶
Index ¶
- Constants
- func CreateDIDKey(pubKey []byte) (string, string)
- func CreateDIDKeyByCode(code uint64, pubKey []byte) (string, string)
- func CreateDIDKeyByJwk(jsonWebKey *jwk.JWK) (string, string, error)
- func KeyFingerprint(code uint64, pubKeyValue []byte) string
- func PubKeyFromDIDKey(didKey string) ([]byte, error)
- func PubKeyFromFingerprint(fingerprint string) ([]byte, uint64, error)
Constants ¶
const ( // X25519PubKeyMultiCodec for Curve25519 public key in multicodec table. // source: https://github.com/multiformats/multicodec/blob/master/table.csv. X25519PubKeyMultiCodec = 0xec // ED25519PubKeyMultiCodec for Ed25519 public key in multicodec table. ED25519PubKeyMultiCodec = 0xed // BLS12381g2PubKeyMultiCodec for BLS12-381 G2 public key in multicodec table. BLS12381g2PubKeyMultiCodec = 0xeb // BLS12381g1g2PubKeyMultiCodec for BLS12-381 G1G2 public key in multicodec table. BLS12381g1g2PubKeyMultiCodec = 0xee // P256PubKeyMultiCodec for NIST P-256 public key in multicodec table. P256PubKeyMultiCodec = 0x1200 // P384PubKeyMultiCodec for NIST P-384 public key in multicodec table. P384PubKeyMultiCodec = 0x1201 // P521PubKeyMultiCodec for NIST P-521 public key in multicodec table. P521PubKeyMultiCodec = 0x1202 )
Variables ¶
This section is empty.
Functions ¶
func CreateDIDKey ¶
CreateDIDKey calls CreateDIDKeyByCode with Ed25519 key code.
func CreateDIDKeyByCode ¶ added in v0.1.6
CreateDIDKeyByCode creates a did:key ID using the multicodec key fingerprint as per the did:key format spec found at: https://w3c-ccg.github.io/did-method-key/#format. It does not parse the contents of 'pubKey'. Use kmsdidkey.BuildDIDKeyByKeyType() for marshalled keys extracted from the KMS instead of this function.
func CreateDIDKeyByJwk ¶ added in v0.1.7
CreateDIDKeyByJwk creates a did:key ID using the multicodec key fingerprint as per the did:key format spec found at: https://w3c-ccg.github.io/did-method-key/#format.
func KeyFingerprint ¶
KeyFingerprint generates a multicode fingerprint for pubKeyValue (raw key []byte). It is mainly used as the controller ID (methodSpecification ID) of a did key.
func PubKeyFromDIDKey ¶ added in v0.1.6
PubKeyFromDIDKey parses the did:key DID and returns the key's raw value. note: for NIST P ECDSA keys, the raw value does not have the compression point.
In order to use elliptic.Unmarshal() with the raw value, the uncompressed point ([]byte{4}) must be prepended. see https://github.com/golang/go/blob/master/src/crypto/elliptic/elliptic.go#L384.
Types ¶
This section is empty.