miracl / MIRACL

MIRACL Cryptographic SDK: Multiprecision Integer and Rational Arithmetic Cryptographic Library is a C software library that is widely regarded by developers as the gold standard open source SDK for elliptic curve cryptography (ECC).
https://miracl.com
654 stars 242 forks source link

how to convert from G1/G2/GT to char* #58

Open zhangyinglong3550 opened 6 years ago

zhangyinglong3550 commented 6 years ago

I want convert from G1/G2/GT to char* , but spill() and restore() cann't work,what can I do ?

mcarrickscott commented 6 years ago

What is the problem exactly? Please give more detail.

Mike

On Fri, Jan 26, 2018 at 12:21 PM, zhangyinglong3550 < notifications@github.com> wrote:

I want convert from G1/G2/GT to char* , but spill() and restore() cann't work,what can I do ?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/miracl/MIRACL/issues/58, or mute the thread https://github.com/notifications/unsubscribe-auth/ACm8jtOF4GJB1TERmClaKdf6DerpPMIyks5tOcNWgaJpZM4RuO5G .

iesiyok commented 6 years ago

I think the question of the issuer was as the same as mine. I want to export G1, G2 or GT perhaps as bytes and import them in other programs. Is there a method for that? It is also not clear to me what spill() and restore() functions do.

mcarrickscott commented 6 years ago

Hello llkan,

Pairing-based cryptography often benefits from pre-computation. For example is a constant P in G1 is often being multiplied by different values, by pre-computing multiples of P this can be speeded up. Typically these pre-computed values can be calculated off-line just once ever, and then loaded up when a program starts. This is what "spill" and "restore" are for. The first function "spills" the pre-computed table to a byte array (which may for example be stored in a disk file), and the second function "restore" reads it back in again into the internal format.

Various pre-computations can be spilled and restored in this way.

Exporting and importing individual members of G1, G2 and GT is not supported. But it would not be hard to add this functionality. For example for G1, access the x and y coordinates as big numbers and then convert these to a byte array using to_binary().

Mike

On Sun, Mar 25, 2018 at 4:09 PM, Ilkan Esiyok notifications@github.com wrote:

I think the question of the issuer was as the same as mine. I want to export G1, G2 or GT perhaps as bytes and import them in other programs. Is there a method for that? It is also not clear to me what spill() and restore() functions do.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/miracl/MIRACL/issues/58#issuecomment-375977494, or mute the thread https://github.com/notifications/unsubscribe-auth/ACm8jtkfK1ht4dSjUMMG0TulnqfP6W-7ks5th7MdgaJpZM4RuO5G .

iesiyok commented 6 years ago

Hello Mike,

Thank you very much for your support, I am able to access G1's x and y coordinates and convert them to byte arrays. But the problem was that I need to create new G1 from scratch from this coordinates. Actually, now I believe I have just found my answer while I was explaining the problem to you :)

Cheers,