Closed bo-hub closed 2 years ago
i.e How to serialize Big object and G1 ,GT object and deserialize ?
Hello zbo,
The functions "spill " and "restore" perform serialization on the G1, G2 and GT types. For example see bn_pair.cpp line 407.
Mike
On Sat, Oct 23, 2021 at 7:22 AM zbo @.***> wrote:
i.e How to serialize Big object and G1 ,GT object and deserialize ?
— 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/107#issuecomment-950099633, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAU3ZDVBPGT2ZZN3K7DJLRTUIJICBANCNFSM5GR4MC4A . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
Hi, Michael.
Thanks for reply. I have another problem in calling this spill function. My example code :
#include <iostream>
#include <ctime>
#define MR_PAIRING_SSP // AES-80 or AES-128 security GF(p) curve
//#define AES_SECURITY 80 // OR
#define AES_SECURITY 128
//*********************************************
#include "pairing_1.h"
int main(int argc , char** argv){
PFC pfc(AES_SECURITY);
time_t seed;
time(&seed);
Big alpha;
G1 g;
pfc.random(g);
pfc.random(alpha);
//save process
int len;
char* bytes;
//pfc.precomp_for_pairing(g);
len = pfc.spill(g,bytes);
printf("len of bytes : %d \n",len);
printf("bytes:\n");
for(int i = 0; i<len; ++i){
printf("%.2X",bytes[i]);
}
return 0;
}
If I do not add pfc.precomp_for_pairing(g)
, then the output of length is 0 . If add the pfc.precomp_for_pairing(g)
,the length is 98688. I guess the function of precomp is to precomputing some values of g^1,g^2,g^3 ... so we can do calculation quickly laterly. It is reasonable when doing encryption. But in the exporting private key process, Why can not just save an element for more short key size ? Since the precomputing work can also be done by the decryptor. Am I missing something? I know some abstract concepts of pairing but no idea the implementation details.
By the way , Is Big also serializable?
By calling sizeof(G1)
, It is 40 bytes. Could we JUST save the 40 bytes and reload it ?
You can use the functions to_binary() and from_binary(). See comments in big.h
Mike
On Sun, Oct 24, 2021 at 10:27 AM zbo @.***> wrote:
By calling sizeof(G1), It is 40 bytes. Could we JUST save the 40 bytes and reload it ?
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/miracl/MIRACL/issues/107#issuecomment-950291191, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAU3ZDTRZOGRJ3SNALPUDEDUIPGQNANCNFSM5GR4MC4A . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
Hi, Michael.
Thanks for reply. I have another problem in calling this spill function. My example code :
#include <iostream> #include <ctime> #define MR_PAIRING_SSP // AES-80 or AES-128 security GF(p) curve //#define AES_SECURITY 80 // OR #define AES_SECURITY 128 //********************************************* #include "pairing_1.h" int main(int argc , char** argv){ PFC pfc(AES_SECURITY); time_t seed; time(&seed); Big alpha; G1 g; pfc.random(g); pfc.random(alpha); //save process int len; char* bytes; //pfc.precomp_for_pairing(g); len = pfc.spill(g,bytes); printf("len of bytes : %d \n",len); printf("bytes:\n"); for(int i = 0; i<len; ++i){ printf("%.2X",bytes[i]); } return 0; }
If I do not add
pfc.precomp_for_pairing(g)
, then the output of length is 0 . If add thepfc.precomp_for_pairing(g)
,the length is 98688. I guess the function of precomp is to precomputing some values of g^1,g^2,g^3 ... so we can do calculation quickly laterly. It is reasonable when doing encryption. But in the exporting private key process, Why can not just save an element for more short key size ? Since the precomputing work can also be done by the decryptor. Am I missing something? I know some abstract concepts of pairing but no idea the implementation details.
Hello Michael,
I checked the comments in big.h, already know how to do this work for Big object.
But still don't understand why spill function should save the precomputation of G1
to bytes array? Could we just save G1
?
Is there a way to do serialization in Miracl? Some Encryption Systems like ABE and broadcast encryption the cipher is the elements in G1 or GT. I want to separate the encryption process and decryption process in the example program https://github.com/miracl/MIRACL/blob/master/source/curve/pairing/cpabe.cpp to two program . So I think I should dump the Big object and G1 , GT object to a file in encryption program and reload it in Decryption program . Is there a method in Miracl can do this kind of work.