crypto

package
v0.0.0-...-91a82d4 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2019 License: LGPL-3.0 Imports: 15 Imported by: 24

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ByteFromECDSA

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

ByteFromECDSA exports a private key into a binary dump.

func ByteFromECDSAPub

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

ByteFromECDSAPub exports a public key into a binary dump.

func ByteToECDSA

func ByteToECDSA(d []byte, strict bool) (*ecdsa.PrivateKey, error)

ByteToECDSA creates a private key with the given D value.

func ByteToECDSAPub

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

ByteToECDSAPub creates a public key with the given value

func CompressPubkey

func CompressPubkey(pubkey *ecdsa.PublicKey) []byte

CompressPubkey encodes a public key to the 33-byte compressed format.

func CreateAddress

func CreateAddress(b utils.Address, nonce uint64) utils.Address

func DecompressPubkey

func DecompressPubkey(pubkey []byte) (*ecdsa.PublicKey, error)

DecompressPubkey parses a public key in the 33-byte compressed format.

func EcrecoverToByte

func EcrecoverToByte(hash, signature []byte) ([]byte, error)

EcrecoverToByte returns the uncompressed public key that created the given signature.

func EcrecoverToPub

func EcrecoverToPub(hash, signature []byte) (*ecdsa.PublicKey, error)

EcrecoverToPub returns the public key that created the given signature.

func FromECDSAPub

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

func GenerateKey

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

GenerateKey creates a private key

func GenerateKeyPair

func GenerateKeyPair() (*utils.Address, *ecdsa.PrivateKey, error)

GenerateKeyPair generates public key and private key

func GenerateRandomAddress

func GenerateRandomAddress() (*utils.Address, error)

GenerateRandomAddress generates and returns a random address.

func HexToECDSA

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

HexToECDSA parses a secp256k1 private key.

func Keccak256

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

Keccak256 the Keccak256 hash of the input data.

func Keccak256Hash

func Keccak256Hash(data ...[]byte) (h utils.Hash)

Keccak256Hash the Keccak256 hash of the input data.

func Keccak512

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

Keccak512 the Keccak512 hash of the input data.

func Keccak512Hash

func Keccak512Hash(data ...[]byte) (h utils.Hash)

Keccak512Hash the Keccak512 hash of the input data.

func LoadECDSA

func LoadECDSA(file string) (*ecdsa.PrivateKey, error)

LoadECDSA loads a private key from the given file.

func MustGenerateRandomAddress

func MustGenerateRandomAddress() *utils.Address

MustGenerateRandomAddress generates and returns a random address. Panic on any error.

func PubkeyToAddress

func PubkeyToAddress(p ecdsa.PublicKey) utils.Address

func S256

func S256() elliptic.Curve

S256 returns an instance of the secp256k1 curve.

func SaveECDSA

func SaveECDSA(file string, key *ecdsa.PrivateKey) error

SaveECDSA saves a private key to the given file.

func Sign

func Sign(hash []byte, prv *ecdsa.PrivateKey) (signature []byte, err error)

Sign calculates an ECDSA signature.

This function is susceptible to chosen plaintext attacks that can leak information about the private key that is used for signing. Callers must be aware that the given hash cannot be chosen by an adversery. Common solution is to hash any input before calculating the signature.

The produced signature is in the [R || S || V] format where V is 0 or 1.

func VerifySignature

func VerifySignature(pubkey, hash, signature []byte) bool

VerifySignature checks that the given public key created signature over hash. The public key should be in compressed (33 bytes) or uncompressed (65 bytes) format. The signature should have the 64 byte [R || S] format.

Types

This section is empty.

Directories

Path Synopsis
Package bn256 implements the Optimal Ate pairing over a 256-bit Barreto-Naehrig curve.
Package bn256 implements the Optimal Ate pairing over a 256-bit Barreto-Naehrig curve.
cloudflare
Package bn256 implements a particular bilinear group at the 128-bit security level.
Package bn256 implements a particular bilinear group at the 128-bit security level.
google
Package bn256 implements a particular bilinear group.
Package bn256 implements a particular bilinear group.
Package secp256k1 wraps the bitcoin secp256k1 C library.
Package secp256k1 wraps the bitcoin secp256k1 C library.

Jump to

Keyboard shortcuts

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