default

NOT FINAL, DO NOT USE IT FOR CRITICAL APPLICATIONS

f
cryptoToJWK

Utility function: get a JWK representation from a binary crypto key/key pair.

f
cryptoToMultikey

Convert a Crypto Key pair to Multikeys. This function exports the cryptokeys into a JWK Key pair, and uses the JWKToMultikey function.

f
generateKeysJWK

Generate a new public/private key pair in one of the ecdsa/eddsa/RSA crypto algorithms (the term Ed25519 can also be used for eddsa). The result is a pair or JWK format for keys.

f
generateKeysMK

Generate a new public/private key pair in one of the ecdsa or eddsa crypto algorithms (the term Ed25519 can also be used for eddsa). The result is a pair or Multibase formatted keys, i.e., in Multikey.

f
JWKToCrypto

Utility function: get a binary crypto representation from a JWK encoded key/key pair.

T
Multibase

Type for a Multibase

I
Multikey

Pair of keys in Multibase encoding. Using the field names as defined in the Multikey specification.

f
multikeyToCrypto

Convert a multikey pair to Web Crypto. This function decodes the multikey data into JWK using the multikeyToJWK function, and imports the resulting keys into Web Crypto.

lib/crypto.ts

The main crypto operations: encrypt/decrypt and sign/verify. These functions are exported (via index.ts) to the external world.

f
decrypt

Decrypt a ciphertext.

f
encrypt

Encrypt a message.

f
sign

Sign a message.

f
verify

Verify a signature.

lib/hash.ts

Hashing function; useful for crypto users, though not used by the rest of the package.

f
calculateHash

Calculate Hash of a string

lib/keys.ts

Key management operations: creation in binary Crypto, JWK, or Multikey formats. Note that Multikeys are only defined for ecdsa and eddsa; it cannot be used for rsa algorithms.

T
CryptoAlgorithm

Crypto identifier values that are relevant for this package. "rsa" is an alias for "rsa-pss"; "ed25519" is an alias for "eddsa".

f
generateKeys

Generate a private/public key pair in one of the ecdsa/eddsa/RSA crypto algorithms (the term Ed25519 can also be used for eddsa). The result is the WebCrypto format for keys.

f
JWKeyPairToCrypto

Convert a public/private key pair in JWK to WebCrypto's binary representation.

f
JWKeyToCrypto

Convert a JWK key representation of a Key to WebCrypto's representation.

lib/types.ts

Common types for the package

T
BaseEncoding

Base encoding alternatives

T
Crv

Elliptic curves that are used for this package.

T
CryptoPublicKey

Used to overload the key argument for verify and encrypt operations

T
CryptoSecretKey

Used to overload the key argument for sign and decrypt operations. Note that a plain Multibase is not an option; the multikey secret key alone may not contain all necessary information.

T
HashAlgorithm

Crypto hash values that are used for this package. "SHA-256" is the usual default.

I
JWKeyPair
No documentation available
I
KeyOptions

Options to specify details for keys, i.e., the underlying algorithms.

I
OutputOptions

Options for the output of signing/verifying and for encryption/decryption.

lib/utils.ts

Various utility functions; not meant to be exported to the external world...

f
algorithmDataCR

Mapping of the CryptoKey instance and the corresponding terms for the WebCrypto API like sign or verify.

f
bytesToText

Array buffer to text, needed for crypto operations. The text is decoded from UTF-8, which is the default for the WebCrypto API.

f
decodeResult

Decode a string from encoded form. If the text is recognized as Multibase, the encoding format is there, otherwise the options argument rules.

f
encodeResult

Encode the result in base58 or base64, possibly in Multibase. The options argument dictates. Default is base64 encoding and plain output.

f
isCryptoKey

Type guard for a CryptoKey object.

f
isCryptoKeyPair

Type guard for a CryptoKeyPair object.

f
isJWKKeyPair

Type guard for a JWK Key Pair

f
isMultibase

Type guard for a Multibase value.

f
isMultikey

Type guard for a Multikey object.

f
textToBytes

Text to array buffer, needed for crypto operations. The text is encoded in UTF-8, which is the default for the WebCrypto API.

I
WebCryptoAPIData

Additional structure needed for operations such as sign or verify in the WebCrypto API. Can be extracted from the WebCrypto representation of the crypto keys, see algorithmDataCR.