Giter Site home page Giter Site logo

ricardojoserf / elgamal-python Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 1.0 101 KB

A Python implementation of Elgamal algorithm: encryption, decryption and signature generation and verification

Python 100.00%
elgamal elgamal-encryption ctf-tools crypto-challenges

elgamal-python's Introduction

Elgamal

Implementation of Elgamal algorithm in Python, based on these series of videos (the parameter nomenclature is based on them).

Public and private keys are composed of 3 elements each:

  • Kpub = (p, alfa, B)

  • Kpriv = (p, alfa, b)

These parameters are:

  • p (parameter -m): A random integer

  • alfa (parameter -a): A generator of Zp

  • b (parameter -b): A secret integer between 2 and (p-2)

  • B (parameter -B): A public modular exponentiation calculated as B = (alfa^(b))mod(p)

Encryption

For the encryption process, it is necessary to add --encrypt, the parameters of the public key (-p, -a and -B) and the plaintext message (parameter -m). The verbose parameter (-vv) is optional:

python3 main.py --encrypt -p 79 -a 30 -B 59 -m 44 -vv

image 1

Decryption

For the decryption process, it is necessary to add --decrypt, the parameters of the private key (-p, -a and -b), the encrypted message (parameter -m) and the ephemeral key received with the message (-ke). The verbose parameter (-vv) is optional:

python3 main.py --decrypt -p 79 -a 30 -b 61 -m 73 -ke 13 -vv

image 2

Signature

For the signing process, it is necessary to add --sign, the parameters of the private key (-p, -a and -b) and the plaintext message (parameter -m). The verbose parameter (-vv) is optional:

python3 main.py --sign -p 541 -a 128 -b 105 -m 95 -vv

image 3

Signature verification

For the signature verification process, it is necessary to add --verify, the parameters of the public key (-p, -a and -B), the plaintext message (parameter -m) and the signature parameters (-r and -s):

python3 main.py --verify -p 541 -a 128 -B 239 -m 95 -r 280 -s 65 -vv

image 4

elgamal-python's People

Contributors

ricardojoserf avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

5l1v3r1

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.