Constructor
new Key(type, params)
Instantiates a new Key instance of the given type and parameters.
Parameters:
Name | Type | Description |
---|---|---|
type |
String | |
params |
Object |
Classes
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 |
Returns:
- Type
- Recipient
toBuffer() → {Buffer}
Returns the Key as a CBOR encoded Buffer.
Returns:
- Type
- Buffer
toObject() → {Object}
Returns the Key as a JWK compatible object.
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.
Returns:
- Type
- Key