bn256

package
v0.0.0-...-bc3f6f8 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2019 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package bn256 allows to use Handel with the BLS signature scheme over the BN256 groups. It implements the relevant Handel interfaces: PublicKey, Secretkey and Signature. The BN256 implementations comes from the cloudflare/bn256 package, including the base points..

Index

Constants

This section is empty.

Variables

View Source
var G2Base *bn256.G2

G2Base is the base point specified for the G2 group. If one wants to use a different point, set this variable before using any public methods / structs of this package.

View Source
var Hash = sha256.New

Hash is the hash function used to hash the message prior to signing

Functions

func NewKeyPair

func NewKeyPair(reader io.Reader) (*SecretKey, *PublicKey, error)

NewKeyPair returns a new keypair generated from the given reader.

Types

type Constructor

type Constructor struct {
}

Constructor implements the handel.Constructor interface

func NewConstructor

func NewConstructor() *Constructor

NewConstructor returns a handel.Constructor capable of creating empty BLS signature object and empty public keys.

func (*Constructor) KeyPair

KeyPair implements the simul/lib/Constructor interface

func (*Constructor) PublicKey

func (s *Constructor) PublicKey() handel.PublicKey

PublicKey implements the handel.Constructor interface

func (*Constructor) SecretKey

func (s *Constructor) SecretKey() handel.SecretKey

SecretKey implements the simul/lib/Constructor interface

func (*Constructor) Signature

func (s *Constructor) Signature() handel.Signature

Signature implements the handel.Constructor interface

type PublicKey

type PublicKey struct {
	// contains filtered or unexported fields
}

PublicKey holds the public key information = point in G2

func (*PublicKey) Combine

func (p *PublicKey) Combine(pp handel.PublicKey) handel.PublicKey

Combine implements the handel.PublicKey interface

func (*PublicKey) MarshalBinary

func (p *PublicKey) MarshalBinary() ([]byte, error)

MarshalBinary implements the simul/lib/PublicKey interface

func (*PublicKey) String

func (p *PublicKey) String() string

func (*PublicKey) UnmarshalBinary

func (p *PublicKey) UnmarshalBinary(buff []byte) error

UnmarshalBinary implements the simul/lib/PublicKey interface

func (*PublicKey) VerifySignature

func (p *PublicKey) VerifySignature(msg []byte, sig handel.Signature) error

VerifySignature checks the given BLS signature bls on the message m using the public key p by verifying that the equality e(H(m), X) == e(H(m), x*B2) == e(x*H(m), B2) == e(S, B2) holds where e is the pairing operation and B2 is the base point from curve G2.

type SecretKey

type SecretKey struct {
	// contains filtered or unexported fields
}

SecretKey holds the secret scalar and can return the corresponding public key. It can sign messages using the BLS signature scheme.

func (*SecretKey) MarshalBinary

func (s *SecretKey) MarshalBinary() ([]byte, error)

MarshalBinary implements the simul/lib/SecretKey interface

func (*SecretKey) Sign

func (s *SecretKey) Sign(msg []byte, reader io.Reader) (handel.Signature, error)

Sign creates a BLS signature S = x * H(m) on a message m using the private key x. The signature S is a point on curve G1.

func (*SecretKey) UnmarshalBinary

func (s *SecretKey) UnmarshalBinary(buff []byte) error

UnmarshalBinary implements the simul/lib/SecretKey interface

type SigBLS

type SigBLS struct {
	// contains filtered or unexported fields
}

SigBLS represents a BLS signature using the BN256 curves

func (*SigBLS) Combine

func (m *SigBLS) Combine(ms handel.Signature) handel.Signature

Combine implements the handel.Signature interface

func (*SigBLS) MarshalBinary

func (m *SigBLS) MarshalBinary() ([]byte, error)

MarshalBinary implements the handel.Signature interface

func (*SigBLS) String

func (m *SigBLS) String() string

func (*SigBLS) UnmarshalBinary

func (m *SigBLS) UnmarshalBinary(b []byte) error

UnmarshalBinary implements the handel.Signature interface

Jump to

Keyboard shortcuts

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