...

Package mlsbset

import "github.com/cloudflare/circl/math/mlsbset"
Overview
Index

Overview ▾

Package mlsbset provides a constant-time exponentiation method with precomputation.

References: "Efficient and secure algorithms for GLV-based scalar multiplication and their implementation on GLV–GLS curves" by (Faz-Hernandez et al.)

type EltG

EltG is a group element.

type EltG interface{}

type EltP

EltP is a precomputed group element.

type EltP interface{}

type Encoder

Encoder allows to convert integers into valid powers.

type Encoder struct {
    // contains filtered or unexported fields
}

func New

func New(t, v, w uint) (Encoder, error)

New produces an encoder of the MLSBSet algorithm.

func (Encoder) Elts

func (m Encoder) Elts() uint

Elts returns the total number of elements that must be precomputed.

func (Encoder) Encode

func (m Encoder) Encode(k []byte) (*Power, error)

Encode converts an odd integer k into a valid power for exponentiation.

func (Encoder) GetParams

func (m Encoder) GetParams() Params

GetParams returns the complementary parameters of the encoding.

func (Encoder) IsExtended

func (m Encoder) IsExtended() bool

IsExtended returns true if the element x^(2^(wd)) must be calculated.

func (Encoder) Ops

func (m Encoder) Ops() (S uint, M uint)

Ops returns the number of squares and multiplications executed during an exponentiation.

func (Encoder) String

func (m Encoder) String() string

type Group

Group defines the operations required by MLSBSet exponentiation method.

type Group interface {
    Identity() EltG                    // Returns the identity of the group.
    Sqr(x EltG)                        // Calculates x = x^2.
    Mul(x EltG, y EltP)                // Calculates x = x*y.
    NewEltP() EltP                     // Returns an arbitrary precomputed element.
    ExtendedEltP() EltP                // Returns the precomputed element x^(2^(w*d)).
    Lookup(a EltP, v uint, s, u int32) // Sets a = s*T[v][u].
}

type Params

Params contains the parameters of the encoding.

type Params struct {
    T uint // T is the maximum size (in bits) of exponents.
    V uint // V is the number of tables.
    W uint // W is the window size.
    E uint // E is the number of digits per table.
    D uint // D is the number of digits in total.
    L uint // L is the length of the code.
}

type Power

Power is a valid exponent produced by the MLSBSet encoding algorithm.

type Power struct {
    // contains filtered or unexported fields
}

func (*Power) Digit

func (p *Power) Digit(v, e uint) (sgn, dig int32)

Digit returns the (v,e)-th digit and its sign.

func (*Power) Exp

func (p *Power) Exp(G Group) EltG

Exp is calculates x^k, where x is a predetermined element of a group G.

func (*Power) String

func (p *Power) String() string