Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to do logarithm operation in PairingGroup #281

Open
Artemisl opened this issue Jan 13, 2022 · 1 comment
Open

How to do logarithm operation in PairingGroup #281

Artemisl opened this issue Jan 13, 2022 · 1 comment

Comments

@Artemisl
Copy link

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
Copy link

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants