为 android 交叉编译 PALSIADE

Cross Compiling PALSIADE for android

我们正在尝试为 Android 构建 PALISADE (https://git.njit.edu/palisade/PALISADE)。通过为 Android 成功构建“gmp”和“ntl”,我们取得了一些进展。

GMP 能够开箱即用地进行交叉编译。 NTL 有点棘手。我们使用 https://github.com/nemirst/ntl-android 但将 headers 和 src 更改为 PALISADE (10.5.0)

中提供的版本

我们还对 PALISADE makefile 进行了一些更改,因此它们支持使用 android 独立工具链进行交叉编译。现在的问题是,当尝试使用交叉编译的 NTL 和 GMP 库编译 PALISADE 时,我们得到以下错误:

PALISADE/bin/build/toolchains/aarch64-linux-android/bin/aarch64-linux-android-gcc --sysroot=PALISADE/bin/build/toolchains/aarch64-linux-android/sysroot -g -Wall -Werror -O3 -fopenmp -pthread -I src -Isrc/core/lib -Isrc/pke/lib -Isrc/abe/lib -Isrc/signature/lib -I test -I /opt/local/include/libomp -fopenmp -I third-party/include -I third-party/include/rapidjson -c -o bin/build/core/lib/math/benative-math-impl.o src/core/lib/math/benative-math-impl.cpp
In file included from src/core/lib/math/benative-math-impl.cpp:28:
In file included from src/core/lib/utils/../math/backend.h:43:
src/core/lib/math/native_int/binint.h:956:79: error: no viable conversion from 'const unsigned long' to 'NTL::wide_double'
                return (uint_type)NTL::MulModPrecon(this->m_value,b.m_value,modulus.m_value,bInv.m_value);
                                                                                            ^~~~~~~~~~~~
src/core/lib/math/transfrm.cpp:192:33: note: in instantiation of member function 'native_int::NativeInteger<unsigned long>::ModMulPreconOptimized' requested here
                                                        InputToFFT[i]=element[i].ModMulPreconOptimized((*rootOfUnityTable)[i],modulus,preconTable[i]);
                                                                                 ^
third-party/include/NTL/sp_arith.h:405:4: note: candidate constructor not viable: no known conversion from 'const unsigned long' to 'const NTL::wide_double &' for 1st argument
   wide_double(const wide_double& x) : data(x.data) { }
   ^
third-party/include/NTL/sp_arith.h:812:62: note: passing argument to parameter 'bninv' here
inline long MulModPrecon(long a, long b, long n, wide_double bninv)
                                                             ^
In file included from src/core/lib/math/benative-math-impl.cpp:36:
src/core/lib/math/transfrm.cpp:107:48: error: too many arguments to function call, expected 4, have 5
                                preconRootOfUnityInverseTable, cycloOrder, ans);
                                                                           ^~~
src/core/lib/math/transfrm.cpp:300:38: note: in instantiation of member function 'lbcrypto::NumberTheoreticTransform<native_int::NativeVector<native_int::NativeInteger<unsigned long> > >::InverseTransformIterative' requested here
                NumberTheoreticTransform<VecType>::InverseTransformIterative(element, *rootOfUnityITable,
                                                   ^
src/core/lib/math/transfrm.h:67:3: note: 'ForwardTransformIterative' declared here
                static void ForwardTransformIterative(const VecType& element, const VecType &rootOfUnityTable, const usint cycloOrder, VecType* result) {
                ^
In file included from src/core/lib/math/benative-math-impl.cpp:28:
In file included from src/core/lib/utils/../math/backend.h:43:
src/core/lib/math/native_int/binint.h:975:88: error: no viable conversion from 'const unsigned long' to 'NTL::wide_double'
                this->m_value = (uint_type)NTL::MulModPrecon(this->m_value,b.m_value,modulus.m_value,bInv.m_value);
                                                                                                     ^~~~~~~~~~~~
src/core/lib/math/transfrm.cpp:313:21: note: in instantiation of member function 'native_int::NativeInteger<unsigned long>::ModMulPreconOptimizedEq' requested here
                                                        (*OpIFFT)[i].ModMulPreconOptimizedEq((*rootOfUnityITable)[i],nativeModulus,preconTable[i]);
                                                                     ^
third-party/include/NTL/sp_arith.h:405:4: note: candidate constructor not viable: no known conversion from 'const unsigned long' to 'const NTL::wide_double &' for 1st argument
   wide_double(const wide_double& x) : data(x.data) { }
   ^
third-party/include/NTL/sp_arith.h:812:62: note: passing argument to parameter 'bninv' here
inline long MulModPrecon(long a, long b, long n, wide_double bninv)
                                                             ^
3 errors generated.
make[1]: *** [bin/build/core/lib/math/benative-math-impl.o] Error 1
make: *** [all] Error 2

如果您能帮助我们为 Android 构建此库,我们将不胜感激。

编辑:拼写

这有点晚了,但如果你仍然感兴趣,新版本的 Palisade 不需要 GMP 或 NTL(只有当用户在 CMake 构建过程中明确启用它们时才会启用),所以它现在可能更容易构建。您应该在 https://gitlab.com/palisade/palisade-release or if you are willing to try it out, the development version at https://gitlab.com/palisade/palisade-development

使用最新的稳定版本

交叉编译有点棘手,但可以做到。我们正在开发一些嵌入式目标,但它们尚未在发布流中。

我们正在考虑在未来的版本中支持 Android 端口,因此非常感谢您可以与我们分享您取得的任何进展。 Dave Cousins -- PALISADE 开发团队。