Skip to content

Library for computations over abstract algebraic structures such as finite fields and polynomial rings.

License

Notifications You must be signed in to change notification settings

jonas-lj/Ruffini

Repository files navigation

Maven Maven Javadoc License: MIT

Ruffini

Computations over algebraic structures in Java made easy.

Table of Contents

  1. About The Project
  2. Built With
  3. Usage
  4. Demos
  5. Contributing
  6. Referencing

About The Project

The Ruffini library is developed to make it easy to write algorithms in Java involving algebraic structures such as finite fields, polynomial rings, field extensions etc. The library includes an extensive library of already implemented algorithms such as the Euclidean algorithm, polynomial division etc. to make implementation even easier.

The project is named after the italian mathematician Paolo Ruffini (1765-1822) who, among other things, contributed to group theory and was the first to give a proof (although incomplete) that there is no general formula to solve quintic (and higher order) equations.

Submodules

The library contains multiple submodules:

  • Common: Definition of most commonly used abstract structures (groups, rings, fields, etc) and generic algorithms used throughout the library.
  • Demos: Example usages of the library. See also the Demos section.
  • Elliptic: Elliptic curves over generic fields and a few concrete constructions (Curve25519 and BLS12-381).
  • Finite-fields: Constructions of finite fields and algebraic field extensions.
  • Integers: Concrete constructions of integers and rational numbers.
  • Parser: Algorithms to parse algebraic expressions from strings and evaluate them.
  • Permutations: Construction and algoritms for permutation groups.
  • Polynomials: Single- and multivariate polynomials over arbitrary rings or fields. Includes common algorithms such as the computation of Lagrange interpolation and Gröbner bases.
  • Reals: Arbitrary precision real numbers using a constructive representation.

Built With

The project may be build using maven,

mvn clean install

and the documentation with

mvn javadoc:aggregate

Usage

The Ruffini library is organized analogous of how abstract algebra is presented in mathematics. The base of the library are a number of interfaces representing abstract algebraic structures. They are organized in an inheritance hierachy as seen in figure below. Note that E is a generic class, representing the element of the given structure.

Inheritance diagram for abstract algebraic structures

As in abstract algebra, an algorithm may be defined for an abstract structure and then be used with any concrete structure satisfying the definition of the abstract structure. As an example, consider the implementation of the Gram-Schmidt process definded over vectors of type V and scalars of type S. Now, this code may be used with any concrete implementations of a vector space over a field.

public class GramSchmidt<V, S, F extends Field<S>> implements Function<List<V>, List<V>> {

    private final VectorSpace<V, S, F> vectorSpace;
    private final BiFunction<V, V, S> innerProduct;

    public GramSchmidt(VectorSpace<V, S, F> V,
                       BiFunction<V, V, S> innerProduct) {
        this.vectorSpace = V;
        this.innerProduct = innerProduct;
    }

    @Override
    public List<V> apply(List<V> vectors) {
        List<V> U = new ArrayList<>();

        Projection<V, S, F> proj = new Projection<>(vectorSpace, innerProduct);

        for (V v : vectors) {
            for (V u : U) {
                V p = proj.apply(v, u);
                v = vectorSpace.subtract(v, p);
            }
            U.add(v);
        }
        return U;
    }

}

The library also contains some concrete instantiations of algebraic structures such as prime fields, finite fields, class groups and certain elliptic curve constructions (Curve25519 and BLS12-381).

Demos

There are a few demo applications showing some capabilities of the library in the demos module.

These include an implementation of the AKS primality testing algorithm, computing the optimal Ate pairing over the BLS12-381 elliptic construction, a demonstration of arbitrary precision arithmetic with real numbers inspired by the work of Hans-J Boehm and an implementation of the Poseidon hash function over BN254.

Contributing

We welcome any help from the community, both if you want to help out developing new features for Ruffini or fix a bug you've stumbled upon. Simply open a pull request with the suggested changes.

Referencing

If you are using the Ruffini library in a research project, please cite it as (setting the date field accordingly):

@software{Ruffini,
  author = {{Jonas Lindstrøm}},
  title = {{Ruffini} - Java library for computations over abstract algebraic structures},
  note = {\url{https://github.com/jonas-lj/Ruffini}},
  date = {},
}

About

Library for computations over abstract algebraic structures such as finite fields and polynomial rings.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages