wallet

package
v0.0.0-...-34de315 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2018 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewSeed

func NewSeed() ([]byte, error)

NewSeed creates a new 256-bit random seed to be used for wallet key store initialization.

func SeedFromEncrypted

func SeedFromEncrypted(encrypted []byte, password string) ([]byte, error)

SeedFromEncrypted takes a AES ECB mode encrypted seed and a password and will decode the original seed from the input. The seed should not be more than 256 bits long to avoid issues with the ECB mode application of AES.

func SeedFromMnemonic

func SeedFromMnemonic(mnemonic string) ([]byte, error)

SeedFromMnemonic takes a mnemonic as defined in BIP39 and turns it back into a byte slice used as seed for a wallet key store.

func SeedToEncrypted

func SeedToEncrypted(seed []byte, password string) ([]byte, error)

SeedToEncrypted takes a random wallet seed and a password and uses AES ECB mode encryption to get the output that can be written to disk securely. The seed shouldn't be more than 256 bits to avoid ECB mode security concerns.

func SeedToMnemonic

func SeedToMnemonic(seed []byte) (string, error)

SeedToMnemonic takes a random byte slice representing the seed of a wallet key store and turns it into the BIP39 mnemonic representation of words to be used as a offline backup for user wallets.

Types

type Store

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

Store represents the key store for a user wallet with a main key used as the root of all key derivations and an argon2 context to parameterize the key derivation algorithm.

func NewStore

func NewStore(seed []byte) (*Store, error)

NewStore initializes a new key store for a wallet from the given seed. The seed should ideally be 256-bit long and will be used to derive the root key of the key store. The preconfigured argon2 context uses 3 iterations, 1 gigabyte of memory, 4 lanes and an output length of 96 bytes.

func (*Store) Key

func (s *Store) Key(levels [][]byte) ([]byte, error)

Key takes a list of derivation levels, where the length of the slice represents the total depth we want to derive to, while each byte value corresponds to the index we want to derive to on the corresponding level.

Jump to

Keyboard shortcuts

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