Documentation
¶
Index ¶
- Variables
- func DetermineCurveType(curveStr string) string
- func GenerateRandomPassword(length int) (string, error)
- func GetSigningSchemeForCurveType(curveType string) (signing.SigningScheme, error)
- func SaveToKeystoreWithCurveType(privateKey signing.PrivateKey, filePath, password, curveType string, ...) error
- func TestKeystore(filePath, password string, scheme signing.SigningScheme) error
- type EIP2335Keystore
- func GenerateKeystore(privateKey signing.PrivateKey, password, curveType string, opts *Options) (*EIP2335Keystore, error)
- func LoadKeystoreFile(filePath string) (*EIP2335Keystore, error)
- func ParseKeystoreJSON(keystoreJSON string) (*EIP2335Keystore, error)
- func ParseLegacyKeystoreToEIP2335Keystore(legacyJSON string, password string, scheme signing.SigningScheme) (*EIP2335Keystore, error)
- type Module
- type Options
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidKeystoreFile = errors.New("invalid keystore file")
ErrInvalidKeystoreFile is returned when a keystore file is not valid or is corrupted
Functions ¶
func DetermineCurveType ¶
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 ¶
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 EIP-2335 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 EIP2335Keystore ¶
type EIP2335Keystore struct {
Crypto struct {
KDF Module `json:"kdf"`
Checksum Module `json:"checksum"`
Cipher Module `json:"cipher"`
} `json:"crypto"`
Description string `json:"description,omitempty"`
Pubkey string `json:"pubkey"`
Path string `json:"path"`
UUID string `json:"uuid"`
Version int `json:"version"`
CurveType string `json:"curveType,omitempty"` // Custom field, either "bls381" or "bn254"
}
EIP2335Keystore represents a BLS private key encrypted using EIP-2335 format
func GenerateKeystore ¶
func GenerateKeystore(privateKey signing.PrivateKey, password, curveType string, opts *Options) (*EIP2335Keystore, error)
func LoadKeystoreFile ¶
func LoadKeystoreFile(filePath string) (*EIP2335Keystore, error)
LoadKeystoreFile loads a keystore from a file and returns the parsed EIP2335Keystore struct
func ParseKeystoreJSON ¶
func ParseKeystoreJSON(keystoreJSON string) (*EIP2335Keystore, error)
ParseKeystoreJSON takes a string representation of the keystore JSON and returns the EIP2335Keystore struct
func ParseLegacyKeystoreToEIP2335Keystore ¶
func ParseLegacyKeystoreToEIP2335Keystore(legacyJSON string, password string, scheme signing.SigningScheme) (*EIP2335Keystore, error)
func (*EIP2335Keystore) GetBLS381PrivateKey ¶
func (k *EIP2335Keystore) GetBLS381PrivateKey(password string) (*bls381.PrivateKey, error)
GetBLS381PrivateKey gets a BLS381 private key from the keystore
func (*EIP2335Keystore) GetBN254PrivateKey ¶
func (k *EIP2335Keystore) GetBN254PrivateKey(password string) (*bn254.PrivateKey, error)
GetBN254PrivateKey gets a BN254 private key from the keystore
func (*EIP2335Keystore) GetPrivateKey ¶
func (k *EIP2335Keystore) GetPrivateKey(password string, scheme signing.SigningScheme) (signing.PrivateKey, error)
GetPrivateKey decrypts and returns the private key from the keystore
type Module ¶
type Module struct {
Function string `json:"function"`
Params map[string]interface{} `json:"params"`
Message string `json:"message"`
}
Module represents a cryptographic module in EIP-2335
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
// ScryptR is the R parameter of scrypt encryption algorithm (added for EIP-2335)
ScryptR int
// KDFType selects which KDF to use ("scrypt" or "pbkdf2")
KDFType string
// Description is an optional description for the keystore
Description string
}
Options provides configuration options for keystore operations