keystore

package
v0.0.0-...-308b279 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

README

go-eth2-wallet-keystore

Table of Contents

Install

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

go get github.com/alex-necsoiu/go-eth-wallet/keystore

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

Alex Necsoiu: @alex-nesoiu.

Contribute

Contributions welcome. Please check out the issues.

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

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

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