blschia

package module
v0.0.0-...-1c2fc79 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2024 License: Apache-2.0 Imports: 6 Imported by: 3

README

bls-signatures

Go library that implements BLS signatures with aggregation as in Boneh, Drijvers, Neven 2018, using the relic toolkit for cryptographic primitives (pairings, EC, hashing).

This library is a Go port of the Chia Network's BLS lib.

Usage

go get github.com/dashpay/bls-signatures/go-bindings

Creating keys and signatures

// seed data must not be less 32 bytes length
seed := []byte{
    0, 50, 6, 244, 24, 199, 1, 25,
    52, 88, 192, 19, 18, 12, 89, 6,
    220, 18, 102, 58, 209, 82, 12, 62,
    89, 110, 182, 9, 44, 20, 254, 22,
}

// create a scheme, available three schemes: BasicSchemeMPL, AugSchemeMPL and PopSchemeMPL 
scheme := NewAugSchemeMPL()

// generate a private key using a seed data
sk, err := scheme.KeyGen(seed)
if err != nil {
    panic(err.Error())
}
// get a public key
pk, err := sk.G1Element()
if err != nil {
    panic(err.Error())
}

msg := []byte{1, 2, 3, 4, 5}

// make a signature for a message
sig := scheme.Sign(sk, msg)

// verify the message signature 
if !scheme.Verify(pk, msg, sig) {
    panic("failed the signature verification")
}

Serializing keys and signatures to bytes

skBytes := sk.Serialize()
pkBytes := pk.Serialize()
sigBytes := sig.Serialize()  

Loading keys and signatures from bytes

sk1, _ := PrivateKeyFromBytes(skBytes, false)
pk1, _ := G1ElementFromBytes(pkBytes)
sig1, _ := G2ElementFromBytes(sigBytes)

Create aggregate signatures

// Generate some more private keys
seed[0] = 1
sk1, _ := scheme.KeyGen(seed)
seed[0] = 2
sk2, _ := scheme.KeyGen(seed)
msg2 := []byte{1, 2, 3, 4, 5,6, 7}

// Generate first sig
pk1, _ := sk1.G1Element()
sig1 := scheme.Sign(sk1, msg)

// Generate second sig
pk2, _ := sk2.G1Element()
sig2 := scheme.Sign(sk2, msg2)

// Signatures can be non-interactively combined by anyone
var aggSig = scheme.AggregateSigs(sig1, sig2)

ok := scheme.AggregateVerify([]*G1Element{pk1, pk2}, [][]byte{msg, msg2}, aggSig)
if !ok {
    panic("failed a verification of the aggregated signature ")
}

Arbitrary trees of aggregates

seed[0] = 3
sk3, _ := scheme.KeyGen(seed)
pk3, _ := sk3.G1Element()
msg3 := []byte{100, 2, 254, 88, 90, 45, 23}
sig3 := scheme.Sign(sk3, msg3)

aggSigFinal := scheme.AggregateSigs(aggSig, sig3)
ok = scheme.AggregateVerify([]*G1Element{pk1, pk2, pk3}, [][]byte{msg, msg2, msg3}, aggSigFinal)
if !ok {
    panic("failed a verification of the aggregated signature ")
}

Very fast verification with Proof of Possession scheme

// create a proof possession scheme
popScheme := NewPopSchemeMPL()

// If the same msg is signed, you can use Proof of Possession (PopScheme) for efficiency
// A proof of possession MUST be passed around with the PK to ensure security.
popSig1 := popScheme.Sign(sk1, msg)
popSig2 := popScheme.Sign(sk2, msg)
popSig3 := popScheme.Sign(sk3, msg)
pop1 := popScheme.PopProve(sk1)
pop2 := popScheme.PopProve(sk2)
pop3 := popScheme.PopProve(sk3)

ok = popScheme.PopVerify(pk1, pop1)
if !ok {
    panic("failed a verification")
}
ok = popScheme.PopVerify(pk2, pop2)
if !ok {
    panic("failed a verification")
}
ok = popScheme.PopVerify(pk3, pop3)
if !ok {
    panic("failed a verification")
}

popSigAgg := popScheme.AggregateSigs(popSig1, popSig2, popSig3)
ok = popScheme.FastAggregateVerify([]*G1Element{pk1, pk2, pk3}, msg, popSigAgg)
if !ok {
    panic("failed a verification")
}

