Documentation ¶
Index ¶
- Variables
- func GenerateKeyPair() (*PrivateKey, *PublicKey, error)
- func HexToECDSA(hexkey string) (*ecdsa.PrivateKey, error)
- func Keccak256(data ...[]byte) []byte
- func Keccak256Hash(data ...[]byte) (h common.Hash)
- func PrivKeyToECDSA(key *PrivateKey) *ecdsa.PrivateKey
- func PubKeyToECDSA(key *PublicKey) *ecdsa.PublicKey
- func S256() elliptic.Curve
- func TEST_GenerateKeyPairWithSeed(seed string) (*PrivateKey, *PublicKey, error)
- type PrivateKey
- type PublicKey
- func (pk *PublicKey) Address() common.Address
- func (pk *PublicKey) DecodeRLP(stream *rlp.Stream) error
- func (pk *PublicKey) EncodeRLP(w io.Writer) error
- func (pk *PublicKey) IsEmpty() bool
- func (pk *PublicKey) ToBytes() common.Bytes
- func (pk *PublicKey) VerifySignature(msg common.Bytes, sig *Signature) bool
- type Signature
- func (sig *Signature) DecodeRLP(stream *rlp.Stream) error
- func (sig *Signature) EncodeRLP(w io.Writer) error
- func (sig *Signature) IsEmpty() bool
- func (sig *Signature) MarshalJSON() ([]byte, error)
- func (sig *Signature) RecoverSignerAddress(msg common.Bytes) (common.Address, error)
- func (sig *Signature) ToBytes() common.Bytes
- func (sig *Signature) UnmarshalJSON(data []byte) error
- func (sig *Signature) Verify(msg common.Bytes, addr common.Address) bool
Constants ¶
This section is empty.
Variables ¶
var ( UnmarshalPubkey = unmarshalPubkey FromECDSAPub = fromECDSAPub ValidateSignatureValues = validateSignatureValues CreateAddress = createAddress CreateAddress2 = createAddress2 )
var ( Ecrecover = ecrecover Sign = sign )
Functions ¶
func GenerateKeyPair ¶
func GenerateKeyPair() (*PrivateKey, *PublicKey, error)
GenerateKeyPair generates a random private/public key pair
func HexToECDSA ¶
func HexToECDSA(hexkey string) (*ecdsa.PrivateKey, error)
HexToECDSA parses a secp256k1 private key.
func Keccak256Hash ¶
Keccak256Hash calculates and returns the Keccak256 hash of the input data, converting it to an internal Hash data structure.
func PrivKeyToECDSA ¶ added in v1.0.4
func PrivKeyToECDSA(key *PrivateKey) *ecdsa.PrivateKey
PrivKeyToECDSA convert private key to ecdsa.
func PubKeyToECDSA ¶ added in v1.0.4
PubKeyToECDSA convert public key to ecdsa.
func TEST_GenerateKeyPairWithSeed ¶
func TEST_GenerateKeyPairWithSeed(seed string) (*PrivateKey, *PublicKey, error)
TEST_GenerateKeyPairWithSeed generates a random private/public key pair with the given seed string
Types ¶
type PrivateKey ¶
type PrivateKey struct {
// contains filtered or unexported fields
}
PrivateKey represents the private key
func ECDSAToPrivKey ¶ added in v1.0.4
func ECDSAToPrivKey(p *ecdsa.PrivateKey) *PrivateKey
ECDSAToPrivKey converts given ecdsa public key to pubkey.
func PrivateKeyFromBytes ¶
func PrivateKeyFromBytes(skBytes common.Bytes) (*PrivateKey, error)
PrivateKeyFromBytes converts the given bytes to a private key
func PrivateKeyFromBytesUnsafe ¶
func PrivateKeyFromBytesUnsafe(skBytes common.Bytes) *PrivateKey
PrivateKeyFromBytesUnsafe blindly converts a binary blob to a private key. It should almost never be used unless you are sure the input is valid and want to avoid hitting errors due to bad origin encoding (0 prefixes cut off).
func PrivateKeyFromFile ¶
func PrivateKeyFromFile(filepath string) (*PrivateKey, error)
PrivateKeyFromFile loads the private key from the given file
func (*PrivateKey) D ¶
func (sk *PrivateKey) D() *big.Int
D returns the D parameter of the ECDSA private key
func (*PrivateKey) PublicKey ¶
func (sk *PrivateKey) PublicKey() *PublicKey
PublicKey returns the public key corresponding to the private key
func (*PrivateKey) SaveToFile ¶
func (sk *PrivateKey) SaveToFile(filepath string) error
SaveToFile saves the private key to the designated file
func (*PrivateKey) Sign ¶
func (sk *PrivateKey) Sign(msg common.Bytes) (*Signature, error)
Sign signs the given message with the private key
func (*PrivateKey) ToBytes ¶
func (sk *PrivateKey) ToBytes() common.Bytes
ToBytes returns the bytes representation of the private key
type PublicKey ¶
type PublicKey struct {
// contains filtered or unexported fields
}
PublicKey represents the public key
func ECDSAToPubKey ¶ added in v1.0.4
ECDSAToPubKey converts given ecdsa public key to pubkey.
func PublicKeyFromBytes ¶
PublicKeyFromBytes converts the given bytes to a public key
type Signature ¶
type Signature struct {
// contains filtered or unexported fields
}
Signature represents the digital signature
func SignatureFromBytes ¶
SignatureFromBytes converts the given bytes to a signature
func (*Signature) MarshalJSON ¶
MarshalJSON returns the JSON representation of the signature
func (*Signature) RecoverSignerAddress ¶
RecoverSignerAddress recovers the address of the signer for the given message
func (*Signature) UnmarshalJSON ¶
UnmarshalJSON parses the JSON representation of the signature
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. |
Package sha3 implements the SHA-3 fixed-output-length hash functions and the SHAKE variable-output-length hash functions defined by FIPS-202.
|
Package sha3 implements the SHA-3 fixed-output-length hash functions and the SHAKE variable-output-length hash functions defined by FIPS-202. |