crypto

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2019 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CurveEd25519   string = "ed25519"
	CurveSecp256K1 string = "secp256k1"
)

Constants shared within subfolders

Variables

This section is empty.

Functions

func GenerateHashPair

func GenerateHashPair(preimageSize int) (preimage, hash []byte, err error)

GenerateHashPair generates a preimage and hash pair. This is useful in a commit reveal scheme such as what we use for anchor pre-commit > commit flow.

func GenerateSigningKeyPair

func GenerateSigningKeyPair(publicFileName, privateFileName, curveType string) (err error)

GenerateSigningKeyPair generates based on the curveType and writes keys to file paths given.

func ObtainP2PKeypair

func ObtainP2PKeypair(pubKeyFile, privKeyFile string) (priv crypto.PrivKey, pub crypto.PubKey, err error)

ObtainP2PKeypair obtains a key pair from given file paths

func Sha256Hash

func Sha256Hash(value []byte) (hash []byte, err error)

Sha256Hash wraps inconvenient sha256 hashing ops

func SignMessage

func SignMessage(privateKey, message []byte, curveType string) ([]byte, error)

SignMessage signs the message using the private key as the curveType provided. if Secp256K1 curve provided, then the signature format is specific to ethereum.

func VerifyMessage

func VerifyMessage(publicKey, message []byte, signature []byte, curveType string) bool

VerifyMessage verifies message using the public key as per the curve type. for Secp256K1 curve the verification is done with ethereum prefix for Secp256K1, public key should be the address of the original public key, following ethereum standards

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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