Nevermind, Jeffrey. It suddently began to work. C++ misteries...

Thanks a lot, again!
Douglas


Jeffrey Walton escreveu:
Hi Douglas,

Does it break when you insert your files (arguments) into Wei's driver
program? Can you post your code? It would be a big help - claiming seg
faults (so I assume Linux/Unix) does not tell the group much.

Also, have you run cryptest -v (I think it is -v) to validate?

Jeff

----- Original Message ----- 
From: "Douglas de Oliveira Mendes" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Tuesday, October 18, 2005 3:56 PM
Subject: Re: Example of using SecretSharing class


  
    I'm getting segfault here:

channelSwitch->AddRoute(channel, *fileSinks[i],
BufferedTransformation::NULL_CHANNEL);

    Have you tested the example?

Jeffrey Walton escreveu:

    
Hi Douglas,

Let's try and get you moving... I took the following from Crypto++ 5.2.1.

Jeff

************************************************
************************************************
>From Usage (actually, usage.dat):

- To secret share a file (shares will be named file.000, file.001, etc)
cryptest ss threshold number-of-shares file

- To reconstruct a secret-shared file
cryptest sr file share1 share2 [....]
(number of shares given must be equal to threshold)

- To information disperse a file (shares will be named file.000,
      
file.001, etc)
  
cryptest id threshold number-of-shares file

- To reconstruct an information-dispersed file
cryptest ir file share1 share2 [....]
(number of shares given must be equal to threshold)

************************************************
************************************************
And the functions. See test.cpp, lines 491-592

************************************************
void SecretShareFile(int threshold, int nShares, const char *filename,
      
const char *seed)
  
{
   assert(nShares<=1000);

   RandomPool rng;
   rng.Put((byte *)seed, strlen(seed));

   ChannelSwitch *channelSwitch;
   FileSource source(filename, false, new SecretSharing(rng, threshold,
      
nShares, channelSwitch = new ChannelSwitch));
  
   vector_member_ptrs<FileSink> fileSinks(nShares);
   string channel;
   for (int i=0; i<nShares; i++)
   {
       char extension[5] = ".000";
       extension[1]='0'+byte(i/100);
       extension[2]='0'+byte((i/10)%10);
       extension[3]='0'+byte(i%10);
       fileSinks[i].reset(new
      
FileSink((string(filename)+extension).c_str()));
  
       channel = WordToString<word32>(i);
       fileSinks[i]->Put((byte *)channel.data(), 4);
       channelSwitch->AddRoute(channel, *fileSinks[i],
      
BufferedTransformation::NULL_CHANNEL);
  
   }

   source.PumpAll();
}

************************************************
void SecretRecoverFile(int threshold, const char *outFilename, char
      
*const *inFilenames)
  
{
   assert(threshold<=1000);

   SecretRecovery recovery(threshold, new FileSink(outFilename));

   vector_member_ptrs<FileSource> fileSources(threshold);
   SecByteBlock channel(4);
   int i;
   for (i=0; i<threshold; i++)
   {
       fileSources[i].reset(new FileSource(inFilenames[i], false));
       fileSources[i]->Pump(4);
       fileSources[i]->Get(channel, 4);
       fileSources[i]->Attach(new ChannelSwitch(recovery, string((char
      
*)channel.begin(), 4)));
  
   }

   while (fileSources[0]->Pump(256))
       for (i=1; i<threshold; i++)
           fileSources[i]->Pump(256);

   for (i=0; i<threshold; i++)
       fileSources[i]->PumpAll();
}

************************************************
void InformationDisperseFile(int threshold, int nShares, const char
      
*filename)
  
{
   assert(nShares<=1000);

   ChannelSwitch *channelSwitch;
   FileSource source(filename, false, new
      
InformationDispersal(threshold, nShares, channelSwitch = new
ChannelSwitch));
  
   vector_member_ptrs<FileSink> fileSinks(nShares);
   string channel;
   for (int i=0; i<nShares; i++)
   {
       char extension[5] = ".000";
       extension[1]='0'+byte(i/100);
       extension[2]='0'+byte((i/10)%10);
       extension[3]='0'+byte(i%10);
       fileSinks[i].reset(new
      
FileSink((string(filename)+extension).c_str()));
  
       channel = WordToString<word32>(i);
       fileSinks[i]->Put((byte *)channel.data(), 4);
       channelSwitch->AddRoute(channel, *fileSinks[i],
      
BufferedTransformation::NULL_CHANNEL);
  
   }

   source.PumpAll();
}

************************************************
void InformationRecoverFile(int threshold, const char *outFilename, char
      
*const *inFilenames)
  
{
   assert(threshold<=1000);

   InformationRecovery recovery(threshold, new FileSink(outFilename));

   vector_member_ptrs<FileSource> fileSources(threshold);
   SecByteBlock channel(4);
   int i;
   for (i=0; i<threshold; i++)
   {
       fileSources[i].reset(new FileSource(inFilenames[i], false));
       fileSources[i]->Pump(4);
       fileSources[i]->Get(channel, 4);
       fileSources[i]->Attach(new ChannelSwitch(recovery, string((char
      
*)channel.begin(), 4)));
  
   }

   while (fileSources[0]->Pump(256))
       for (i=1; i<threshold; i++)
           fileSources[i]->Pump(256);

   for (i=0; i<threshold; i++)
       fileSources[i]->PumpAll();
}




      



_______________________________________________________
Promoção Yahoo! Acesso Grátis: a cada hora navegada você acumula cupons e
    
concorre a mais de 500 prêmios! Participe! http://yahoo.fbiz.com.br/
  


  

Reply via email to