crypto

package
v0.0.0-...-4fc266b Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2025 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BytesFromECDSAPrivateKey

func BytesFromECDSAPrivateKey(privateKey *ecdsa.PrivateKey) []byte

func ECDSAKeysFromPrivateKeyBytes

func ECDSAKeysFromPrivateKeyBytes(pk []byte) (*ecdsa.PrivateKey, *ecdsa.PublicKey)

func ECDSAKeysFromPrivateKeyHex

func ECDSAKeysFromPrivateKeyHex(pk string) (priv *ecdsa.PrivateKey, pub *ecdsa.PublicKey, err error)

func ECDSAPublicKeyCompressedToBytes

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

func ECDSAPublicKeyToBytes

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

func Keccak256

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

Keccak256 calculates and returns the Keccak256 hash of the input data or few pieces of data.

func PubKeyToAddressBytes

func PubKeyToAddressBytes(p ecdsa.PublicKey) []byte

func SignEcdsaRfc6979

func SignEcdsaRfc6979(priv *ecdsa.PrivateKey, hash []byte, alg func() hash.Hash) (v byte, r, s *big.Int)

func SignEcdsaRfc6979Bytes

func SignEcdsaRfc6979Bytes(privateKey *ecdsa.PrivateKey, hash []byte, alg func() hash.Hash) (sig []byte)

Types

type EthTxSigner

type EthTxSigner struct {
	Nonce    uint64   // nonce of sender account
	GasPrice *big.Int // wei per gas
	Gas      uint64   // gas limit
	To       *[]byte  `rlp:"nil"` // nil means contract creation
	Value    *big.Int // wei amount
	Data     []byte   // contract invocation input data
	V, R, S  *big.Int // signature values
	// contains filtered or unexported fields
}

func NewEthTxSigner

func NewEthTxSigner(nonce uint64, gasPrice *big.Int, gas uint64, To []byte, value *big.Int, data []byte) *EthTxSigner

func (*EthTxSigner) EncodeRPL

func (tx *EthTxSigner) EncodeRPL() (data []byte, err error)

func (*EthTxSigner) Hash

func (tx *EthTxSigner) Hash() []byte

func (*EthTxSigner) SetChainId

func (tx *EthTxSigner) SetChainId(id *big.Int)

func (*EthTxSigner) Sign

func (tx *EthTxSigner) Sign(privateKey *ecdsa.PrivateKey) (sig []byte)

type KeccakState

type KeccakState interface {
	hash.Hash
	Read([]byte) (int, error)
}

KeccakState wraps sha3.state. In addition to the usual hash methods, it also supports Read to get a variable amount of data from the hash state. Read is faster than Sum because it doesn't copy the internal state, but also modifies the internal state. imported from go-ethereum, modified to remove dependency on go-ethereum/common because "A little copying is better than a little dependency." (https://go-proverbs.github.io) ;)

func NewKeccakState

func NewKeccakState() KeccakState

Directories

Path Synopsis
Package secp256k1 bsed on original elliptic, implements several standard elliptic curves over prime fields.
Package secp256k1 bsed on original elliptic, implements several standard elliptic curves over prime fields.

Jump to

Keyboard shortcuts

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