SEAL
SEAL copied to clipboard
Create secret key from a seed
Is it possible to create an asymmetric secret key from a given seed and then re-use this seed to create the same secret key?
Thanks for suggestion. We'll leave this issue open and will get back to it after the next release. One issue is that this kind of seeded secret key is not described in the HE.org security standard.
There is already a pretty easy way to achieve this by using a PRNG seed as the key and then use that PRNG only for setting up the KeyGenerator as follows:
#include <seal/randomgen.h>
#include <seal/keygenerator.h>
#include <memory>
using namespace seal;
random_seed_type secret_key = {
random_uint64(), random_uint64(), random_uint64(), random_uint64(),
random_uint64(), random_uint64(), random_uint64(), random_uint64()
};
std::shared_ptr<UniformRandomGeneratorFactory> rg = make_shared<BlakePRNGFactory(secret_key);
EncryptionParameters parms_copy(<your encryption parameters here>);
parms_copy.set_random_generator(rg);
auto context_copy = SEALContext::Create(parms_copy, false);
KeyGenerator keygen_copy(context_copy);
SecretKey seal_secret_key = keygen_copy.secret_key();
// Now you have the short secret key seed in secret_key and the full key in seal_secret_key.
// Now you can set up the real context and use the SecretKey to initialize a new KeyGenerator that
// can be used for GaloisKeys etc.
The security also relies on the seeded PRNG used to generate or expand the secret key. The encryption schemes remain secure as long as the uniform ternary distribution generated from a seeded PRNG is computationally indistinguishable from a uniform ternary distribution. Using a cryptographically secure PRNG is required, and Blake2 is one of them.