crypto

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2017 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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)

2528 Shi TeemoGuo

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(prv *ecdsa.PrivateKey) []byte

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)

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)

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 from json 把int数组点转公钥数组点

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. The key data is expected to be hex-encoded.

func PubkeyToAddress

func PubkeyToAddress(p ecdsa.PublicKey) common.Address

func PublicKeyToInt

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

PublicKeyToInt for json 把公钥数组点转int数组,(0放x,1放y) PublicKeys[n]数组时,调用 outInt=PublicKeyToInt(PublicKeys...), 单个公钥KeyImage时,调用outInt=PublicKeyToInt(KeyImage), outInt[0]为返回值

func RingSign

func RingSign(M []byte, x *big.Int, PublicKeys []*ecdsa.PublicKey) ([]*ecdsa.PublicKey, *ecdsa.PublicKey, []*big.Int, []*big.Int)

明文,私钥x,公钥组,(P的公钥放在第0位,0....n) 环签名 2528 Pengbo add Shi TeemoGuo revise

func Rsa_decrypt

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

func Rsa_encrypt

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

2528 add

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 Sha3Hash deprecated added in v0.2.0

func Sha3Hash(data ...[]byte) common.Hash

Deprecated: For backward compatibility as other packages depend on these

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(prv []byte) *ecdsa.PrivateKey

ToECDSA creates a private key with the given D value.

func ToECDSAPub

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

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 验证环签名

Types

This section is empty.

Directories

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