I need help to convert the list representation (string) of elliptic curve pairing group element back to an object.
Explanation:
I am using charm crypto v0.43 to use CPABE scheme in my web application. I need to store the pairing element that is generated into my database. When I did that, it is storing it as list. I need to map it back to pairing group element object.
Convert:
[771281202364725359015275543519860265278248937600027018972741977722880288402810467924555583431036045929994018001453439703799448692568829067937466068366897, 5928426678871551838449004494119368314093842432141364739971117261348155912543962117516776973405646414105108743246860323245910977796691638669773215755592297]
to
<pairing.Element object at 0x7f1a1e840300>`
Code:
group = PairingGroup('SS512') alpha = group.random(ZR) g= group.random(G1)
Advertisement
Answer
Found a solution to my problem. Here is what i did.You can use groups serialize function.
g = group.random(G1) # generates a random group element in that pairing group
You can serialize g
using groups serialize function:
str = group.serialize(g)
You can deserialize it using
obj = group.deserialize(str)
Hope it might help somebody facing the same issue.