schnorr

package
v0.2.15 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2019 License: Unlicense, MIT Imports: 9 Imported by: 0

README

Schnorr Signature Algorithm

GoDoc

This Package implements the schnorr signature as defined in Wikipedia. Schnorr signature

This will be the basis of the bindcoin transaction signature algorithm.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ECPrivateKey

type ECPrivateKey struct {
	ECPublicKey
	Key *big.Int
}

func ECGenerateKeyPair

func ECGenerateKeyPair(curve elliptic.Curve, rand io.Reader) (pk *ECPrivateKey, e error)

type ECPublicKey

type ECPublicKey struct {
	elliptic.Curve
	X, Y *big.Int
}

type Group

type Group struct {
	P *big.Int
	G *big.Int
}

type KeyMAC

type KeyMAC interface {
	// Creates a new, keyed Hash.
	New(key []byte) hash.Hash

	// MaxHashSize returns the maximum number of bytes of the hash
	// that will be used. If Hash.Sum() yields more bytes, they'll
	// be cut off. Ideal is Hash.Sum()==MaxHashSize().
	MaxHashSize() int
}

MAC Algorithm, that spawns a keyed hash.Hash instance.

func HMAC

func HMAC(h func() hash.Hash, est int) KeyMAC

Implements Keyed-Hash Message Authentication Code (HMAC) est should be h().Size()

func NewBlake2b

func NewBlake2b() KeyMAC

Implements the keyed BLAKE2b-512 MAC. If the key is > 64, then the key is BLAKE2b-512-Hashed first.

func NewBlake2s

func NewBlake2s() KeyMAC

Implements the keyed BLAKE2s-256 MAC. If the key is > 32, then the key is BLAKE2s-256-Hashed first.

func SimpleHash

func SimpleHash(h func() hash.Hash, est int) KeyMAC

Implements HASH( key || message ) est should be h().Size()

func WrapMAC

func WrapMAC(h func(key []byte) hash.Hash, est int) KeyMAC

type PrivateKey

type PrivateKey struct {
	PublicKey
	Key *big.Int
}

func GenerateKeyPair

func GenerateKeyPair(group *Group, rand io.Reader) (pk *PrivateKey, e error)

type PublicKey

type PublicKey struct {
	Group
	A *big.Int
}

type Signer

type Signer interface {
	io.Writer

	GetSignature() (*big.Int, []byte)
}

func ECSign

func ECSign(rand io.Reader, pk *ECPrivateKey, mac KeyMAC) (Signer, error)

func Sign

func Sign(rand io.Reader, pk *PrivateKey, mac KeyMAC) (Signer, error)

type Verifier

type Verifier interface {
	io.Writer

	Verify() bool
}

func ECVerify

func ECVerify(pk *ECPublicKey, mac KeyMAC, s *big.Int, e []byte) Verifier

func Verify

func Verify(pk *PublicKey, mac KeyMAC, s *big.Int, e []byte) Verifier

Jump to

Keyboard shortcuts

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