Documentation ¶
Index ¶
- Variables
- func AesDecrypt(encResult, key []byte) ([]byte, error)
- func AesEncrypt(originData, key []byte) ([]byte, error)
- func CheckPublic(public string) bool
- func CompressPubkey(pubkey *ecdsa.PublicKey) []byte
- func CreateContractAddress(b common.Address, hash common.Hash) common.Address
- func CreateTempAddress(creator common.Address, userId [10]byte) common.Address
- func DecompressPubkey(pubkey []byte) (*ecdsa.PublicKey, error)
- func Ecrecover(hash, sig []byte) ([]byte, error)
- func FromECDSA(priv *ecdsa.PrivateKey) []byte
- func FromECDSAPub(pub *ecdsa.PublicKey) []byte
- func GenerateKey() (*ecdsa.PrivateKey, error)
- func HexToECDSA(hexkey string) (*ecdsa.PrivateKey, error)
- func Keccak256(data ...[]byte) []byte
- func Keccak256Hash(data ...[]byte) (h common.Hash)
- func Keccak512(data ...[]byte) []byte
- func LoadECDSA(file string) (*ecdsa.PrivateKey, error)
- func PKCS5Padding(cipherText []byte, blockSize int) []byte
- func PKCS5UnPadding(originData []byte) []byte
- func PrivateKeyToNodeID(private *ecdsa.PrivateKey) []byte
- func PubToAddress(pub []byte) common.Address
- func PubkeyToAddress(p ecdsa.PublicKey) common.Address
- func S256() elliptic.Curve
- func SaveECDSA(file string, key *ecdsa.PrivateKey) error
- func SigToPub(hash, sig []byte) (*ecdsa.PublicKey, error)
- func Sign(hash []byte, prv *ecdsa.PrivateKey) (sig []byte, err error)
- func ToECDSA(d []byte) (*ecdsa.PrivateKey, error)
- func ToECDSAPub(pub []byte) *ecdsa.PublicKey
- func ToECDSAUnsafe(d []byte) *ecdsa.PrivateKey
- func ValidateSignatureValues(v byte, r, s *big.Int) bool
- func VerifySignature(pubkey, hash, signature []byte) bool
- type AccountKey
Constants ¶
This section is empty.
Variables ¶
var (
ErrPKCS5UnPadding = errors.New("PKCS5UnPadding error")
)
Functions ¶
func AesDecrypt ¶ added in v1.0.2
func AesEncrypt ¶ added in v1.0.2
func CompressPubkey ¶
CompressPubkey encodes a public key to the 33-byte compressed format.
func CreateContractAddress ¶ added in v1.3.0
Creates an lemochain address given the bytes and the hash
func CreateTempAddress ¶ added in v1.3.0
CreateTempAddress return a temp account address
func DecompressPubkey ¶
DecompressPubkey parses a public key in the 33-byte compressed format.
func FromECDSA ¶
func FromECDSA(priv *ecdsa.PrivateKey) []byte
FromECDSA exports a private key into a binary dump.
func FromECDSAPub ¶
func GenerateKey ¶
func GenerateKey() (*ecdsa.PrivateKey, error)
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 LoadECDSA ¶
func LoadECDSA(file string) (*ecdsa.PrivateKey, error)
LoadECDSA loads a secp256k1 private key from the given file.
func PKCS5Padding ¶ added in v1.0.2
func PKCS5UnPadding ¶ added in v1.0.2
func PrivateKeyToNodeID ¶ added in v1.4.0
func PrivateKeyToNodeID(private *ecdsa.PrivateKey) []byte
func PubToAddress ¶
func SaveECDSA ¶
func SaveECDSA(file string, key *ecdsa.PrivateKey) error
SaveECDSA saves a secp256k1 private key to the given file with restrictive permissions. The key data is saved hex-encoded.
func Sign ¶
func Sign(hash []byte, prv *ecdsa.PrivateKey) (sig []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 ToECDSA ¶
func ToECDSA(d []byte) (*ecdsa.PrivateKey, error)
ToECDSA creates a private key with the given D value.
func ToECDSAPub ¶
func ToECDSAUnsafe ¶
func ToECDSAUnsafe(d []byte) *ecdsa.PrivateKey
ToECDSAUnsafe 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 ValidateSignatureValues ¶
ValidateSignatureValues verifies whether the signature values are valid with the given chain rules. The v value is assumed to be either 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 ¶
type AccountKey ¶
type AccountKey struct { Private string `json:"private"` Public string `json:"public"` Address common.Address `json:"address"` }
func GenerateAddress ¶
func GenerateAddress() (*AccountKey, error)
GenerateAddress generate Lemo address
func (AccountKey) MarshalJSON ¶
func (a AccountKey) MarshalJSON() ([]byte, error)
MarshalJSON marshals as JSON.
func (*AccountKey) UnmarshalJSON ¶
func (a *AccountKey) UnmarshalJSON(input []byte) error
UnmarshalJSON unmarshals from JSON.
Source Files ¶
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. |