crypto

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const AddressLength = 20

Variables

This section is empty.

Functions

func FromECDSA

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

func FromECDSAPub

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

func GenerateKey

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

func HexToECDSA

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

func Keccak256

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

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

func S256

func S256() elliptic.Curve

func ToECDSA

func ToECDSA(b []byte) (*ecdsa.PrivateKey, error)

Types

type Address

type Address [AddressLength]byte

func BytesToAddress

func BytesToAddress(b []byte) Address

func PubkeyToAddress

func PubkeyToAddress(p ecdsa.PublicKey) Address

func (Address) Hex

func (a Address) Hex() string

func (*Address) SetBytes

func (a *Address) SetBytes(b []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.

func NewKeccakState

func NewKeccakState() KeccakState

NewKeccakState creates a new KeccakState

Jump to

Keyboard shortcuts

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