项目作者: horeilly1101

项目描述 :
𝜻(s) A collection of efficient number theoretic algorithms and data structures
高级语言: Python
项目地址: git://github.com/horeilly1101/fermat.git
创建时间: 2019-10-04T04:59:21Z
项目社区:https://github.com/horeilly1101/fermat

开源协议:

下载


fermat

A collection of efficient number theoretic algorithms and data structures

Build Status
codecov

Description

Fermat contains algorithms and data structures to efficiently
compute many important results in number theory. Most methods are
based off of MATH 365 at Rice University and A Friendly
Introduction to Number Theory
by Joseph H. Silverman.

This library includes:

  • Arithmetic functions and the dirichlet convolution
  • Continued fractions
  • Cryptographic operations and the RSA algorithm
  • Efficient algorithms to solve common diophantine equations
    • Linear, Sum of Squares, Pell-like, etc.
  • Common factorization strategies
  • Primality testing (Rabin-Miller)
  • Operations with quadratic reciprocity and the Jacobi symbol
  • Random (large) prime generation
  • An algorithm to compute modular inverses
  • Various utility methods
  • And more to come …

How to use

Set up the environment and install dependencies.

  1. # start in the repository directory
  2. python3 -m venv venv
  3. . venv/bin/activate
  4. pip install -r requirements.txt

All code is available in the /fermat directory.

RSA Encryption API

This project also contains a REST API that generates arbitrarily
large public/private keys for RSA encryption. You can run the server
with

  1. python3 run_server.py

The server will then be available at localhost:2345. The only
available GET endpoint is /get-keys/<min_bits>, where min_bits
is an integer that specifies the minimum allowable bits in the
public key. The private key and modulus will have about twice
as many bits.

Example Response

  1. {
  2. min_bits: 10,
  3. publicKey: "0x3d981",
  4. privateKey: "0x568bcc181",
  5. modulus: "0xdab06fce1"
  6. }

How to test

Tests are set up with the unittest module. You can run them with

  1. python3 -m unittest