I want to convert an integer to a number in ZP group. I have written following code but it is returning a number of <class 'integer.Element'>
type. Can someone tell me how can I do this?
num= 193857774579808121448
bb= Conversion. IP2OS(num, 20)
ele= Conversion.OS2IP(bb, element=True)
You can use PairingGroup.init(ZR, 193857774579808121448)
to convert a Python integer to a Charm element in Zr.
Example:
>>> from charm.toolbox.pairinggroup import PairingGroup,ZR,G1,G2,GT,pair
>>> group = PairingGroup('SS512')
>>> i = group.init(ZR, 193857774579808121448)
>>> i
193857774579808121448
>>> type(i)
<class 'pairing.Element'>
Keep in mind that the Python integer that you pass in must be smaller than r
which is shown in the pairing parameters (i.e. group.__dict__
). Charm will silently apply the modulo operator to the passed number so that the resulting element is in Zr.