2

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)
Artjom B.
  • 61,146
  • 24
  • 125
  • 222
  • 1
    StackOverflow is not a code writing service. If you have made an attempted at writing code to meet your requirement, please post the code and explain the problem you are having with it. – Blackwood Dec 24 '15 at 03:12
  • I have tried pickling it. Converting it to json and so. But no use. – venkata praneeth Dec 24 '15 at 03:28
  • @Blackwood I a bit confused about StackOverflow now. But i have seen many simple questions asked in this site and answered well. I did tried things like pickling, converting to json etc. – venkata praneeth Dec 24 '15 at 03:37
  • This is a understandable question *now* (but may need a little more editing). There were too few details to provide a meaningful answer before your edit. – Artjom B. Dec 24 '15 at 10:51

1 Answers1

2

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.

Litone
  • 3
  • 2