Giter VIP home page Giter VIP logo

elgamal-golang's Introduction

Elgamal

Implementation of Elgamal algorithm in Golang, 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 --p): A random integer

  • alfa (parameter --alfa): 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, --alfa and --B) and the plaintext message (parameter --m). The verbose parameter (--debug) is optional:

go run elgamal.go --encrypt --p=79 --alfa=30 --B=59 --m=44 --debug

image 1

Decryption

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

go run elgamal.go --decrypt --p=79 --alfa=30 --b=61 --m=73 --Ke=13 --debug

image 2

Signature

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

go run elgamal.go --sign --p=541 --alfa=128 --b=105 --m=95 --debug

image 3

Signature verification

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

go run elgamal.go --verify --p=541 --alfa=128 --B=239 --m=95 --r=280 --s=65 --debug

image 4


Note

This is a rewrite of this repository which has the same functionality but written in Python.

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.