Reputation: 324
I am trying to run the code of a Proxy Re-Encryption implementation, thanks to Nikosft on https://github.com/nikosft/IB-PRE
I am using the pre_mg07a.py file. Python executes and successfully prints all debug messages for encryption and reencryption, but on the last line of the following code, it shows python.exe stopped working. I tried finding out source of problem, but all I know is it crashes during decryption when it calls the HybridEnc.decrypt() method in charm.adapters.pkenc_adapt_hybrid.
my test.py file:
from pre_mg07a import PreGA
def main():
from charm.toolbox.pairinggroup import PairingGroup,GT
from charm.core.engine.util import objectToBytes,bytesToObject
from charm.schemes.pkenc.pkenc_cs98 import CS98
from charm.toolbox.ecgroup import ECGroup
from charm.toolbox.eccurve import prime192v2
group = PairingGroup('SS512', secparam=1024)
groupcs98 = ECGroup(prime192v2)
pkenc = CS98(groupcs98)
pre = PreGA(group,pkenc)
ID1 = "nikos"
msg = group.random(GT)
print("MESSAGE:::::::\n %s", msg)
(master_secret_key, params) = pre.setup()
(public_key, secret_key) = pkenc.keygen()
id1_secret_key = pre.keyGen(master_secret_key, ID1)
ciphertext = pre.encrypt(params, ID1, msg)
re_encryption_key = pre.rkGenPKenc(params,id1_secret_key, public_key)
ciphertext2 = pre.reEncryptPKenc(params, re_encryption_key, ciphertext)
pre.decryptPKenc(params, public_key, secret_key, ciphertext2) #problem here
if __name__ == "__main__": main()
https://github.com/nikosft/IB-PRE/blob/master/pre_mg07a.py file 'decrptPKenc' method:
def decryptPKenc(self, params, public_key, secret_key, cid):
print('here')
Xbytes = pkenc.decrypt(public_key, secret_key, cid['C3'])#stopped working
X = bytesToObject(Xbytes, group)
m = cid['C2']/pair(cid['C1'],group.hash(X,G1))
if(debug):
print('\nDecrypting...')
print('m=>')
print(m)
return m
Platform details: Windows 7 64bit, Python 3.4 32bit, MingW 32bit with Msys. Installed: openssl 1.0.1u, GMP 5.0.2, PBC 0.5.14, Charm Crypto 0.43.
Tried: Using different python versions, 2.7 and 3.2. I cant configure and make charm correctly with them.
Any help would be really appreciated. I know this might be a very specific topic, but maybe the problem is different. Any suggestions welcome too.
Upvotes: 0
Views: 302
Reputation: 324
Eventually gave up on windows. Tried Ubuntu 14.04 and it worked after some usual config problems.
Here's for others how to configure Charm-Crypto for Python 3.4:
sudo apt-get install subversion
sudo apt-get install m4
sudo apt-get install flex
sudo apt-get install bison
sudo apt-get install libssl-dev
sudo apt-get install python3-setuptools python3-dev
sudo apt-get install libgmp-dev
wget http://crypto.stanford.edu/pbc/files/pbc-0.5.14.tar.gz
tar xf pbc-0.5.14.tar.gz
cd pbc-0.5.14
./configure && make && sudo make install
Downloaded charm's tar.gz file from https://pypi.python.org/pypi/charm-crypto/0.43, extracted, and changed directory, then:
./configure.sh
sudo make
sudo make install
sudo ldconfig
Upvotes: 1