signature

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2021 License: Apache-2.0 Imports: 2 Imported by: 38

Documentation

Overview

Package signature defines interfaces for a Signer and a PublicKey similarly to go/crypto standard package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(ss SignatureScheme, f func(io.Reader) (Signer, error))

Register registers a key pair generating function for a given signature scheme.

Types

type PublicKey

type PublicKey interface {

	// Verify verifies a signature of a message
	// If hFunc is not provided, implementation may consider the message
	// to be pre-hashed, else, will use hFunc to hash the message.
	Verify(sigBin, message []byte, hFunc hash.Hash) (bool, error)

	// SetBytes sets p from binary representation in buf.
	// buf represents a public key as x||y where x, y are
	// interpreted as big endian binary numbers corresponding
	// to the coordinates of a point on the twisted Edwards.
	// It returns the number of bytes read from the buffer.
	SetBytes(buf []byte) (int, error)

	// Bytes returns the binary representation of pk
	// as x||y where x, y are the coordinates of the point
	// on the twisted Edwards as big endian integers.
	Bytes() []byte

	// Equal compares the public key to other.
	Equal(other PublicKey) bool
}

PublicKey public key interface. The public key has a Verify function to check signatures.

type SignatureScheme

type SignatureScheme uint
const (
	EDDSA_BN254 SignatureScheme = iota
	EDDSA_BLS12_381
	EDDSA_BLS12_377
	EDDSA_BW6_761
	EDDSA_BLS24_315
	EDDSA_BW6_633
)

func (SignatureScheme) New

func (ss SignatureScheme) New(r io.Reader) (Signer, error)

New takes a source of randomness and returns a new key pair

type Signer

type Signer interface {

	// Public returns the public key associated to
	// the signer's private key.
	Public() PublicKey

	// Sign signs a message. If hFunc is not provided, implementation may consider the message
	// to be pre-hashed, else, will use hFunc to hash the message.
	// Returns Signature or error
	Sign(message []byte, hFunc hash.Hash) ([]byte, error)

	// Bytes returns the binary representation of pk,
	// as byte array publicKey||scalar||randSrc
	// where publicKey is as publicKey.Bytes(), and
	// scalar is in big endian, of size sizeFr.
	Bytes() []byte

	// SetBytes sets pk from buf, where buf is interpreted
	// as  publicKey||scalar||randSrc
	// where publicKey is as publicKey.Bytes(), and
	// scalar is in big endian, of size sizeFr.
	// It returns the number byte read.
	SetBytes(buf []byte) (int, error)
}

Signer signer interface.

Jump to

Keyboard shortcuts

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