示例#1
0
 def testElGamal(self):
     groupObj = ECGroup(prime192v2)
     el = ElGamal(groupObj)   
     (pk, sk) = el.keygen()
     msg = b"hello world!"
     cipher1 = el.encrypt(pk, msg)
     m = el.decrypt(pk, sk, cipher1)    
     assert m == msg, "Failed Decryption!!!"
     if debug: print("SUCCESSFULLY DECRYPTED!!!")
示例#2
0
 def testElGamal(self):
     groupObj = ECGroup(prime192v2)
     el = ElGamal(groupObj)
     (pk, sk) = el.keygen()
     msg = b"hello world!"
     cipher1 = el.encrypt(pk, msg)
     m = el.decrypt(pk, sk, cipher1)
     assert m == msg, "Failed Decryption!!!"
     if debug: print("SUCCESSFULLY DECRYPTED!!!")
示例#3
0
 def testElGamal(self):
     groupObj = ECGroup(prime192v2)
     el = ElGamal(groupObj)
     (pk, sk) = el.keygen()
     # message len should be group.bitsize() len for prime192v1 (or 20 bytes)
     msg = b'the hello world msg1'
     cipher1 = el.encrypt(pk, msg)
     m = el.decrypt(pk, sk, cipher1)
     assert m == msg, "Failed Decryption!!!"
     if debug: print("SUCCESSFULLY DECRYPTED!!!")
示例#4
0
 def testElGamal(self):
     p = integer(148829018183496626261556856344710600327516732500226144177322012998064772051982752493460332138204351040296264880017943408846937646702376203733370973197019636813306480144595809796154634625021213611577190781215296823124523899584781302512549499802030946698512327294159881907114777803654670044046376468983244647367)
     q = integer(74414509091748313130778428172355300163758366250113072088661006499032386025991376246730166069102175520148132440008971704423468823351188101866685486598509818406653240072297904898077317312510606805788595390607648411562261949792390651256274749901015473349256163647079940953557388901827335022023188234491622323683)
     groupObj = IntegerGroupQ()
     el = ElGamal(groupObj, p, q) 
     (pk, sk) = el.keygen()
     msg = b"hello world!"
     cipher1 = el.encrypt(pk, msg)
     m = el.decrypt(pk, sk, cipher1)
     assert m == msg, "Failed Decryption!!!"
     if debug: print("SUCCESSFULLY DECRYPTED!!!")
示例#5
0
def el_gamal_cryptosystem():
    from charm.toolbox.eccurve import prime192v2
    from charm.toolbox.ecgroup import ECGroup
    from charm.schemes.pkenc.pkenc_elgamal85 import ElGamal

    groupObj = ECGroup(prime192v2)
    el = ElGamal(groupObj)
    (public_key, secret_key) = el.keygen()
    msg = b"hello world!12345678"
    cipher_text = el.encrypt(public_key, msg)
    decrypted_msg = el.decrypt(public_key, secret_key, cipher_text)
    print(decrypted_msg == msg)
示例#6
0
 def testElGamal(self):
     p = integer(
         148829018183496626261556856344710600327516732500226144177322012998064772051982752493460332138204351040296264880017943408846937646702376203733370973197019636813306480144595809796154634625021213611577190781215296823124523899584781302512549499802030946698512327294159881907114777803654670044046376468983244647367
     )
     q = integer(
         74414509091748313130778428172355300163758366250113072088661006499032386025991376246730166069102175520148132440008971704423468823351188101866685486598509818406653240072297904898077317312510606805788595390607648411562261949792390651256274749901015473349256163647079940953557388901827335022023188234491622323683
     )
     groupObj = IntegerGroupQ()
     el = ElGamal(groupObj, p, q)
     (pk, sk) = el.keygen()
     msg = b"hello world!"
     cipher1 = el.encrypt(pk, msg)
     m = el.decrypt(pk, sk, cipher1)
     assert m == msg, "Failed Decryption!!!"
     if debug: print("SUCCESSFULLY DECRYPTED!!!")