Importing and exporting an element in PBC

March 6, 2013 | Posted in Asynchronous Key Generation for IBE | None

I added this function to the PBC wrapper classes:

void Zr::dumpfile(FILE *f)const{
  unsigned char sharedump[20];
  int bt;
  bt = element_length_in_bytes(*(element_t*)&r);
  element_to_bytes(sharedump, *(element_t*)&r);
  fwrite(sharedump, bt, 1, f);
}

So when the DKG completes, I call ‘result.share.dumpfile’. Not going into the depths. Just documenting these functions.

To extract the element saved in binary, I use this function :

int read_share(){
  FILE *fp;
  unsigned char str[20];
  fp = fopen("../secrets","rb");
  if(!fp)
    return -1;
  fread(str, 20, 1, fp);
  fclose(fp);
  element_init_Zr(share, pairing);
  element_from_bytes(share, str);
}

Related Posts

16 Mar 2013 » Decryption for distributed Boneh-Franklin IBC

16 Mar 2013 » Encryption for distributed Boneh-Franklin IBC

15 Mar 2013 » Hash functions for distributed Boneh Franklin IBC

02 Mar 2013 » Using python to complete IBC

27 Feb 2013 » Modifying a DKG header

23 Feb 2013 » Analyzing messages in DKG

23 Feb 2013 » Understanding DKG

20 Feb 2013 » Pseudo code for the mathematical functions

19 Feb 2013 » Modifying the DKG protocol

19 Feb 2013 » The DKG protocol, in short

19 Feb 2013 » The DKG Protocol

19 Feb 2013 » Asynchronous Distributed Key Generation for Identity-Based Cryptography

19 Feb 2013 » Distributed Key Generation

19 Feb 2013 » Boneh Franklin IBC using the PBC library