algopts

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: May 13, 2026 License: Apache-2.0 Imports: 1 Imported by: 26

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 deprecated

func WithCompleteArithmetic() AlgebraOption

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

Deprecated: Scalar multiplication is now complete by default. This option is a no-op and will be removed in a future version. To opt into faster incomplete formulas (when inputs are guaranteed non-degenerate), use WithIncompleteArithmetic.

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 WithIncompleteArithmetic added in v0.15.0

func WithIncompleteArithmetic() AlgebraOption

WithIncompleteArithmetic opts into faster incomplete formulas for scalar multiplication. The caller must guarantee that the scalar is non-zero and the input point is not the point at infinity (0,0). Using this option with degenerate inputs leads to undefined circuit behavior.

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.

func WithNoSubgroupMembershipCheck added in v0.15.0

func WithNoSubgroupMembershipCheck() AlgebraOption

WithNoSubgroupMembershipCheck disables the subgroup membership checks if the method performs them. This is useful in cases where it is checked separately, for example in the [evmprecompiles] package. If this is not set, then by default subgroup membership checks are always performed.

Jump to

Keyboard shortcuts

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