sebastinas / pyrelic

Python bindings for relic
MIT License
7 stars 1 forks source link

e'th modular root (RSA) #10

Open Loryerba opened 4 months ago

Loryerba commented 4 months ago

Hi, I'm trying to implement Catalano & Fiore Commitment Scheme based on RSA assumption. I've to compute the e'th root of an integer mod N (since N = p * q two primes number), but with built-in function in python i obtain a float number instead of an integer. There is any way in your library to evaluate e'th root of integer and get an integer like RSA? Thank you.

@sebastinas

sebastinas commented 4 months ago

Note that relic is designed for elliptic curve crypto. pyrelic is probably the wrong pick to implement anything based on RSA.

Loryerba commented 4 months ago

Okay, so this library is what i was looking for. Because I want to use bilinear pairings on my commitment scheme, but i didn't understand what curves use this library e which method i need to use for:

sebastinas commented 4 months ago
import pyrelic
# generator
g = pyrelic.generator_G1()
# order
p = pyrelic.order()
# random scalar
scalar = pyrelic.rand_BN_order()
# scalar from an int
scalar = pyrelic.BN_from_int(123)
# h = g^scalar
h = g ** scalar
# pair h with generator of G2
t = pyrelic.pair(h, pyrelic.generator_G2())
Loryerba commented 4 months ago

In this case is a symmetric pairing? Like tate pairing? Because i need a pairing map which works in this way: e: G x G -> Gt where G x G are two elements of the same group G Thank you a lot

sebastinas commented 4 months ago

That's not supported by pyrelic. It only provides Type-3 pairings as supported by relic.

Loryerba commented 4 months ago

Ok so G1 and G2 are two generator of different curve? Or same curve?

sebastinas commented 4 months ago

generator_G1() returns the generator of the group G1, generator_G2() the generator for group G2.

Loryerba commented 4 months ago

Okok thank you so much. There is any way to cast the output of pyrelic.pair() to string?

Loryerba commented 4 months ago

Because i try to print the result of g**random_integer but i obtain bytes string (b') and i can't decode it

Loryerba commented 4 months ago

@sebastinas

sebastinas commented 4 months ago

You can convert the group elements to byte representation. How you convert this representation to a string and back is up to you. Serialization beyond a byte representation is left to the user.