crypto

package
v0.0.0-...-ee99c87 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2018 License: LGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromECDSA

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

FromECDSA exports a private key into a binary dump.

func FromECDSAPub

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

FromECDSAPub marshals and returns byte array of ECDSA public key.

func GenerateKey

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

GenerateKey generates and returns a ECDSA private key.

func Keccak256Hash

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

Keccak256Hash calculates and returns the Keccak256 hash of the input data, converting it to an internal Hash data structure.

func LoadECDSAFromString

func LoadECDSAFromString(ecStr string) (*ecdsa.PrivateKey, error)

LoadECDSAFromString create ecdsa privatekey from string ecStr should start with 0x or 0X

func PubkeyToString

func PubkeyToString(pub *ecdsa.PublicKey) (pubStr string)

PubkeyToString returns string of public key, prefix with 0x

func S256

func S256() elliptic.Curve

S256 returns an instance of the secp256k1 curve.

func ToECDSA

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

ToECDSA creates a private key with the given D value.

func ToECDSAPub

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

ToECDSAPub create ecdsa.PublicKey object by byte array. Pubkey length derived from ecdsa is 65, with constant prefix 4 in the first byte. So if pubkey length equals 64, we insert one byte in front

Types

type Signature

type Signature struct {
	R *big.Int // Signature of elliptic curve cryptography.
	S *big.Int // Signature of elliptic curve cryptography.
}

Signature is a wrapper for signed message, and is serializable.

func NewSignature

func NewSignature(privKey *ecdsa.PrivateKey, hash []byte) *Signature

NewSignature sign the specified hash with private key and returns a signature. Panics if failed to sign hash.

func (*Signature) Verify

func (sig *Signature) Verify(pubKey *ecdsa.PublicKey, hash []byte) bool

Verify verifies the signature against the specified hash. Return true if signature is valid, otherwise false.

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