Skip to content

Commit

Permalink
repo-sync-2024-06-20T15:21:55+0800 (#137)
Browse files Browse the repository at this point in the history
  • Loading branch information
shaojian-ant authored Jun 20, 2024
1 parent c6886af commit 801aca7
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 47 deletions.
42 changes: 9 additions & 33 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,16 @@ workspace(name = "com_alipay_sf_heu")

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

### ref yacl ###
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")

SECRETFLOW_GIT = "https://github.com/secretflow"
#### fetch third-party deps ####

YACL_COMMIT_ID = "05b879b8133e280d16ee03d24d2f2bba1c9db7ea"
load("//third_party/bazel_cpp:repositories.bzl", "heu_cpp_deps")

git_repository(
name = "yacl",
commit = YACL_COMMIT_ID,
recursive_init_submodules = True,
remote = "{}/yacl.git".format(SECRETFLOW_GIT),
)
heu_cpp_deps()

load("@yacl//bazel:repositories.bzl", "yacl_deps")

yacl_deps()

#### fetch third-party deps ####

load("//third_party/bazel_cpp:repositories.bzl", "heu_cpp_deps")

heu_cpp_deps()

#### for cpp ####

load(
Expand All @@ -62,21 +48,21 @@ py_repositories()
# Python binding.
http_archive(
name = "pybind11_bazel",
sha256 = "6426567481ee345eb48661e7db86adc053881cb4dd39fbf527c8986316b682b9",
strip_prefix = "pybind11_bazel-fc56ce8a8b51e3dd941139d329b63ccfea1d304b",
sha256 = "dc4882b23a617575d0fd822aba88aa4a14133c3d428b5a8fb83d81d03444a475",
strip_prefix = "pybind11_bazel-8889d39b2b925b2a47519ae09402a96f00ccf2b4",
urls = [
"https://github.com/pybind/pybind11_bazel/archive/fc56ce8a8b51e3dd941139d329b63ccfea1d304b.zip",
"https://github.com/pybind/pybind11_bazel/archive/8889d39b2b925b2a47519ae09402a96f00ccf2b4.zip",
],
)

# We still require the pybind library.
http_archive(
name = "pybind11",
build_file = "@pybind11_bazel//:pybind11.BUILD",
sha256 = "eacf582fa8f696227988d08cfc46121770823839fe9e301a20fbce67e7cd70ec",
strip_prefix = "pybind11-2.10.0",
sha256 = "bf8f242abd1abcd375d516a7067490fb71abd79519a282d22b6e4d19282185a7",
strip_prefix = "pybind11-2.12.0",
urls = [
"https://github.com/pybind/pybind11/archive/refs/tags/v2.10.0.tar.gz",
"https://github.com/pybind/pybind11/archive/refs/tags/v2.12.0.tar.gz",
],
)

Expand Down Expand Up @@ -106,16 +92,6 @@ rust_fetch_remote_crates()

#### for cuda ####

http_archive(
name = "rules_cuda",
sha256 = "f62baee0150ac91f4cdfcb10df2be0d0e9b941d1d32c8cddf00b16b57bdb1540",
strip_prefix = "rules_cuda-17ca7f8c04cf746aa4c0a0c3722799278df7ca93",
urls = [
# Main branch as of 2023-1-07
"https://github.com/bazel-contrib/rules_cuda/archive/17ca7f8c04cf746aa4c0a0c3722799278df7ca93.tar.gz",
],
)

load("@rules_cuda//cuda:repositories.bzl", "register_detected_cuda_toolchains", "rules_cuda_dependencies")

rules_cuda_dependencies()
Expand Down
2 changes: 1 addition & 1 deletion heu/experimental/gemini-rlwe/poly_encoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void PolyEncoder::DoBackward(absl::Span<const T> vec, RLWEPt *out,
size_t base_mod_bitlen = ms_helper_.base_mod_bitlen();
T mask = static_cast<T>(-1);
if (sizeof(T) * 8 < base_mod_bitlen) {
mask = (static_cast<T>(1) << base_mod_bitlen) - 1;
mask = (static_cast<T>(1) << base_mod_bitlen) - 1; // FIXME: BAD_SHIFT
}
auto mempool = seal::MemoryManager::GetPool();
auto backward = seal::util::allocate<T>(poly_deg_, mempool);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ void fpn_matrix_elementwise_multiply_pen_matrix(

fpga_config *cfg;
cfg = (fpga_config *)malloc(sizeof(fpga_config));
memset(cfg, 0, sizeof(fpga_config));
cfg->operate_mode = 7; // call encrypted mul2 function of FPGA to calulate
cfg->para_data_size = para_length / 8;
cfg->data3_size = 0;
Expand Down Expand Up @@ -533,6 +534,7 @@ void encrypt_without_obf(char *fpn_encode, void *fpn_base_void,

fpga_config *cfg;
cfg = (fpga_config *)malloc(sizeof(fpga_config));
memset(cfg, 0, sizeof(fpga_config));
cfg->operate_mode =
15; // call encrypt without obfucation function of FPGA to calculate
cfg->para_data_size = (para_length + data2_length) / 8;
Expand Down Expand Up @@ -633,6 +635,7 @@ void obf_modular_exponentiation(char *randoms, size_t random_bitlength, char *n,

fpga_config *cfg;
cfg = (fpga_config *)malloc(sizeof(fpga_config));
memset(cfg, 0, sizeof(fpga_config));
cfg->operate_mode = 1; // call modexp function of FPGA to calulate
cfg->para_data_size = (para_length + data2_length) / 8;
cfg->data2_size = 0;
Expand Down Expand Up @@ -723,6 +726,7 @@ void obf_modular_multiplication(char *pen_cipher, void *pen_base_void,

fpga_config *cfg;
cfg = (fpga_config *)malloc(sizeof(fpga_config));
memset(cfg, 0, sizeof(fpga_config));
cfg->operate_mode = 2; // call mulmod function of FPGA to calulate
cfg->para_data_size = para_length / 8;
cfg->data3_size = 0;
Expand Down Expand Up @@ -812,6 +816,7 @@ void decrypt(char *pen_cipher, void *pen_base_void, void *pen_exp_void,

fpga_config *cfg;
cfg = (fpga_config *)malloc(sizeof(fpga_config));
memset(cfg, 0, sizeof(fpga_config));
cfg->operate_mode = 10; // call decrypt function of FPGA to calulate
cfg->para_data_size = (para_length * 11) / 8;
cfg->data2_size = 0;
Expand Down Expand Up @@ -931,6 +936,7 @@ void pen_add_with_same_exp(char *pen1_cipher, void *pen1_base_void,

fpga_config *cfg;
cfg = (fpga_config *)malloc(sizeof(fpga_config));
memset(cfg, 0, sizeof(fpga_config));
cfg->operate_mode = 2;
cfg->para_data_size = para_length / 8;
cfg->para_bitlen = get_data_width(para_length);
Expand Down
16 changes: 4 additions & 12 deletions heu/library/algorithms/paillier_ipcl/utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,8 @@ void ShiftRightN(std::vector<uint32_t> &bn, int n) {
uint32_t shift;
uint32_t carry = 0;
uint32_t next_carry;
if (n > BN_DIGITS) {
num_digits = n / BN_DIGITS;
remainder = n % BN_DIGITS;
} else {
remainder = n;
}
num_digits = n / BN_DIGITS;
remainder = n % BN_DIGITS;
if (remainder > 0) {
int size = bn.size();
mask = ((uint32_t)1 << remainder) - (uint32_t)1;
Expand All @@ -143,12 +139,8 @@ void ShiftLeftN(std::vector<uint32_t> &bn, int n) {
uint32_t shift;
uint32_t carry = 0;
uint32_t next_carry;
if (n > BN_DIGITS) {
num_digits = n / BN_DIGITS;
remainder = n % BN_DIGITS;
} else {
remainder = n;
}
num_digits = n / BN_DIGITS;
remainder = n % BN_DIGITS;
if (remainder > 0) {
size_t size = bn.size();
mask = ((uint32_t)1 << remainder) - (uint32_t)1;
Expand Down
1 change: 1 addition & 0 deletions heu/pylib/numpy_binding/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ pybind_library(
name = "numpy_binding",
srcs = ["bind_numpy.cc"],
hdrs = ["bind_numpy.h"],
defines = ["PYBIND11_NO_ASSERT_GIL_HELD_INCREF_DECREF"],
deps = [
":extension_functions",
":infeed",
Expand Down
2 changes: 1 addition & 1 deletion heu/pylib/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
# limitations under the License.


__version__ = "0.6.0.dev20240529"
__version__ = "0.6.0.dev0"
26 changes: 26 additions & 0 deletions third_party/bazel_cpp/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")

Expand All @@ -23,6 +24,8 @@ def heu_cpp_deps():
_com_github_uscilab_cereal()
_com_github_nvlabs_cgbn()
_com_github_intel_ipp()
_yacl()
_rules_cuda()

def _bazel_skylib():
maybe(
Expand Down Expand Up @@ -128,3 +131,26 @@ def _com_github_intel_ipp():
"https://github.com/intel/ipp-crypto/archive/refs/tags/ippcp_2021.8.tar.gz",
],
)

def _yacl():
maybe(
http_archive,
name = "yacl",
urls = [
"https://github.com/secretflow/yacl/archive/refs/tags/0.4.5b1.tar.gz",
],
strip_prefix = "yacl-0.4.5b1",
sha256 = "28064053b9add0db8e1e8e648421a0579f1d3e7ee8a4bbd7bd5959cb59598088",
)

def _rules_cuda():
maybe(
http_archive,
name = "rules_cuda",
sha256 = "f62baee0150ac91f4cdfcb10df2be0d0e9b941d1d32c8cddf00b16b57bdb1540",
strip_prefix = "rules_cuda-17ca7f8c04cf746aa4c0a0c3722799278df7ca93",
urls = [
# Main branch as of 2023-1-07
"https://github.com/bazel-contrib/rules_cuda/archive/17ca7f8c04cf746aa4c0a0c3722799278df7ca93.tar.gz",
],
)

0 comments on commit 801aca7

Please sign in to comment.