sortition

package
v1.6.4 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var UndefVerifiableSeed = VerifiableSeed{}

Functions

func GetIndex added in v0.13.0

func GetIndex(proof Proof, max uint64) uint64

func Verify added in v0.13.0

func Verify(seed VerifiableSeed, pub *bls.PublicKey, proof Proof, max uint64) (uint64, bool)

Verify checks if the provided proof, based on the seed and public key, is valid. If the proof is valid, it calculates the random number that can be generated based on the given proof.

func VerifyProof

func VerifyProof(seed VerifiableSeed, proof Proof, pub *bls.PublicKey, total, threshold int64) bool

Types

type Proof

type Proof [48]byte

func Evaluate added in v0.13.0

func Evaluate(seed VerifiableSeed, prv *bls.PrivateKey, max uint64) (uint64, Proof)

Evaluate returns a provable random number between [0, max) along with a proof. It returns the random number and the proof that can regenerate the random number using the public key of the signer, without revealing the private key.

func EvaluateSortition

func EvaluateSortition(seed VerifiableSeed, prv *bls.PrivateKey, total, threshold int64) (bool, Proof)

func ProofFromBytes

func ProofFromBytes(data []byte) (Proof, error)

func ProofFromString

func ProofFromString(text string) (Proof, error)

type VerifiableSeed

type VerifiableSeed [48]byte

func VerifiableSeedFromBytes

func VerifiableSeedFromBytes(data []byte) (VerifiableSeed, error)

func VerifiableSeedFromString

func VerifiableSeedFromString(text string) (VerifiableSeed, error)

func (*VerifiableSeed) GenerateNext added in v0.10.0

func (s *VerifiableSeed) GenerateNext(prv *bls.PrivateKey) VerifiableSeed

func (*VerifiableSeed) Verify

func (s *VerifiableSeed) Verify(public *bls.PublicKey, prevSeed VerifiableSeed) bool

Jump to

Keyboard shortcuts

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