new Signature(algorithm, secretKeyopt)
- Source:
Constructs an instance of Signature.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
algorithm |
Sigs.Algorithm | The signature algorithm to use. |
|
secretKey |
Buffer |
<optional> |
An optional secret key. If not specified, use Signature#generateKeypair later to create a secret key. |
Throws:
-
Will throw an error if any argument is invalid.
- Type
- TypeError
Methods
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 signature algorithm that the instance was constructed with.
Returns:
- An object containing the details of the signature algorithm.
- Type
- Object
sign(message) → {Buffer}
- Source:
Signs a message.
Parameters:
Name | Type | Description |
---|---|---|
message |
Buffer | The message to sign. |
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 signature for the message.
- Type
- Buffer
verify(message, signature, publicKey) → {boolean}
- Source:
Verifies the signature belonging to a message using a public key.
Parameters:
Name | Type | Description |
---|---|---|
message |
Buffer | The message that was signed to produce the signature. |
signature |
Buffer | The signature to verify. |
publicKey |
Buffer | The public key to verify the signature against. |
Throws:
-
Will throw an error if any argument is invalid.
- Type
- TypeError
Returns:
- Whether the message has a valid signature from the owner of the public key.
- Type
- boolean