Esempio n. 1
0
def main():
    group = PairingGroup('SS512')
    waters_hash = Waters(group)
    ibe = IBE_N04(group)
    (master_public_key, master_key) = ibe.setup()

    ID = "*****@*****.**"
    kID = waters_hash.hash(ID)
    secret_key = ibe.extract(master_key, kID)
    msg = group.random(GT)
    cipher_text = ibe.encrypt(master_public_key, kID, msg)
    decrypted_msg = ibe.decrypt(master_public_key, secret_key, cipher_text)
    assert msg == decrypted_msg, "invalid decryption"
    if debug: print("Successful Decryption!")
Esempio n. 2
0
def main():
    group = PairingGroup('SS512')
    waters_hash = Waters(group)
    ibe = IBE_N04(group)
    (master_public_key, master_key) = ibe.setup()

    ID = "*****@*****.**"
    kID = waters_hash.hash(ID)
    secret_key = ibe.extract(master_key, kID)
    msg = group.random(GT)
    cipher_text = ibe.encrypt(master_public_key, kID, msg)
    decrypted_msg = ibe.decrypt(master_public_key, secret_key, cipher_text)
    assert msg == decrypted_msg, "invalid decryption"
    if debug: print("Successful Decryption!")
def main():
    groupObj = PairingGroup('SS512')
    ibe = IBE_N04_Sig_z(groupObj)
    waters = Waters(group)
    (pk, sk) = ibe.keygen()

    # represents public identity
    M = "*****@*****.**"
    msg = waters.hash("This is a test.")    
    sig = ibe.sign(pk, sk, msg)
    if debug:
        print("original msg => '%s'" % M)
        print("msg => '%s'" % msg)
        print("sig => '%s'" % sig)

    assert ibe.verify(pk, msg, sig), "Failed verification!"
    if debug: print("Successful Verification!!! msg => '%s'" % msg)
Esempio n. 4
0
    def testIBE_N04_Sig(self):
        # initialize the element object so that object references have global scope
        groupObj = PairingGroup('SS512')
        waters = Waters(groupObj)
        ibe = IBE_N04_Sig(groupObj)
        (pk, sk) = ibe.keygen()

        # represents public identity
        M = "*****@*****.**"

        msg = waters.hash(M)
        sig = ibe.sign(pk, sk, msg)
        if debug:
            print("original msg => '%s'" % M)
            print("msg => '%s'" % msg)
            print("sig => '%s'" % sig)

        assert ibe.verify(pk, msg, sig), "Failed verification!"
        if debug: print("Successful Verification!!! msg => '%s'" % msg)
Esempio n. 5
0
    def testIBE_N04(self):
        # initialize the element object so that object references have global scope
        groupObj = PairingGroup('SS512')
        waters = Waters(groupObj)
        ibe = IBE_N04(groupObj)
        (pk, mk) = ibe.setup()

        # represents public identity
        ID = "*****@*****.**"
        kID = waters.hash(ID)
        #if debug: print("Bob's key  =>", kID)
        key = ibe.extract(mk, kID)

        M = groupObj.random(GT)
        cipher = ibe.encrypt(pk, kID, M)
        m = ibe.decrypt(pk, key, cipher)
        #print('m    =>', m)

        assert m == M, "FAILED Decryption!"
        if debug: print("Successful Decryption!!! m => '%s'" % m)
        del groupObj
    def testIBE_N04(self):
        # initialize the element object so that object references have global scope
        groupObj = PairingGroup('SS512')
        waters = Waters(groupObj)
        ibe = IBE_N04(groupObj)
        (pk, mk) = ibe.setup()

        # represents public identity
        ID = "*****@*****.**"
        kID = waters.hash(ID)
        # if debug: print("Bob's key  =>", kID)
        key = ibe.extract(mk, kID)

        M = groupObj.random(GT)
        cipher = ibe.encrypt(pk, kID, M)
        m = ibe.decrypt(pk, key, cipher)
        # print('m    =>', m)

        assert m == M, "FAILED Decryption!"
        if debug: print("Successful Decryption!!! m => '%s'" % m)
        del groupObj
        startTime = time.time()
        assert bls.verify(pk, sig, m), "Failure!!!"
        cllwwVerifyTime += time.time() - startTime
    print("Bls04: Keygen %d times, average time %f ms" %(n, cllwwKeyGenTime/n*1000))
    print("Bls04: Sign random message %d times, average time %f ms" %(n, cllwwSignTime/n*1000))
    print("Bls04: Verify %d times, average time %f ms" %(n, cllwwVerifyTime/n*1000))
    print("&%.2f () &%.2f () &%.2f ()" %(cllwwKeyGenTime/n*1000,
                                         cllwwSignTime/n*1000,
                                         cllwwVerifyTime/n*1000))
#groupObj = PairingGroup('MNT159')
#groupObj = PairingGroup('SS512')
if(1):
    ibe = IBE_N04_Sig(groupObj)
    waters = Waters(groupObj)
    msg = waters.hash("This is a test.")  
    cllwwKeyGenTime = 0.0
    cllwwSignTime = 0.0
    cllwwVerifyTime = 0.0
    for i in range(0, n):
        startTime = time.time()
        (pk, sk) = ibe.keygen()
        cllwwKeyGenTime += time.time() - startTime

        msg = waters.hash(randomStringGen()) 
        startTime = time.time()
        sig = ibe.sign(pk, sk, msg) 
        cllwwSignTime += time.time() - startTime

        startTime = time.time()
        assert ibe.verify(pk, msg, sig), "Failed verification!"
