keystorev4

package module
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2023 License: Apache-2.0 Imports: 15 Imported by: 110

README

go-eth2-wallet-encryptor-keystorev4

Tag License GoDoc Travis CI codecov.io Go Report Card

Keystore version 4-compliant encryptor for the Ethereum 2 wallet.

Table of Contents

Install

go-eth2-wallet-encryptor-keystorev4 is a standard Go module which can be installed with:

go get github.com/wealdtech/go-eth2-wallet-encryptor-keystorev4

Usage

In normal operation this module should not be used directly. Instead, it should be configured to be used as part of go-eth2-wallet.

Maintainers

Jim McDonald: @mcdee.

Contribute

Contributions welcome. Please check out the issues.

License

Apache-2.0 © 2019 Weald Technology Trading Ltd

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Encryptor

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

Encryptor is an encryptor that follows the Ethereum keystore V4 specification.

func New

func New(opts ...Option) *Encryptor

New creates a new keystore V4 encryptor. This takes the following options: - cipher: the cipher to use when encrypting the secret, can be either "pbkdf2" (default) or "scrypt". - costPower: the cipher key cost to use as power of 2.

func (*Encryptor) Decrypt

func (e *Encryptor) Decrypt(input map[string]any, passphrase string) ([]byte, error)

Decrypt decrypts the data provided, returning the secret.

func (*Encryptor) Encrypt

func (e *Encryptor) Encrypt(secret []byte, passphrase string) (map[string]any, error)

Encrypt encrypts data.

func (*Encryptor) Name

func (e *Encryptor) Name() string

Name returns the name of this encryptor.

func (*Encryptor) String added in v1.4.0

func (e *Encryptor) String() string

String returns a string representing this encryptor.

func (*Encryptor) Version

func (e *Encryptor) Version() uint

Version returns the version of this encryptor.

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option gives options to New.

func WithCipher

func WithCipher(cipher string) Option

WithCipher sets the cipher for the encryptor.

func WithCost added in v1.3.0

func WithCost(t *testing.T, costPower uint) Option

WithCost sets the cipher key cost for the encryptor to 2^power overriding the default value. Higher values increases the cost of an exhaustive search but makes encoding and decoding proportionally slower. This should only be in testing as it affects security. It panics if t is nil.

Jump to

Keyboard shortcuts

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