crypto

package
v0.0.0-...-168a2c3 Latest Latest
Warning

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

Go to latest
Published: May 30, 2019 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddressOf

func AddressOf(pk common.PublicKey) common.Address

AddressOf calculates hash of the PublicKey.

func DecodeSignature

func DecodeSignature(sig string) (r, s *big.Int, err error)

DecodeSignature decode signature from string

func EncodeSignature

func EncodeSignature(r, s *big.Int) string

EncodeSignature string print

func GenerateECDSAKey

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

GenerateECDSAKey generate ECDSA Key

func GenerateFakeKey

func GenerateFakeKey(n int) *common.PrivateKey

GenerateFakeKey creates fake private key.

func GenerateKey

func GenerateKey() *common.PrivateKey

GenerateKey creates new private key.

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 KeyToPem

func KeyToPem(key *common.PrivateKey) ([]byte, error)

KeyToPem encodes key to PEM.

func PemToKey

func PemToKey(b []byte) (*common.PrivateKey, error)

PemToKey parses key from PEM.

func Sign

func Sign(priv *ecdsa.PrivateKey, hash []byte) (r, s *big.Int, err error)

Sign signs with key NOTE: deprecated

func Verify

func Verify(pub *ecdsa.PublicKey, hash []byte, r, s *big.Int) bool

Verify verifies the signatures NOTE: deprecated

Types

type PemDump

type PemDump struct {
	PublicKey  string
	PrivateKey string
}

PemDump struct

func GeneratePemKey

func GeneratePemKey() (*PemDump, error)

GeneratePemKey generate new PEM key

func ToPemKey

func ToPemKey(priv *ecdsa.PrivateKey) (*PemDump, error)

ToPemKey get PEM mfrom private key

type PemKey

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

PemKey struct

func NewPemKey

func NewPemKey(base string) *PemKey

NewPemKey constructor

func (*PemKey) ReadKey

func (k *PemKey) ReadKey() (*ecdsa.PrivateKey, error)

ReadKey from disk

func (*PemKey) ReadKeyFromBuf

func (k *PemKey) ReadKeyFromBuf(buf []byte) (*ecdsa.PrivateKey, error)

ReadKeyFromBuf from buffer

func (*PemKey) WriteKey

func (k *PemKey) WriteKey(key *ecdsa.PrivateKey) error

WriteKey to disk

Directories

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