Class: CompressedSecp256k1PublicKey ​
Defined in: public.ts:120
Encapsulates a secp256k1 public key compliant to BIP-340 BIP schnorr signature scheme. Provides get methods for different formats (compressed, x-only, multibase). Provides helpers methods for comparison and serialization. CompressedSecp256k1PublicKey
Implements ​
Constructors ​
Constructor ​
new CompressedSecp256k1PublicKey(
initialBytes):CompressedSecp256k1PublicKey
Defined in: public.ts:140
Creates a CompressedSecp256k1PublicKey instance.
Parameters ​
initialBytes ​
The public key byte array.
Returns ​
CompressedSecp256k1PublicKey
Throws ​
if the byte length is not 32 (x-only) or 33 (compressed)
Accessors ​
compressed ​
Get Signature ​
get compressed():
Bytes
Defined in: public.ts:173
Get the compressed public key.
Returns ​
The 33-byte compressed public key (0x02 or 0x03, x).
Compressed public key getter.
Implementation of ​
hex ​
Get Signature ​
get hex():
string
Defined in: public.ts:252
Returns the raw public key as a hex string.
Returns ​
string
The public key as a hex string.
CompressedSecp256k1PublicKey hex string getter.
Implementation of ​
isEven ​
Get Signature ​
get isEven():
boolean
Defined in: public.ts:214
Whether the SEC compressed public key has even Y.
Returns ​
boolean
True if the public key has even Y.
CompressedSecp256k1PublicKey isEven getter.
Implementation of ​
multibase ​
Get Signature ​
get multibase():
MultibaseObject
Defined in: public.ts:240
Get the multibase public key.
Returns ​
An object containing the multibase bytes, address and prefix.
CompressedSecp256k1PublicKey multibase getter.
Implementation of ​
parity ​
Get Signature ​
get parity():
2|3
Defined in: public.ts:199
Parity of the SEC compressed public key.
Throws ​
If the parity byte is not 0x02 or 0x03.
Returns ​
2 | 3
The parity byte (0x02 if even, 0x03 if odd).
CompressedSecp256k1PublicKey parity getter.
Implementation of ​
point ​
Get Signature ​
get point():
Point
Defined in: public.ts:261
Return the public key point.
Returns ​
The public key point.
CompressedSecp256k1PublicKey point getter.
Implementation of ​
uncompressed ​
Get Signature ​
get uncompressed():
Bytes
Defined in: public.ts:182
Get the uncompressed public key.
Returns ​
The 65-byte uncompressed public key (0x04, x, y).
Uncompressed public key getter.
Implementation of ​
x ​
Get Signature ​
get x():
Bytes
Defined in: public.ts:222
Get the x-coordinate of the public key.
Returns ​
The 32-byte x-coordinate of the public key.
CompressedSecp256k1PublicKey x-coordinate getter.
Implementation of ​
xOnly ​
Get Signature ​
get xOnly():
Bytes
Defined in: public.ts:189
X-only (32-byte) view of the public key per BIP-340.
Returns ​
X-only public key getter.
Implementation of ​
y ​
Get Signature ​
get y():
Bytes
Defined in: public.ts:231
Get the y-coordinate of the public key.
Returns ​
The 32-byte y-coordinate of the public key.
CompressedSecp256k1PublicKey y-coordinate getter.
Implementation of ​
Methods ​
bip340() ​
bip340():
Bytes
Defined in: public.ts:272
Returns the BIP-340 (x-only) representation of this key.
Returns ​
The BIP-340 (x-only) representation of the public key.
decode() ​
decode():
Bytes
Defined in: public.ts:280
Decodes the multibase string to the 35-byte corresponding public key (2 byte prefix + 32 byte public key).
Returns ​
The decoded public key: prefix and public key bytes
Implementation of ​
encode() ​
encode():
string
Defined in: public.ts:288
Encodes compressed secp256k1 public key from bytes to BIP340 multibase format.
Returns ​
string
The public key encoded in base-58-btc multibase format.
Implementation of ​
equals() ​
equals(
other):boolean
Defined in: public.ts:323
Compares this public key to another public key.
Parameters ​
other ​
The other public key to compare
Returns ​
boolean
True if the public keys are equal, false otherwise.
Implementation of ​
toJSON() ​
toJSON():
PublicKeyObject
Defined in: public.ts:331
JSON representation of a CompressedSecp256k1PublicKey object.
Returns ​
The CompressedSecp256k1PublicKey as a JSON object.
verify() ​
verify(
signature,data,opts?):boolean
Defined in: public.ts:303
Verify a signature using schnorr or ecdsa.
Parameters ​
signature ​
Signature for verification.
data ​
Data for verification.
opts? ​
Options for signing.
Returns ​
boolean
If the signature is valid against the public key.
fromJSON() ​
staticfromJSON(json):CompressedSecp256k1PublicKey
Defined in: public.ts:362
Creates a CompressedSecp256k1PublicKey object from a JSON representation.
Parameters ​
json ​
The JSON object to initialize the CompressedSecp256k1PublicKey.
Returns ​
CompressedSecp256k1PublicKey
The initialized CompressedSecp256k1PublicKey object.
isValid() ​
staticisValid(pk):boolean
Defined in: public.ts:348
Static method to validate a public key.
Parameters ​
pk ​
The public key in hex (Uint8Array or string) format.
Returns ​
boolean
True if the public key is valid, false otherwise.