crypto

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2024 License: GPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// https://eips.ethereum.org/EIPS/eip-7251
	MIN_ACTIVATION_BALANCE   phase0.Gwei = 32000000000
	MAX_EFFECTIVE_BALANCE    phase0.Gwei = 2048000000000
	ETH1WithdrawalPrefixByte             = byte(1)
)

Variables

This section is empty.

Functions

func ComputeDepositMessageSigningRoot

func ComputeDepositMessageSigningRoot(network core.Network, message *phase0.DepositMessage) (phase0.Root, error)

func Decrypt

func Decrypt(pk *rsa.PrivateKey, msg []byte) ([]byte, error)

func DepositDataRootForFork

func DepositDataRootForFork(
	fork [4]byte,
	validatorPK []byte,
	withdrawalCredentials []byte,
	amount phase0.Gwei,
) (phase0.Root, error)

func ETH1WithdrawalCredentials

func ETH1WithdrawalCredentials(withdrawalAddr []byte) []byte

func EncodeRSAPublicKey

func EncodeRSAPublicKey(pk *rsa.PublicKey) ([]byte, error)

func Encrypt

func Encrypt(pub *rsa.PublicKey, msg []byte) ([]byte, error)

Encrypt with RSA public key private DKG share key

func GenerateRSAKeys

func GenerateRSAKeys() (*rsa.PrivateKey, *rsa.PublicKey, error)

GenerateRSAKeys creates a random RSA key pair

func GetNetworkByFork

func GetNetworkByFork(fork [4]byte) (core.Network, error)

GetNetworkByFork translates the network fork bytes into name

TODO: once eth2_key_manager implements this we can get rid of it and support all networks ekm supports automatically

func InitBLS

func InitBLS()

func IsEOAAccount

func IsEOAAccount(client eip1271.ETHClient, address common.Address) (bool, error)

func ParseRSAPublicKey

func ParseRSAPublicKey(pk []byte) (*rsa.PublicKey, error)

ParseRSAPublicKey parses encoded to base64 x509 RSA public key

func RecoverBLSSignature

func RecoverBLSSignature(ids []uint64, partialSigs []*bls.Sign) (*bls.Sign, error)

RecoverBLSSignature recovers a BLS master signature from T-threshold partial signatures

func RecoverValidatorPublicKey

func RecoverValidatorPublicKey(ids []uint64, sharePks []*bls.PublicKey) (*bls.PublicKey, error)

RecoverValidatorPublicKey recovers a BLS master public key (validator pub key) from provided partial pub keys

func SignRSA

func SignRSA(sk *rsa.PrivateKey, byts []byte) ([]byte, error)

SignRSA create a RSA signature for incoming bytes

func VerifyDepositData

func VerifyDepositData(network core.Network, depositData *phase0.DepositData) error

VerifyDepositData reconstructs and checks BLS signatures for ETH2 deposit message

func VerifyPartialSigs

func VerifyPartialSigs(sigs []*bls.Sign, pubs []*bls.PublicKey, data []byte) error

func VerifyRSA

func VerifyRSA(pk *rsa.PublicKey, msg, signature []byte) error

VerifyRSA verifies RSA signature for incoming message

func VerifySignedMessageByOwner

func VerifySignedMessageByOwner(
	client eip1271.ETHClient,
	owner [20]byte,
	hash [32]byte,
	signature []byte,
) error

VerifySignedMessageByOwner returns nil if signature over message is valid (signed by owner)

Types

This section is empty.

Jump to

Keyboard shortcuts

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