Documentation ¶
Index ¶
- Constants
- Variables
- func AddressToHex(a common.Address) string
- func CompressPubkey(pubkey *ecdsa.PublicKey) []byte
- func CreateAddress(b common.Address, nonce uint64) common.Address
- func CreateAddress2(b common.Address, salt [32]byte, inithash []byte) common.Address
- func CreateGroupkey(b common.Address, id uint64) common.Address
- func DecompressPubkey(pubkey []byte) (*ecdsa.PublicKey, error)
- func Decrypt(pri *ecdsa.PrivateKey, c, s1, s2 []byte) (m []byte, err error)
- func Double256(b []byte) []byte
- func Ecrecover(hash, sig []byte) ([]byte, error)
- func Encrypt(pub *ecdsa.PublicKey, m, s1, s2 []byte) (ct []byte, err error)
- func FromECDSA(priv *ecdsa.PrivateKey) []byte
- func FromECDSAPub(pub *ecdsa.PublicKey) []byte
- func GenerateKey() (*ecdsa.PrivateKey, error)
- func GenerateShared(pri *ecdsa.PrivateKey, pub *ecdsa.PublicKey, skLen, macLen int) (sk []byte, err error)
- func GetVRS(sign []byte) (v byte, r, s *big.Int)
- func Hash256(auth, s, h []byte) hash.Hash
- func Hash256Byte(seedBytes, riseedBytes []byte) []byte
- 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 NewCipher(key []byte) (cipher.Block, error)
- func NewHash() hash.Hash
- func NewHashObject() func() hash.Hash
- func PubkeyToAddress(p ecdsa.PublicKey) common.Address
- func RlpHash(x interface{}) (h common.Hash)
- func S256() elliptic.Curve
- func SaveECDSA(file string, key *ecdsa.PrivateKey) error
- func SetCrtptoType(cryptoType uint8)
- func SigToPub(hash, sig []byte) (*ecdsa.PublicKey, error)
- func Sign(digestHash []byte, prv *ecdsa.PrivateKey) (sig []byte, err error)
- func Sum256(input []byte) ([]byte, error)
- func ToECDSA(d []byte) (*ecdsa.PrivateKey, error)
- func ToECDSAUnsafe(d []byte) *ecdsa.PrivateKey
- func UnmarshalPubkey(pub []byte) (*ecdsa.PublicKey, error)
- func ValidateSignatureValues(v byte, r, s *big.Int, homestead bool) bool
- func VerifySignature(pubkey, digestHash, signature []byte) bool
- func VerifySignatureTransaction(digestHash, signature []byte) bool
- func VerifySignatureTransactionPk(digestHash, signature, pk []byte) bool
Constants ¶
const ( CRYPTO_P256_SH3_AES = 1 //GUOJI HASH AND Asymmetric Encryption CRYPTO_SM2_SM3_SM4 = 2 //GUOMI hash and Asymmetric Encryption; CRYPTO_S256_SH3_AES = 3 )
const DigestLength = 32
DigestLength sets the signature digest exact length
const RecoveryIDOffset = 64
RecoveryIDOffset points to the byte offset within the signature that contains the recovery id.
const SignatureLength = 64 + 1 // 64 bytes ECDSA signature + 1 byte recovery id
SignatureLength indicates the byte length required to carry a signature with recovery id.
Variables ¶
var CryptoType = CRYPTO_SM2_SM3_SM4
Functions ¶
func AddressToHex ¶
According to gm,s256 or p256 param,convert address to string.
func CompressPubkey ¶
CompressPubkey encodes a public key to the 33-byte compressed format.
func CreateAddress ¶
CreateAddress creates an ethereum address given the bytes and the nonce
func CreateAddress2 ¶
CreateAddress2 creates an ethereum address given the address bytes, initial contract code hash and a salt.
func CreateGroupkey ¶
CreateGroupkey is for permission
func DecompressPubkey ¶
DecompressPubkey parses a public key in the 33-byte compressed format.
func Decrypt ¶
func Decrypt(pri *ecdsa.PrivateKey, c, s1, s2 []byte) (m []byte, err error)
According to gm,s256 or p256 param,decrypt message.
func Ecrecover ¶
Ecrecover returns the uncompressed public key that created the given signature.
func Ecrecover(hash, sig []byte) ([]byte, error) { return secp256k1.RecoverPubkey(hash, sig) }
func FromECDSA ¶
func FromECDSA(priv *ecdsa.PrivateKey) []byte
According to gm,s256 or p256 param to FromECDSA exports a private key into a binary dump.
func FromECDSAPub ¶
According to gm,s256 or p256 param to FromECDSA exports a publickey key into a binary dump.
func GenerateKey ¶
func GenerateKey() (*ecdsa.PrivateKey, error)
According to gm,s256 or p256 param to generate publickey and privatekey.
func GenerateShared ¶
func GenerateShared(pri *ecdsa.PrivateKey, pub *ecdsa.PublicKey, skLen, macLen int) (sk []byte, err error)
According to gm,s256 or p256 param,to generate communication key.
func Hash256 ¶
According to gm,s256 or p256 param write two param to Hash value,but xor s and h to write.
func Hash256Byte ¶
According to gm,s256 or p256 param write two param to Hash value.
func HexToECDSA ¶
func HexToECDSA(hexkey string) (*ecdsa.PrivateKey, error)
According to gm,s256 or p256 param to HexToECDSA parses a secp256k1 private key.
func Keccak256 ¶
According to gm,s256 or p256 param to Keccak256 calculates and returns the Keccak256 hash of the input data.
func Keccak256Hash ¶
According to gm,s256 or p256 param to Keccak256Hash calculates and returns the Keccak256 hash of the input data,converting it to an internal Hash data structure.
func Keccak512 ¶
According to gm,s256 or p256 param to Keccak512 calculates and returns the Keccak512 hash of the input data.
func LoadECDSA ¶
func LoadECDSA(file string) (*ecdsa.PrivateKey, error)
According to gm,s256 or p256 param to LoadECDSA loads a secp256k1 private key from the given file.
func NewHashObject ¶
According to gm,s256 or p256 param to new distinct hash method.
func PubkeyToAddress ¶
According to gm,s256 or p256 param,publickey to address.
func SaveECDSA ¶
func SaveECDSA(file string, key *ecdsa.PrivateKey) error
According to gm,s256 or p256 param to saveECDSA saves a secp256k1 private key to the given file with restrictive permissions. The key data is saved hex-encoded.
func SetCrtptoType ¶
func SetCrtptoType(cryptoType uint8)
func Sign ¶
func Sign(digestHash []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 digest 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)
According to gm,s256 or p256 param ToECDSA creates a private key with the given D value.
func ToECDSAUnsafe ¶
func ToECDSAUnsafe(d []byte) *ecdsa.PrivateKey
According to gm,s256 or p256 param to ToECDSA creates a private key with the given D value. but not return error
func UnmarshalPubkey ¶
According to gm,s256 or p256 param to UnmarshalPubkey exports a binary dump. into ecdsa PublicKey key.
func ValidateSignatureValues ¶
According to gm,s256 or p256 param,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 ¶
Types ¶
This section is empty.
Directories ¶
Path | Synopsis |
---|---|
Package blake2b implements the BLAKE2b hash algorithm defined by RFC 7693 and the extendable output function (XOF) BLAKE2Xb.
|
Package blake2b implements the BLAKE2b hash algorithm defined by RFC 7693 and the extendable output function (XOF) BLAKE2Xb. |
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. |