// network serialization implementation:
	void initFromString(const string & s) override {
		auto vec = explode(s, ':');
		if (vec.size() == 2) {
			x = make_shared<string>(vec[0]);
			r = make_shared<BigIntegerRandomValue>(biginteger(vec[1]));
		} else if (vec.size() == 3) {
			x = make_shared<string>(vec[0] + ":" + vec[1]);
			r = make_shared<BigIntegerRandomValue>(biginteger(vec[2]));
		} 
	}
Example #2
0
RSAElement::RSAElement(biginteger modN){
	/*
	* samples a number between 1 to n-1
	*/
	mt19937 generator = get_seeded_random();
	biginteger randNumber;
	int numbit = NumberOfBits(modN);
	biginteger expo = mp::pow(biginteger(2), numbit-1);
	boost::random::uniform_int_distribution<biginteger> ui(0, expo);
	do {
		randNumber = ui(generator); // samples a random BigInteger with modN.bitLength()+1 bits
	} while (randNumber > (modN - 2)); // drops the element if it's bigger than mod(N)-2
	// gets a random biginteger between 1 to modN-1
	randNumber += 1;
	// sets it to be the element
	element = randNumber;
}
Example #3
0
RSAElement::RSAElement(biginteger modN){
	/*
	* samples a number between 1 to n-1
	*/
	mt19937 generator = get_seeded_random();
	biginteger randNumber;
	int numbit = NumberOfBits(modN);
	biginteger expo = mp::pow(biginteger(2), numbit-1);
	do {
		// samples a random BigInteger with modN.bitLength()+1 bits
		randNumber = getRandomInRange(0, expo, generator); 
	} while (randNumber > (modN - 2)); // drops the element if it's bigger than mod(N)-2
	// gets a random biginteger between 1 to modN-1
	randNumber += 1;
	// sets it to be the element
	element = randNumber;
}
Example #4
0
	OpenSSLDlogZpSafePrime(string q, string g, string p) : OpenSSLDlogZpSafePrime(
		make_shared<ZpGroupParams>(biginteger(q), biginteger(g), biginteger(p))) {};
Example #5
0
biginteger cryptoppint_to_biginteger(CryptoPP::Integer cint)
{
	string s = boost::lexical_cast<std::string>(cint);
	s = s.substr(0, s.size() - 1); // from some reason casting cryptoPP to string ends with '.'
	return biginteger(s);
}