Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/pke/include/cryptocontext.h
Original file line number Diff line number Diff line change
Expand Up @@ -3412,6 +3412,14 @@ class CryptoContextImpl : public Serializable {
* @return Random ring element as ciphertext.
*/
Ciphertext<Element> IntMPBootRandomElementGen(const PublicKey<Element> publicKey) const;
/**
* @brief Generates a common random polynomial for Multi-Party Interactive Bootstrapping (Threshold FHE)
* using an existing ciphertext, eliminating the need to supply a public key explicitly
*
* @param ciphertext Reference ciphertext used to derive the cryptocontext and parameters.
* @return Random ring element as ciphertext.
*/
Ciphertext<Element> IntMPBootRandomElementGen(ConstCiphertext<Element>& ciphertext) const;

/**
* @brief Performs masked decryption as part of Multi-Party Interactive Bootstrapping (Threshold FHE).
Expand Down
3 changes: 3 additions & 0 deletions src/pke/include/scheme/ckksrns/ckksrns-multiparty.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ class MultipartyCKKSRNS : public MultipartyRNS {
Ciphertext<DCRTPoly> IntMPBootRandomElementGen(std::shared_ptr<CryptoParametersCKKSRNS> params,
const PublicKey<DCRTPoly> publicKey) const override;

Ciphertext<DCRTPoly> IntMPBootRandomElementGen(std::shared_ptr<CryptoParametersCKKSRNS> params,
ConstCiphertext<DCRTPoly>& ciphertext) const override;

std::vector<Ciphertext<DCRTPoly>> IntMPBootDecrypt(const PrivateKey<DCRTPoly> privateKey,
ConstCiphertext<DCRTPoly> ciphertext,
ConstCiphertext<DCRTPoly> a) const override;
Expand Down
4 changes: 4 additions & 0 deletions src/pke/include/schemebase/base-multiparty.h
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,10 @@ class MultipartyBase {
const PublicKey<Element> publicKey) const {
OPENFHE_THROW(NOT_SUPPORTED_ERROR);
}
virtual Ciphertext<Element> IntMPBootRandomElementGen(std::shared_ptr<CryptoParametersCKKSRNS> params,
ConstCiphertext<Element>& ciphertext) const {
OPENFHE_THROW(NOT_SUPPORTED_ERROR);
}

/**
* Threshold FHE: Does masked decryption as part of Multi-Party Interactive Bootstrapping.
Expand Down
6 changes: 6 additions & 0 deletions src/pke/include/schemebase/base-scheme.h
Original file line number Diff line number Diff line change
Expand Up @@ -1110,6 +1110,12 @@ class SchemeBase {
return m_Multiparty->IntMPBootRandomElementGen(cryptoParameters, publicKey);
}

Ciphertext<Element> IntMPBootRandomElementGen(std::shared_ptr<CryptoParametersCKKSRNS> cryptoParameters,
ConstCiphertext<Element>& ciphertext) const {
VerifyMultipartyEnabled(__func__);
return m_Multiparty->IntMPBootRandomElementGen(cryptoParameters, ciphertext);
}

std::vector<Ciphertext<Element>> IntMPBootDecrypt(const PrivateKey<Element> privateKey,
ConstCiphertext<Element> ciphertext,
ConstCiphertext<Element> a) const {
Expand Down
12 changes: 12 additions & 0 deletions src/pke/lib/cryptocontext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -658,9 +658,21 @@ Ciphertext<Element> CryptoContextImpl<Element>::IntMPBootAdjustScale(ConstCipher
template <typename Element>
Ciphertext<Element> CryptoContextImpl<Element>::IntMPBootRandomElementGen(const PublicKey<Element> publicKey) const {
const auto cryptoParamsCKKS = std::dynamic_pointer_cast<CryptoParametersCKKSRNS>(this->GetCryptoParameters());
if (cryptoParamsCKKS == nullptr)
OPENFHE_THROW("The parameter object is not of the CryptoParametersCKKSRNS type");

return GetScheme()->IntMPBootRandomElementGen(cryptoParamsCKKS, publicKey);
}

template <typename Element>
Ciphertext<Element> CryptoContextImpl<Element>::IntMPBootRandomElementGen(ConstCiphertext<Element>& ciphertext) const {
const auto cryptoParamsCKKS = std::dynamic_pointer_cast<CryptoParametersCKKSRNS>(ciphertext->GetCryptoParameters());
if (cryptoParamsCKKS == nullptr)
OPENFHE_THROW("The parameter object is not of the CryptoParametersCKKSRNS type");

return GetScheme()->IntMPBootRandomElementGen(cryptoParamsCKKS, ciphertext);
}

template <typename Element>
std::vector<Ciphertext<Element>> CryptoContextImpl<Element>::IntMPBootDecrypt(const PrivateKey<Element> privateKey,
ConstCiphertext<Element>& ciphertext,
Expand Down
17 changes: 15 additions & 2 deletions src/pke/lib/scheme/ckksrns/ckksrns-multiparty.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,8 @@ Ciphertext<DCRTPoly> MultipartyCKKSRNS::IntMPBootAdjustScale(ConstCiphertext<DCR

Ciphertext<DCRTPoly> MultipartyCKKSRNS::IntMPBootRandomElementGen(std::shared_ptr<CryptoParametersCKKSRNS> params,
const PublicKey<DCRTPoly> publicKey) const {
auto ildcrtparams = params->GetElementParams();
typename DCRTPoly::DugType dug;
DCRTPoly crp(dug, ildcrtparams);
DCRTPoly crp(dug, params->GetElementParams());
crp.SetFormat(Format::EVALUATION);

Ciphertext<DCRTPoly> outCtxt(std::make_shared<CiphertextImpl<DCRTPoly>>(publicKey));
Expand All @@ -170,6 +169,20 @@ Ciphertext<DCRTPoly> MultipartyCKKSRNS::IntMPBootRandomElementGen(std::shared_pt
return outCtxt;
}

Ciphertext<DCRTPoly> MultipartyCKKSRNS::IntMPBootRandomElementGen(std::shared_ptr<CryptoParametersCKKSRNS> params,
ConstCiphertext<DCRTPoly>& ciphertext) const {
const auto& ctxtElems = ciphertext->GetElements();

typename DCRTPoly::DugType dug;
DCRTPoly crp(dug, ctxtElems[0].GetParams());
crp.SetFormat(Format::EVALUATION);

Ciphertext<DCRTPoly> outCtxt(std::make_shared<CiphertextImpl<DCRTPoly>>(*ciphertext));

outCtxt->SetElements({std::move(crp)});
return outCtxt;
}

// Subroutines for Interactive Multi-Party Bootstrapping
// Calculating RNS parameters
void PrecomputeRNSExtensionTables(CryptoContext<DCRTPoly>& cc, usint from, usint to, RNSExtensionTables& rnsExtTables) {
Expand Down