简单加密算术库(SEAL)和seal :: Ciphertext变量

时间:2018-07-19 07:04:32

标签: c++ postgresql encryption cryptography seal

我正在使用Microsoft密码研究小组的Simple Encrypted Arithmetic Library (SEAL)库。有没有办法获取DateTime datetime= org.joda.time.LocalDateTime.parse(date).toDateTime(UTC)的内容?我试图了解ciphertext.h和ciphertext.cpp并找到了:

sentinel = ''
multi_line = ','.join(iter(input,sentinel))
list = multi_line.split(',')

但是我找不到另一种选择来获取任何seal::Ciphertext variable的内容,这些内容不是二进制流,也不是指向某个内存地址的指针,而是将其保存为字符串。

如果您有任何人从上面的链接下载了SEAL库并提取了它,而没有进行任何更改。您可以在 SEAL_2.3.1 \ SEAL \ seal \ ciphertext.h SEAL_2.3.1 \ SEAL \ seal \ ciphertext.cpp 中找到/** 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); 上所有允许的操作>

1 个答案:

答案 0 :(得分:1)

简短的回答是,没有其他方法可以访问SEAL中的密文数据。由public interface IGameApi { @GET("/games/?fields=name,cover&filter[release_dates.platform][any]={platform}") @Headers("Accept:application/json") Call<List<Games>> getGameByPlatform(@Path("platform") int platform, @Header("user-key") String key); } 返回的指针可让您直接访问密文数据,从这种意义上讲,您可以对其进行任何类型的计算,例如如果出于某种原因想要转换为人类可读的字符串。

当然,要做任何可理解的事情,您需要知道密文的数据布局。在BFV方案中,密文由一对系数(大小为Ciphertext::data)的多项式(c 0 ,c 1 )组成。由于对具有如此大系数的多项式进行运算很不方便,因此SEAL 2.3.1改为使用复合coeff_modulus并以模数形式分别存储c 0 和c 1 coeff_modulus中指定的主要因子(表示这些因子q 1 ,q 2 ,...,q k )。每个q i 都适合一个64位字,因此所有这2k多项式都具有字长系数。

密文系数数据布局如下(在内存中是连续的):

[c 0 mod q 1 ] [c 0 mod q 2 ] ... [c 0 mod q k ] [c 1 mod q 1 ] [c 1 mod q 2 ] ... [c 1 mod q k ]

每个[c i mod q j ]的样子

[c 0 [0] mod q j ] [c 1 [0] mod q j ] ... [c n-1 [0] mod q j ]

在这里,我使用c i [k]表示c i 的度k系数。注意,每个系数都存储在coeff_modulus中。

uint64_t返回一个指向c 0 多项式的常数系数的指针,该常数相对于Ciphertext::data中的第一个模数,即c 0 [0] mod q 1 。除此系数数据外,密文还包含一些其他字段,您可以使用成员函数读取这些字段。