crypto

package
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// EVMBIP44HDPath is the default Ethereum derivation path (coin type 60).
	EVMBIP44HDPath = "m/44'/60'/0'/0/0"
)

Variables

This section is empty.

Functions

func AddressFromKey

func AddressFromKey(kr keyring.Keyring, keyName, hrp string) (string, error)

AddressFromKey derives an account address for the given HRP from the public key stored in the keyring under keyName, without mutating the global bech32 prefix configuration.

func GetKey

func GetKey(kr keyring.Keyring, keyName string) (*keyring.Record, error)

GetKey returns metadata for the named key in the provided keyring.

func ImportKey added in v1.0.9

func ImportKey(kr keyring.Keyring, keyName, mnemonicFile, hrp string, keyType KeyType) ([]byte, string, error)

ImportKey imports a mnemonic into an existing keyring using the specified key type, returning the pubkey bytes and address for the provided HRP.

If a key with the same name already exists, ImportKey verifies that its algorithm matches the requested keyType and returns an error on mismatch.

func LoadKeyring added in v1.0.9

func LoadKeyring(keyName, mnemonicFile string, keyType KeyType) (keyring.Keyring, []byte, string, error)

LoadKeyring creates a test keyring in a temporary directory under os.TempDir(), imports the mnemonic using the specified key type, and returns the keyring, pubkey bytes, and Lumera address.

The temporary directory is cleaned up by the OS on reboot. For production use, prefer NewKeyring with an explicit directory and import keys via kr.NewAccount directly.

func NewDefaultTxConfig

func NewDefaultTxConfig() client.TxConfig

NewDefaultTxConfig constructs a client.TxConfig backed by a protobuf codec, registering Lumera action message interfaces as required for signing/encoding.

func NewKeyring

func NewKeyring(p KeyringParams) (keyring.Keyring, error)

NewKeyring creates a new keyring that supports both Cosmos (secp256k1) and EVM (eth_secp256k1) key types. The key type used is determined when importing or creating keys, not at keyring creation time.

func SignTxWithKeyring

func SignTxWithKeyring(
	ctx context.Context,
	txCfg client.TxConfig,
	kr keyring.Keyring,
	keyName string,
	builder client.TxBuilder,
	chainID string,
	accountNumber uint64,
	sequence uint64,
	overwrite bool,
) error

SignTxWithKeyring signs the provided TxBuilder using the given keyring identity. The caller must supply chainID, account number and sequence. Set overwrite=false for the first signature; true for subsequent signers on the same tx.

Types

type KeyType added in v1.0.9

type KeyType int

KeyType represents the cryptographic key algorithm and HD derivation path to use for a chain. Controller and host chains can each be configured with an independent KeyType.

const (
	// KeyTypeCosmos uses secp256k1 with BIP44 coin type 118 (standard Cosmos).
	KeyTypeCosmos KeyType = iota
	// KeyTypeEVM uses eth_secp256k1 with BIP44 coin type 60 (Ethereum-compatible).
	KeyTypeEVM
)

func (KeyType) HDPath added in v1.0.9

func (kt KeyType) HDPath() string

HDPath returns the BIP44 HD derivation path for this key type.

func (KeyType) SigningAlgo added in v1.0.9

func (kt KeyType) SigningAlgo() keyring.SignatureAlgo

SigningAlgo returns the keyring signing algorithm for this key type.

func (KeyType) String added in v1.0.9

func (kt KeyType) String() string

String returns the string representation of the key type.

type KeyringParams

type KeyringParams struct {
	// AppName names the keyring namespace. Default: "lumera"
	AppName string
	// Backend selects the keyring backend ("os" | "file" | "test"). Default: "os"
	Backend string
	// Dir is the root directory for the keyring (if Backend="file"). Default: $HOME/.lumera
	Dir string
	// Input is an optional io.Reader for interactive backends (nil for non-interactive)
	Input io.Reader
}

KeyringParams holds configuration for initializing a Cosmos keyring.

func DefaultKeyringParams

func DefaultKeyringParams() KeyringParams

DefaultKeyringParams returns sensible defaults:

  • AppName: "lumera"
  • Backend: "os"
  • Dir: $HOME/.lumera

Directories

Path Synopsis
sdk-go/pkg/crypto/ethsecp256k1/ethsecp256k1.go
sdk-go/pkg/crypto/ethsecp256k1/ethsecp256k1.go

Jump to

Keyboard shortcuts

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