crypto

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var B58Enc = basen.NewEncoding("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")

B58Enc is the base58 library used for base58 encoding data

Functions

func DerivePrivateKey

func DerivePrivateKey(seed []byte, path []uint32, wif bool) (privKey string, err error)

DerivePrivateKey derives a single HD wallet's private key given the seed and a path of indices. Returns hex string representation of private key

func GetCurrencyType

func GetCurrencyType(path []uint32) (name string, err error)

GetCurrencyType takes a path (set of u32 indices) and returns the name of the currency, if applicable. Returns error if currency is not supported or path is malformed.

func GetElectrumBIP49MasterPriv

func GetElectrumBIP49MasterPriv(seed []byte) (privKey string, err error)

GetElectrumBIP49MasterPriv exports a BIP49 master private key for import into Electrum. Generally, the master private key would be the `masterKey` defined below. However, Electrum requires further derivation: m/49'/0'/0'. They consider this derived key to be the "master private key". As far as I can tell this breaks from other wallet software, but Electrum is the only popular one that lets you import a master private key for an HD wallet.

func GetElectrumPrivKeyPrefix

func GetElectrumPrivKeyPrefix(path []uint32) (prefix string, err error)

GetElectrumPrivKeyPrefix returns a string containing a prefix that must be included when a user imports a private key string into Electrum (Bitcoin wallet). The Lattice uses BIP49 derivations, so we expect 49' most of the time, though 44' is also supported (legacy p2pkh, so there is no prefix needed). Otherwise an error is thrown.

func GetPath

func GetPath(pathStr string) ([]uint32, error)

GetPath takes a path string (e.g. m/44'/0'/0'/0/0) and converts it to uint32 indices

func GetStrPath

func GetStrPath(path []uint32) string

GetStrPath converts a set of indices to a BIP32 path string (e.g. m/44'/0'/0'/0/0)

Types

This section is empty.

Jump to

Keyboard shortcuts

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