SEAL开源库源码01

SEAL开源库源码01

seal/util/defines.h

这个头文件没有相应的cpp文件,定义了一些其他文件中需要用到的基本的东西

通用的判断函数

// Debugging help
#define SEAL_ASSERT(condition)                                                                                         \
    {
                                                                                                                       \
        if (!(condition))                                                                                              \
        {
                                                                                                                   \
            std::cerr << "ASSERT FAILED: " << #condition << " @ " << __FILE__ << " (" << __LINE__ << ")" << std::endl; \
        }                                                                                                              \
    }

将x输出为字符串

一个井号和两个井号的意思:一个井号将x转换为字符串,两个井号为字符串的拼接
井号和两个井号

// String expansion
#define _SEAL_STRINGIZE(x) #x
#define SEAL_STRINGIZE(x) _SEAL_STRINGIZE(x)

字符串的拼接

// Join
#define _SEAL_JOIN(M, N) M##N
#define SEAL_JOIN(M, N) _SEAL_JOIN(M, N)

检查double类型是否是64比特

// Check that double is 64 bits
static_assert(sizeof(double) == 8, "Require sizeof(double) == 8");

检查int是否为32比特

// Check that int is 32 bits
static_assert(sizeof(int) == 4, "Require sizeof(int) == 4");

检查unsigned long long 是否为64比特

// Check that unsigned long long is 64 bits
static_assert(sizeof(unsigned long long) == 8, "Require sizeof(unsigned long long) == 8");

多项式系数模数的上下界

上界为61比特,下界为2比特

// Bounds for bit-length of all coefficient moduli
#define SEAL_MOD_BIT_COUNT_MAX 61
#define SEAL_MOD_BIT_COUNT_MIN 2

内部使用的系数模长

似乎是定长的61比特

// Bit-length of internally used coefficient moduli, e.g., auxiliary base in BFV
#define SEAL_INTERNAL_MOD_BIT_COUNT 61

用户定义的系数模长的上下界

上界60比特,下界2比特

// Bounds for bit-length of user-defined coefficient moduli
#define SEAL_USER_MOD_BIT_COUNT_MAX 60
#define SEAL_USER_MOD_BIT_COUNT_MIN 2

明文模长的上下界

跟用户定义的模长的上下界相同,上界60比特,下界2比特

// Bounds for bit-length of the plaintext modulus
#define SEAL_PLAIN_MOD_BIT_COUNT_MAX SEAL_USER_MOD_BIT_COUNT_MAX
#define SEAL_PLAIN_MOD_BIT_COUNT_MIN SEAL_USER_MOD_BIT_COUNT_MIN

系数模数数量的上下界(没有硬性的要求)

上界为64个,下界为1个

// Bounds for number of coefficient moduli (no hard requirement)
#define SEAL_COEFF_MOD_COUNT_MAX 64
#define SEAL_COEFF_MOD_COUNT_MIN 1

多项式模的次数 (模一个多项式,指的是这个多项式的次数)

上界为131072 = 2 17 2^{17} 217,下界为2

// Bounds for polynomial modulus degree (no hard requirement)
#define SEAL_POLY_MOD_DEGREE_MAX 131072
#define SEAL_POLY_MOD_DEGREE_MIN 2

密文大小的上界

不能超过 2 32 2^{32} 232除以多项式模的degree上界,即 2 32 / 2 17 = 2 15 = 32768 2^{32}/2^{17} = 2^{15} = 32768 232/217=215

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值