Keypair (Class)¶
A cryptographic keypair containing private and public keys.
Provides convenient access to all key forms needed for signing and address generation.
__new__
¶
__new__(secret_key: str, public_key: str, xonly_public_key: str) -> Keypair
Create a keypair from hex string representations.
| PARAMETER | DESCRIPTION |
|---|---|
secret_key
|
The secret key as hex.
TYPE:
|
public_key
|
The public key as hex.
TYPE:
|
xonly_public_key
|
The x-only public key as hex.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Keypair
|
A new Keypair instance.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
Exception
|
If any key format is invalid. |
from_private_key
staticmethod
¶
from_private_key(private_key: PrivateKey) -> Keypair
Create a keypair from a private key.
| PARAMETER | DESCRIPTION |
|---|---|
private_key
|
The private key to derive from.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Keypair
|
A new Keypair with derived public keys.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
Exception
|
If derivation fails. |
random
staticmethod
¶
random() -> Keypair
Generate a random keypair.
| RETURNS | DESCRIPTION |
|---|---|
Keypair
|
A new random Keypair.
TYPE:
|
to_address
¶
to_address(network: str | NetworkType) -> Address
Derive a Schnorr address from this keypair.
| PARAMETER | DESCRIPTION |
|---|---|
network
|
The network type for address encoding.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Address
|
The derived Schnorr address.
TYPE:
|
to_address_ecdsa
¶
to_address_ecdsa(network: str | NetworkType) -> Address
Derive an ECDSA address from this keypair.
| PARAMETER | DESCRIPTION |
|---|---|
network
|
The network type for address encoding.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Address
|
The derived ECDSA address.
TYPE:
|