uleaderselection

package
v2.1.4+incompatible Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2019 License: GPL-3.0 Imports: 11 Imported by: 2

Documentation

Overview

package uleaderselection Algorithms for unique leader selection including Random proposer + Epoch leader selection, Secret Message Array Construction, Slot Leader Selection and DLEQ Proof Generation

Index

Constants

View Source
const Accuracy float64 = 1024.0 //accuracy to magnificate

Variables

View Source
var (
	Big1                                   = big.NewInt(1)
	Big0                                   = big.NewInt(0)
	ErrInvalidRandomProposerSelection      = errors.New("Invalid Random Proposer Selection")                  //Invalid Random Proposer Selection
	ErrInvalidProbabilityfloat2big         = errors.New("Invalid Transform Probability From Float To Bigint") //Invalid Transform Probability From Float To Bigint
	ErrInvalidGenerateCommitment           = errors.New("Invalid Commitment Generation")                      //Invalid Commitment Generation
	ErrInvalidArrayPieceGeneration         = errors.New("Invalid ArrayPiece Generation")                      //Invalid ArrayPiece Generation
	ErrInvalidDleqProofGeneration          = errors.New("Invalid DLEQ Proof Generation")                      //Invalid DLEQ Proof Generation
	ErrInvalidSecretMessageArrayGeneration = errors.New("Invalid Secret Message Array Generation")            //Invalid Secret Message Array Generation
	ErrInvalidSortPublicKeys               = errors.New("Invalid PublicKeys Sort Operation")                  //Invalid PublicKeys Sort Operation
	ErrInvalidSlotLeaderSequenceGeneration = errors.New("Invalid Slot Leader Sequence Generation")            //Invalid Slot Leader Sequence Generation
	ErrInvalidSlotLeaderLocation           = errors.New("Invalid Slot Leader Location")                       //Invalid Slot Leader Location
	ErrInvalidSlotLeaderProofGeneration    = errors.New("Invalid Slot Leader Proof Generation")               //Invalid Slot Leader Proof Generation

	ErrInvalidPrivateKey = errors.New("private key is nil")
	ErrInvalidSMA        = errors.New("SMA is nil")
	ErrInvalidPublicKey  = errors.New("public key is nil")
	ErrSortPublicKey     = errors.New("sort public key error")
	ErrPublicKeyNotEqual = errors.New("public key is not equal")
	ErrZeroBigIntProof   = errors.New("zero big int proof")

	ErrNoInPreEPLS     = errors.New("Local node is not in pre epoch leaders at generateSlotLeadsGroup")
	ErrInvalidProof    = errors.New("In valid proof in the block head")
	ErrInvalidProofMeg = errors.New("In valid proofMeg in the block head")
)

Parameters

Functions

func DleqProofGeneration

func DleqProofGeneration(PublicKeys []*ecdsa.PublicKey, AlphaPublicKeys []*ecdsa.PublicKey,
	alpha *big.Int) ([]*big.Int, error)

DlequProofGeneration generate the DLEQ Proof PublicKeys = [PK1, PK2, ...,Pkn] AlphaPublicKeys = [alpha*PK1, alpha*PK2,...,alpha*PKn] return Proof = [e,z]

func GenerateArrayPiece

func GenerateArrayPiece(PublicKeys []*ecdsa.PublicKey,
	alpha *big.Int) ([]*ecdsa.PublicKey, []*ecdsa.PublicKey, []*big.Int, error)

GenerateArrayPiece compute message sent out, where ArrayPiece = (alpha * Pk1, alpha * Pk2, ..., alpha * Pkn) Additional DLEQ proof needs to be added

func GenerateCommitment

func GenerateCommitment(PublicKey *ecdsa.PublicKey, alpha *big.Int) ([]*ecdsa.PublicKey, error)

GenerateCommitment compute the commitment of PublicKey, Commitment = PublicKey || alpha * PublicKey

func GenerateSMA

func GenerateSMA(PrivateKey *ecdsa.PrivateKey, ArrayPiece []*ecdsa.PublicKey) ([]*ecdsa.PublicKey, error)

GenerateSMA compute the Secret Message Array from the array piece received need to sort the array received based on PublicKeys in advance

func GenerateSlotLeaderProof

func GenerateSlotLeaderProof(PrivateKey *ecdsa.PrivateKey, SMA []*ecdsa.PublicKey, PublicKeys []*ecdsa.PublicKey,
	RB []byte, slt uint64, epochID uint64) ([]*ecdsa.PublicKey, []*big.Int, error)

GenerateSlotLeaderProof produce the proof of being the slt slot leader

func GenerateSlotLeaderSeqAndIndex

func GenerateSlotLeaderSeqAndIndex(SMA []*ecdsa.PublicKey, PublicKeys []*ecdsa.PublicKey, RB []byte, epochlen uint64,
	epochID uint64) ([]*ecdsa.PublicKey, []*big.Int, []uint64, error)

func GenerateSlotLeaderSeqOne

func GenerateSlotLeaderSeqOne(SMA []*ecdsa.PublicKey, PublicKeys []*ecdsa.PublicKey, RB []byte, slotID uint64,
	epochID uint64) (*ecdsa.PublicKey, error)

func ProbabilityFloat2big

func ProbabilityFloat2big(Probabilities []*float64) ([]*big.Int, error)

Transform Probabilities from float to bigint

func PublicKeyEqual

func PublicKeyEqual(PublicKey1 *ecdsa.PublicKey, PublicKey2 *ecdsa.PublicKey) bool

PublicKeyEqual test the equavalance of two public key

func RandFieldElement

func RandFieldElement(rand io.Reader) (k *big.Int, err error)

_________________________________________________________DLEQ Proof_________________________________________________________________

func RandomProposerSelection

func RandomProposerSelection(r []byte, nr int, PublicKeys []*ecdsa.PublicKey,
	Probabilities []*float64) ([]*ecdsa.PublicKey, error)

samples nr random proposers by random number r(Random Beacon) from PublicKeys based on proportion of Probabilities

func SortPublicKeys

func SortPublicKeys(PublicKeys []*ecdsa.PublicKey, RB []byte) ([]*ecdsa.PublicKey, error)

SortPublicKeys sort the publickeys by random beacon to produce a public key sequence

func SortPublicKeysAndIndex

func SortPublicKeysAndIndex(PublicKeys []*ecdsa.PublicKey, RB []byte) ([]*ecdsa.PublicKey,
	[]uint64, error)

func Uint64ToBytes

func Uint64ToBytes(input uint64) []byte

func VerifyArrayPiece

func VerifyArrayPiece(Commitment []*ecdsa.PublicKey, PublicKeys []*ecdsa.PublicKey, ArrayPiece []*ecdsa.PublicKey,
	Proof []*big.Int) bool

VerifyArrayPiece validates the encrypted message array

func VerifyDleqProof

func VerifyDleqProof(PublicKeys []*ecdsa.PublicKey, AlphaPublicKeys []*ecdsa.PublicKey,
	Proof []*big.Int) bool

func VerifySlotLeaderProof

func VerifySlotLeaderProof(Proof []*big.Int, ProofMeg []*ecdsa.PublicKey, PublicKeys []*ecdsa.PublicKey,
	RB []byte) bool

VerifySlotLeaderProof validates the proof of being the slot leader need a verification before that the message array received by PublicKey(ProofMeg[0]) equals to ProofMeg[2]

func Wadd

func Wadd(x1, y1, x2, y2 *big.Int) (*big.Int, *big.Int)

Types

This section is empty.

Jump to

Keyboard shortcuts

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