Documentation
¶
Index ¶
- Constants
- Variables
- func DegreeFromThreshold(threshold uint64) uint64
- func Hash1(b []byte) *blst.P1Affine
- func Hash3(b []byte) *big.Int
- func IdentifyVersion(d []byte) byte
- func KeyperX(keyperIndex int) *big.Int
- func Shuffle(txs [][]byte, key *EpochSecretKey) [][]byte
- func Uint64toBytes(i uint64) ([]byte, int)
- func UnpadMessage(blocks []Block) ([]byte, error)
- func ValidEval(v *big.Int) bool
- func VerifyEpochSecretKey(epochSecretKey *EpochSecretKey, eonPublicKey *EonPublicKey, ...) (bool, error)
- func VerifyEpochSecretKeyDeterministic(epochSecretKey *EpochSecretKey, eonPublicKey *EonPublicKey, ...) (bool, error)
- func VerifyEpochSecretKeyShare(epochSecretKeyShare *EpochSecretKeyShare, eonPublicKeyShare *EonPublicKeyShare, ...) bool
- func VerifyPolyEval(keyperIndex int, polyEval *big.Int, gammas *Gammas, threshold uint64) bool
- type Block
- type EncryptedMessage
- func (m *EncryptedMessage) Decrypt(epochSecretKey *EpochSecretKey) ([]byte, error)
- func (m *EncryptedMessage) Marshal() []byte
- func (m EncryptedMessage) MarshalText() ([]byte, error)
- func (m *EncryptedMessage) Sigma(epochSecretKey *EpochSecretKey) Block
- func (m *EncryptedMessage) Unmarshal(d []byte) error
- func (m *EncryptedMessage) UnmarshalText(b []byte) error
- type EonPublicKey
- func (eonPublicKey *EonPublicKey) Equal(pk2 *EonPublicKey) bool
- func (eonPublicKey *EonPublicKey) GobDecode(data []byte) error
- func (eonPublicKey *EonPublicKey) GobEncode() ([]byte, error)
- func (eonPublicKey *EonPublicKey) Marshal() []byte
- func (eonPublicKey EonPublicKey) MarshalText() ([]byte, error)
- func (eonPublicKey *EonPublicKey) Unmarshal(m []byte) error
- func (eonPublicKey *EonPublicKey) UnmarshalText(input []byte) error
- type EonPublicKeyShare
- func (eonPublicKeyShare *EonPublicKeyShare) Equal(pk2 *EonPublicKeyShare) bool
- func (eonPublicKeyShare *EonPublicKeyShare) GobDecode(data []byte) error
- func (eonPublicKeyShare *EonPublicKeyShare) GobEncode() ([]byte, error)
- func (eonPublicKeyShare *EonPublicKeyShare) Marshal() []byte
- func (eonPublicKeyShare *EonPublicKeyShare) Unmarshal(m []byte) error
- type EonSecretKeyShare
- func (eonSecretKeyShare *EonSecretKeyShare) Equal(e2 *EonSecretKeyShare) bool
- func (eonSecretKeyShare *EonSecretKeyShare) GobDecode(data []byte) error
- func (eonSecretKeyShare *EonSecretKeyShare) GobEncode() ([]byte, error)
- func (eonSecretKeyShare *EonSecretKeyShare) Marshal() []byte
- func (eonSecretKeyShare *EonSecretKeyShare) Unmarshal(m []byte) error
- type EpochID
- type EpochSecretKey
- func (epochSecretKey *EpochSecretKey) Equal(g2 *EpochSecretKey) bool
- func (epochSecretKey *EpochSecretKey) GobDecode(data []byte) error
- func (epochSecretKey *EpochSecretKey) GobEncode() ([]byte, error)
- func (epochSecretKey *EpochSecretKey) Marshal() []byte
- func (epochSecretKey EpochSecretKey) MarshalText() ([]byte, error)
- func (epochSecretKey *EpochSecretKey) Unmarshal(m []byte) error
- func (epochSecretKey *EpochSecretKey) UnmarshalText(input []byte) error
- type EpochSecretKeyShare
- func (epochSecretKeyShare *EpochSecretKeyShare) Equal(g2 *EpochSecretKeyShare) bool
- func (epochSecretKeyShare *EpochSecretKeyShare) GobDecode(data []byte) error
- func (epochSecretKeyShare *EpochSecretKeyShare) GobEncode() ([]byte, error)
- func (epochSecretKeyShare *EpochSecretKeyShare) Marshal() []byte
- func (epochSecretKeyShare *EpochSecretKeyShare) Unmarshal(m []byte) error
- type Gammas
- func (g *Gammas) Degree() uint64
- func (g Gammas) Equal(otherG Gammas) bool
- func (g *Gammas) GobDecode(data []byte) error
- func (g *Gammas) GobEncode() ([]byte, error)
- func (g *Gammas) Marshal() []byte
- func (g *Gammas) MarshalText() ([]byte, error)
- func (g *Gammas) Pi(xi *big.Int) *blst.P2Affine
- func (g *Gammas) Unmarshal(m []byte) error
- func (g *Gammas) UnmarshalText(b []byte) error
- type LagrangeCoeffs
- type Polynomial
- type TestKeyGen
Constants ¶
const BlockSize = 32
BlockSize is the size in bytes of the blocks into which a message is split up before encryption.
const HashToG1DST = "SHUTTER_V01_BLS12381G1_XMD:SHA-256_SSWU_RO_"
const VersionIdentifier byte = 0x03
Variables ¶
var ( ErrInputTooLong = errors.New("input too long") ErrVersionMismatch = func(version_got byte) error { return fmt.Errorf("version mismatch. want %d got %d", VersionIdentifier, version_got) } )
Functions ¶
func DegreeFromThreshold ¶
DegreeFromThreshold returns the degree polynomials should have for the given threshold.
func IdentifyVersion ¶ added in v0.1.17
IdentifyVersion reads the version identifier byte from the given (marshaled) EncryptedMessage.
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 Uint64toBytes ¶ added in v0.1.13
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 VerifyEpochSecretKey ¶ added in v0.1.8
func VerifyEpochSecretKey(epochSecretKey *EpochSecretKey, eonPublicKey *EonPublicKey, epochIDBytes []byte) (bool, error)
VerifyEpochSecretKey checks that an epoch secret key is the correct key for an epoch given the eon public key.
func VerifyEpochSecretKeyDeterministic ¶ added in v0.1.14
func VerifyEpochSecretKeyDeterministic(epochSecretKey *EpochSecretKey, eonPublicKey *EonPublicKey, epochIDBytes []byte, sigma Block, message []byte) (bool, error)
VerifyEpochSecretKeyDeterministic checks that an epoch secret key is the correct key for an epoch given the eon public key and random inputs for sigma and message.
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 DecryptBlocks ¶ added in v0.1.12
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.
func (Block) MarshalText ¶ added in v0.1.12
MarshalText serializes the block to hex.
func (*Block) UnmarshalText ¶ added in v0.1.12
UnmarshalText deserializes the block from hex.
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) MarshalText ¶ added in v0.1.12
func (m EncryptedMessage) MarshalText() ([]byte, error)
MarshalText serializes the encrypted message to hex.
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.
func (*EncryptedMessage) UnmarshalText ¶ added in v0.1.12
func (m *EncryptedMessage) UnmarshalText(b []byte) error
UnmarshalText deserializes the encrypted message from hex.
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 (eonPublicKey *EonPublicKey) Equal(pk2 *EonPublicKey) bool
func (*EonPublicKey) GobDecode ¶
func (eonPublicKey *EonPublicKey) GobDecode(data []byte) error
func (*EonPublicKey) GobEncode ¶
func (eonPublicKey *EonPublicKey) GobEncode() ([]byte, error)
func (*EonPublicKey) Marshal ¶
func (eonPublicKey *EonPublicKey) Marshal() []byte
Marshal serializes the eon public key.
func (EonPublicKey) MarshalText ¶ added in v0.1.12
func (eonPublicKey EonPublicKey) MarshalText() ([]byte, error)
MarshalText serializes the eon public key to hex.
func (*EonPublicKey) Unmarshal ¶
func (eonPublicKey *EonPublicKey) Unmarshal(m []byte) error
Unmarshal deserializes an eon public key from the given byte slice.
func (*EonPublicKey) UnmarshalText ¶ added in v0.1.12
func (eonPublicKey *EonPublicKey) UnmarshalText(input []byte) error
UnmarshalText deserializes the eon public key from hex.
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 (eonPublicKeyShare *EonPublicKeyShare) Equal(pk2 *EonPublicKeyShare) bool
func (*EonPublicKeyShare) GobDecode ¶
func (eonPublicKeyShare *EonPublicKeyShare) GobDecode(data []byte) error
func (*EonPublicKeyShare) GobEncode ¶
func (eonPublicKeyShare *EonPublicKeyShare) GobEncode() ([]byte, error)
func (*EonPublicKeyShare) Marshal ¶ added in v0.1.9
func (eonPublicKeyShare *EonPublicKeyShare) Marshal() []byte
Marshal serializes the eon public key share.
func (*EonPublicKeyShare) Unmarshal ¶ added in v0.1.9
func (eonPublicKeyShare *EonPublicKeyShare) Unmarshal(m []byte) error
Unmarshal deserializes an eon public key share.
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 (eonSecretKeyShare *EonSecretKeyShare) Equal(e2 *EonSecretKeyShare) bool
func (*EonSecretKeyShare) GobDecode ¶
func (eonSecretKeyShare *EonSecretKeyShare) GobDecode(data []byte) error
func (*EonSecretKeyShare) GobEncode ¶
func (eonSecretKeyShare *EonSecretKeyShare) GobEncode() ([]byte, error)
func (*EonSecretKeyShare) Marshal ¶ added in v0.1.9
func (eonSecretKeyShare *EonSecretKeyShare) Marshal() []byte
Marshal serializes the eon secret key share.
func (*EonSecretKeyShare) Unmarshal ¶ added in v0.1.9
func (eonSecretKeyShare *EonSecretKeyShare) Unmarshal(m []byte) error
Unarshal deserializes an eon secret key share.
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 (epochSecretKey *EpochSecretKey) Equal(g2 *EpochSecretKey) bool
func (*EpochSecretKey) GobDecode ¶
func (epochSecretKey *EpochSecretKey) GobDecode(data []byte) error
func (*EpochSecretKey) GobEncode ¶
func (epochSecretKey *EpochSecretKey) GobEncode() ([]byte, error)
func (*EpochSecretKey) Marshal ¶ added in v0.1.9
func (epochSecretKey *EpochSecretKey) Marshal() []byte
Marshal serializes the epoch secret key.
func (EpochSecretKey) MarshalText ¶ added in v0.1.12
func (epochSecretKey EpochSecretKey) MarshalText() ([]byte, error)
MarshalText serializes the epoch secret key to hex.
func (*EpochSecretKey) Unmarshal ¶ added in v0.1.9
func (epochSecretKey *EpochSecretKey) Unmarshal(m []byte) error
Unmarshal deserializes an epoch secret key.
func (*EpochSecretKey) UnmarshalText ¶ added in v0.1.12
func (epochSecretKey *EpochSecretKey) UnmarshalText(input []byte) error
UnmarshalText deserializes the epoch secret key from hex.
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 (epochSecretKeyShare *EpochSecretKeyShare) Equal(g2 *EpochSecretKeyShare) bool
func (*EpochSecretKeyShare) GobDecode ¶
func (epochSecretKeyShare *EpochSecretKeyShare) GobDecode(data []byte) error
func (*EpochSecretKeyShare) GobEncode ¶
func (epochSecretKeyShare *EpochSecretKeyShare) GobEncode() ([]byte, error)
func (*EpochSecretKeyShare) Marshal ¶ added in v0.1.9
func (epochSecretKeyShare *EpochSecretKeyShare) Marshal() []byte
Marshal serializes the epoch secret key share.
func (*EpochSecretKeyShare) Unmarshal ¶ added in v0.1.9
func (epochSecretKeyShare *EpochSecretKeyShare) Unmarshal(m []byte) error
Unmarshal deserializes an epoch secret key share.
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
func (*Gammas) Marshal ¶ added in v0.1.19
Marshal serializes the gammas value.
Serialization format: [n:4][gamma1:96]...[gamman:96]
func (*Gammas) MarshalText ¶ added in v0.1.19
MarshalText serializes the gammas as hex.
func (*Gammas) UnmarshalText ¶ added in v0.1.19
UnmarshalText deserializes the gammas from hex.
type LagrangeCoeffs ¶ added in v0.1.11
type LagrangeCoeffs struct {
// contains filtered or unexported fields
}
LagrangeCoeffs stores the lagrange coefficients that are needed to compute an epoch secret key for a certain array of keypers. We use this to speedup epoch secret key generation.
func NewLagrangeCoeffs ¶ added in v0.1.11
func NewLagrangeCoeffs(keyperIndices []int) *LagrangeCoeffs
NewLagrangeCoeffs computes the lagrange coefficients for the given array of keypers.
func (*LagrangeCoeffs) ComputeEpochSecretKey ¶ added in v0.1.11
func (lc *LagrangeCoeffs) ComputeEpochSecretKey(epochSecretKeyShares []*EpochSecretKeyShare) (*EpochSecretKey, error)
ComputeEpochSecretKey computes the epoch secret key given the secret key shares of the keypers. The caller has to ensure that the secret shares match the keyperIndices used during initialisation.
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.
type TestKeyGen ¶ added in v0.1.15
type TestKeyGen struct { EonPublicKey *EonPublicKey // contains filtered or unexported fields }
func NewTestKeyGen ¶ added in v0.1.15
func NewTestKeyGen() (*TestKeyGen, error)
func (*TestKeyGen) ComputeEpochSecretKey ¶ added in v0.1.15
func (g *TestKeyGen) ComputeEpochSecretKey(epochID *EpochID) (*EpochSecretKey, error)