GithubHelp home page GithubHelp logo

diffie-hellman's Introduction

DIffie-Hellman

Basic practice script for diffie-helman algorithm

Process

Diffie – Hellman algorithm is an algorithm that allows two parties to get the shared secret key using the communication channel, which is not protected from the interception but is protected from modification.

Supposing there are two participants of the exchange (let’s call them Alice and Bob, as it is traditionally established in cryptography). Both of them know two numbers p and r. These numbers are not secret and can be known to anyone. The goal of Alice and Bob is to obtain the shared secret key to help them to exchange messages in future.

Prompt user for a Prime Number and store the input in p. Prompt user for a primitive root of p and store the input in r. Prompt user for Alice’s private key and store the input in a. Prompt user for Bob’s private key and store in b. Calculate Alice’s public key (x = ra mod p), Calculate Bob’s public key (y = rb mod p). Assume public values x and y are exchanged. Calculate Alice’s shared private key ( ka = ya mod p). Calculate Bob’s shared key (kb = xb mod p). Is ka = kb?

Example

Alice and Bob get public numbers. p = 23, r = 9 Alice and Bob compute public values. Alice's private key is 4 Bob's private key is 3 X = 9^4 mod 23 = 6561 mod 23 = 6 Y = 9^3 mod 23 = 729 mod 23 = 16 Alice and Bob exchange public numbers. Alice and Bob compute symmetric keys. ka = ya mod p = 164 mod 23 = 9 kb = xb mod p = 63 mod 23 = 9 9 is the shared secret.

diffie-hellman's People

Contributors

silversmithe avatar

Watchers

 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.