// Aggregate public key, indistinguishable from a single public key
var popAggPk = pk1.Add(pk2).Add(pk3)
ok = popScheme.Verify(popAggPk, msg, popSigAgg)
if !ok {
    panic("failed a verification")
}

// Aggregate private keys
var aggSk = PrivateKeyAggregate(sk1, sk2, sk3)
ok = popScheme.Sign(aggSk, msg).EqualTo(popSigAgg)
if !ok {
    panic("failed a verification")
}

HD keys using EIP-2333

// You can derive 'child' keys from any key, to create arbitrary trees. 4 byte indeces are used.
// Hardened (more secure, but no parent pk -> child pk)
masterSk, _ := augScheme.KeyGen(seed)

// Unhardened (less secure, but can go from parent pk -> child pk), BIP32 style
masterPk, _ := masterSk.G1Element()
childU := augScheme.DeriveChildSkUnhardened(masterSk, 22)
grandchildU := augScheme.DeriveChildSkUnhardened(childU, 0)

childUPk := augScheme.DeriveChildPkUnhardened(masterPk, 22)
grandchildUPk := augScheme.DeriveChildPkUnhardened(childUPk, 0)

pkChildU, _ := grandchildU.G1Element()
ok = grandchildUPk.EqualTo(pkChildU)
if !ok {
    panic("keys are not equal")
}

Do not forget to handle the errors properly, this part of the code was omitted deliberately

Use cases can be found in the original lib's readme.

Important note: Since this library is a port of the c++ library, so every piece of memory allocated by the library MUST be released on our own in GO. To release the memory is used runtime.SetFinalizer function, that will invoke automatically before GC release a memory allocated by GO.

Run tests

To run tests, build the library, then go to the go-bindings folder in the build directory and run

make test

Documentation

Index

Constants

View Source
const HashSize = sha256.Size

HashSize is the allowed size of a hash

Variables

This section is empty.

Functions

func ThresholdVerify

func ThresholdVerify(pk *G1Element, hash Hash, sig *G2Element) bool

ThresholdVerify verifies of the hash with G1Element (public key) this function is a binding of bls::Threshold::Verify

Types

type Aggregator

type Aggregator interface {
	AggregatePubKeys(pks ...*G1Element) *G1Element
	AggregateSigs(sigs ...*G2Element) *G2Element
}

Aggregator is the interface that's described methods for aggregation public (G1) and private (g2) keys

type AugSchemeMPL

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

AugSchemeMPL represents bls::AugSchemeMPL augmented should be enough for most use cases

func NewAugSchemeMPL

func NewAugSchemeMPL() *AugSchemeMPL

NewAugSchemeMPL returns a new AugSchemeMPL this method allocates the bls::AugSchemeMPL object and keeps its pointer

func (*AugSchemeMPL) AggregatePubKeys

func (s *AugSchemeMPL) AggregatePubKeys(pks ...*G1Element) *G1Element

AggregatePubKeys returns a new G1Element (public key) as an aggregated public keys this method is a binding of bls::CoreMPL::AggregatePubKeys

func (*AugSchemeMPL) AggregateSigs

func (s *AugSchemeMPL) AggregateSigs(sigs ...*G2Element) *G2Element

AggregateSigs returns a new G1Element (aggregated public keys) as a result of the aggregation of the passed public keys this method is a binding of bls::CoreMPL::AggregateSigs

func (*AugSchemeMPL) AggregateVerify

func (s *AugSchemeMPL) AggregateVerify(pks []*G1Element, msgs [][]byte, sig *G2Element) bool

AggregateVerify verifies the aggregated signature for a list of messages with public keys this method is a binding of bls::AugSchemeMPL::AggregateVerify

func (*AugSchemeMPL) DeriveChildPkUnhardened

func (s *AugSchemeMPL) DeriveChildPkUnhardened(el *G1Element, index int) *G1Element

DeriveChildPkUnhardened returns a child G1Element of the passed master G1Element this method is a binding of bls::CoreMPL::DeriveChildPkUnhardened

func (*AugSchemeMPL) DeriveChildSk

func (s *AugSchemeMPL) DeriveChildSk(sk *PrivateKey, index int) *PrivateKey

DeriveChildSk returns a child PrivateKey using the passed as a master key this method is a binding of bls::CoreMPL::DeriveChildSk

func (*AugSchemeMPL) DeriveChildSkUnhardened

func (s *AugSchemeMPL) DeriveChildSkUnhardened(sk *PrivateKey, index int) *PrivateKey

DeriveChildSkUnhardened returns a child PrivateKey of the passed master PrivateKey this method is a binding of bls::CoreMPL::DeriveChildSkUnhardened

func (*AugSchemeMPL) KeyGen

func (s *AugSchemeMPL) KeyGen(seed []byte) (*PrivateKey, error)

KeyGen returns a new generated PrivateKey using passed a genSeed data this method is a binding of bls::CoreMPL::KeyGen

func (*AugSchemeMPL) Sign

func (s *AugSchemeMPL) Sign(sk *PrivateKey, msg []byte) *G2Element

Sign signs a message with a PrivateKey this method is a binding of bls::AugSchemeMPL::Sign

func (*AugSchemeMPL) SignPrepend

func (s *AugSchemeMPL) SignPrepend(sk *PrivateKey, msg []byte, prepPk *G1Element) *G2Element

SignPrepend is used for prepending different message this method is a binding of bls::AugSchemeMPL::Sign

func (*AugSchemeMPL) SkToG1

func (s *AugSchemeMPL) SkToG1(sk *PrivateKey) *G1Element

SkToG1 converts PrivateKey into G1Element (public key) this method is a binding of bls::CoreMPL::SkToG1

func (*AugSchemeMPL) Verify

func (s *AugSchemeMPL) Verify(pk *G1Element, msg []byte, sig *G2Element) bool

Verify verifies a G2Element (signature) for a message with a G1Element (public key) this method is a binding of bls::AugSchemeMPL::Verify

type BasicSchemeMPL

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

BasicSchemeMPL represents bls::BasicSchemeMPL (basic scheme using minimum public key sizes)

func NewBasicSchemeMPL

func NewBasicSchemeMPL() *BasicSchemeMPL

NewBasicSchemeMPL returns a new BasicSchemeMPL this method allocates the bls::BasicSchemeMPL object and keeps its pointer

func (*BasicSchemeMPL) AggregatePubKeys

func (s *BasicSchemeMPL) AggregatePubKeys(pks ...*G1Element) *G1Element

AggregatePubKeys returns a new G1Element (public key) as an aggregated public keys this method is a binding of bls::CoreMPL::AggregatePubKeys

func (*BasicSchemeMPL) AggregateSigs

func (s *BasicSchemeMPL) AggregateSigs(sigs ...*G2Element) *G2Element

AggregateSigs returns a new G1Element (aggregated public keys) as a result of the aggregation of the passed public keys this method is a binding of bls::CoreMPL::AggregateSigs

func (*BasicSchemeMPL) AggregateVerify

func (s *BasicSchemeMPL) AggregateVerify(pks []*G1Element, msgs [][]byte, sig *G2Element) bool

AggregateVerify verifies the aggregated signature for a list of messages with public keys this method is a binding of bls::BasicSchemeMPL::AggregateVerify

func (*BasicSchemeMPL) DeriveChildPkUnhardened

func (s *BasicSchemeMPL) DeriveChildPkUnhardened(el *G1Element, index int) *G1Element

DeriveChildPkUnhardened returns a child G1Element of the passed master G1Element this method is a binding of bls::CoreMPL::DeriveChildPkUnhardened

func (*BasicSchemeMPL) DeriveChildSk

func (s *BasicSchemeMPL) DeriveChildSk(sk *PrivateKey, index int) *PrivateKey

DeriveChildSk returns a child PrivateKey using the passed as a master key this method is a binding of bls::CoreMPL::DeriveChildSk

func (*BasicSchemeMPL) DeriveChildSkUnhardened

func (s *BasicSchemeMPL) DeriveChildSkUnhardened(sk *PrivateKey, index int) *PrivateKey

DeriveChildSkUnhardened returns a child PrivateKey of the passed master PrivateKey this method is a binding of bls::CoreMPL::DeriveChildSkUnhardened

func (*BasicSchemeMPL) KeyGen

func (s *BasicSchemeMPL) KeyGen(seed []byte) (*PrivateKey, error)

KeyGen returns a new generated PrivateKey using passed a genSeed data this method is a binding of bls::CoreMPL::KeyGen

func (*BasicSchemeMPL) Sign

func (s *BasicSchemeMPL) Sign(sk *PrivateKey, msg []byte) *G2Element

Sign signs a message using a PrivateKey and returns the G2Element as a signature this method is a binding of bls::CoreMPL::Sign

func (*BasicSchemeMPL) SkToG1

func (s *BasicSchemeMPL) SkToG1(sk *PrivateKey) *G1Element

SkToG1 converts PrivateKey into G1Element (public key) this method is a binding of bls::CoreMPL::SkToG1

func (*BasicSchemeMPL) Verify

func (s *BasicSchemeMPL) Verify(pk *G1Element, msg []byte, sig *G2Element) bool

Verify verifies a signature for a message with a G1Element as a public key this method is a binding of bls::CoreMPL::Verify

type Deriver

type Deriver interface {
	DeriveChildSk(sk *PrivateKey, index int) *PrivateKey
	DeriveChildSkUnhardened(sk *PrivateKey, index int) *PrivateKey
	DeriveChildPkUnhardened(el *G1Element, index int) *G1Element
}

Deriver is an interface for describing some methods for the derivation of children

type G1Element

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

G1Element represents a bls::G1Element (48 bytes) in fact G1Element is corresponding to a public-key

func G1ElementFromBytes

func G1ElementFromBytes(data []byte) (*G1Element, error)

G1ElementFromBytes returns a new G1Element (public-key) from bytes this method allocates the new bls::G2Element object and keeps its pointer

func ThresholdPublicKeyRecover

func ThresholdPublicKeyRecover(pks []*G1Element, hashes []Hash) (*G1Element, error)

ThresholdPublicKeyRecover recovers G1Element (public key) from the set of shared G1Element(s) with a list of the hashes this function is a binding of bls::Threshold::PublicKeyRecover

func ThresholdPublicKeyShare

func ThresholdPublicKeyShare(pks []*G1Element, hash Hash) (*G1Element, error)

ThresholdPublicKeyShare retrieves a shared G1Element (public key) from a set of G1Element(s) and a hash this function is a binding of bls::Threshold::PublicKeyShare

func (*G1Element) Add

func (g *G1Element) Add(el *G1Element) *G1Element

Add performs addition operation on the passed G1Element (public key) and returns a new G1Element (public key) this method is a binding of the bls::G1Element::GetFingerprint

func (*G1Element) EqualTo

func (g *G1Element) EqualTo(el *G1Element) bool

EqualTo returns true if the elements are equal otherwise returns false this method is the binding of the equality operation

func (*G1Element) Fingerprint

func (g *G1Element) Fingerprint() int

Fingerprint returns a fingerprint of G1Element (public key) this method is a binding of the bls::G1Element::GetFingerprint

func (*G1Element) HexString

func (g *G1Element) HexString() string

HexString returns a hex string representation of serialized data

func (*G1Element) IsValid

func (g *G1Element) IsValid() bool

IsValid returns true if a state of G1Element (public key) is valid this method is the binding of the bls::G1Element::IsValid

func (*G1Element) Mul

func (g *G1Element) Mul(sk *PrivateKey) *G1Element

Mul performs multiplication operation with PrivateKey and returns a new G1Element (public-key) this method is the binding of the multiplication operation

func (*G1Element) Serialize

func (g *G1Element) Serialize() []byte

Serialize serializes G1Element (public key) into a slice of bytes and returns it this method is a binding of the bls::G1Element::Serialize

type G2Element

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

G2Element represents a bls::G2Element (96 bytes) in fact G2Element is corresponding to a signature

func G2ElementFromBytes

func G2ElementFromBytes(data []byte) (*G2Element, error)

G2ElementFromBytes returns a new G2Element (signature) from passed byte slice this method allocates the new bls::G2Element object and keeps its pointer

func ThresholdSign

func ThresholdSign(sk *PrivateKey, hash Hash) *G2Element

ThresholdSign signs of the hash with PrivateKey this function is a binding of bls::Threshold::Sign

func ThresholdSignatureRecover

func ThresholdSignatureRecover(sigs []*G2Element, hashes []Hash) (*G2Element, error)

ThresholdSignatureRecover recovers G2Element (signature) from the set of shared G2Element(s) with a list of the hashes this function is a binding of bls::Threshold::SignatureRecover

func ThresholdSignatureShare

func ThresholdSignatureShare(sigs []*G2Element, hash Hash) (*G2Element, error)

ThresholdSignatureShare retrieves a shared G2Element (signature) from a set of G2Element(s) and a hash this function is a binding of bls::Threshold::SignatureShare

