ECDSA
- Description:
ECDSA signature operations for Bitcoin
- Source:
Methods
(static) getPublicKey(privateKey, compressedopt) → {Buffer}
- Description:
Get public key from private key
- Source:
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
privateKey |
string | Buffer | Uint8Array | Private key |
||
compressed |
boolean |
<optional> |
true
|
Return compressed format |
Returns:
Public key
- Type
- Buffer
(static) recoverPublicKey(signature, messageHash, recovery) → {Buffer}
- Description:
Recover public key from signature
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
signature |
Object | Signature with r, s components |
messageHash |
string | Buffer | Original message hash |
recovery |
number | Recovery parameter (0-3) |
Throws:
-
If signature format is invalid
- Type
- ECDSAError
Returns:
Recovered compressed public key
- Type
- Buffer
(static) sign(privateKey, messageHash, optionsopt) → {Object}
- Description:
Sign a message hash with ECDSA
- Source:
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
privateKey |
string | Buffer | Uint8Array | Private key |
||
messageHash |
string | Buffer | 32-byte hash to sign |
||
options |
Object |
<optional> |
{}
|
Signing options |
Throws:
-
If inputs are invalid
- Type
- ECDSAError
Returns:
Signature with r, s, recovery, signature, der
- Type
- Object
(static) signMessage(privateKey, message) → {Object}
- Description:
Sign a message with Bitcoin message prefix
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
privateKey |
string | Buffer | Uint8Array | Private key |
message |
string | Buffer | Message to sign |
Returns:
Signature
- Type
- Object
(static) verify(signature, messageHash, publicKey) → {boolean}
- Description:
Verify an ECDSA signature
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
signature |
Object | Buffer | Uint8Array | Signature to verify |
messageHash |
string | Buffer | 32-byte message hash |
publicKey |
string | Buffer | Uint8Array | Public key |
Returns:
True if signature is valid
- Type
- boolean
(static) verifyMessage(signature, message, publicKey) → {boolean}
- Description:
Verify a Bitcoin signed message
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
signature |
Object | Signature to verify |
message |
string | Buffer | Original message |
publicKey |
string | Buffer | Uint8Array | Public key |
Returns:
True if valid
- Type
- boolean