Palisade math backends设计思路

PALISADE supports a number of different math backends

The design goal is to have several math backends available at the same time, and to permit the programmer to choose,
at runtime, which backend to use.
用户可以在运行时选择使用哪种backend

The current implementation supports the availability of several backends, but requires the programmer to make a
compile-time choice of which backend to use as the default type for BigInteger and BigVector in the library.

两种控制方式
Math backend selection is controlled by editing src/core/include/math/backend.h. or by adding a CMAKE flag, e.g.

 cmake -DMATHBACKEND=4 ..

The programmer should select a value for MATHBACKEND; the file contains several options. As indicated in the comments
in this file:

//To select backend, please UNCOMMENT the appropriate line rather than changing the number on the
//uncommented line

By selecting a particular value for MATHBACKEND, the programmer selects a particular default implementation for
BigInteger, BigVector, and for the composite Poly and ciphertext modulus used in DCRTPoly

For native integer arithmetic NativeInteger, NativeVector implementation is available.
The following is the status of the various MATHBACKEND implementations. We expect subsequent releases to remove these
restrictions and expand available options

  • MATHBACKEND 2
    If the programmer selects MATHBACKEND 2, the maximum size of BigInteger will be set to BigIntegerBitLength, which is defined in
    backend.h and which has a default value of 3000 bits. It’s advisable to select a value for BigIntegerBitLength that is larger than the double bitwidth of the largest (ciphertext) modulus. This parameter can be decreased for runtime/space optimization when the largest modulus is under 1500 bits.

The underlying implementation is a fixed-size array of native integers. The native integer used in MATHBACKEND 2, which is defined
by the typedef integral_dtype, MUST be uint32_t; using other types is an open work item.

  • MATHBACKEND 4
    If the programmer selects MATHBACKEND 4, there is no explicit maximum size of BigInteger; the size grows dynamically as needed and
    is constrained only by memory. This implementation requires that UBINT_32 be defined, as is done in the file. Setting UBINT_64 is
    currently not functioning and is an open work item.

  • MATHBACKEND 6
    This is an integration of the NTL library with PALISADE, and is only available when NTL/GMP is enabled using CMAKE.

All implementations for Big/Native Integer/Vector are based on interface.h.

Palisade supports several methods for modular multiplication.
We use the following naming conventions:

  • ModMul(b, mod) - Naive modular multiplication that uses % operator for modular reduction, and usually slow.

  • ModMul(b, mod, mu) - Barrett modular multiplication.
    mu for Barrett modulo can be precomputed by mod.ComputeMu().

  • ModMulFast(b, mod) - Naive modular multiplication w/ operands < mod

  • ModMulFast(b, mod, mu) - Barrett modular multiplication w/ operands < mod

  • ModMulFastConst(b, mod, bPrecomp) - modular multiplication using precomputed information on b, w/ operands < mod.
    bPrecomp can be precomputed by b.PrepModMulConst(mod). This method is currently implemented only for NativeInteger class. The fastest method.

Naming conventions for standard modular operations:

VariantNaiveBarrettFast NaiveFast BarrettFast Const
ModMod(mod)Mod(mod, mu)---
ModAddModAdd(b, mod)ModAdd(b, mod, mu)ModAddFast(b, mod)--
ModSubModSub(b, mod)ModSub(b, mod, mu)ModSubFast(b, mod)--
ModMulModMul(b, mod)ModMul(b, mod, mu)ModMulFast(b, mod)ModMulFast(b, mod, mu)ModMulFastConst(b, mod, bPrecomp)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值