crypto

package
v2.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenSecp256k1PrivKey

func GenSecp256k1PrivKey(mnemonic, bip39Passphrase string) (secp256k1.PrivKey, error)

GenSecp256k1PrivKey generates a Secp256k1 private key from mnemonic anad bip39Passphrase. If mnemonic is an empty string, this function generates a random mnemonic. The bip39Passphrase can be an empty string.

Types

type KeyStore

type KeyStore struct {
	// contains filtered or unexported fields
}

KeyStore stores an encrypted private key on disk. It implements the Web3 Secret Storage Definition: https://github.com/ethereum/wiki/wiki/Web3-Secret-Storage-Definition.

func NewKeyStore

func NewKeyStore(baseDir string) (*KeyStore, error)

NewKeyStore creates a KeyStore using baseDir. If baseDir doesn't exists, it is created automatically.

func (*KeyStore) Load

func (ks *KeyStore) Load(path string, passwd string) ([]byte, error)

Load loads a key from path by decrypting it using passwd.

func (*KeyStore) LoadByAddress

func (ks *KeyStore) LoadByAddress(address string, passwd string) ([]byte, error)

LoadByAddress loads a key by decrypting it using passwd. If there are multiple files related to the address, it uses the recent one.

func (*KeyStore) Save

func (ks *KeyStore) Save(address string, key []byte, passwd string) (string, error)

Save stores a key by encrypting it using passwd. The address is the name of the key which can be anything such as a blockchain address or a DID key ID. The address is used for generating a file name of the stored key.

Jump to

Keyboard shortcuts

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