DEV Community

BLACK
BLACK

Posted on

I Built Neva, a Small Lattice Analysis Toolkit in Python


https://github.com/black-210/neva
I started working on a small project called Neva because I wanted to experiment with lattice mathematics without starting with a huge framework.

The original idea was pretty simple:

Take a lattice, enter its basis vectors, and let the program show me what is happening mathematically.

I used Python and NumPy for the first version.

What Neva Does

Neva currently lets you enter a lattice interactively and analyze it using several linear algebra operations.

For example, you can enter:

Dimension: 2
Row 1: 105 821
Row 2: 12 95

Neva then calculates things such as:

  • Vector norms
  • Dot products
  • Determinant
  • Angles between vectors
  • Projections
  • Gram-Schmidt related calculations
  • Eigenvalues
  • Eigenvectors
  • Singular values

It also has an experimental LLL reduction implementation.

Why Lattices?

I became interested in lattices because of their connection to modern cryptography and post-quantum cryptography.

Lattice-based cryptography uses mathematical problems that are believed to be difficult even for quantum computers.

I wanted to understand some of the mathematics behind these systems rather than just using cryptographic libraries as black boxes.

Neva is one of my experiments in that direction.

LLL Reduction

One of the first algorithms I wanted to experiment with was LLL.

The basic idea is to transform a lattice basis into a reduced basis containing shorter and more useful vectors.

For example, Neva can start with a basis such as:

[105 821]
[ 12 95]

and perform reduction operations on the basis.

The interesting part for me isn't just getting a final matrix.

I wanted to see the intermediate mathematical properties of the lattice as well.

Keeping the Code Small

One thing I deliberately wanted to avoid was building a massive framework immediately.

The current version mainly uses:

import numpy as np

NumPy provides most of the linear algebra functionality needed for the first version.

This makes the project relatively easy to inspect and experiment with.

There is something useful about being able to open the source code and actually understand what the program is doing.

What I Learned

Building Neva has been less about writing a huge amount of code and more about connecting mathematical concepts together.

For example:

Basis

Vectors

Norms

Dot Products

Projections

Gram-Schmidt

Lattice Reduction

Seeing these operations as parts of the same problem made the subject much easier to understand.

What's Next?

Neva is still experimental.

Some of the things I want to explore next include:

  • Improving the LLL implementation
  • BKZ experimentation
  • SVP-related experiments
  • CVP-related experiments
  • Better lattice visualization
  • Benchmarking reduction algorithms
  • More lattice-analysis tools
  • Experiments related to post-quantum cryptography

I don't want to turn Neva into a giant framework just for the sake of having more code.

I'd rather keep it understandable while gradually making the mathematics more useful.

Try It

The project is available on GitHub:

Neva

If you're interested in lattice mathematics, linear algebra, cryptography, or just experimenting with mathematical algorithms, the source code is there to explore.

Neva is currently a research and educational project, not a production cryptographic library.

I'm still building it, so the current implementation is only the beginning.

Top comments (0)