func (*G2Element) Add

func (g *G2Element) Add(el *G2Element) *G2Element

Add performs an addition operation on the passed G2Element (signature) and returns a new G2Element (signature) this method is the binding of the addition operation

func (*G2Element) EqualTo

func (g *G2Element) EqualTo(el *G2Element) bool

EqualTo returns true if the elements are equal, otherwise returns false this method is the binding of the equality operation

func (*G2Element) HexString

func (g *G2Element) HexString() string

HexString returns a hex string representation of serialized data

func (*G2Element) Mul

func (g *G2Element) Mul(sk *PrivateKey) *G2Element

Mul performs multiplication operation with PrivateKey and returns a new G2Element (signature) this method is the binding of the multiplication operation

func (*G2Element) Serialize

func (g *G2Element) Serialize() []byte

Serialize serializes G2Element (signature) into a slice of bytes and returns it this method is a binding of the bls::G2Element::Serialize

type Generator

type Generator interface {
	KeyGen(seed []byte) (*PrivateKey, error)
}

Generator is the interface that wraps the method needed to generate a private key

type Hash

type Hash [HashSize]byte

Hash represents 32 byte of hash data

func BuildSignHash

func BuildSignHash(llmqType uint8, quorumHash Hash, signID Hash, msgHash Hash) Hash

BuildSignHash creates the required signHash for LLMQ threshold signing process

func HashFromString

func HashFromString(hexString string) (Hash, error)

HashFromString convert a hex string into a Hash

type PopSchemeMPL

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

PopSchemeMPL represents bls::PopSchemeMPL (proof of possession scheme) proof of possession can be used where verification must be fast

func NewPopSchemeMPL

func NewPopSchemeMPL() *PopSchemeMPL

NewPopSchemeMPL returns a new bls::PopSchemeMPL this method allocates the new bls::PopSchemeMPL object and keeps its pointer

func (*PopSchemeMPL) AggregatePubKeys

func (s *PopSchemeMPL) AggregatePubKeys(pks ...*G1Element) *G1Element

AggregatePubKeys returns a new G1Element (public key) as an aggregated public keys this method is a binding of bls::CoreMPL::AggregatePubKeys

func (*PopSchemeMPL) AggregateSigs

func (s *PopSchemeMPL) AggregateSigs(sigs ...*G2Element) *G2Element

AggregateSigs returns a new G1Element (aggregated public keys) as a result of the aggregation of the passed public keys this method is a binding of bls::CoreMPL::AggregateSigs

func (*PopSchemeMPL) AggregateVerify

func (s *PopSchemeMPL) AggregateVerify(pks []*G1Element, msgs [][]byte, sig *G2Element) bool

AggregateVerify verifies the aggregated signature for a list of messages with public keys returns true if the signature is a valid otherwise returns false this method is a binding of bls::CoreMPL::AggregateVerify

func (*PopSchemeMPL) DeriveChildPkUnhardened

func (s *PopSchemeMPL) DeriveChildPkUnhardened(el *G1Element, index int) *G1Element

DeriveChildPkUnhardened returns a child G1Element of the passed master G1Element this method is a binding of bls::CoreMPL::DeriveChildPkUnhardened

func (*PopSchemeMPL) DeriveChildSk

func (s *PopSchemeMPL) DeriveChildSk(sk *PrivateKey, index int) *PrivateKey

DeriveChildSk returns a child PrivateKey using the passed as a master key this method is a binding of bls::CoreMPL::DeriveChildSk

func (*PopSchemeMPL) DeriveChildSkUnhardened

func (s *PopSchemeMPL) DeriveChildSkUnhardened(sk *PrivateKey, index int) *PrivateKey

DeriveChildSkUnhardened returns a child PrivateKey of the passed master PrivateKey this method is a binding of bls::CoreMPL::DeriveChildSkUnhardened

func (*PopSchemeMPL) FastAggregateVerify

func (s *PopSchemeMPL) FastAggregateVerify(pks []*G1Element, msg []byte, sig *G2Element) bool

FastAggregateVerify uses for a fast verification this method is a binding of bls::PopSchemeMPL::FastAggregateVerify

func (*PopSchemeMPL) KeyGen

func (s *PopSchemeMPL) KeyGen(seed []byte) (*PrivateKey, error)

KeyGen returns a new generated PrivateKey using passed a genSeed data this method is a binding of bls::CoreMPL::KeyGen

