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
- Variables
- func DleqProofGeneration(PublicKeys []*ecdsa.PublicKey, AlphaPublicKeys []*ecdsa.PublicKey, ...) ([]*big.Int, error)
- func GenerateArrayPiece(PublicKeys []*ecdsa.PublicKey, alpha *big.Int) ([]*ecdsa.PublicKey, []*ecdsa.PublicKey, []*big.Int, error)
- func GenerateCommitment(PublicKey *ecdsa.PublicKey, alpha *big.Int) ([]*ecdsa.PublicKey, error)
- func GenerateSMA(PrivateKey *ecdsa.PrivateKey, ArrayPiece []*ecdsa.PublicKey) ([]*ecdsa.PublicKey, error)
- func GenerateSlotLeaderProof(PrivateKey *ecdsa.PrivateKey, SMA []*ecdsa.PublicKey, ...) ([]*ecdsa.PublicKey, []*big.Int, error)
- func GenerateSlotLeaderSeqAndIndex(SMA []*ecdsa.PublicKey, PublicKeys []*ecdsa.PublicKey, RB []byte, ...) ([]*ecdsa.PublicKey, []*big.Int, []uint64, error)
- func GenerateSlotLeaderSeqOne(SMA []*ecdsa.PublicKey, PublicKeys []*ecdsa.PublicKey, RB []byte, ...) (*ecdsa.PublicKey, error)
- func ProbabilityFloat2big(Probabilities []*float64) ([]*big.Int, error)
- func PublicKeyEqual(PublicKey1 *ecdsa.PublicKey, PublicKey2 *ecdsa.PublicKey) bool
- func RandFieldElement(rand io.Reader) (k *big.Int, err error)
- func RandomProposerSelection(r []byte, nr int, PublicKeys []*ecdsa.PublicKey, Probabilities []*float64) ([]*ecdsa.PublicKey, error)
- func SortPublicKeys(PublicKeys []*ecdsa.PublicKey, RB []byte) ([]*ecdsa.PublicKey, error)
- func SortPublicKeysAndIndex(PublicKeys []*ecdsa.PublicKey, RB []byte) ([]*ecdsa.PublicKey, []uint64, error)
- func Uint64ToBytes(input uint64) []byte
- func VerifyArrayPiece(Commitment []*ecdsa.PublicKey, PublicKeys []*ecdsa.PublicKey, ...) bool
- func VerifyDleqProof(PublicKeys []*ecdsa.PublicKey, AlphaPublicKeys []*ecdsa.PublicKey, ...) bool
- func VerifySlotLeaderProof(Proof []*big.Int, ProofMeg []*ecdsa.PublicKey, PublicKeys []*ecdsa.PublicKey, ...) bool
- func Wadd(x1, y1, x2, y2 *big.Int) (*big.Int, *big.Int)
Constants ¶
const Accuracy float64 = 1024.0 //accuracy to magnificate
Variables ¶
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 ¶
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 ProbabilityFloat2big ¶
Transform Probabilities from float to bigint
func PublicKeyEqual ¶
PublicKeyEqual test the equavalance of two public key
func RandFieldElement ¶
_________________________________________________________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 ¶
SortPublicKeys sort the publickeys by random beacon to produce a public key sequence
func SortPublicKeysAndIndex ¶
func Uint64ToBytes ¶
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 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]
Types ¶
This section is empty.