common

package
v1.5.2 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: MIT Imports: 26 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var FlateHeader = []byte{0xF1, 0xA7, 0xE0}

Should be a constant

View Source
var Verbose bool

Functions

func AddressFromPub

func AddressFromPub(pubkeyeth []byte) []byte

func CRCAddressFromPub

func CRCAddressFromPub(pubkeyeth []byte) string

func CRCAddressString

func CRCAddressString(addr []byte) (adstr string)

func CalcCREATE2Address

func CalcCREATE2Address(address, codehash, salt []byte) ([]byte, error)

func CalcCREATEAddress

func CalcCREATEAddress(address []byte, nonce uint) ([]byte, error)

func Decrypt

func Decrypt(kf *Keyfile, key []byte) (plaintext []byte, err error)

func DecryptAESCTR

func DecryptAESCTR(kf *Keyfile, key []byte) (privkey []byte, err error)

func DecryptAESGCM

func DecryptAESGCM(kf *Keyfile, key []byte) (plaintext []byte, err error)

func DeriveChildKey added in v1.5.0

func DeriveChildKey(key *bip32.Key, path []uint32) (*bip32.Key, error)

Derive child key from parent key according to path (bip32)

func EncryptAES

func EncryptAES(kf *Keyfile, plaintext []byte, password []byte) error

func FlateData added in v1.5.1

func FlateData(data []byte) ([]byte, error)

func GenerateVanityKey

func GenerateVanityKey(vanity string, caseSensitive bool, done *bool) vanityResult

func GetPasswordHint added in v1.5.0

func GetPasswordHint() (string, error)

PRompt for a password hint

func GunzipData added in v1.5.1

func GunzipData(data []byte) ([]byte, error)

func GzipData added in v1.5.1

func GzipData(data []byte) ([]byte, error)

func Keccak256

func Keccak256(data ...[]byte) []byte

Just a convenience wrapper copied from geth

func KeyFromPassPbkdf2

func KeyFromPassPbkdf2(password []byte, params KdfPbkdf2params) ([]byte, error)

Recoveres the encryption key from password

func KeyFromPassScrypt

func KeyFromPassScrypt(password []byte, params KdfScryptparams) ([]byte, error)

Recoveres the encryption key from password

func Pad added in v1.5.0

func Pad(data []byte, length int) []byte

func ParseHexString

func ParseHexString(hexstring string) ([]byte, error)

func PathToUint32 added in v1.5.0

func PathToUint32(path string) ([]uint32, error)

Translate bop32 path to uint32 array

func ReadPassword

func ReadPassword(prompt string) ([]byte, error)

Reading a password on a CLI without echoing it

func ReadString added in v1.5.0

func ReadString(prompt string) (string, error)

func RootKeyFromKey added in v1.5.0

func RootKeyFromKey(key, chainCode []byte) (*bip32.Key, error)

Create bip32 key (root) from eth key and additional entropy (chaincode)

func Scalar2Pub

func Scalar2Pub(ethkey []byte) (pubkeyeth []byte)

func SetPassword

func SetPassword(prompt string) ([]byte, error)

func SplitBytesToFiles added in v1.5.1

func SplitBytesToFiles(secret []byte, fpattern string, numshares, threshold int, encalg, kdf, addrlabel string)

func TimeConstraindedVanityKey

func TimeConstraindedVanityKey(vanity string, caseSensitive bool, timeout int) ([]byte, string, error, int, time.Duration)

func UnflateData added in v1.5.1

func UnflateData(data []byte) ([]byte, error)

func WriteKeyfile added in v1.5.0

func WriteKeyfile(kf *Keyfile, filename string) error

Types

type KdfPbkdf2params

type KdfPbkdf2params struct {
	C     int    `json:"c"`
	Dklen int    `json:"dklen"`
	Prf   string `json:"prf"`
	Salt  string `json:"salt"`
}

