crypto

package
v0.0.0-...-491e088 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2019 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateHash

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

func Initialize

func Initialize(c Crypto)

func IsKSAccountUnlocked

func IsKSAccountUnlocked(addr common.Address) bool

func SigToAddress

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

func SigToVRS

func SigToVRS(sig []byte) (v byte, r []byte, s []byte)

func Sign

func Sign(hash []byte, signer common.Address) ([]byte, error)

func SignTx

func SignTx(a common.Address, tx *types.Transaction, chainID *big.Int) (*types.Transaction, error)

func UnlockKSAccount

func UnlockKSAccount(acc accounts.Account, passphrase string) error

func VRSToSig

func VRSToSig(v byte, r, s []byte) ([]byte, error)

func ValidateSignatureValues

func ValidateSignatureValues(v byte, r, s []byte) bool

Types

type Crypto

type Crypto interface {
	//签名验证
	ValidateSignatureValues(v byte, r, s []byte) bool
	//生成hash
	GenerateHash(data ...[]byte) []byte
	//签名
	Sign(hash []byte, signer common.Address) ([]byte, error)
	//签名恢复到地址
	SigToAddress(hash, sig []byte) ([]byte, error)
	//生成sig
	VRSToSig(v byte, r, s []byte) ([]byte, error)

	SigToVRS(sig []byte) (v byte, r []byte, s []byte)

	SignTx(a common.Address, tx *types.Transaction, chainID *big.Int) (*types.Transaction, error)
}

type EthCrypto

type EthCrypto struct {
	// contains filtered or unexported fields
}

func (EthCrypto) GenerateHash

func (c EthCrypto) GenerateHash(data ...[]byte) []byte

生成hash

func (EthCrypto) SigToAddress

func (c EthCrypto) SigToAddress(hashPre, sig []byte) ([]byte, error)

签名回复到地址

func (EthCrypto) SigToVRS

func (c EthCrypto) SigToVRS(sig []byte) (v byte, r []byte, s []byte)

func (EthCrypto) VRSToSig

func (c EthCrypto) VRSToSig(v byte, r, s []byte) (sig []byte, err error)

func (EthCrypto) ValidateSignatureValues

func (c EthCrypto) ValidateSignatureValues(v byte, r, s []byte) bool

签名验证

type EthKSCrypto

type EthKSCrypto struct {
	EthCrypto
	// contains filtered or unexported fields
}

func NewKSCrypto

func NewKSCrypto(homestead bool, ks *keystore.KeyStore) EthKSCrypto

func (EthKSCrypto) IsUnlocked

func (c EthKSCrypto) IsUnlocked(addr common.Address) bool

func (EthKSCrypto) Sign

func (c EthKSCrypto) Sign(hashPre []byte, signerAddr common.Address) ([]byte, error)

func (EthKSCrypto) SignTx

func (c EthKSCrypto) SignTx(addr common.Address, tx *types.Transaction, chainID *big.Int) (*types.Transaction, error)

func (EthKSCrypto) UnlockAccount

func (c EthKSCrypto) UnlockAccount(acc accounts.Account, passphrase string) error

type EthPrivateKeyCrypto

type EthPrivateKeyCrypto struct {
	EthCrypto
	// contains filtered or unexported fields
}

func NewPrivateKeyCrypto

func NewPrivateKeyCrypto(homestead bool, privateKeyHex string) (EthPrivateKeyCrypto, error)

func (EthPrivateKeyCrypto) Address

func (c EthPrivateKeyCrypto) Address() common.Address

func (*EthPrivateKeyCrypto) MarshalText

func (h *EthPrivateKeyCrypto) MarshalText() ([]byte, error)

func (EthPrivateKeyCrypto) Sign

func (c EthPrivateKeyCrypto) Sign(hashPre []byte, signerAddr common.Address) ([]byte, error)

func (EthPrivateKeyCrypto) SignTx

func (c EthPrivateKeyCrypto) SignTx(addr common.Address, tx *types.Transaction, chainID *big.Int) (*types.Transaction, error)

func (*EthPrivateKeyCrypto) UnmarshalText

func (h *EthPrivateKeyCrypto) UnmarshalText(input []byte) error

Jump to

Keyboard shortcuts

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