package mlsbset

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

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.)

Index

Types

type EltG

type EltG interface{}

EltG is a group element.

type EltP

type EltP interface{}

EltP is a precomputed group element.

type Encoder

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

Encoder allows to convert integers into valid powers.

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

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].
}

Group defines the operations required by MLSBSet exponentiation method.

type Params

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.
}

Params contains the parameters of the encoding.

type Power

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

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

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

Source Files

mlsbset.go power.go

Version
v1.6.1 (latest)
Published
Apr 9, 2025
Platform
linux/amd64
Imports
4 packages
Last checked
1 week ago

Tools for package owners.