Class: Secp256k1SecretKey ​
Defined in: secret.ts:80
Encapsulates a secp256k1 secret key Provides get methods for different formats (raw, secret, point). Provides helpers methods for comparison, serialization and publicKey generation. Secp256k1SecretKey
Implements ​
Implements ​
Constructors ​
Constructor ​
new Secp256k1SecretKey(
entropy):Secp256k1SecretKey
Defined in: secret.ts:95
Instantiates an instance of Secp256k1SecretKey.
Parameters ​
entropy ​
bytes (Uint8Array) or secret (bigint)
Returns ​
Secp256k1SecretKey
Throws ​
If entropy is not provided, not a valid 32-byte secret key or not a valid bigint seed
Accessors ​
bytes ​
Get Signature ​
get bytes():
Uint8Array
Defined in: secret.ts:140
Get the secret key entropy as a byte array.
Returns ​
Uint8Array
The secret key bytes as a Uint8Array
Get the secret key bytes.
Implementation of ​
hex ​
Get Signature ​
get hex():
Hex
Defined in: secret.ts:160
Returns the raw secret key as a hex string.
Returns ​
The secret key as a hex string
Get the secret key as a hex string.
Implementation of ​
multibase ​
Get Signature ​
get multibase():
string
Defined in: secret.ts:170
Encode the secret key bytes as a secretKeyMultibase string.
Returns ​
string
The secret key in base58btc multibase format
seed ​
Get Signature ​
get seed():
bigint
Defined in: secret.ts:150
Get the secret key entropy as a bigint.
Returns ​
bigint
The secret key as a bigint
Getter returns the secret key bytes in bigint format. Setter allows alternative method of using a bigint seed for the entropy.
Implementation of ​
Methods ​
computePublicKey() ​
computePublicKey():
CompressedSecp256k1PublicKey
Defined in: secret.ts:213
Computes the public key from the secret key bytes.
Returns ​
The computed public key
Implementation of ​
encode() ​
encode():
string
Defined in: secret.ts:179
Encodes the secret key bytes to BIP340 multibase format.
Returns ​
string
The secret key in BIP340 multibase format.
equals() ​
equals(
other):boolean
Defined in: secret.ts:204
Checks if this secret key is equal to another.
Parameters ​
other ​
Secp256k1SecretKey
The other secret key
Returns ​
boolean
True if the private keys are equal, false otherwise
Implementation of ​
hasValidPublicKey() ​
hasValidPublicKey():
boolean
Defined in: secret.ts:260
Checks if the public key is a valid secp256k1 point.
Returns ​
boolean
True if the public key is valid, false otherwise
isValid() ​
isValid():
boolean
Defined in: secret.ts:252
Checks if the secret key is valid.
Returns ​
boolean
True if the secret key is valid, false otherwise
Implementation of ​
json() ​
json():
SecretKeyObject
Defined in: secret.ts:240
Converts the secret key to a JSON object.
Returns ​
The secret key as a JSON object
Implementation of ​
sign() ​
sign(
data,opts?):Bytes
Defined in: secret.ts:281
Produce a signature over arbitrary data using schnorr or ecdsa.
Parameters ​
data ​
Data to be signed.
opts? ​
Options for signing.
Returns ​
Signature byte array.
Throws ​
if no private key is provided.
decode() ​
staticdecode(multibase):Bytes
Defined in: secret.ts:303
Decodes the multibase string to the 34-byte secret key (2 byte prefix + 32 byte key).
Parameters ​
multibase ​
string
The multibase string to decode
Returns ​
The decoded secret key.
fromEntropy() ​
staticfromEntropy(entropy):Secp256k1SecretKey
Defined in: secret.ts:395
Creates a new Secp256k1SecretKey object from a bigint secret.
Parameters ​
entropy ​
bigint
The secret bigint
Returns ​
Secp256k1SecretKey
A new Secp256k1SecretKey object
fromJSON() ​
staticfromJSON(json):Secp256k1SecretKey
Defined in: secret.ts:338
Creates a Secp256k1SecretKey object from a JSON object.
Parameters ​
json ​
The JSON object containing the secret key bytes
Returns ​
Secp256k1SecretKey
A new Secp256k1SecretKey object
generate() ​
staticgenerate():Secp256k1SecretKey
Defined in: secret.ts:420
Creates a new Secp256k1SecretKey from random secret key bytes.
Returns ​
Secp256k1SecretKey
A new Secp256k1SecretKey object
getPublicKey() ​
staticgetPublicKey(bytes):CompressedSecp256k1PublicKey
Defined in: secret.ts:433
Generates a public key from the given secret key bytes.
Parameters ​
bytes ​
The secret key bytes
Returns ​
The computed public key bytes
random() ​
staticrandom():Bytes
Defined in: secret.ts:408
Generates random secret key bytes.
Returns ​
Uint8Array of 32 random bytes.
toBytes() ​
statictoBytes(secret):Bytes
Defined in: secret.ts:373
Convert a secret key bytes to a bigint secret.
Parameters ​
secret ​
bigint
The secret key secret.
Returns ​
The secret key secret as secret key bytes.
toKeyPair() ​
statictoKeyPair(bytes):SchnorrKeyPair
Defined in: secret.ts:348
Converts a Secp256k1SecretKey or KeyBytes to a SchnorrKeyPair.
Parameters ​
bytes ​
The secret key bytes
Returns ​
The SchnorrKeyPair object containing the public and private keys
Throws ​
If the secret key is not valid
toSecret() ​
statictoSecret(bytes):bigint
Defined in: secret.ts:364
Convert a bigint secret to secret key bytes.
Parameters ​
bytes ​
The secret key bytes
Returns ​
bigint
The secret key bytes as a bigint secret