fingerprint

package
v0.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 9, 2023 License: Apache-2.0 Imports: 9 Imported by: 32

Documentation

Index

Constants

View Source
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

func CreateDIDKey(pubKey []byte) (string, string)

CreateDIDKey calls CreateDIDKeyByCode with Ed25519 key code.

func CreateDIDKeyByCode added in v0.1.6

func CreateDIDKeyByCode(code uint64, pubKey []byte) (string, string)

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

func CreateDIDKeyByJwk(jsonWebKey *jwk.JWK) (string, string, error)

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

func KeyFingerprint(code uint64, pubKeyValue []byte) string

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

func PubKeyFromDIDKey(didKey string) ([]byte, error)

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.

func PubKeyFromFingerprint

func PubKeyFromFingerprint(fingerprint string) ([]byte, uint64, error)

PubKeyFromFingerprint extracts the raw public key from a did:key fingerprint.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL