Cryptography implementation for assymetric keys in Node
This library implements some methods for the following key types:
- Ed25519
- X25519
- P-256, prime256v1, Secp256r1
- Secp256k1
createPrivateKey: initialises the private key to a random valueinitialisePrivateKey(Uint8Array): initialise the private key to a set byte arraybytesToHex(Uint8Array): returns abase16/hexencoded string of the byte arrayhexToBytes(string): returns a byte array based on the passed hexadecimal stringhasPublicKey(): returns a boolean depending on the value of the public key byte arraypublicKey(): returns a byte array, empty if no public key is setexportPublicKey(): exports the public key inhexformatsetPublicKey(string): sets the public key based on the hexadecimal string valuehasPrivateKey(): returns a boolean depending on the value of the private key byte arrayprivateKey(): returns a byte array, empty if no private key is setexportPrivateKey(): exports the private key inhexformatsetPrivateKey(string): sets the private key based on the hexadecimal string value
toDIDKey(): exports the key as adid:key:..identifierimportFromDID(string): imports adididentifier. Currently ondid:key:is supportedtoJWK(): exports a JWK object for the public keyalgorithms(): provides a list of signature algorithms implementeddidDocument(): returns the DID document valueimportFromManagedKey(IKey): imports the key from a@veramo/coreIKeystructuresign(string, Uint8Array, string): signs the byte array according to the algorithm (first parameter) and encodes the result according to the last parameter. Usesrawencoding by default, butbase64urlis an often used encodingverify(string, string, Uint8Array): verifies the byte array agains the signature (second parameter) using the algorithm (first parameter)