new KeyEncapsulation(algorithm, secretKeyopt)
- Source:
Constructs an instance of KeyEncapsulation.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
algorithm |
KEMs.Algorithm | The KEM algorithm to use. |
|
secretKey |
Buffer |
<optional> |
An optional secret key. If not specified, use KeyEncapsulation#generateKeypair later to create a secret key. |
Throws:
-
Will throw an error if any argument is invalid.
- Type
- TypeError
Methods
decapsulateSecret(ciphertext) → {Buffer}
- Source:
Decapsulates the shared secret using a provided public key.
Parameters:
Name | Type | Description |
---|---|---|
ciphertext |
Buffer | The ciphertext that was encrypted using the instance's public key. |
Throws:
-
-
Will throw an error if any argument is invalid.
- Type
- TypeError
-
-
-
Will throw an error if memory cannot be allocated.
- Type
- Error
-
Returns:
- The shared secret.
- Type
- Buffer
encapsulateSecret(publicKey) → {KeyEncapsulation.CiphertextSharedSecretPair}
- Source:
Encapsulates the shared secret using a provided public key.
Parameters:
Name | Type | Description |
---|---|---|
publicKey |
Buffer | The public key belonging to the intended recipient of the shared secret. |
Throws:
-
-
Will throw an error if any argument is invalid.
- Type
- TypeError
-
-
-
Will throw an error if memory cannot be allocated.
- Type
- Error
-
Returns:
- The ciphertext and shared secret.
exportSecretKey() → {Buffer}
- Source:
Exports the secret key.
Throws:
-
Will throw an error if memory cannot be allocated.
- Type
- Error
Returns:
- A Buffer containing the secret key.
- Type
- Buffer
generateKeypair() → {Buffer}
- Source:
Generates a keypair. Overwrites any existing secret key on the instance with the generated secret key.
Throws:
-
Will throw an error if memory cannot be allocated..
- Type
- Error
Returns:
- A Buffer containing the public key.
- Type
- Buffer
getDetails() → {Object}
- Source:
Gets the details for the KEM algorithm that the instance was constructed with.
Returns:
- An object containing the details of the KEM algorithm.
- Type
- Object
Type Definitions
CiphertextSharedSecretPair
- Source:
An object with the following properties:
ciphertext
: The ciphertext to be given to the owner of the public key.sharedSecret
: The shared secret.
Type:
- Object