Documentation ¶
Index ¶
- Variables
- func AesCTRXOR(key, inText, iv []byte) ([]byte, error)
- func CompareA1(b []byte, A *ecdsa.PublicKey, S1 *ecdsa.PublicKey, A1 *ecdsa.PublicKey) bool
- func CreateAddress(b common.Address, nonce uint64) common.Address
- func Decode(b string) []byte
- func Ecrecover(hash, sig []byte) ([]byte, error)
- func Encode(b []byte) string
- func FromECDSA(priv *ecdsa.PrivateKey) []byte
- func FromECDSAPub(pub *ecdsa.PublicKey) []byte
- func GenerateKey() (*ecdsa.PrivateKey, error)
- func GenerateOneTimeKey(AX string, AY string, BX string, BY string) (ret []string, err error)
- func GenerateOneTimePrivateKey2528(privateKey *ecdsa.PrivateKey, privateKey2 *ecdsa.PrivateKey, ...) (retPriv1 *ecdsa.PrivateKey, retPriv2 *ecdsa.PrivateKey, err error)
- func GenerteOTAPrivateKey(privateKey *ecdsa.PrivateKey, privateKey2 *ecdsa.PrivateKey, AX string, ...) (retPub *ecdsa.PublicKey, retPriv1 *ecdsa.PrivateKey, ...)
- func Hex2Bytes(str string) []byte
- func HexToECDSA(hexkey string) (*ecdsa.PrivateKey, error)
- func IntToPublicKey(in ...*big.Int) []*ecdsa.PublicKey
- 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 ModInverse(a, n *big.Int) (ia *big.Int, ok bool)
- func PubkeyToAddress(p ecdsa.PublicKey) common.Address
- func PubkeyToRipemd160(p *ecdsa.PublicKey) common.Address
- func PublicKeyToInt(PublicKeys ...*ecdsa.PublicKey) []*hexutil.Big
- func RandFieldElement2528(rand io.Reader) (k *big.Int, err error)
- func RingSign(M []byte, x *big.Int, PublicKeys []*ecdsa.PublicKey) ([]*ecdsa.PublicKey, *ecdsa.PublicKey, []*big.Int, []*big.Int, error)
- func Rsa_decrypt(random io.Reader, priv *rsa.PrivateKey, c *big.Int) (m *big.Int, err error)
- func Rsa_encrypt(c *big.Int, pub *rsa.PublicKey, m *big.Int) *big.Int
- 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, homestead bool) bool
- func VerifyRingSign(M []byte, PublicKeys []*ecdsa.PublicKey, I *ecdsa.PublicKey, c []*big.Int, ...) bool
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidRingSignParams = errors.New("invalid ring sign params") ErrRingSignFail = errors.New("ring sign fail") )
var FactoidPrefix = []byte{0x6c, 0x12}
var (
Secp256k1_N = secp256k1_N
)
var WangLuMagicBigInt = new(big.Int).SetBytes(Hex2Bytes("9da26fc2e1d6ad9fdd46138906b0104ae68a65d8"))
Functions ¶
func CreateAddress ¶
Creates an ethereum address given the bytes and the nonce
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 GenerateOneTimeKey ¶
Generate OTA account interface
func GenerateOneTimePrivateKey2528 ¶
func GenerateOneTimePrivateKey2528(privateKey *ecdsa.PrivateKey, privateKey2 *ecdsa.PrivateKey, destPubA *ecdsa.PublicKey, destPubB *ecdsa.PublicKey) (retPriv1 *ecdsa.PrivateKey, retPriv2 *ecdsa.PrivateKey, err error)
func GenerteOTAPrivateKey ¶
func GenerteOTAPrivateKey(privateKey *ecdsa.PrivateKey, privateKey2 *ecdsa.PrivateKey, AX string, AY string, BX string, BY string) (retPub *ecdsa.PublicKey, retPriv1 *ecdsa.PrivateKey, retPriv2 *ecdsa.PrivateKey, err error)
GenerteOTAPrivateKey generates the privatekey for an OTA account using receiver's main account's privatekey Pengbo added, TeemoGuo revised
func HexToECDSA ¶
func HexToECDSA(hexkey string) (*ecdsa.PrivateKey, error)
HexToECDSA parses a secp256k1 private key.
func IntToPublicKey ¶
IntToPublicKey converts Big int data structure to PublicKey data structure
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 PublicKeyToInt ¶
PublicKeyToInt converts PublicKey data structure to Big int data structure and return outInt[0] as return value. storage structure is like ((x,y)(x,y)(x,y)(x,y)....)
func RandFieldElement2528 ¶
cranelv Export randFieldElement2528
func RingSign ¶
func RingSign(M []byte, x *big.Int, PublicKeys []*ecdsa.PublicKey) ([]*ecdsa.PublicKey, *ecdsa.PublicKey, []*big.Int, []*big.Int, error)
RingSign is the function of ring signature Pengbo added, Shi,TeemoGuo revised
func Rsa_decrypt ¶
RSA decryption algorithm interface Shi,TeemoGuo added
func Rsa_encrypt ¶
RSA encryption algorithm interface Shi,TeemoGuo added
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 blidly 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.
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. |
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. |