Documentation
¶
Overview ¶
Package keys provides key management utilities for TRON accounts.
Index ¶
- Variables
- func AddNewKey(password string)deprecated
- func FromMnemonicSeedAndPassphrase(m, passphrase string, index int) (*btcec.PrivateKey, *btcec.PublicKey)deprecated
- func GenerateKey() (*btcec.PrivateKey, error)
- func GetPrivateKeyFromBytes(privateKeyBytes []byte) (*btcec.PrivateKey, error)
- func GetPrivateKeyFromHex(privateKeyHex string) (*btcec.PrivateKey, error)
- func ListKeys(keystoreDir string)deprecated
- func ZeroECDSAKey(key *ecdsa.PrivateKey)
- func ZeroPrivateKey(key *btcec.PrivateKey)
- type Dump
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidPrivateKey = errors.New("invalid private key: out of range for secp256k1")
ErrInvalidPrivateKey is returned when key material is zero or not below the secp256k1 curve order n, so it is not a valid private key.
Functions ¶
func AddNewKey
deprecated
func AddNewKey(password string)
AddNewKey creates a new account in the default keystore directory (~/.tronctl/keystore) and prints its address and file. On failure it prints the error to stderr and nothing else.
Deprecated: use account.CreateNewLocalAccount, or keystore.NewKeyStore and KeyStore.NewAccount, which return errors instead of printing them.
func FromMnemonicSeedAndPassphrase
deprecated
func FromMnemonicSeedAndPassphrase(m, passphrase string, index int) (*btcec.PrivateKey, *btcec.PublicKey)
FromMnemonicSeedAndPassphrase derives a key pair at the TRON HD path index (44'/195'/0'/0/{index}). Like mnemonic.FromSeedAndPassphrase, it does NOT check the mnemonic's checksum, and it returns nil, nil on failure.
Deprecated: Use mnemonic.DeriveKey, which validates the mnemonic and returns an error, or mnemonic.Validate followed by mnemonic.FromSeedAndPassphrase.
func GenerateKey ¶ added in v0.24.1
func GenerateKey() (*btcec.PrivateKey, error)
GenerateKey generates a new random secp256k1 private key.
func GetPrivateKeyFromBytes ¶ added in v0.24.1
func GetPrivateKeyFromBytes(privateKeyBytes []byte) (*btcec.PrivateKey, error)
GetPrivateKeyFromBytes creates a private key from raw 32-byte key material. The value must be in [1, n-1] for the secp256k1 order n; zero or any value >= n returns ErrInvalidPrivateKey rather than being reduced mod n.
func GetPrivateKeyFromHex ¶ added in v0.24.1
func GetPrivateKeyFromHex(privateKeyHex string) (*btcec.PrivateKey, error)
GetPrivateKeyFromHex parses a hex-encoded private key string.
func ListKeys
deprecated
func ListKeys(keystoreDir string)
ListKeys prints all accounts in keystoreDir to stdout. An empty keystoreDir means the default ~/.tronctl/keystore, which is created if missing.
Deprecated: use keystore.NewKeyStore(dir, ...).Accounts(), or the account and store packages, which return the accounts instead of printing them.
func ZeroECDSAKey ¶ added in v0.26.0
func ZeroECDSAKey(key *ecdsa.PrivateKey)
ZeroECDSAKey overwrites the backing memory of an ECDSA private key's D value. Unlike big.Int.SetInt64(0) which only changes the logical value, this zeros the actual backing array to prevent key material from lingering in memory.
func ZeroPrivateKey ¶ added in v0.26.0
func ZeroPrivateKey(key *btcec.PrivateKey)
ZeroPrivateKey overwrites the private key bytes with zeros.