func (*PopSchemeMPL) PopProve

func (s *PopSchemeMPL) PopProve(sk *PrivateKey) *G2Element

PopProve proves using the PrivateKey this method is a binding of bls::PopSchemeMPL::PopProve

func (*PopSchemeMPL) PopVerify

func (s *PopSchemeMPL) PopVerify(pk *G1Element, sig *G2Element) bool

PopVerify verifies of a signature using proof of possession this method is a binding of bls::PopSchemeMPL::PopVerify

func (*PopSchemeMPL) Sign

func (s *PopSchemeMPL) Sign(sk *PrivateKey, msg []byte) *G2Element

Sign signs a message using a PrivateKey and returns the G2Element as a signature this method is a binding of bls::CoreMPL::Sign

func (*PopSchemeMPL) SkToG1

func (s *PopSchemeMPL) SkToG1(sk *PrivateKey) *G1Element

SkToG1 converts PrivateKey into G1Element (public key) this method is a binding of bls::CoreMPL::SkToG1

func (*PopSchemeMPL) Verify

func (s *PopSchemeMPL) Verify(pk *G1Element, msg []byte, sig *G2Element) bool

Verify verifies a signature for a message with a G1Element as a public key this method is a binding of bls::CoreMPL::Verify

type PrivateKey

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

PrivateKey represents a bls::PrivateKey (32 byte integer)

func PrivateKeyAggregate

func PrivateKeyAggregate(sks ...*PrivateKey) *PrivateKey

PrivateKeyAggregate securely aggregates multiple private keys into one this method is a binding of the bls::PrivateKey::Aggregate

func PrivateKeyFromBytes

func PrivateKeyFromBytes(data []byte, modOrder bool) (*PrivateKey, error)

PrivateKeyFromBytes returns a new PrivateKey from bytes this method allocates the new bls::PrivateKey object and keeps its pointer

func ThresholdPrivateKeyRecover

func ThresholdPrivateKeyRecover(sks []*PrivateKey, hashes []Hash) (*PrivateKey, error)

ThresholdPrivateKeyRecover recovers PrivateKey from the set of shared PrivateKey(s) with a list of the hashes this function is a binding of bls::Threshold::PrivateKeyRecover

func ThresholdPrivateKeyShare

func ThresholdPrivateKeyShare(sks []*PrivateKey, hash Hash) (*PrivateKey, error)

ThresholdPrivateKeyShare retrieves a shared PrivateKey from a set of PrivateKey(s) and a hash this function is a binding of bls::Threshold::PrivateKeyShare

func (*PrivateKey) EqualTo

func (sk *PrivateKey) EqualTo(other *PrivateKey) bool

EqualTo tests if one PrivateKey is equal to another this method is the binding of the equality operation

func (*PrivateKey) G1Element

func (sk *PrivateKey) G1Element() (*G1Element, error)

G1Element returns a G1Element (public key) using a state of the current private key this method is a binding of the bls::PrivateKey::G1Element

func (*PrivateKey) G2Element

func (sk *PrivateKey) G2Element() (*G2Element, error)

G2Element returns a G2Element (signature) using a state of the current private key this method is a binding of the bls::PrivateKey::G2Element

func (*PrivateKey) G2Power

func (sk *PrivateKey) G2Power(el *G2Element) *G2Element

G2Power returns a power of G2Element (signature) this method is a binding of the bls::PrivateKey::G2Power

func (*PrivateKey) HexString

func (sk *PrivateKey) HexString() string

HexString returns a hex string representation of serialized data

func (*PrivateKey) Serialize

func (sk *PrivateKey) Serialize() []byte

Serialize returns the byte representation of the private key this method is a binding of the bls::PrivateKey::Serialize

type Scheme

type Scheme interface {
	Signer
	Generator
	Verifier
	Aggregator
	Deriver
}

Scheme is a schema interface

type Signer

type Signer interface {
	Sign(sk *PrivateKey, msg []byte) *G2Element
}

Signer is a signer interface

type Verifier

type Verifier interface {
	Verify(pk *G1Element, msg []byte, sig *G2Element) bool
	AggregateVerify(pks []*G1Element, msgs [][]byte, sig *G2Element) bool
}

Verifier is the interface that wraps the methods needed to verifications the interface contains the method for direct verification and aggregation with verification

Jump to

Keyboard shortcuts

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