@did-btc1/keypair / SchnorrKeyPair
Class: SchnorrKeyPair
Defined in: pair.ts:54
Encapsulates a PublicKey and a SecretKey object as a single Keys object. SchnorrKeyPair
Implements
Constructors
Constructor
> new SchnorrKeyPair(secretKey
): SchnorrKeyPair
Defined in: pair.ts:72
Creates an instance of Keys. Must provide a at least a secret key. Can optionally provide both a private and public key, but must be a valid pair.
Parameters
secretKey
KeyParams
= {}
The secret key object
Returns
SchnorrKeyPair
Accessors
multibase
Get Signature
> get multibase(): MultibaseKeys
Defined in: pair.ts:156
Get the Keys in multibase format.
Returns
MultibaseKeys
The SecretKey in multibase format
publicKey
Get Signature
> get publicKey(): PublicKey
Defined in: pair.ts:136
Get the PublicKey.
Returns
The PublicKey object
Set Signature
> set publicKey(publicKey
): void
Defined in: pair.ts:122
Set the PublicKey.
Throws
If the public key is not a valid pair with the secret key.
Parameters
publicKey
The PublicKey object
Returns
void
Implementation of
raw
Get Signature
> get raw(): RawKeyPair
Defined in: pair.ts:145
Get the Keys as a raw key pair.
Returns
RawKeyPair
The Keys as a raw key pair
secretKey
Get Signature
> get secretKey(): SecretKey
Defined in: pair.ts:103
Get the SecretKey.
Throws
If the secret key is not available
Returns
The SecretKey object
Throws
If the secret key is not available.
Implementation of
Methods
json()
> json(): SchnorrKeyPairObject
Defined in: pair.ts:167
JSON representation of a Keys.
Returns
SchnorrKeyPairObject
The Keys as a JSON object
Implementation of
equals()
> static
equals(keys
, otherKeys
): boolean
Defined in: pair.ts:236
Compares two Keys objects for equality.
Parameters
keys
SchnorrKeyPair
The main keys.
otherKeys
SchnorrKeyPair
The other keys to compare.
Returns
boolean
True if the public key and secret key are equal, false otherwise.
fromJSON()
> static
fromJSON(keys
): SchnorrKeyPair
Defined in: pair.ts:179
Static method creates a new Keys from a JSON object.
Parameters
keys
SchnorrKeyPairObject
The JSON object to initialize the Keys.
Returns
SchnorrKeyPair
The initialized Keys object.
fromPrivateKey()
> static
fromPrivateKey(data
): SchnorrKeyPair
Defined in: pair.ts:190
Static method creates a new SchnorrKeyPair from a SecretKey object or secret key bytes.
Parameters
data
The secret key bytes
Bytes
| SecretKey
Returns
SchnorrKeyPair
A new SchnorrKeyPair object
fromSecret()
> static
fromSecret(secret
): SchnorrKeyPair
Defined in: pair.ts:215
Static method creates a new Keys (SecretKey/PublicKey) bigint secret.
Parameters
secret
bigint
The secret key secret
Returns
SchnorrKeyPair
A new Keys object
generate()
> static
generate(): SchnorrKeyPair
Defined in: pair.ts:261
Static method to generate a new random SchnorrKeyPair instance.
Returns
SchnorrKeyPair
A new SecretKey object.
toHex()
> static
toHex(keyBytes
): Hex
Defined in: pair.ts:226
Converts key bytes to a hex string.
Parameters
keyBytes
Bytes
The key bytes (private or public).
Returns
Hex
The key bytes as a hex string.