keystore

package
v0.52.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 30, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Keystore

type Keystore struct {
	Keys map[string]*ecdsa.PrivateKey
	core.UnimplementedKeystore
}

Keystore is a simple in-memory key store that holds private keys for signing. The `Keys` map holds:

  • key (string): the string representation of a Tron address
  • value (*ecdsa.PrivateKey): the private key associated with that address

func NewKeystore

func NewKeystore(privateKey *ecdsa.PrivateKey) (*Keystore, address.Address)

NewKeystore initializes a new Keystore with a single ECDSA private key. The key is stored using the derived Tron address as the map key.

func (*Keystore) Accounts

func (ks *Keystore) Accounts(ctx context.Context) ([]string, error)

Accounts returns a list of all address strings currently stored in the Keystore.

func (*Keystore) ImportECDSA

func (ks *Keystore) ImportECDSA(privateKey *ecdsa.PrivateKey) address.Address

ImportECDSA adds a new private key to the Keystore, deriving its Tron address and storing it using that address as the map key.

func (*Keystore) Sign

func (ks *Keystore) Sign(ctx context.Context, id string, hash []byte) ([]byte, error)

Sign signs the given hash using the private key associated with the provided ID (address string). If the key does not exist, it returns an error. If the hash is nil (e.g., used as an existence check), it returns nil.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL