keys

package
v2.12.0-beta2 Latest Latest
Warning

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

Go to latest
Published: May 20, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromEncryptedJSON

func FromEncryptedJSON[E Encrypted, K any](
	identifier string,
	keyJSON []byte,
	password string,
	passwordFunc func(string) string,
	privKeyToKey func(export E, rawPrivKey []byte) (K, error),
) (K, error)

FromEncryptedJSON gets key [K] from keyJSON [E] and password

func RunKeyExportImportTestcase

func RunKeyExportImportTestcase(t *testing.T, createKey CreateKeyFunc, decrypt DecryptFunc)

RunKeyExportImportTestcase executes a testcase to validate keys import/export functionality

func ToEncryptedJSON

func ToEncryptedJSON[E Encrypted, K any](
	identifier string,
	raw []byte,
	key K,
	password string,
	scryptParams utils.ScryptParams,
	passwordFunc func(string) string,
	buildExport func(id string, key K, cryptoJSON keystore.CryptoJSON) E,
) (export []byte, err error)

ToEncryptedJSON returns encrypted JSON [E] representing key [K]

Types

type CreateKeyFunc

type CreateKeyFunc func() (KeyType, error)

CreateKeyFunc represents a function to create a key

type DecryptFunc

type DecryptFunc func(keyJSON []byte, password string) (KeyType, error)

DecryptFunc represents a function to decrypt a key

type Encrypted

type Encrypted interface {
	GetCrypto() keystore.CryptoJSON
}

type EncryptedKeyExport

type EncryptedKeyExport struct {
	KeyType   string              `json:"keyType"`
	PublicKey string              `json:"publicKey"`
	Crypto    keystore.CryptoJSON `json:"crypto"`
}

EncryptedKeyExport represents a chain specific encrypted key

func (EncryptedKeyExport) GetCrypto

func (x EncryptedKeyExport) GetCrypto() keystore.CryptoJSON

type KeyType

type KeyType interface {
	ToEncryptedJSON(password string, scryptParams utils.ScryptParams) (export []byte, err error)
	String() string
}

KeyType represents a key type for keys testing

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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