Class: Key

Key(type, params)

Key class

Univrse Keys mirror the API of, and are compatible with, JSON JWK keys.

Constructor

new Key(type, params)

Instantiates a new Key instance of the given type and parameters.

Parameters:
Name Type Description
type String
params Object
Source:

Classes

decode
generate

Methods

(async) encrypt(key, headers, opts) → {Recipient}

Encrypts the key using the given encryption key, and returns the encrypted key wrapped in a Recipient instance.

A headers object must be given including at least the encryption alg value.

A third argument of options can be given for the relevant encryption algorithm.

Parameters:
Name Type Description
key Key

encryption key

headers Object
opts Object
Source:
Returns:
Type
Recipient

toBuffer() → {Buffer}

Returns the Key as a CBOR encoded Buffer.

Source:
Returns:
Type
Buffer

toObject() → {Object}

Returns the Key as a JWK compatible object.

Source:
Returns:
Type
Object

toPublic() → {Key}

Returns a public key from the current key, which can be safely shared with other parties.

Only for use with EC key types.

Source:
Returns:
Type
Key