herumi / mcl

a portable and fast pairing-based cryptography library
BSD 3-Clause "New" or "Revised" License
450 stars 151 forks source link

Generate random number of class Fr #189

Closed anujamodi0107 closed 9 months ago

anujamodi0107 commented 9 months ago

Hello, I want to generate a matrix of n by n whose elements need to be in class Fr. Is there a function in MCL that can do this job? I found the function mcl::fp::RandGen rg = mcl::fp::RandGen(), which generates a random number in class Fp. I want a random number in class, Fr.

Thank you in advance.

herumi commented 9 months ago

You can get a random number by

Fr x;
x.setByCSPRNG();

See Set a random value.