GithubHelp home page GithubHelp logo

quadratic-sieve-cxx's Introduction

Quadratic Sieve C++

A simple Quadratic Sieve implementation in C++, this is an adaptation of the C version here https://github.com/martani/Quadratic-Sieve.

Status

The current version is fully working but have several performance issues compared to the C version. It does not play nice with small RSA integers (less than 50 bits) and natuarally with very large ones (more than 200 bits).

Compilling and testing the code

  1. autoreconf -v
  2. ./configure (if another compiler, clang for example use: CXX=clang ./configure)
  3. cd tests/ && make
  4. ./test-qs

Factoring RSA integers from C++ code

You can use the code as follows:

  • Include the QS.h header file
  • Initialize the Qudratic Sieve algorithm from the QS class
    //N represents the RSA integer you want to factor
    //NB_LINEAR_RELATIONS is a const (between 1..10 usually) indicating how much it is likely to find a factorization
    QS qs(N, NB_LINEAR_RELATIONS);
  • Start factoring (this may take a while depending on the size of your RSA modulus)
    //Start factoring
    qs.Factor();
  • Get the results back
    if(qs.GetFactor1 () == 1 || qs.GetFactor1 () == N)
    {
  		cout << ">>>> Failed to factor " << N << " <<<<\t"
  				<< "Try using more linear relations" << endl;
  	}
  	else
  	{
  		cout << endl << ">>>>>>> Factored " << N << endl;
  		cout << "\t Factor 1: " << qs.GetFactor1 () << endl;
  		cout << "\t Factor 2: " << qs.GetFactor2 () << endl;
  	}

Note If the algorithm fails to factor the RSA integer is returns the result (N, 1) as factors.

Check tests/test-qs.C for a complete example of how to use the QS class.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.