Documentation
¶
Index ¶
- Constants
- Variables
- func ToPubKey(s string) (crypto.PubKey, error)
- type DID
- func FromPrivKey(privKey crypto.PrivKey) (DID, error)
- func FromPubKey(pubKey crypto.PubKey) (DID, error)
- func GenerateECDSA() (crypto.PrivKey, DID, error)
- func GenerateECDSAWithCurve(code multicodec.Code) (crypto.PrivKey, DID, error)
- func GenerateEd25519() (crypto.PrivKey, DID, error)
- func GenerateRSA() (crypto.PrivKey, DID, error)
- func GenerateSecp256k1() (crypto.PrivKey, DID, error)
- func MustParse(str string) DID
- func Parse(str string) (DID, error)
Constants ¶
const ( X25519 = multicodec.X25519Pub Ed25519 = multicodec.Ed25519Pub // UCAN required/recommended P256 = multicodec.P256Pub // UCAN required P384 = multicodec.P384Pub P521 = multicodec.P521Pub Secp256k1 = multicodec.Secp256k1Pub // UCAN required RSA = multicodec.RsaPub )
Signature algorithms from the did:key specification
Variables ¶
var Undef = DID{}
Undef can be used to represent a nil or undefined DID, using DID{} directly is also acceptable.
Functions ¶
Types ¶
type DID ¶
type DID struct {
// contains filtered or unexported fields
}
DID is a Decentralized Identifier of the did:key type, directly holding a cryptographic public key. [did:key format]: https://w3c-ccg.github.io/did-method-key/
func FromPrivKey ¶
FromPrivKey is a convenience function that returns the DID associated with the public key associated with the provided private key.
func FromPubKey ¶
FromPubKey returns a did:key constructed from the provided public key.
func GenerateECDSA ¶
GenerateECDSA generates an ECDSA private key and the matching DID for the default P256 curve.
func GenerateECDSAWithCurve ¶
GenerateECDSAWithCurve generates an ECDSA private key and matching DID for the user-supplied curve
func GenerateEd25519 ¶
GenerateEd25519 generates an Ed25519 private key and the matching DID. This is the RECOMMENDED algorithm.
func GenerateRSA ¶
GenerateRSA generates a RSA private key and the matching DID.
func GenerateSecp256k1 ¶
GenerateEd25519 generates a Secp256k1 private key and the matching DID.
func Parse ¶
Parse returns the DID from the string representation or an error if the prefix and method are incorrect, if an unknown encryption algorithm is specified or if the method-specific-identifier's bytes don't represent a public key for the specified encryption algorithm.