Documentation ¶
Index ¶
- Constants
- Variables
- func DegreeFromThreshold(threshold uint64) uint64
- func EqualG1(p1, p2 *bn256.G1) bool
- func EqualG2(p1, p2 *bn256.G2) bool
- func EqualGT(p1, p2 *bn256.GT) bool
- func HashBlockToInt(d Block) *big.Int
- func KeyperX(keyperIndex int) *big.Int
- func Shuffle(txs [][]byte, key *EpochSecretKey) [][]byte
- func UnpadMessage(blocks []Block) ([]byte, error)
- func ValidEval(v *big.Int) bool
- func VerifyEpochSecretKeyShare(epochSecretKeyShare *EpochSecretKeyShare, eonPublicKeyShare *EonPublicKeyShare, ...) bool
- func VerifyPolyEval(keyperIndex int, polyEval *big.Int, gammas *Gammas, threshold uint64) bool
- type Block
- type EncryptedMessage
- type EonPublicKey
- type EonPublicKeyShare
- type EonSecretKeyShare
- type EpochID
- type EpochSecretKey
- type EpochSecretKeyShare
- type Gammas
- type Polynomial
Constants ¶
const BlockSize = 32
BlockSize is the size in bytes of the blocks into which a message is split up before encryption.
Variables ¶
var G1Comparer = gocmp.Comparer(EqualG1)
var G2Comparer = gocmp.Comparer(EqualG2)
var GTComparer = gocmp.Comparer(EqualGT)
Functions ¶
func DegreeFromThreshold ¶
DegreeFromThreshold returns the degree polynomials should have for the given threshold.
func HashBlockToInt ¶
HashBlockToInt hashes a block and returns the result as an integer in Z_q.
func Shuffle ¶
func Shuffle(txs [][]byte, key *EpochSecretKey) [][]byte
Shuffle shuffles the order of the transactions using the epoch secret key as a source of randomness.
func UnpadMessage ¶
UnpadMessage returns the message provided in padded form as a sequence of blocks.
func ValidEval ¶
ValidEval checks if the given value is a valid polynomial evaluation, i.e., if it is in Z_q.
func VerifyEpochSecretKeyShare ¶
func VerifyEpochSecretKeyShare(epochSecretKeyShare *EpochSecretKeyShare, eonPublicKeyShare *EonPublicKeyShare, epochID *EpochID) bool
VerifyEpochSecretKeyShare checks that an epoch sk share published by a keyper is correct.
Types ¶
type Block ¶
Block represents a block of data.
func HashBytesToBlock ¶
HashBytesToBlock hashes the given byte slice and returns the result as a block.
func HashGTToBlock ¶
HashGTToBlock hashes an element of GT and returns the result as a block.
func PadMessage ¶
PadMessage pads a message and returns it as a sequence of blocks. Implements PKCS #7 according to https://www.ietf.org/rfc/rfc2315.txt
func RandomSigma ¶
RandomSigma returns a random value to be used during encryption.
type EncryptedMessage ¶
EncryptedMessage represents the full output of the encryption procedure.
func Encrypt ¶
func Encrypt(message []byte, eonPublicKey *EonPublicKey, epochID *EpochID, sigma Block) *EncryptedMessage
Encrypt encrypts a message for the epoch given by its id. It uses the eon public key and randomness provided in sigma.
func (*EncryptedMessage) Decrypt ¶
func (m *EncryptedMessage) Decrypt(epochSecretKey *EpochSecretKey) ([]byte, error)
Decrypt decrypts the given message using the given epoch secret key.
func (*EncryptedMessage) Marshal ¶
func (m *EncryptedMessage) Marshal() []byte
Marshal serializes the EncryptedMessage object. It panics, if C1 is nil.
func (*EncryptedMessage) Sigma ¶
func (m *EncryptedMessage) Sigma(epochSecretKey *EpochSecretKey) Block
Sigma computes the sigma value of the encrypted message given the epoch secret key.
func (*EncryptedMessage) Unmarshal ¶
func (m *EncryptedMessage) Unmarshal(d []byte) error
Unmarshal deserializes an EncryptedMessage from the given byte slice.
type EonPublicKey ¶
EonPublicKey represents the combined eon public key.
func ComputeEonPublicKey ¶
func ComputeEonPublicKey(gammas []*Gammas) *EonPublicKey
ComputeEonPublicKey computes the combined eon public key from the set of eon public key shares.
func (*EonPublicKey) Equal ¶
func (eonpubkey *EonPublicKey) Equal(pk2 *EonPublicKey) bool
func (*EonPublicKey) GobDecode ¶
func (eonpubkey *EonPublicKey) GobDecode(data []byte) error
func (*EonPublicKey) GobEncode ¶
func (eonpubkey *EonPublicKey) GobEncode() ([]byte, error)
func (*EonPublicKey) Marshal ¶
func (eonpubkey *EonPublicKey) Marshal() []byte
Marshal serialized the eon public key.
func (*EonPublicKey) Unmarshal ¶
func (eonpubkey *EonPublicKey) Unmarshal(m []byte) error
Unmarshal deserializes an eon public key from the given byte slice.
type EonPublicKeyShare ¶
EonPublicKeyShare represents a share of the eon public key.
func ComputeEonPublicKeyShare ¶
func ComputeEonPublicKeyShare(keyperIndex int, gammas []*Gammas) *EonPublicKeyShare
ComputeEonPublicKeyShare computes the eon public key share of the given keyper.
func (*EonPublicKeyShare) Equal ¶
func (g2 *EonPublicKeyShare) Equal(pk2 *EonPublicKeyShare) bool
func (*EonPublicKeyShare) GobDecode ¶
func (g2 *EonPublicKeyShare) GobDecode(data []byte) error
func (*EonPublicKeyShare) GobEncode ¶
func (g2 *EonPublicKeyShare) GobEncode() ([]byte, error)
type EonSecretKeyShare ¶
EonSecretKeyShare represents a share of the eon secret key.
func ComputeEonSecretKeyShare ¶
func ComputeEonSecretKeyShare(polyEvals []*big.Int) *EonSecretKeyShare
ComputeEonSecretKeyShare computes the keyper's secret key share from the set of poly evals received from the other keypers.
func (*EonSecretKeyShare) Equal ¶
func (esks *EonSecretKeyShare) Equal(e2 *EonSecretKeyShare) bool
func (*EonSecretKeyShare) GobDecode ¶
func (esks *EonSecretKeyShare) GobDecode(data []byte) error
func (*EonSecretKeyShare) GobEncode ¶
func (esks *EonSecretKeyShare) GobEncode() ([]byte, error)
type EpochID ¶
EpochID is the identifier of an epoch.
func ComputeEpochID ¶
ComputeEpochID computes the id of the given epoch.
type EpochSecretKey ¶
EpochSecretKey represents an epoch secret key.
func ComputeEpochSecretKey ¶
func ComputeEpochSecretKey(keyperIndices []int, epochSecretKeyShares []*EpochSecretKeyShare, threshold uint64) (*EpochSecretKey, error)
ComputeEpochSecretKey computes the epoch secret key from a set of shares.
func (*EpochSecretKey) Equal ¶
func (g *EpochSecretKey) Equal(g2 *EpochSecretKey) bool
func (*EpochSecretKey) GobDecode ¶
func (g *EpochSecretKey) GobDecode(data []byte) error
func (*EpochSecretKey) GobEncode ¶
func (g *EpochSecretKey) GobEncode() ([]byte, error)
type EpochSecretKeyShare ¶
EpochSecretKeyShare represents a keyper's share of the epoch sk key.
func ComputeEpochSecretKeyShare ¶
func ComputeEpochSecretKeyShare(eonSecretKeyShare *EonSecretKeyShare, epochID *EpochID) *EpochSecretKeyShare
ComputeEpochSecretKeyShare computes a keyper's epoch sk share.
func (*EpochSecretKeyShare) Equal ¶
func (g *EpochSecretKeyShare) Equal(g2 *EpochSecretKeyShare) bool
func (*EpochSecretKeyShare) GobDecode ¶
func (g *EpochSecretKeyShare) GobDecode(data []byte) error
func (*EpochSecretKeyShare) GobEncode ¶
func (g *EpochSecretKeyShare) GobEncode() ([]byte, error)
type Gammas ¶
Gammas is a sequence of G2 points based on a polynomial.
func ZeroGammas ¶
ZeroGammas returns the zero value for gammas.
func (*Gammas) GobDecode ¶
GobDecode decodes a Gammas value. See https://golang.org/pkg/encoding/gob/#GobDecoder
func (*Gammas) GobEncode ¶
GobEncode encodes a Gammas value. See https://golang.org/pkg/encoding/gob/#GobEncoder
type Polynomial ¶
Polynomial represents a polynomial over Z_q.
func NewPolynomial ¶
func NewPolynomial(coefficients []*big.Int) (*Polynomial, error)
NewPolynomial creates a new polynomial from the given coefficients. It verifies the number and range of them.
func RandomPolynomial ¶
func RandomPolynomial(r io.Reader, degree uint64) (*Polynomial, error)
RandomPolynomial generates a random polynomial of given degree.
func (*Polynomial) Degree ¶
func (p *Polynomial) Degree() uint64
Degree returns the degree of the polynomial.
func (*Polynomial) Eval ¶
func (p *Polynomial) Eval(x *big.Int) *big.Int
Eval evaluates the polynomial at the given coordinate.
func (*Polynomial) EvalForKeyper ¶
func (p *Polynomial) EvalForKeyper(keyperIndex int) *big.Int
EvalForKeyper evaluates the polynomial at the position designated for the given keyper.
func (*Polynomial) Gammas ¶
func (p *Polynomial) Gammas() *Gammas
Gammas computes the gamma values for a given polynomial.