func StdPbkdf2Params added in v1.5.0

func StdPbkdf2Params() *KdfPbkdf2params

function returning stadard pbkdf2 parameters as KdfPbkdf2params struct

type KdfScryptparams

type KdfScryptparams struct {
	Dklen int    `json:"dklen"`
	Salt  string `json:"salt"`
	N     int    `json:"n"`
	R     int    `json:"r"`
	P     int    `json:"p"`
}

func StdScryptParams added in v1.5.0

func StdScryptParams() *KdfScryptparams

function returning stadard scryp parameters as KdfScryptparams struct

type Keyfile

type Keyfile struct {
	Version int    `json:"version"`
	ID      string `json:"id"`
	Address string `json:"address"`
	Crypto  struct {
		Ciphertext   string `json:"ciphertext"`
		Cipherparams struct {
			Iv string `json:"iv"`
		} `json:"cipherparams"`
		Cipher          string          `json:"cipher"`
		Kdf             string          `json:"kdf"`
		KdfparamsPack   json.RawMessage `json:"kdfparams,omitempty"`
		KdfScryptParams KdfScryptparams `json:"-"`
		KdfPbkdf2params KdfPbkdf2params `json:"-"`
		Mac             string          `json:"mac"`
	} `json:"crypto"`
	Plaintext []byte `json:"-"`
	PubKey    string `json:"-"`
	Hint      string `json:"hint,omitempty"`
	Filename  string `json:"-"`
}

func GenerateAndWrapNewKey added in v1.5.0

func GenerateAndWrapNewKey(pass []byte, kdf string, encalg string, priv []byte, vanity string, caseSensitive bool, timeout int) (kf *Keyfile, err error, tries int, span time.Duration)

Need to revive this function for external use

func ReadAndProcessKeyfile

func ReadAndProcessKeyfile(filename string) (keyfile *Keyfile, err error)

func ReadKeyfile

func ReadKeyfile(filename string) (*Keyfile, error)

Reads and parses a json from a file

func WrapNSecrets added in v1.5.1

func WrapNSecrets(filenameptrn string, idptrn *Uuid, plaintexts [][]byte, encalg, kdf, addressTextPtrn string) ([]*Keyfile, error)

func WrapSecret added in v1.5.1

func WrapSecret(filename string, id string, plaintext []byte, encalg, kdf, addressText string) (*Keyfile, error)

func (*Keyfile) Decrypt

func (kf *Keyfile) Decrypt(pass []byte) (err error)

func (*Keyfile) Deserialize added in v1.5.0

func (kf *Keyfile) Deserialize(jsonbytes []byte) (err error)

func (*Keyfile) KeyFromPass

func (keyfile *Keyfile) KeyFromPass(pass []byte) (key []byte, err error)

func (*Keyfile) Serialize added in v1.5.0

func (kf *Keyfile) Serialize() (jsonbytes []byte, err error)

func (*Keyfile) UnmarshalKdfJSON

func (kf *Keyfile) UnmarshalKdfJSON() (err error)

func (*Keyfile) VerifyMAC

func (keyfile *Keyfile) VerifyMAC(key []byte) error

type Uuid added in v1.5.0

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

func NewUuid added in v1.5.0

func NewUuid() *Uuid

func (*Uuid) GetPattern added in v1.5.0

func (u *Uuid) GetPattern(n int) string

Returns a string with n leading X characters

func (*Uuid) GetSeg added in v1.5.0

func (u *Uuid) GetSeg() int

func (*Uuid) Next added in v1.5.0

func (u *Uuid) Next() string

func (*Uuid) NthUuidString added in v1.5.0

func (u *Uuid) NthUuidString(n int, nbytes int) string

func (*Uuid) SetSeq added in v1.5.0

func (u *Uuid) SetSeq(seq int)

func (*Uuid) String added in v1.5.0

func (u *Uuid) String() string

Jump to

Keyboard shortcuts

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