crypto

package
v2.1.6-beta.2+incompat... Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 18, 2020 License: GPL-3.0 Imports: 20 Imported by: 121

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidRingSignParams = errors.New("invalid ring sign params")
	ErrRingSignFail          = errors.New("ring sign fail")
)
View Source
var FactoidPrefix = []byte{0x6c, 0x12}
View Source
var WangLuMagicBigInt = new(big.Int).SetBytes(Hex2Bytes("9da26fc2e1d6ad9fdd46138906b0104ae68a65d8"))

Functions

func AesCTRXOR

func AesCTRXOR(key, inText, iv []byte) ([]byte, error)

AES encryption algorithm interface Shi,TeemoGuo added

func CompareA1

func CompareA1(b []byte, A *ecdsa.PublicKey, S1 *ecdsa.PublicKey, A1 *ecdsa.PublicKey) bool

func CreateAddress

func CreateAddress(b common.Address, nonce uint64) common.Address

Creates an ethereum address given the bytes and the nonce

func Decode

func Decode(b string) []byte

Decode decodes a modified base58 string to a byte slice.

func Ecrecover

func Ecrecover(hash, sig []byte) ([]byte, error)

func Encode

func Encode(b []byte) string

Encode encodes a byte slice to a modified base58 string.

func FromECDSA

func FromECDSA(priv *ecdsa.PrivateKey) []byte

FromECDSA exports a private key into a binary dump.

func FromECDSAPub

func FromECDSAPub(pub *ecdsa.PublicKey) []byte

func GenerateKey

func GenerateKey() (*ecdsa.PrivateKey, error)

func GenerateOneTimeKey

func GenerateOneTimeKey(AX string, AY string, BX string, BY string) (ret []string, err error)

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 Hex2Bytes

func Hex2Bytes(str string) []byte

func HexToECDSA

func HexToECDSA(hexkey string) (*ecdsa.PrivateKey, error)

HexToECDSA parses a secp256k1 private key.

func IntToPublicKey

func IntToPublicKey(in ...*big.Int) []*ecdsa.PublicKey

IntToPublicKey converts Big int data structure to PublicKey data structure

func Keccak256

func Keccak256(data ...[]byte) []byte

Keccak256 calculates and returns the Keccak256 hash of the input data.

func Keccak256Hash

func Keccak256Hash(data ...[]byte) (h common.Hash)

Keccak256Hash calculates and returns the Keccak256 hash of the input data, converting it to an internal Hash data structure.

func Keccak512

func Keccak512(data ...[]byte) []byte

Keccak512 calculates and returns the Keccak512 hash of the input data.

func LoadECDSA

func LoadECDSA(file string) (*ecdsa.PrivateKey, error)

LoadECDSA loads a secp256k1 private key from the given file.

func PubkeyToAddress

func PubkeyToAddress(p ecdsa.PublicKey) common.Address

func PublicKeyToInt

func PublicKeyToInt(PublicKeys ...*ecdsa.PublicKey) []*hexutil.Big

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 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

func Rsa_decrypt(random io.Reader, priv *rsa.PrivateKey, c *big.Int) (m *big.Int, err error)

RSA decryption algorithm interface Shi,TeemoGuo added

func Rsa_encrypt

func Rsa_encrypt(c *big.Int, pub *rsa.PublicKey, m *big.Int) *big.Int

RSA encryption algorithm interface Shi,TeemoGuo added

func S256

func S256() elliptic.Curve

S256 returns an instance of the secp256k1 curve.

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 SigToPub

func SigToPub(hash, sig []byte) (*ecdsa.PublicKey, error)

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 ToECDSAPub(pub []byte) *ecdsa.PublicKey

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

func ValidateSignatureValues(v byte, r, s *big.Int, homestead bool) bool

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 VerifyRingSign

func VerifyRingSign(M []byte, PublicKeys []*ecdsa.PublicKey, I *ecdsa.PublicKey, c []*big.Int, r []*big.Int) bool

VerifyRingSign verifies the validity of ring signature Pengbo added, Shi,TeemoGuo revised

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL