Git Product home page Git Product logo

csci6230-hw03's Introduction

CSCI6230-HW03

Homework 3 Programming a

This program implements Blum-Goldwasser Probabilistic Encryption Algorithm with parameters p=499, q=547, a=-57, b=52, X0 =159201 and message m=10011100000100001100.

Code Path

[Programming-a](Programming-a)

Key Generation (Alice)

Alice * chooses a Blum integer n such that n=p \cdot q and p \equiv 3~mod~4, q \equiv 3~mod~4. * computes two integers a and b using Euler-Extended Algorithm such that ap + bq = 1

public key is n private keys are p,q,a,b

In this homework,

n = 159201, p = 499, q = 547, a = -57, b = 52

Encryption (Bob)

Bob chooses a random number x_0 \in QR_n. Compute

k = \lfloor log n \rfloor\\
h = \lfloor log k \rfloor

The message is divided into t blocks such that each block is of h bits.

In this homework, k=18, h=4, t=5

Then follow the encryption rule of BG, we will have the ciphertext: [50, 0, 44, 46, 52, 40632].

50, 0, 44, 46, 52 are c_1, c_2, c_3, c_4, c_5

40632 is X_{t+1}.

Decryption (Alice)

&d_1 = [(p+1)/4]^{t+1} ~mod~p-1\\
&d_2 = [(q+1)/4]^{t+1} ~mod~q-1\\\\
&u = X_{t+1}^d_1 ~mod~p \\
&v = X_{t+1}^d_2 ~mod~q\\
&X_0 = vap + ubq~mod~N

Follow the above steps to compute X_0, we then can decode the ciphertext and get 10011100000100001100

In the code, I don't use the given a and b. Instead, I use

      a = p^{-1}~mod~q\\
b = q^{-1}~mod~p.

Code Description

  • BG_demo.py is the main program. Run it using Python 3.
  • Blum_Goldwessar_Class.py defines class BG which is used for both encryption and decryption.
  • Number_Package.py contains useful functions related to number manipulation such as multiplicative inverse, exponential with modulo.

How to run

python3 BG_demo.py

and the expected output is

Ciphertext is
[50, 0, 44, 46, 52, 40632]
Decryption result
10011100000100001100
Decryption success

csci6230-hw03's People

Watchers

Yu Wang 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.