Files
concrete/compilers/concrete-compiler/compiler/include/concretelang/Common/Keysets.h
Benoit Chevallier-Mames e37a840e7e docs(compiler): adding API doc
2024-03-13 17:10:00 +01:00

84 lines
2.2 KiB
C++

// Part of the Concrete Compiler Project, under the BSD3 License with Zama
// Exceptions. See
// https://github.com/zama-ai/concrete/blob/main/LICENSE.txt
// for license information.
#ifndef CONCRETELANG_COMMON_KEYSETS_H
#define CONCRETELANG_COMMON_KEYSETS_H
#include "concrete-protocol.capnp.h"
#include "concretelang/Common/Csprng.h"
#include "concretelang/Common/Error.h"
#include "concretelang/Common/Keys.h"
#include <functional>
#include <memory>
#include <stdlib.h>
#include <string>
using concretelang::error::Result;
using concretelang::error::StringError;
using concretelang::keys::LweBootstrapKey;
using concretelang::keys::LweKeyswitchKey;
using concretelang::keys::LweSecretKey;
using concretelang::keys::PackingKeyswitchKey;
namespace concretelang {
namespace keysets {
struct ClientKeyset {
std::vector<LweSecretKey> lweSecretKeys;
static ClientKeyset
fromProto(const Message<concreteprotocol::ClientKeyset> &proto);
Message<concreteprotocol::ClientKeyset> toProto() const;
};
struct ServerKeyset {
std::vector<LweBootstrapKey> lweBootstrapKeys;
std::vector<LweKeyswitchKey> lweKeyswitchKeys;
std::vector<PackingKeyswitchKey> packingKeyswitchKeys;
static ServerKeyset
fromProto(const Message<concreteprotocol::ServerKeyset> &proto);
Message<concreteprotocol::ServerKeyset> toProto() const;
};
struct Keyset {
ServerKeyset server;
ClientKeyset client;
Keyset(){};
/// Generates a fresh keyset from infos.
Keyset(const Message<concreteprotocol::KeysetInfo> &info,
concretelang::csprng::SecretCSPRNG &secretCsprng,
csprng::EncryptionCSPRNG &encryptionCsprng);
Keyset(ServerKeyset server, ClientKeyset client)
: server(server), client(client) {}
static Keyset fromProto(const Message<concreteprotocol::Keyset> &proto);
Message<concreteprotocol::Keyset> toProto() const;
};
class KeysetCache {
std::string backingDirectoryPath;
public:
KeysetCache(std::string backingDirectoryPath);
Result<Keyset>
getKeyset(const Message<concreteprotocol::KeysetInfo> &keysetInfo,
__uint128_t secret_seed, __uint128_t encryption_seed);
private:
KeysetCache() = default;
};
} // namespace keysets
} // namespace concretelang
#endif