Documentation
¶
Index ¶
- func CheckCanonicalSignature(signature []byte) error
- func CheckSignature(hash, signature []byte, voters []common.Address) (common.Address, error)
- func ConstantSlice[T any](val T, n int) []T
- func Decrypt(ciphertext []byte, privateKey *ecdsa.PrivateKey) ([]byte, error)
- func ECDSAPrivKeyToECIES(privKey *ecdsa.PrivateKey) (*ecies.PrivateKey, error)
- func ECDSAPubKeyToECIES(pubKey *ecdsa.PublicKey) (*ecies.PublicKey, error)
- func Encrypt(plaintext []byte, publicKey *ecdsa.PublicKey) ([]byte, error)
- func HasDuplicateAddresses(addrs []common.Address) bool
- func ParsePubKeys(pubKeys []wallet.PublicKey) ([]*ecdsa.PublicKey, error)
- func PubKeysToAddresses(pubKeys []types.PublicKey) ([]common.Address, error)
- func Sign(msgHash []byte, privKey *ecdsa.PrivateKey) ([]byte, error)
- func SignatureToSignersAddress(hash, signature []byte) (common.Address, error)
- func Sum[T Number](numbers []T) T
- func SumUint64[T constraints.Unsigned](numbers []T) uint64
- func ToHash(s string) common.Hash
- func VerifySignature(hash, signature []byte, signerAddress common.Address) error
- type Number
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckCanonicalSignature ¶ added in v0.0.23
CheckCanonicalSignature rejects malformed and non-canonical (high-S) [R || S || V] signatures to keep the (data, signature) pair unique.
func CheckSignature ¶
CheckSignature recovers the signer address and optionally verifies it is in the allowed voter list.
func ConstantSlice ¶
ConstantSlice crates a slice of length n with all the entries equal to val.
func Decrypt ¶ added in v0.0.21
func Decrypt(ciphertext []byte, privateKey *ecdsa.PrivateKey) ([]byte, error)
Decrypt ECIES-decrypts ciphertext under the given secp256k1 ECDSA private key.
func ECDSAPrivKeyToECIES ¶
func ECDSAPrivKeyToECIES(privKey *ecdsa.PrivateKey) (*ecies.PrivateKey, error)
ECDSAPrivKeyToECIES converts a secp256k1 ECDSA private key to an ECIES private key.
func ECDSAPubKeyToECIES ¶
ECDSAPubKeyToECIES converts a secp256k1 ECDSA public key to an ECIES public key.
func Encrypt ¶ added in v0.0.21
Encrypt ECIES-encrypts plaintext under the given secp256k1 ECDSA public key.
func HasDuplicateAddresses ¶ added in v0.0.20
HasDuplicateAddresses reports whether addrs contains any address more than once.
func ParsePubKeys ¶
ParsePubKeys converts the wallet public key structures to ECDSA keys.
func PubKeysToAddresses ¶
PubKeysToAddresses returns the Ethereum addresses derived from the keys.
func Sign ¶
func Sign(msgHash []byte, privKey *ecdsa.PrivateKey) ([]byte, error)
Sign signs the provided hash with the given private key.
func SignatureToSignersAddress ¶
SignatureToSignersAddress recovers the Ethereum address associated with the signature of the given hash. Non-canonical signatures are rejected.
func SumUint64 ¶ added in v0.0.21
func SumUint64[T constraints.Unsigned](numbers []T) uint64
SumUint64 returns the sum of the slice elements accumulated in uint64. Unlike Sum, which accumulates in the element type and can wrap for narrow types (e.g. a []uint16 whose total exceeds 65535), this widens each element so the total cannot overflow for any realistic input.
Types ¶
type Number ¶
type Number interface {
constraints.Integer | constraints.Float
}