Coder Social home page Coder Social logo

discrete-log's Introduction

The Discrete Log Problem

Given a large prime number p, a large intgeger a, and a number g such that every number b coprime to p is congruent to a power of g mod p (i.e. g is a primite root mod p), then ga mod p = s is very easy to compute using the repeated squaring algorithm. However, determining the value of a if we are given g, p and s is extremely diffucult, and thus discrete log is considered a one way function. Several important public-key cryptographic systems base their security on the assumption that the discrete logarithm problem over carefully chosen groups has no efficient solution. These include Diffie-Hellman Key Exchange, ElGamal encryption, and the Digital Signature Algorithm.

While the discrete log problem is considered cryptographically sound, this repository provides three algorithms that provide significant improvement over a brute-force tactic. They include the Pohlig-Hellman Algorithm (practically the fastest), the Baby Step Giant Step Algorithm and the Rho Algorithm.

Java code

Containts a Spring Boot application with four endpoints, one that calculates the discrete log problem using all three algorithms, and then one endpoint for each algorithm.

generatorsolution mod prime = base

http://localhost:8080/discrete-log?generator=5&base=222137199848&prime=4889427811007

http://localhost:8080/pohlig-hellman?generator=5&base=222137199848&prime=4889427811007
http://localhost:8080/rho?generator=5&base=222137199848&prime=4889427811007
http://localhost:8080/baby-giant?generator=5&base=222137199848&prime=4889427811007

Python code

import the discrete_log module and then you have the three algorithms available to you

import discrete_log

rho_metadata = discrete_log.rho.solve(5, 222137199848, 4889427811007)
print(rho_metadata.solution, rho_metadata.secondsTaken)

pohlig_hellman_metadata = discrete_log.pohlig_hellman.solve(5, 222137199848, 4889427811007)
print(pohlig_hellman_metadata.solution, pohlig_hellman_metadata.secondsTaken)

baby_giant_metadata = discrete_log.baby_giant.solve(5, 222137199848, 4889427811007)
print(baby_giant_metadata.solution, baby_giant_metadata.secondsTaken)

discrete-log's People

Contributors

bobmitch23 avatar dependabot[bot] avatar

Watchers

James Cloos avatar

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.