PrivateKey (Class)¶
A private key for signing transactions and messages.
Private keys should be kept secret and never shared.
__new__
¶
__new__(key: str) -> PrivateKey
Create a private key from a hex string.
| PARAMETER | DESCRIPTION |
|---|---|
key
|
A 64-character hex string representing the secret key.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
PrivateKey
|
A new PrivateKey instance.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
Exception
|
If the hex string is invalid. |
to_address
¶
to_address(network: str | NetworkType) -> Address
Derive a Schnorr address from this private key.
| PARAMETER | DESCRIPTION |
|---|---|
network
|
The network type for address encoding.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Address
|
The derived Schnorr address.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
Exception
|
If derivation fails. |
to_address_ecdsa
¶
to_address_ecdsa(network: str | NetworkType) -> Address
Derive an ECDSA address from this private key.
| PARAMETER | DESCRIPTION |
|---|---|
network
|
The network type for address encoding.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Address
|
The derived ECDSA address.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
Exception
|
If derivation fails. |
to_keypair
¶
to_keypair() -> Keypair
Create a Keypair from this private key.
| RETURNS | DESCRIPTION |
|---|---|
Keypair
|
A keypair containing this private key and derived public keys.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
Exception
|
If keypair creation fails. |
to_public_key
¶
to_public_key() -> PublicKey
Derive the corresponding public key.
| RETURNS | DESCRIPTION |
|---|---|
PublicKey
|
The derived public key.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
Exception
|
If derivation fails. |
to_string
¶
Convert to hex string representation.
| RETURNS | DESCRIPTION |
|---|---|
str
|
The private key as a hex string.
TYPE:
|