0% found this document useful (0 votes)
185 views4 pages

Goldwasser-Micali Algorithm: Shruthi Srinivasan 2017PIS5174

This document describes the Goldwasser-Micali encryption algorithm. It provides: 1) An introduction stating that the GM algorithm is the first probabilistic public-key encryption scheme and consists of key generation, encryption, and decryption algorithms. 2) Python source code implementing the GM algorithm with functions for encryption, decryption, checking primality, etc. 3) Sample output from encrypting and then decrypting a message using the GM algorithm.

Uploaded by

albus_ron
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
185 views4 pages

Goldwasser-Micali Algorithm: Shruthi Srinivasan 2017PIS5174

This document describes the Goldwasser-Micali encryption algorithm. It provides: 1) An introduction stating that the GM algorithm is the first probabilistic public-key encryption scheme and consists of key generation, encryption, and decryption algorithms. 2) Python source code implementing the GM algorithm with functions for encryption, decryption, checking primality, etc. 3) Sample output from encrypting and then decrypting a message using the GM algorithm.

Uploaded by

albus_ron
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

GOLDWASSER-MICALI ALGORITHM

Shruthi Srinivasan
2017PIS5174

INTRODUCTION
The Goldwasser–Micali (GM) encryption scheme is a public-key encryption al-
gorithm developed by Shafi Goldwasser and Silvio Micali in 1982. It is the
first probabilistic public-key encryption scheme which is provably secure under
standard cryptographic assumptions.It consists of three parts:
1. Probabilistic key generation algorithm

2. Probabilistic encryption algorithm,


3. Deterministic decryption algorithm.

SOURCE CODE IN PYTHON


d e f checka ( a , p , q , p1 , q1 ) :
v a l = ( a ˆp ) % p
r e s = ( v a l ˆq ) % q
return res

d e f gcd ( a , b ) :
i f ( b==0) :
v a l u e =a ;
else :
v a l u e =gcd ( b , a%b )
return value

def enteraval () :
a1= i n t ( i n p u t ( ” Enter t h e v a l u e o f a ” ) )
r e s = checkb ( a1 , n )
i f ( r e s !=1) : #c h e c k i n g i f gcd =1 and i f b i
b e l o n g s t o mod n
p r i n t ( ” Entered an i n c o r r e c t v a l u e . Enter c o r r e c t
value ”)
enteraval ()

1
else :
a . append ( a1 ) ;

def enterbval () :
b1= i n t ( i n p u t ( ” Enter t h e v a l u e whose GCd with n i s 1
where n=p∗q i e o f b ” ) )
r e s = checkb ( b1 , n )
i f ( r e s !=1 o r b1>(n−1) ) : #c h e c k i n g i f gcd =1 and
i f b i b e l o n g s t o mod n
p r i n t ( ” Entered an i n c o r r e c t v a l u e . Enter c o r r e c t
value ”)
enterbval ()
else :
b . append ( b1 ) ;

d e f checkb ( b1 , n ) :
r e s = gcd ( b1 , n )
return res

def encryptionprocess () :
f o r q i n r a n g e ( 0 , l e n ( s t r (m) ) ) :
eb = i n t ( b [ q ] )
mb = i n t (m1 [ q ] )
eb = eb ∗∗2
mb = a1 ∗∗mb
v a l u e c = ( ( eb ) ∗ (mb) )%n
c . append ( v a l u e c )
return c

def decryptionprocess () :
f o r q in range (0 , len ( c ) ) :
cx = i n t ( c [ q ] )
v a l = ( cx ∗ ∗ ( ( p−1) / 2 ) )%p
i f ( v a l !=1) :
p l a i n . append ( ” 1 ” )
else :
p l a i n . append ( ” 0 ” )
return plain
def enterprimeval () :
p1 = i n t ( i n p u t ( ” Enter t h e prime number ” ) )
r e s = checkprime ( p1 )
i f ( r e s !=1) : #c h e c k i n g i f gcd =1 and i f b i
b e l o n g s t o mod n
p r i n t ( ” Entered an i n c o r r e c t v a l u e . Enter c o r r e c t
value ”)
enterprimeval ()

2
else :
p r i m e v a l s . append ( p1 ) ;

d e f checkprime (num) :
i f num > 1 :
f o r i i n r a n g e ( 2 ,num) :
i f (num % i ) == 0 :
return 0

else :
return 0
i f ( ( num%4) !=3) :
return 0
return 1

primevals =[]
enterprimeval () ;
enterprimeval () ;

p =i n t ( p r i m e v a l s [ 0 ] ) ;
q =i n t ( p r i m e v a l s [ 1 ] ) ;

m = ( i n p u t ( ” Enter t h e message (m) ” ) )


b = []
a =[]
c =[]
n = p∗q
a1 =0;
m1 = [ ] ;
plain =[];

enteraval () ;

for k in a :
a1=i n t ( a [ 0 ] ) ;

f o r j i n r a n g e ( 0 , l e n ( s t r (m) ) ) :
enterbval () ;

# Encryption Process
f o r x i n r a n g e ( 0 , l e n ( s t r (m) ) ) :
valuem = ( i n t ) (m[ x : x +1])
m1 . append ( valuem ) ;
x=x+1;

c = encryptionprocess ()

3
p r i n t ( ” Value o f c i p h e r t e x t i s ” , c )

# Decryption Process
pt = d e c r y p t i o n p r o c e s s ( )
p r i n t ( ” Value o f p l a i n t e x t i s ” , pt )

OUTPUT

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy