How to do logarithm operation in PairingGroup
Artemisl opened this issue · 1 comments
Artemisl commented
In my project, I want to do a logarithm operation. But it will report an error message "TypeError : must be real number, not pairing.Element".
r = group.random(ZR)
math.log( r, g )
I don't know how to transform the pairing.Element to real number or integer. Does anyone have the same problem?
alejandro-imt commented
I assume you are using pairinggroup:
Just explicitly convert the ZR element to an int.
from charm.toolbox.pairinggroup import PairingGroup, ZR
import math
r = group.random(ZR)
base = 10 # or whatever you need
int_r = int(r)
log_r = math.log(int_r, base)