MCPcopy Create free account
hub / github.com/LUX-Core/lux / SecretShareFile

Function SecretShareFile

src/cryptopp/test.cpp:645–673  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

643}
644
645void SecretShareFile(int threshold, int nShares, const char *filename, const char *seed)
646{
647 CRYPTOPP_ASSERT(nShares >= 1 && nShares<=1000);
648 if (nShares < 1 || nShares > 1000)
649 throw InvalidArgument("SecretShareFile: " + IntToString(nShares) + " is not in range [1, 1000]");
650
651 RandomPool rng;
652 rng.IncorporateEntropy((byte *)seed, strlen(seed));
653
654 ChannelSwitch *channelSwitch = NULL;
655 FileSource source(filename, false, new SecretSharing(rng, threshold, nShares, channelSwitch = new ChannelSwitch));
656
657 vector_member_ptrs<FileSink> fileSinks(nShares);
658 string channel;
659 for (int i=0; i<nShares; i++)
660 {
661 char extension[5] = ".000";
662 extension[1]='0'+byte(i/100);
663 extension[2]='0'+byte((i/10)%10);
664 extension[3]='0'+byte(i%10);
665 fileSinks[i].reset(new FileSink((string(filename)+extension).c_str()));
666
667 channel = WordToString<word32>(i);
668 fileSinks[i]->Put((const byte *)channel.data(), 4);
669 channelSwitch->AddRoute(channel, *fileSinks[i], DEFAULT_CHANNEL);
670 }
671
672 source.PumpAll();
673}
674
675void SecretRecoverFile(int threshold, const char *outFilename, char *const *inFilenames)
676{

Callers 1

CRYPTOPP_API mainFunction · 0.85

Calls 6

IntToStringFunction · 0.85
AddRouteMethod · 0.80
IncorporateEntropyMethod · 0.45
resetMethod · 0.45
PutMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected