algebrautils

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

README

Algebrautils

Utilities for working with algebraic structures such as monoids, groups, rings, and fields.

Features

  • Random Sampling - Generate random non-identity elements from finite monoids
  • Folding Operations - Apply binary operations, addition, or multiplication across elements
  • Scalar Multiplication - Efficient fixed-window scalar multiplication for monoid elements

Designed to work with the abstract algebra structures defined in pkg/base/algebra.

Documentation

Overview

Package algebrautils provides utilities for working with algebraic structures such as monoids, groups, rings, and fields.

See README.md for details.

Index

Constants

This section is empty.

Variables

View Source
var ErrArgumentIsNil = errs.New("argument is nil")

Functions

func Fold

func Fold[S algebra.Operand[S]](first S, rest ...S) S

Fold applies the binary operation of the given operand type to all provided elements, returning the final result.

func MultiScalarMul

func MultiScalarMul[E algebra.MonoidElement[E], S algebra.Numeric](
	scalars []S,
	points []E,
) E

MultiScalarMul performs a Pippenger-style multi-scalar multiplication:

sum_i scalars[i] * points[i]

using a fixed window size w.

It assumes S.Bytes() is big-endian. Bits are extracted in LSB-first order.

func Prod

func Prod[M algebra.Multiplicand[M]](first M, rest ...M) M

Prod applies the multiplication operation of the given multiplicand type to all provided elements, returning the final result.

func RandomNonIdentity

func RandomNonIdentity[M interface {
	algebra.FiniteStructure[E]
	algebra.Monoid[E]
}, E algebra.MonoidElement[E]](m M, prng io.Reader) (E, error)

RandomNonIdentity samples a random element from the given finite monoid that is not the identity element.

func ScalarMul

func ScalarMul[E algebra.MonoidElement[E], S algebra.Numeric](base E, exponent S) E

ScalarMul computes the scalar multiplication of the given base element by the given exponent using a fixed-window method.

func Sum

func Sum[S algebra.Summand[S]](first S, rest ...S) S

Sum applies the addition operation of the given summand type to all provided elements, returning the final result.

Types

This section is empty.

Jump to

Keyboard shortcuts

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