Documentation ¶
Index ¶
- func ByteFromECDSA(priv *ecdsa.PrivateKey) []byte
- func ByteFromECDSAPub(pub *ecdsa.PublicKey) []byte
- func ByteToECDSA(d []byte, strict bool) (*ecdsa.PrivateKey, error)
- func ByteToECDSAPub(pub []byte) *ecdsa.PublicKey
- func CompressPubkey(pubkey *ecdsa.PublicKey) []byte
- func CreateAddress(b utils.Address, nonce uint64) utils.Address
- func DecompressPubkey(pubkey []byte) (*ecdsa.PublicKey, error)
- func EcrecoverToByte(hash, signature []byte) ([]byte, error)
- func EcrecoverToPub(hash, signature []byte) (*ecdsa.PublicKey, error)
- func FromECDSAPub(pub *ecdsa.PublicKey) []byte
- func GenerateKey() (*ecdsa.PrivateKey, error)
- func GenerateKeyPair() (*utils.Address, *ecdsa.PrivateKey, error)
- func GenerateRandomAddress() (*utils.Address, error)
- func HexToECDSA(hexkey string) (*ecdsa.PrivateKey, error)
- func Keccak256(data ...[]byte) []byte
- func Keccak256Hash(data ...[]byte) (h utils.Hash)
- func Keccak512(data ...[]byte) []byte
- func Keccak512Hash(data ...[]byte) (h utils.Hash)
- func LoadECDSA(file string) (*ecdsa.PrivateKey, error)
- func MustGenerateRandomAddress() *utils.Address
- func PubkeyToAddress(p ecdsa.PublicKey) utils.Address
- func S256() elliptic.Curve
- func SaveECDSA(file string, key *ecdsa.PrivateKey) error
- func Sign(hash []byte, prv *ecdsa.PrivateKey) (signature []byte, err error)
- func VerifySignature(pubkey, hash, signature []byte) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ByteFromECDSA ¶
func ByteFromECDSA(priv *ecdsa.PrivateKey) []byte
ByteFromECDSA exports a private key into a binary dump.
func ByteFromECDSAPub ¶
ByteFromECDSAPub exports a public key into a binary dump.
func ByteToECDSA ¶
func ByteToECDSA(d []byte, strict bool) (*ecdsa.PrivateKey, error)
ByteToECDSA creates a private key with the given D value.
func ByteToECDSAPub ¶
ByteToECDSAPub creates a public key with the given value
func CompressPubkey ¶
CompressPubkey encodes a public key to the 33-byte compressed format.
func DecompressPubkey ¶
DecompressPubkey parses a public key in the 33-byte compressed format.
func EcrecoverToByte ¶
EcrecoverToByte returns the uncompressed public key that created the given signature.
func EcrecoverToPub ¶
EcrecoverToPub returns the public key that created the given signature.
func FromECDSAPub ¶
func GenerateKeyPair ¶
func GenerateKeyPair() (*utils.Address, *ecdsa.PrivateKey, error)
GenerateKeyPair generates public key and private key
func GenerateRandomAddress ¶
GenerateRandomAddress generates and returns a random address.
func HexToECDSA ¶
func HexToECDSA(hexkey string) (*ecdsa.PrivateKey, error)
HexToECDSA parses a secp256k1 private key.
func Keccak256Hash ¶
Keccak256Hash the Keccak256 hash of the input data.
func Keccak512Hash ¶
Keccak512Hash the Keccak512 hash of the input data.
func LoadECDSA ¶
func LoadECDSA(file string) (*ecdsa.PrivateKey, error)
LoadECDSA loads a private key from the given file.
func MustGenerateRandomAddress ¶
MustGenerateRandomAddress generates and returns a random address. Panic on any error.
func SaveECDSA ¶
func SaveECDSA(file string, key *ecdsa.PrivateKey) error
SaveECDSA saves a private key to the given file.
func Sign ¶
func Sign(hash []byte, prv *ecdsa.PrivateKey) (signature []byte, err error)
Sign calculates an ECDSA signature.
This function is susceptible to chosen plaintext attacks that can leak information about the private key that is used for signing. Callers must be aware that the given hash cannot be chosen by an adversery. Common solution is to hash any input before calculating the signature.
The produced signature is in the [R || S || V] format where V is 0 or 1.
func VerifySignature ¶
VerifySignature checks that the given public key created signature over hash. The public key should be in compressed (33 bytes) or uncompressed (65 bytes) format. The signature should have the 64 byte [R || S] format.
Types ¶
This section is empty.
Directories ¶
Path | Synopsis |
---|---|
Package bn256 implements the Optimal Ate pairing over a 256-bit Barreto-Naehrig curve.
|
Package bn256 implements the Optimal Ate pairing over a 256-bit Barreto-Naehrig curve. |
cloudflare
Package bn256 implements a particular bilinear group at the 128-bit security level.
|
Package bn256 implements a particular bilinear group at the 128-bit security level. |
google
Package bn256 implements a particular bilinear group.
|
Package bn256 implements a particular bilinear group. |
Package secp256k1 wraps the bitcoin secp256k1 C library.
|
Package secp256k1 wraps the bitcoin secp256k1 C library. |