Esempio n. 8
0
#group = PairingGroup('SS512')
#group = PairingGroup('MNT224')
if (1):
    waters_hash = Waters(group)
    ibe = IBE_N04(group)
    IBE_N04SetupTime = 0.0
    IBE_N04ExtTime = 0.0
    IBE_N04EncTime = 0.0
    IBE_N04DecTime = 0.0
    for i in range(0, n):
        startTime = time.time()
        (master_public_key, master_key) = ibe.setup()
        IBE_N04SetupTime += time.time() - startTime

        ID = randomStringGen()
        kID = waters_hash.hash(ID)
        startTime = time.time()
        secret_key = ibe.extract(master_key, kID)
        IBE_N04ExtTime += time.time() - startTime

        msg = group.random(GT)
        startTime = time.time()
        cipher_text = ibe.encrypt(master_public_key, kID, msg)
        IBE_N04EncTime += time.time() - startTime

        startTime = time.time()
        decrypted_msg = ibe.decrypt(master_public_key, secret_key, cipher_text)
        IBE_N04DecTime += time.time() - startTime
    print(
        "\nDavid Naccache Secure and Practical Identity-Based Encryption, Section 4"
    )
Esempio n. 9
0
for a in range(0, b):
    startTime = time.time()
    g = group.random(G1)
    RandomG1 += time.time() - startTime
print(" %d times of Random(G1), average = %f ms" %(b, RandomG1/b*1000))

for a in range(0, b):
    startTime = time.time()
    j = group.random(G2)
    RandomG2 += time.time() - startTime
print(" %d times of Random(G2), average = %f ms" %(b, RandomG2/b*1000))

for a in range(0, b):
    ID = randomStringGen()
    v = waters_hash.hash(ID)
    g = group.random(G1)
    startTime = time.time()
    h = g ** v[0]
    bitG1 += time.time() - startTime
print(" %d times of 32 bit G1 Exp, average = %f ms" %(b, bitG1/b*1000))

for a in range(0, b):
    ID = randomStringGen()
    v = waters_hash.hash(ID)
    k = group.random(G2)
    startTime = time.time()
    j = k ** v[0]
    bitG2 += time.time() - startTime
print(" %d times of 32 bit G2 Exp, average = %f ms" %(b, bitG2/b*1000))
#group = PairingGroup('SS512')
#group = PairingGroup('MNT224')
if(1):
    waters_hash = Waters(group)
    ibe = IBE_N04(group)
    IBE_N04SetupTime = 0.0
    IBE_N04ExtTime = 0.0
    IBE_N04EncTime = 0.0
    IBE_N04DecTime = 0.0
    for i in range(0, n):
        startTime = time.time()
        (master_public_key, master_key) = ibe.setup()
        IBE_N04SetupTime += time.time() - startTime
        
        ID = randomStringGen() 
        kID = waters_hash.hash(ID)
        startTime = time.time()
        secret_key = ibe.extract(master_key, kID)
        IBE_N04ExtTime += time.time() - startTime

        msg = group.random(GT)
        startTime = time.time()
        cipher_text = ibe.encrypt(master_public_key, kID, msg)
        IBE_N04EncTime += time.time() - startTime
        
        startTime = time.time()
        decrypted_msg = ibe.decrypt(master_public_key, secret_key, cipher_text)
        IBE_N04DecTime += time.time() - startTime
    print("\nDavid Naccache Secure and Practical Identity-Based Encryption, Section 4")
    #print("Group: SS512")
    print("IBE_N04: Setup %d times, average time %f ms" %(n, IBE_N04SetupTime/n*1000))
Esempio n. 11
0
        cllwwVerifyTime += time.time() - startTime
    print("Bls04: Keygen %d times, average time %f ms" %
          (n, cllwwKeyGenTime / n * 1000))
    print("Bls04: Sign random message %d times, average time %f ms" %
          (n, cllwwSignTime / n * 1000))
    print("Bls04: Verify %d times, average time %f ms" %
          (n, cllwwVerifyTime / n * 1000))
    print("&%.2f () &%.2f () &%.2f ()" %
          (cllwwKeyGenTime / n * 1000, cllwwSignTime / n * 1000,
           cllwwVerifyTime / n * 1000))
#groupObj = PairingGroup('MNT159')
#groupObj = PairingGroup('SS512')
if (1):
    ibe = IBE_N04_Sig(groupObj)
    waters = Waters(groupObj)
    msg = waters.hash("This is a test.")
    cllwwKeyGenTime = 0.0
    cllwwSignTime = 0.0
    cllwwVerifyTime = 0.0
    for i in range(0, n):
        startTime = time.time()
        (pk, sk) = ibe.keygen()
        cllwwKeyGenTime += time.time() - startTime

        msg = waters.hash(randomStringGen())
        startTime = time.time()
        sig = ibe.sign(pk, sk, msg)
        cllwwSignTime += time.time() - startTime

        startTime = time.time()
        assert ibe.verify(pk, msg, sig), "Failed verification!"