herumi / mcl

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

constructing a field from __int128 #202

Closed quwenjie closed 1 month ago

quwenjie commented 1 month ago

Is it possible to construct an Fr from __int128? I see the function only supports from long long int, which is 64bits. How can this be achieved? Is it possible?

herumi commented 1 month ago

If your system is a little-endian architecture such as x64, then use setLittleEndianMod.

__int128 v;
Fr x;
x.setLittleEndianMod((const uint8_t*)&v, sizeof(v));

Remark: v must not be a negative integer.

quwenjie commented 1 month ago

Solved, thanks.