algopts

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2024 License: Apache-2.0 Imports: 1 Imported by: 25

Documentation

Overview

Package algopts provides shareable options for modifying algebraic operations.

This package is separate to avoid cyclic imports and sharing the structures between interface definition, implementation getters and actual implementations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewConfig

func NewConfig(opts ...AlgebraOption) (*algebraCfg, error)

NewConfig applies all given options and returns a configuration to be used.

Types

type AlgebraOption

type AlgebraOption func(*algebraCfg) error

AlgebraOption allows modifying algebraic operation behaviour.

func WithCanonicalBitRepresentation added in v0.11.0

func WithCanonicalBitRepresentation() AlgebraOption

WithCanonicalBitRepresentation enforces the marshalling methods to assert that the bit representation is in canonical form. For field elements this means that the bits represent a number less than the modulus.

This option is useful when performing direct comparison between the bit form of two elements. It can be avoided when the bit representation is used in other cases, such as computing a challenge using a hash function, where non-canonical bit representation leads to incorrect challenge (which in turn makes the verification fail).

func WithCompleteArithmetic

func WithCompleteArithmetic() AlgebraOption

WithCompleteArithmetic forces the use of safe addition formulas for scalar multiplication.

func WithFoldingScalarMul

func WithFoldingScalarMul() AlgebraOption

WithFoldingScalarMul can be used when calling MultiScalarMul. By using this option we assume that the scalars are `1, scalar, scalar^2, ...`. We use the first element as the scalar to be used as a folding coefficients. By using this option we avoid one scalar multiplication and do not need to compute the powers of the folding coefficient.

func WithNbScalarBits

func WithNbScalarBits(bits int) AlgebraOption

WithNbScalarBits defines the number bits when doing scalar multiplication. May be used when it is known that only bits least significant bits are non-zero. Reduces the cost for scalar multiplication. If not set then full width of scalars used.

Jump to

Keyboard shortcuts

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