コード例 #1
0
ファイル: pkenc_test.py プロジェクト: FinalF/charm
 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
ファイル: pkenc_test.py プロジェクト: marciopocebon/ENCODERS
 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
ファイル: pkenc_test.py プロジェクト: wuquanda/abe_py
 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
ファイル: pkenc_test.py プロジェクト: FinalF/charm
 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
ファイル: pkenc_test.py プロジェクト: wuquanda/abe_py
 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!!!")
コード例 #7
0
ファイル: pkenc_test.py プロジェクト: wuquanda/abe_py
    def testHybridEnc(self):
        groupObj = ECGroup(prime192v1)
        pkenc = ElGamal(groupObj)
        hyenc = HybridEnc(pkenc, msg_len=groupObj.bitsize())

        (pk, sk) = hyenc.keygen()

        # message len should be group.bitsize() len for prime192v1 (or 20 bytes)
        m = b'the hello world msg1'
        cipher = hyenc.encrypt(pk, m)
        orig_m = hyenc.decrypt(pk, sk, cipher)
        assert m == orig_m, "Failed Decryption"
        if debug: print("Successful Decryption!!")
コード例 #8
0
ファイル: pkenc_test.py プロジェクト: marciopocebon/ENCODERS
    def testHybridEnc(self):
        #    pkenc = EC_CS98(prime192v1)
        groupObj = ECGroup(prime192v1)
        pkenc = ElGamal(groupObj)
        hyenc = HybridEnc(pkenc)

        (pk, sk) = hyenc.keygen()

        m = b'this is a new message'
        cipher = hyenc.encrypt(pk, m)
        orig_m = hyenc.decrypt(pk, sk, cipher)
        assert m == orig_m, "Failed Decryption"
        if debug: print("Successful Decryption!!")