Documentation
¶
Overview ¶
Package crypto provides wrappers functions for cryptographic primitives along with various helper functions
Index ¶
- Variables
- func ECDSAToHex(key *ecdsa.PrivateKey) string
- func EtherHash(msg Message) []byte
- func GenerateKeyPair() (pri PrivateKey, pub PublicKey, err error)
- func HexToECDSA(key string) (*ecdsa.PrivateKey, error)
- func PublicKeyToAddress(pub PublicKey) types.WalletAddr
- func RecoverWalletAddress(msg Message, signature Signature, recovery uint8) (wallet types.WalletAddr, err error)
- func Verify(pub PublicKey, msg Message, sig Signature) bool
- type Message
- type PrivateKey
- type PublicKey
- type Signature
- type SignatureBytes
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func ECDSAToHex ¶
func ECDSAToHex(key *ecdsa.PrivateKey) string
func EtherHash ¶
EtherHash implements the Ethereum hashing standard used to create signatures. Uses an Ethereum specific prefix and the Keccak256 Hashing algorithm
func GenerateKeyPair ¶
func GenerateKeyPair() (pri PrivateKey, pub PublicKey, err error)
GenerateKey generates a Secp256k1 key pair.
func HexToECDSA ¶
func HexToECDSA(key string) (*ecdsa.PrivateKey, error)
func PublicKeyToAddress ¶
func PublicKeyToAddress(pub PublicKey) types.WalletAddr
PublicKeyToAddress converts a public key to a wallet address
func RecoverWalletAddress ¶
func RecoverWalletAddress(msg Message, signature Signature, recovery uint8) (wallet types.WalletAddr, err error)
RecoverWalletAddress calculates the WalletAddress of the identity which was used to sign the given message. A value is always returned and needs to verified before it can be trusted.
Types ¶
type PrivateKey ¶
type PrivateKey *[32]byte
func PrivateKeyFromBytes ¶
func PrivateKeyFromBytes(bytes []byte) (PrivateKey, error)
PrivateKeyFromBytes converts from a byte slice to a PrivateKey Type
type PublicKey ¶
type PublicKey *[65]byte
func PublicKeyFromBytes ¶
PublicKeyFromBytes converts from a byte slice to a PublicKey type
type Signature ¶
type Signature *[64]byte
func Sign ¶
func Sign(privateKey PrivateKey, msg Message) (Signature, uint8, error)
Sign generates a signature for the unhashed message provided.
func SignDigest ¶
func SignDigest(privateKey PrivateKey, digest []byte) (Signature, uint8, error)
SignDigest generates an RFC1363 formatted signature for the provided digest. It returns a signature in IEEE p1363 Format [R||S],the recovery bit and any error encountered
func SignatureFromBytes ¶
SignatureFromBytes converts from a byte slice to a Signature type
type SignatureBytes ¶
type SignatureBytes []byte