Simple Encrypted Arithmetic Library (SEAL) and the seal::Ciphertext variable(简单加密算术库 (SEAL) 和 seal::Ciphertext 变量)
问题描述
I'm using the Simple Encrypted Arithmetic Library (SEAL) library from Microsoft Cryptography Research Group. Is there a way to get the content of seal::Ciphertext variable
? I've tried to understand the ciphertext.h and ciphertext.cpp and found the:
/**
Saves the ciphertext to an output stream. The output is in binary format and not
human-readable. The output stream must have the "binary" flag set.
@param[in] stream The stream to save the ciphertext to
@see load() to load a saved ciphertext.
*/
void save(std::ostream &stream) const;
/**
Loads a ciphertext from an input stream overwriting the current ciphertext.
@param[in] stream The stream to load the ciphertext from
@see save() to save a ciphertext.
*/
void load(std::istream &stream);
But I coudn't find another option to get the content of anyseal::Ciphertext variable
that is not a binary stream or just a pointer to some memory address and save it a string.
If any of you have download the SEAL library from the link above and extracted it without changing anything. You can find all the allowed operations on seal::Ciphertext
in SEAL_2.3.1SEALsealciphertext.h and SEAL_2.3.1SEALsealciphertext.cpp
Short answer is that there are no other ways of accessing the ciphertext data in SEAL. The pointer returned by Ciphertext::data
will give you direct access to the ciphertext data and in that sense allows you to do any kind of computation on it, e.g. converting to a human-readable string if for some reason you would want to do that.
Of course to do anything intelligible you need to know the data layout of the ciphertext. In the BFV scheme a ciphertext consists of a pair of polynomials (c0, c1) with large (size coeff_modulus
) coefficients. Since operating on polynomials with such large coefficients is inconvenient, SEAL 2.3.1 instead uses a composite coeff_modulus
and stores both c0 and c1 modulo each of the prime factors specified in the coeff_modulus
(denote these factors q1,q2,...,qk). Each qi fits into a 64-bit word, so all of these 2k polynomials have word-size coefficients.
The ciphertext coefficient data layout is as follows (contiguous in memory):
[ c0 mod q1 ][ c0 mod q2 ]...[ c0 mod qk ][ c1 mod q1 ][ c1 mod q2 ]...[ c1 mod qk ]
where each [ ci mod qj ] looks like
[ c0[0] mod qj ][ c1[0] mod qj ]...[ cn-1[0] mod qj ]
Here I used ci[k] to denote the degree k coefficient of ci. Note that each coefficient is stored in a uint64_t
.
Ciphertext::data
returns a pointer to the constant coefficient of the c0 polynomial with respect to the first modulus in your coeff_modulus
, i.e. to c0[0] mod q1. In addition to this coefficient data, a Ciphertext contains a few other fields that you can read using the member functions.
这篇关于简单加密算术库 (SEAL) 和 seal::Ciphertext 变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:简单加密算术库 (SEAL) 和 seal::Ciphertext 变量
基础教程推荐
- 调用std::Package_TASK::Get_Future()时可能出现争用情况 2022-12-17
- 运算符重载的基本规则和习语是什么? 2022-10-31
- C++ 标准:取消引用 NULL 指针以获取引用? 2021-01-01
- 什么是T&&(双与号)在 C++11 中是什么意思? 2022-11-04
- C++ 程序在执行 std::string 分配时总是崩溃 2022-01-01
- 设计字符串本地化的最佳方法 2022-01-01
- C++,'if' 表达式中的变量声明 2021-01-01
- 如何定义双括号/双迭代器运算符,类似于向量的向量? 2022-01-01
- 如何在 C++ 中处理或避免堆栈溢出 2022-01-01
- 您如何将 CreateThread 用于属于类成员的函数? 2021-01-01