Class: CompressedSecp256k1PublicKey ​
Defined in: public.ts:127
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(
bytes):CompressedSecp256k1PublicKey
Defined in: public.ts:143
Creates a CompressedSecp256k1PublicKey instance.
Parameters ​
bytes ​
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:171
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:248
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:213
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:239
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:198
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:257
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:180
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:221
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:188
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:230
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:268
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:302
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:336
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:383
Compares this public key to another public key.
Parameters ​
other ​
CompressedSecp256k1PublicKey
The other public key to compare
Returns ​
boolean
True if the public keys are equal, false otherwise.
Implementation of ​
json() ​
json():
PublicKeyObject
Defined in: public.ts:391
JSON representation of a CompressedSecp256k1PublicKey object.
Returns ​
The CompressedSecp256k1PublicKey as a JSON object.
Implementation of ​
liftX() ​
liftX():
Uint8Array
Defined in: public.ts:470
Lifts a 32-byte x-only coordinate into a full secp256k1 point (x, y).
Returns ​
Uint8Array
65-byte uncompressed public key (starts with 0x04)
modPow() ​
modPow(
base,exp,mod):bigint
Defined in: public.ts:444
Computes modular exponentiation: (base^exp) % mod. Used for computing modular square roots.
Parameters ​
base ​
bigint
The base value
exp ​
bigint
The exponent value
mod ​
bigint
The modulus value
Returns ​
bigint
The result of the modular exponentiation
sqrtMod() ​
sqrtMod(
a,p):bigint
Defined in: public.ts:461
Computes sqrt(a) mod p using Tonelli-Shanks algorithm. This finds y such that y^2 ≡ a mod p.
Parameters ​
a ​
bigint
The value to find the square root of
p ​
bigint
The prime modulus
Returns ​
bigint
The square root of a mod p
verify() ​
verify(
signature,data,opts?):boolean
Defined in: public.ts:366
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:408
Creates a CompressedSecp256k1PublicKey object from a JSON representation.
Parameters ​
json ​
The JSON object to initialize the CompressedSecp256k1PublicKey.
Returns ​
CompressedSecp256k1PublicKey
The initialized CompressedSecp256k1PublicKey object.
fromSecretKey() ​
staticfromSecretKey(sk):CompressedSecp256k1PublicKey
Defined in: public.ts:418
Computes the deterministic public key for a given secret key.
Parameters ​
sk ​
The Secp256k1SecretKey object or the secret key bytes
Returns ​
CompressedSecp256k1PublicKey
A new CompressedSecp256k1PublicKey object
point() ​
staticpoint(pk):Point
Defined in: public.ts:278
Returns the point of the public key.
Parameters ​
pk ​
The public key in hex (Uint8Array or string) format.
Returns ​
The point of the public key.
Throws ​
If the public key is not a valid hex string or byte array.