legacy

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2025 License: MIT Imports: 12 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidKeystoreFile = errors.New("invalid keystore file")

Functions

func DetermineCurveType

func DetermineCurveType(curveStr string) string

DetermineCurveType attempts to determine the curve type based on the private key This is a best-effort function that uses the curveStr path in the keygen operation

func GenerateRandomPassword

func GenerateRandomPassword(length int) (string, error)

GenerateRandomPassword generates a cryptographically secure random password

func GetSigningSchemeForCurveType

func GetSigningSchemeForCurveType(curveType string) (signing.SigningScheme, error)

GetSigningSchemeForCurveType returns the appropriate signing scheme based on curve type

func SaveToKeystoreWithCurveType

func SaveToKeystoreWithCurveType(privateKey signing.PrivateKey, filePath, password, curveType string, opts *Options) error

SaveToKeystoreWithCurveType saves a private key to a keystore file using the Web3 Secret Storage format and includes the curve type in the keystore file

func TestKeystore

func TestKeystore(filePath, password string, scheme signing.SigningScheme) error

TestKeystore tests a keystore by signing a test message

Types

type LegacyKeystore

type LegacyKeystore struct {
	PublicKey string              `json:"publicKey"`
	Crypto    keystore.CryptoJSON `json:"crypto"`
	UUID      string              `json:"uuid"`
	Version   int                 `json:"version"`
	CurveType string              `json:"curveType"` // Either "bls381" or "bn254"
}

LegacyKeystore represents a private key encrypted using keystore V4 format

func LoadKeystoreFile

func LoadKeystoreFile(filePath string) (*LegacyKeystore, error)

LoadKeystoreFile loads a keystore from a file and returns the parsed LegacyKeystore struct

func ParseKeystoreJSON

func ParseKeystoreJSON(keystoreJSON string) (*LegacyKeystore, error)

ParseKeystoreJSON takes a string representation of the keystore JSON and returns the LegacyKeystore struct

func (*LegacyKeystore) GetBN254PrivateKey

func (k *LegacyKeystore) GetBN254PrivateKey(password string) (*bn254.PrivateKey, error)

func (*LegacyKeystore) GetPrivateKey

func (k *LegacyKeystore) GetPrivateKey(password string, scheme signing.SigningScheme) (signing.PrivateKey, error)

GetPrivateKey decrypts and returns the private key from the keystore

type Options

type Options struct {
	// ScryptN is the N parameter of scrypt encryption algorithm
	ScryptN int
	// ScryptP is the P parameter of scrypt encryption algorithm
	ScryptP int
}

Options provides configuration options for keystore operations

func Default

func Default() *Options

Default returns the default options for keystore operations

func Light

func Light() *Options

Light returns light options for keystore operations (faster but less secure)

Jump to

Keyboard shortcuts

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