From 86f31388289e3ecaad8a4d158273407072d33759 Mon Sep 17 00:00:00 2001 From: sh1k4ku Date: Wed, 11 Mar 2026 19:27:24 +0800 Subject: [PATCH 01/12] Add YPIR algorithm implementation - Add YPIR PIR scheme with SimplePIR and DoublePIR support - Add AES PRNG, HEXL NTT integration, and utility modules - Add Bazel build rules for YPIR and hexl dependency - Update Spiral algorithm (NTT, params, poly matrix, client/server) - Add integration tests and basic flow tests --- .vscode/settings.json | 83 + MODULE.bazel | 6 + MODULE.bazel.lock | 122 -- bazel/hexl.BUILD | 15 + bazel/psi.bzl | 2 +- psi/algorithm/spiral/arith/ntt.cc | 93 +- psi/algorithm/spiral/arith/ntt.h | 1 + psi/algorithm/spiral/params.cc | 20 + psi/algorithm/spiral/params.h | 22 +- psi/algorithm/spiral/poly_matrix.cc | 37 +- psi/algorithm/spiral/poly_matrix.h | 12 +- psi/algorithm/spiral/poly_matrix_utils.cc | 96 +- psi/algorithm/spiral/poly_matrix_utils.h | 17 +- psi/algorithm/spiral/spiral_client.cc | 62 +- psi/algorithm/spiral/spiral_client.h | 27 +- psi/algorithm/spiral/spiral_server.cc | 6 +- psi/algorithm/spiral/util.cc | 62 + psi/algorithm/spiral/util.h | 5 +- psi/algorithm/ypir/BUILD.bazel | 257 +++ psi/algorithm/ypir/aes_prng.cc | 98 ++ psi/algorithm/ypir/aes_prng.h | 51 + psi/algorithm/ypir/automorphism_test.cc | 96 + psi/algorithm/ypir/byhe_util_test.cc | 59 + psi/algorithm/ypir/client.cc | 279 +++ psi/algorithm/ypir/client.h | 29 + psi/algorithm/ypir/convolution.cc | 157 ++ psi/algorithm/ypir/convolution.h | 41 + psi/algorithm/ypir/fast_dot_product_test.cc | 106 ++ psi/algorithm/ypir/hexl.cc | 62 + psi/algorithm/ypir/hexl.h | 53 + psi/algorithm/ypir/integration_test.cc | 758 ++++++++ psi/algorithm/ypir/matmul.cpp | 1556 +++++++++++++++++ psi/algorithm/ypir/params.cc | 37 + psi/algorithm/ypir/params.h | 53 + psi/algorithm/ypir/rescale_test.cc | 58 + psi/algorithm/ypir/scale_k_test.cc | 38 + psi/algorithm/ypir/server.cc | 160 ++ psi/algorithm/ypir/server.h | 24 + psi/algorithm/ypir/server.rs | 1377 +++++++++++++++ .../ypir/simplepir_basic_flow_test.cc | 135 ++ psi/algorithm/ypir/types.h | 55 + psi/algorithm/ypir/util.cc | 1130 ++++++++++++ psi/algorithm/ypir/util.h | 128 ++ psi/algorithm/ypir/util_test.cc | 201 +++ psi/algorithm/ypir/ypir_basic_flow_test.cc | 138 ++ psi/algorithm/ypir/ypir_params.cc | 454 +++++ psi/algorithm/ypir/ypir_params.h | 155 ++ psi/algorithm/ypir/ypir_util.cc | 519 ++++++ psi/algorithm/ypir/ypir_util.h | 134 ++ 49 files changed, 8876 insertions(+), 210 deletions(-) create mode 100644 .vscode/settings.json create mode 100644 bazel/hexl.BUILD create mode 100644 psi/algorithm/ypir/BUILD.bazel create mode 100644 psi/algorithm/ypir/aes_prng.cc create mode 100644 psi/algorithm/ypir/aes_prng.h create mode 100644 psi/algorithm/ypir/automorphism_test.cc create mode 100644 psi/algorithm/ypir/byhe_util_test.cc create mode 100644 psi/algorithm/ypir/client.cc create mode 100644 psi/algorithm/ypir/client.h create mode 100644 psi/algorithm/ypir/convolution.cc create mode 100644 psi/algorithm/ypir/convolution.h create mode 100644 psi/algorithm/ypir/fast_dot_product_test.cc create mode 100644 psi/algorithm/ypir/hexl.cc create mode 100644 psi/algorithm/ypir/hexl.h create mode 100644 psi/algorithm/ypir/integration_test.cc create mode 100644 psi/algorithm/ypir/matmul.cpp create mode 100644 psi/algorithm/ypir/params.cc create mode 100644 psi/algorithm/ypir/params.h create mode 100644 psi/algorithm/ypir/rescale_test.cc create mode 100644 psi/algorithm/ypir/scale_k_test.cc create mode 100644 psi/algorithm/ypir/server.cc create mode 100644 psi/algorithm/ypir/server.h create mode 100644 psi/algorithm/ypir/server.rs create mode 100644 psi/algorithm/ypir/simplepir_basic_flow_test.cc create mode 100644 psi/algorithm/ypir/types.h create mode 100644 psi/algorithm/ypir/util.cc create mode 100644 psi/algorithm/ypir/util.h create mode 100644 psi/algorithm/ypir/util_test.cc create mode 100644 psi/algorithm/ypir/ypir_basic_flow_test.cc create mode 100644 psi/algorithm/ypir/ypir_params.cc create mode 100644 psi/algorithm/ypir/ypir_params.h create mode 100644 psi/algorithm/ypir/ypir_util.cc create mode 100644 psi/algorithm/ypir/ypir_util.h diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..e7081524 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,83 @@ +{ + "files.associations": { + "*.inc": "cpp", + "random": "cpp", + "algorithm": "cpp", + "ratio": "cpp", + "cmath": "cpp", + "cstdint": "cpp", + "valarray": "cpp", + "optional": "cpp", + "system_error": "cpp", + "array": "cpp", + "functional": "cpp", + "regex": "cpp", + "tuple": "cpp", + "type_traits": "cpp", + "utility": "cpp", + "variant": "cpp", + "charconv": "cpp", + "chrono": "cpp", + "format": "cpp", + "istream": "cpp", + "ostream": "cpp", + "span": "cpp", + "cctype": "cpp", + "clocale": "cpp", + "cstdarg": "cpp", + "cstddef": "cpp", + "cstdio": "cpp", + "cstdlib": "cpp", + "cstring": "cpp", + "ctime": "cpp", + "cwchar": "cpp", + "cwctype": "cpp", + "atomic": "cpp", + "bit": "cpp", + "bitset": "cpp", + "cinttypes": "cpp", + "compare": "cpp", + "concepts": "cpp", + "condition_variable": "cpp", + "deque": "cpp", + "list": "cpp", + "map": "cpp", + "set": "cpp", + "string": "cpp", + "unordered_map": "cpp", + "unordered_set": "cpp", + "vector": "cpp", + "exception": "cpp", + "iterator": "cpp", + "memory": "cpp", + "memory_resource": "cpp", + "numeric": "cpp", + "string_view": "cpp", + "fstream": "cpp", + "initializer_list": "cpp", + "iomanip": "cpp", + "iosfwd": "cpp", + "iostream": "cpp", + "limits": "cpp", + "mutex": "cpp", + "new": "cpp", + "numbers": "cpp", + "sstream": "cpp", + "stdexcept": "cpp", + "stop_token": "cpp", + "streambuf": "cpp", + "thread": "cpp", + "typeinfo": "cpp", + "any": "cpp", + "hash_map": "cpp", + "hash_set": "cpp", + "codecvt": "cpp", + "complex": "cpp", + "forward_list": "cpp", + "future": "cpp", + "semaphore": "cpp", + "shared_mutex": "cpp", + "source_location": "cpp", + "typeindex": "cpp" + } +} \ No newline at end of file diff --git a/MODULE.bazel b/MODULE.bazel index 78147e81..c4b3ca43 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -70,6 +70,12 @@ new_local_repository( path = "/opt/homebrew/opt/libomp/", ) +new_local_repository( + name = "hexl", + build_file = "//bazel:hexl.BUILD", + path = "/usr/local", +) + bazel_dep(name = "kuscia", version = "0.14.0b0") bazel_dep(name = "perfetto", version = "41.0") diff --git a/MODULE.bazel.lock b/MODULE.bazel.lock index 6196ea06..2b1e424d 100644 --- a/MODULE.bazel.lock +++ b/MODULE.bazel.lock @@ -910,128 +910,6 @@ }, "selectedYankedVersions": {}, "moduleExtensions": { - "//bazel:defs.bzl%non_module_dependencies": { - "general": { - "bzlTransitiveDigest": "NAC0+n0skvguFGiSWQSZMhbrQQVV+nNsrNIVDde/xQE=", - "usagesDigest": "89PlExpoF4wVcL+M7Z1YGe8ZyC3E1M5lGgLzpZSTyvE=", - "recordedFileInputs": {}, - "recordedDirentsInputs": {}, - "envVariables": {}, - "generatedRepoSpecs": { - "apsi": { - "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_archive", - "attributes": { - "sha256": "82c0f9329c79222675109d4a3682d204acd3ea9a724bcd98fa58eabe53851333", - "strip_prefix": "APSI-0.11.0", - "urls": [ - "https://github.com/microsoft/APSI/archive/refs/tags/v0.11.0.tar.gz" - ], - "build_file": "@@//bazel:microsoft_apsi.BUILD", - "patch_args": [ - "-p1" - ], - "patches": [ - "@@//bazel/patches:apsi.patch", - "@@//bazel/patches:apsi-fourq.patch" - ], - "patch_cmds": [ - "rm -rf common/apsi/fourq" - ] - } - }, - "kuku": { - "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_archive", - "attributes": { - "sha256": "96ed5fad82ea8c8a8bb82f6eaf0b5dce744c0c2566b4baa11d8f5443ad1f83b7", - "strip_prefix": "Kuku-2.1.0", - "type": "tar.gz", - "urls": [ - "https://github.com/microsoft/Kuku/archive/refs/tags/v2.1.0.tar.gz" - ], - "build_file": "@@//bazel:microsoft_kuku.BUILD" - } - }, - "com_google_flatbuffers": { - "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_archive", - "attributes": { - "sha256": "4157c5cacdb59737c5d627e47ac26b140e9ee28b1102f812b36068aab728c1ed", - "strip_prefix": "flatbuffers-24.3.25", - "urls": [ - "https://github.com/google/flatbuffers/archive/refs/tags/v24.3.25.tar.gz" - ], - "patch_cmds": [ - "rm grpc/BUILD.bazel", - "rm grpc/src/compiler/BUILD.bazel", - "rm src/BUILD.bazel" - ], - "build_file": "@@//bazel:flatbuffers.BUILD" - } - }, - "curve25519-donna": { - "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_archive", - "attributes": { - "strip_prefix": "curve25519-donna-2fe66b65ea1acb788024f40a3373b8b3e6f4bbb2", - "sha256": "ba57d538c241ad30ff85f49102ab2c8dd996148456ed238a8c319f263b7b149a", - "type": "tar.gz", - "build_file": "@@//bazel:curve25519-donna.BUILD", - "urls": [ - "https://github.com/floodyberry/curve25519-donna/archive/2fe66b65ea1acb788024f40a3373b8b3e6f4bbb2.tar.gz" - ] - } - }, - "com_github_zeromq_cppzmq": { - "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_archive", - "attributes": { - "build_file": "@@//bazel:cppzmq.BUILD", - "strip_prefix": "cppzmq-4.10.0", - "sha256": "c81c81bba8a7644c84932225f018b5088743a22999c6d82a2b5f5cd1e6942b74", - "type": ".tar.gz", - "urls": [ - "https://github.com/zeromq/cppzmq/archive/refs/tags/v4.10.0.tar.gz" - ] - } - }, - "com_github_zeromq_libzmq": { - "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_archive", - "attributes": { - "build_file": "@@//bazel:libzmq.BUILD", - "strip_prefix": "libzmq-4.3.5", - "sha256": "6c972d1e6a91a0ecd79c3236f04cf0126f2f4dfbbad407d72b4606a7ba93f9c6", - "type": ".tar.gz", - "urls": [ - "https://github.com/zeromq/libzmq/archive/refs/tags/v4.3.5.tar.gz" - ] - } - }, - "com_github_open_source_parsers_jsoncpp": { - "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_archive", - "attributes": { - "build_file": "@@//bazel:jsoncpp.BUILD", - "strip_prefix": "jsoncpp-1.9.6", - "sha256": "f93b6dd7ce796b13d02c108bc9f79812245a82e577581c4c9aabe57075c90ea2", - "type": ".tar.gz", - "urls": [ - "https://github.com/open-source-parsers/jsoncpp/archive/refs/tags/1.9.6.tar.gz" - ] - } - } - }, - "recordedRepoMappingEntries": [ - [ - "", - "bazel_tools", - "bazel_tools" - ] - ] - } - }, "@@apple_support~//crosstool:setup.bzl%apple_cc_configure_extension": { "general": { "bzlTransitiveDigest": "7ii+gFxWSxHhQPrBxfMEHhtrGvHmBTvsh+KOyGunP/s=", diff --git a/bazel/hexl.BUILD b/bazel/hexl.BUILD new file mode 100644 index 00000000..faf6aa63 --- /dev/null +++ b/bazel/hexl.BUILD @@ -0,0 +1,15 @@ +load("@rules_cc//cc:defs.bzl", "cc_import", "cc_library") + +package(default_visibility = ["//visibility:public"]) + +cc_import( + name = "hexl_lib", + static_library = "lib/libhexl.a", +) + +cc_library( + name = "hexl", + hdrs = glob(["include/hexl/**/*.h", "include/hexl/**/*.hpp"]), + includes = ["include"], + deps = [":hexl_lib"], +) diff --git a/bazel/psi.bzl b/bazel/psi.bzl index 2ebadb70..e7663364 100644 --- a/bazel/psi.bzl +++ b/bazel/psi.bzl @@ -26,7 +26,7 @@ WARNING_FLAGS = [ ] DEBUG_FLAGS = ["-O0", "-g", "-DSPDLOG_ACTIVE_LEVEL=1"] RELEASE_FLAGS = ["-O2"] -FAST_FLAGS = ["-O1"] +FAST_FLAGS = ["-O3", "-march=native"] def _psi_copts(): return select({ diff --git a/psi/algorithm/spiral/arith/ntt.cc b/psi/algorithm/spiral/arith/ntt.cc index eb2e693e..95f04efb 100644 --- a/psi/algorithm/spiral/arith/ntt.cc +++ b/psi/algorithm/spiral/arith/ntt.cc @@ -77,15 +77,14 @@ void NttForward(const Params& params, absl::Span operand_overall) { curr_x + (static_cast(two_times_modulus_small) - q_new); } } - - // Update the operand with modulus constraints - for (std::size_t i = 0; i < n; ++i) { - operand[i] -= - static_cast(operand[i] >= two_times_modulus_small) * - two_times_modulus_small; - operand[i] -= static_cast(operand[i] >= modulus_small) * - modulus_small; - } + } + // Update the operand with modulus constraints + for (std::size_t i = 0; i < n; ++i) { + operand[i] -= + static_cast(operand[i] >= two_times_modulus_small) * + two_times_modulus_small; + operand[i] -= static_cast(operand[i] >= modulus_small) * + modulus_small; } } } @@ -99,6 +98,7 @@ void NttForward(const Params& params, absl::Span operand_overall) { std::size_t log_n = params.PolyLenLog2(); std::size_t n = static_cast(1) << log_n; + YACL_ENFORCE(n >= 4, "PolyLen must be >= 4 for AVX2 impl"); YACL_ENFORCE(operand_overall.size() >= params.CrtCount() * n); for (std::size_t coeff_mod = 0; coeff_mod < params.CrtCount(); ++coeff_mod) { @@ -116,11 +116,8 @@ void NttForward(const Params& params, absl::Span operand_overall) { for (std::size_t i = 0; i < m; ++i) { uint64_t w = forward_table[m + i]; uint64_t w_prime = forward_table_prime[m + i]; - auto op = operand.subspan(i * (2 * t), 2 * t); - SPDLOG_DEBUG("Processing coeff_mod: {}, m: {}, i: {}", coeff_mod, m, i); - if (t < 4) { for (std::size_t j = 0; j < t; ++j) { uint32_t x = static_cast(op[j]); @@ -129,6 +126,7 @@ void NttForward(const Params& params, absl::Span operand_overall) { std::uint32_t curr_x = x - (two_times_modulus_small * static_cast(x >= two_times_modulus_small)); + std::uint64_t q_tmp = (static_cast(y) * static_cast(w_prime)) >> 32; @@ -143,46 +141,36 @@ void NttForward(const Params& params, absl::Span operand_overall) { } } else { for (std::size_t j = 0; j < t; j += 4) { - if (j + 4 > t) break; // Ensure we do not exceed bounds - __m256i* p_x = reinterpret_cast<__m256i*>(&op[j]); __m256i* p_y = reinterpret_cast<__m256i*>(&op[j + t]); __m256i x = _mm256_loadu_si256(p_x); __m256i y = _mm256_loadu_si256(p_y); - __m256i cmp_val = _mm256_set1_epi64x( + __m256i threshold_2q = _mm256_set1_epi64x( + static_cast(two_times_modulus_small - 1)); + __m256i val_2q = _mm256_set1_epi64x( static_cast(two_times_modulus_small)); - // reuse this variable to reduce variable num - // gt_mask - __m256i tmp1 = _mm256_cmpgt_epi64(x, cmp_val); - // __m256i to_subtract = _mm256_and_si256(gt_mask_reused, cmp_val); - tmp1 = _mm256_and_si256(tmp1, cmp_val); - __m256i curr_x = _mm256_sub_epi64(x, tmp1); + __m256i gt_mask = _mm256_cmpgt_epi64(x, threshold_2q); + __m256i to_subtract = _mm256_and_si256(gt_mask, val_2q); + __m256i curr_x = _mm256_sub_epi64(x, to_subtract); - // __m256i w_prime_vec = - // _mm256_set1_epi64x(static_cast(w_prime)); - tmp1 = _mm256_set1_epi64x(static_cast(w_prime)); - // __m256i product = _mm256_mul_epu32(y, tmp1); - tmp1 = _mm256_mul_epu32(y, tmp1); - // __m256i q_val = _mm256_srli_epi64(tmp1, 32); - tmp1 = _mm256_srli_epi64(tmp1, 32); + __m256i w_prime_vec = + _mm256_set1_epi64x(static_cast(w_prime)); + __m256i product = _mm256_mul_epu32(y, w_prime_vec); + __m256i q_val = _mm256_srli_epi64(product, 32); - // __m256i w_vec = _mm256_set1_epi64x(static_cast(w)); - __m256i tmp2 = _mm256_set1_epi64x(static_cast(w)); - // __m256i w_times_y = _mm256_mul_epu32(y, w_vec); - // __m256i w_times_y = _mm256_mul_epu32(y, tmp2); - tmp2 = _mm256_mul_epu32(y, tmp2); + __m256i w_vec = _mm256_set1_epi64x(static_cast(w)); + __m256i w_times_y = _mm256_mul_epu32(y, w_vec); __m256i modulus_small_vec = _mm256_set1_epi64x(static_cast(modulus_small)); - // __m256i q_scaled = _mm256_mul_epu32(q_val, modulus_small_vec); - __m256i q_scaled = _mm256_mul_epu32(tmp1, modulus_small_vec); - __m256i q_final = _mm256_sub_epi64(tmp2, q_scaled); + __m256i q_scaled = _mm256_mul_epu32(q_val, modulus_small_vec); + __m256i q_final = _mm256_sub_epi64(w_times_y, q_scaled); __m256i new_x = _mm256_add_epi64(curr_x, q_final); - __m256i q_final_inverted = _mm256_sub_epi64(cmp_val, q_final); + __m256i q_final_inverted = _mm256_sub_epi64(val_2q, q_final); __m256i new_y = _mm256_add_epi64(curr_x, q_final_inverted); _mm256_storeu_si256(p_x, new_x); @@ -193,21 +181,28 @@ void NttForward(const Params& params, absl::Span operand_overall) { } for (std::size_t i = 0; i < n; i += 4) { - if (i + 4 > n) break; // Ensure we do not exceed bounds __m256i* p_x = reinterpret_cast<__m256i*>(&operand[i]); + __m256i x = _mm256_loadu_si256(p_x); - __m256i cmp_val1 = + // Check >= 2q + __m256i threshold_2q = + _mm256_set1_epi64x(static_cast(two_times_modulus_small - 1)); + __m256i val_2q = _mm256_set1_epi64x(static_cast(two_times_modulus_small)); - __m256i x = _mm256_loadu_si256(p_x); - __m256i gt_mask = _mm256_cmpgt_epi64(x, cmp_val1); - __m256i to_subtract = _mm256_and_si256(gt_mask, cmp_val1); + + __m256i gt_mask = _mm256_cmpgt_epi64(x, threshold_2q); + __m256i to_subtract = _mm256_and_si256(gt_mask, val_2q); x = _mm256_sub_epi64(x, to_subtract); - __m256i cmp_val2 = - _mm256_set1_epi64x(static_cast(modulus_small)); - gt_mask = _mm256_cmpgt_epi64(x, cmp_val2); - to_subtract = _mm256_and_si256(gt_mask, cmp_val2); + // Check >= q + __m256i threshold_q = + _mm256_set1_epi64x(static_cast(modulus_small - 1)); + __m256i val_q = _mm256_set1_epi64x(static_cast(modulus_small)); + + gt_mask = _mm256_cmpgt_epi64(x, threshold_q); + to_subtract = _mm256_and_si256(gt_mask, val_q); x = _mm256_sub_epi64(x, to_subtract); + _mm256_storeu_si256(p_x, x); } } @@ -265,7 +260,7 @@ void NttInverse(const Params& params, absl::Span operand_overall) { #else void NttInverse(const Params& params, absl::Span operand_overall) { - SPDLOG_DEBUG("use AVX2 NttInverse"); + SPDLOG_DEBUG("using AVX2 NttInverse"); for (size_t coeff_mod = 0; coeff_mod < params.CrtCount(); ++coeff_mod) { size_t n = params.PolyLen(); @@ -295,7 +290,9 @@ void NttInverse(const Params& params, absl::Span operand_overall) { uint64_t y = op[t + j]; uint64_t t_tmp = two_times_modulus - y + x; - uint64_t curr_x = x + y - (two_times_modulus * ((x << 1) >= t_tmp)); + uint64_t curr_x = + x + y - + (two_times_modulus * static_cast((x << 1) >= t_tmp)); uint64_t h_tmp = (t_tmp * w_prime) >> 32; uint64_t res_x = (curr_x + (modulus * (t_tmp & 1))) >> 1; diff --git a/psi/algorithm/spiral/arith/ntt.h b/psi/algorithm/spiral/arith/ntt.h index 65109b64..ac682d16 100644 --- a/psi/algorithm/spiral/arith/ntt.h +++ b/psi/algorithm/spiral/arith/ntt.h @@ -23,6 +23,7 @@ namespace psi::spiral::arith { void NttForward(const Params& params, absl::Span operand_overall); + void NttInverse(const Params& params, absl::Span operand_overall); } // namespace psi::spiral::arith diff --git a/psi/algorithm/spiral/params.cc b/psi/algorithm/spiral/params.cc index ce417e68..4dd986b0 100644 --- a/psi/algorithm/spiral/params.cc +++ b/psi/algorithm/spiral/params.cc @@ -163,6 +163,7 @@ std::uint64_t Params::CrtCompose2(std::uint64_t x, std::uint64_t y) const { crt_params_.modulus_.value()); } +// TODO: optimize memory copy span? std::uint64_t Params::CrtCompose(const std::vector& a, std::size_t idx) const { if (crt_params_.crt_count_ == 1) { @@ -192,4 +193,23 @@ std::uint64_t Params::CrtCompose(const std::vector& a, return ss.str(); } +size_t Params::Rho() const { + const size_t q2_bits = 28; + const size_t lwe_q_prime_bits = q2_bits; + + const size_t pt_bits = PtModulusBitLen(); + const double blowup_factor = + static_cast(lwe_q_prime_bits) / static_cast(pt_bits); + const double num_polys_needed = + (blowup_factor * static_cast(1024 + 1)) / + static_cast(PolyLen()); + + const size_t smaller_params_db_dim_2 = + static_cast(std::ceil(std::log2(num_polys_needed))); + + const size_t rho = 1ULL << smaller_params_db_dim_2; + + return rho; +} + } // namespace psi::spiral diff --git a/psi/algorithm/spiral/params.h b/psi/algorithm/spiral/params.h index 2ab57bd8..c3cddda9 100644 --- a/psi/algorithm/spiral/params.h +++ b/psi/algorithm/spiral/params.h @@ -276,9 +276,9 @@ class Params { [[nodiscard]] size_t CrtCount() const { return crt_params_.crt_count_; } - [[nodiscard]] uint64_t DbDim2() const { return query_params_.db_dim2_; } + [[nodiscard]] size_t DbDim2() const { return query_params_.db_dim2_; } - [[nodiscard]] uint64_t DbDim1() const { return query_params_.db_dim1_; } + [[nodiscard]] size_t DbDim1() const { return query_params_.db_dim1_; } [[nodiscard]] uint64_t Modulus() const { return crt_params_.modulus_.value(); @@ -310,7 +310,15 @@ class Params { std::uint64_t CrtCompose(const std::vector& a, std::size_t idx) const; + uint64_t GetQPrime1() const { return 1 << 20; } + uint64_t GetQPrime2() const { + if (Q2Bits() == ModulusLog2()) { + return Modulus(); + } else { + return kQ2Values[Q2Bits()]; + } + } // other util methods [[nodiscard]] std::string ToString(); @@ -385,11 +393,17 @@ class Params { ParamsId Id() const { return id_; } - private: - void ComputeId(); + size_t DbRowsPadded() const { + return 1 << (query_params_.db_dim1_ + poly_len_log2_); + } + + size_t Rho() const; void SetDbDim1(size_t v1) { query_params_.db_dim1_ = v1; } void SetDbDim2(size_t v2) { query_params_.db_dim2_ = v2; } + private: + void ComputeId(); + // d in R = Z[x]/x^d + 1 std::size_t poly_len_ = 0; diff --git a/psi/algorithm/spiral/poly_matrix.cc b/psi/algorithm/spiral/poly_matrix.cc index 07079af6..1b0cfe1b 100644 --- a/psi/algorithm/spiral/poly_matrix.cc +++ b/psi/algorithm/spiral/poly_matrix.cc @@ -225,7 +225,7 @@ PolyMatrixRaw PolyMatrixRaw::SingleValue(size_t poly_len, uint64_t value) { PolyMatrixRaw PolyMatrixRaw::Random(const Params& params, size_t rows, size_t cols) { - yacl::crypto::Prg prg(yacl::crypto::SecureRandU128()); + yacl::crypto::Prg prg(yacl::MakeUint128(0, 20001)); return RandomPrg(params, rows, cols, prg); } @@ -238,7 +238,38 @@ PolyMatrixRaw PolyMatrixRaw::RandomPrg(const Params& params, size_t rows, return out; } -//--------------- PolyMatrixNtt +PolyMatrixRaw PolyMatrixRaw::Recover(const Params& params, uint64_t q_1, + uint64_t q_2, + const std::vector& ciphertext) { + const size_t q_1_bits = + static_cast(std::ceil(std::log2(static_cast(q_2)))); + const size_t q_2_bits = + static_cast(std::ceil(std::log2(static_cast(q_1)))); + + const size_t total_sz_bits = (q_1_bits + q_2_bits) * params.PolyLen(); + const size_t total_sz_bytes = (total_sz_bits + 7) / 8; + assert(ciphertext.size() == total_sz_bytes && "Ciphertext size mismatch"); + + PolyMatrixRaw res = PolyMatrixRaw::Zero(params.PolyLen(), 2, 1); + size_t bit_offs = 0; + + uint64_t* row_0_ptr = res.Data().data(); + uint64_t* row_1_ptr = res.Data().data() + params.PolyLen(); + + for (size_t z = 0; z < params.PolyLen(); ++z) { + uint64_t val = util::ReadArbitraryBits(ciphertext, bit_offs, q_1_bits); + row_0_ptr[z] = arith::Rescale(val, q_2, params.Modulus()); + bit_offs += q_1_bits; + } + + for (size_t z = 0; z < params.PolyLen(); ++z) { + uint64_t val = util::ReadArbitraryBits(ciphertext, bit_offs, q_2_bits); + row_1_ptr[z] = arith::Rescale(val, q_1, params.Modulus()); + bit_offs += q_2_bits; + } + + return res; +} void PolyMatrixNtt::CopyInto(const PolyMatrixNtt& p, size_t target_row, size_t target_col) { @@ -299,7 +330,7 @@ absl::Span PolyMatrixNtt::Poly(size_t r, size_t c) const { PolyMatrixNtt PolyMatrixNtt::Random(const Params& params, size_t rows, size_t cols) { - yacl::crypto::Prg prg(yacl::crypto::SecureRandU128()); + yacl::crypto::Prg prg(yacl::MakeUint128(0, 20002)); return RandomPrg(params, rows, cols, prg); } diff --git a/psi/algorithm/spiral/poly_matrix.h b/psi/algorithm/spiral/poly_matrix.h index 1314616e..114f79c9 100644 --- a/psi/algorithm/spiral/poly_matrix.h +++ b/psi/algorithm/spiral/poly_matrix.h @@ -170,6 +170,8 @@ class PolyMatrixRaw { static PolyMatrixRaw RandomPrg(const Params& params, size_t rows, size_t cols, yacl::crypto::Prg& prg); + static PolyMatrixRaw Recover(const Params& params, uint64_t q_1, uint64_t q_2, + const std::vector& ciphertext); private: size_t poly_len_ = 0; @@ -339,7 +341,7 @@ void AddPoly(const Params& params, absl::Span res, void AddPolyInto(const Params& params, absl::Span res, absl::Span a); // res = -a -void InvertPoly(const Params& params, absl::Span res, +void NegatePoly(const Params& params, absl::Span res, absl::Span a); void AutomotphPoly(const Params& params, absl::Span res, @@ -369,6 +371,8 @@ void Multiply(const Params& params, PolyMatrixNtt& res, const PolyMatrixNtt& a, PolyMatrixNtt Multiply(const Params& params, const PolyMatrixNtt& a, const PolyMatrixNtt& b); +void MultiplyNoReduce(PolyMatrixNtt& res, const PolyMatrixNtt& a, + const PolyMatrixNtt& b, size_t start_inner_dim); void Automorphism(const Params& params, PolyMatrixRaw& res, const PolyMatrixRaw& a, size_t t); @@ -385,11 +389,13 @@ void AddInto(const Params& params, PolyMatrixNtt& res, const PolyMatrixNtt& a); void AddIntoAt(const Params& params, PolyMatrixNtt& res, const PolyMatrixNtt& a, size_t t_row, size_t t_col); -void Invert(const Params& params, PolyMatrixRaw& res, const PolyMatrixRaw& a); -PolyMatrixRaw Invert(const Params& params, const PolyMatrixRaw& a); +void Negate(const Params& params, PolyMatrixRaw& res, const PolyMatrixRaw& a); +PolyMatrixRaw Negate(const Params& params, const PolyMatrixRaw& a); void FromNtt(const Params& params, PolyMatrixRaw& out, const PolyMatrixNtt& in); PolyMatrixRaw FromNtt(const Params& params, const PolyMatrixNtt& in); +void FromNttScratch(const Params& params, PolyMatrixRaw& out, + absl::Span scratch, const PolyMatrixNtt& in); void ToNtt(const Params& params, PolyMatrixNtt& out, const PolyMatrixRaw& in); PolyMatrixNtt ToNtt(const Params& params, const PolyMatrixRaw& in); diff --git a/psi/algorithm/spiral/poly_matrix_utils.cc b/psi/algorithm/spiral/poly_matrix_utils.cc index 46154b6f..ffb785b7 100644 --- a/psi/algorithm/spiral/poly_matrix_utils.cc +++ b/psi/algorithm/spiral/poly_matrix_utils.cc @@ -121,15 +121,15 @@ void AddPolyInto(const Params& params, absl::Span res, } } -void InvertPoly(const Params& params, absl::Span res, +void NegatePoly(const Params& params, absl::Span res, absl::Span a) { for (size_t i = 0; i < params.PolyLen(); ++i) { res[i] = params.Modulus() - a[i]; } } -void AutomotphPoly(const Params& params, absl::Span res, - absl::Span a, size_t t) { +void AutomorphismPoly(const Params& params, absl::Span res, + absl::Span a, size_t t) { auto poly_len = params.PolyLen(); for (size_t i = 0; i < poly_len; ++i) { uint64_t num = (i * t) / poly_len; @@ -142,6 +142,32 @@ void AutomotphPoly(const Params& params, absl::Span res, } } +void AutomorphismPolyUncrtd(const Params& params, absl::Span res, + absl::Span a, size_t t) { + size_t poly_len = params.PolyLen(); + size_t crt_count = params.CrtCount(); + for (size_t m = 0; m < crt_count; ++m) { + size_t offset = m * poly_len; + auto a_chunk = a.subspan(offset, poly_len); + auto res_chunk = res.subspan(offset, poly_len); + uint64_t current_modulus = params.Moduli(m); + for (size_t i = 0; i < poly_len; ++i) { + size_t num = (i * t) / poly_len; + size_t rem = (i * t) % poly_len; + + if (num % 2 == 0) { + res_chunk[rem] = a_chunk[i]; + } else { + if (a_chunk[i] == 0) { + res_chunk[rem] = 0; + } else { + res_chunk[rem] = current_modulus - a_chunk[i]; + } + } + } + } +} + void ReduceCopy(const Params& params, absl::Span res, absl::Span in) { for (size_t i = 0; i < params.CrtCount(); ++i) { @@ -250,7 +276,7 @@ void Automorphism(const Params& params, PolyMatrixRaw& res, for (size_t j = 0; j < a.Cols(); ++j) { auto poly_a = a.Poly(i, j); auto poly_res = res.Poly(i, j); - AutomotphPoly(params, poly_res, poly_a, t); + AutomorphismPoly(params, poly_res, poly_a, t); } } } @@ -320,7 +346,7 @@ void AddIntoAt(const Params& params, PolyMatrixNtt& res, const PolyMatrixNtt& a, } } -void Invert(const Params& params, PolyMatrixRaw& res, const PolyMatrixRaw& a) { +void Negate(const Params& params, PolyMatrixRaw& res, const PolyMatrixRaw& a) { WEAK_ENFORCE(res.Rows() == a.Rows()); WEAK_ENFORCE(res.Cols() == a.Cols()); @@ -328,18 +354,18 @@ void Invert(const Params& params, PolyMatrixRaw& res, const PolyMatrixRaw& a) { for (size_t j = 0; j < a.Cols(); ++j) { auto res_poly = res.Poly(i, j); auto a_poly = a.Poly(i, j); - InvertPoly(params, res_poly, a_poly); + NegatePoly(params, res_poly, a_poly); } } } -PolyMatrixRaw Invert(const Params& params, const PolyMatrixRaw& a) { +PolyMatrixRaw Negate(const Params& params, const PolyMatrixRaw& a) { PolyMatrixRaw res(params.PolyLen(), a.Rows(), a.Cols()); for (size_t i = 0; i < a.Rows(); ++i) { for (size_t j = 0; j < a.Cols(); ++j) { auto res_poly = res.Poly(i, j); auto a_poly = a.Poly(i, j); - InvertPoly(params, res_poly, a_poly); + NegatePoly(params, res_poly, a_poly); } } return res; @@ -375,6 +401,34 @@ PolyMatrixRaw FromNtt(const Params& params, const PolyMatrixNtt& in) { return res; } +void FromNttScratch(const Params& params, PolyMatrixRaw& out, + absl::Span scratch, const PolyMatrixNtt& in) { + YACL_ENFORCE(in.Rows() == 2, "in rows must be 2, got {}", in.Rows()); + YACL_ENFORCE(in.Cols() == 1, "in cols must be 1, got {}", in.Cols()); + + size_t poly_size = in.Poly(0, 0).size(); + YACL_ENFORCE(scratch.size() >= poly_size, "scratch size too small: {} < {}", + scratch.size(), poly_size); + + for (size_t r = 0; r < in.Rows(); ++r) { + size_t c = 0; + + auto in_poly = in.Poly(r, c); + auto scratch_sub = scratch.subspan(0, poly_size); + std::copy(in_poly.begin(), in_poly.end(), scratch_sub.begin()); + + arith::NttInverse(params, scratch_sub); + + if (r == 0) { + size_t raw_poly_idx = out.PolyStartIndex(r, c); + std::vector temp_vec(scratch_sub.begin(), scratch_sub.end()); + for (size_t i = 0; i < params.PolyLen(); ++i) { + out.Data()[raw_poly_idx + i] = params.CrtCompose(temp_vec, i); + } + } + } +} + void ToNtt(const Params& params, PolyMatrixNtt& out, const PolyMatrixRaw& in) { for (size_t r = 0; r < out.Rows(); ++r) { for (size_t c = 0; c < out.Cols(); ++c) { @@ -456,6 +510,32 @@ PolyMatrixNtt Multiply(const Params& params, const PolyMatrixNtt& a, return res; } +void MultiplyNoReduce(PolyMatrixNtt& res, const PolyMatrixNtt& a, + const PolyMatrixNtt& b, size_t start_inner_dim) { + WEAK_ENFORCE(res.Rows() == a.Rows(), "Row mismatch: res={}, a={}", res.Rows(), + a.Rows()); + WEAK_ENFORCE(res.Cols() == b.Cols(), "Col mismatch: res={}, b={}", res.Cols(), + b.Cols()); + WEAK_ENFORCE(a.Cols() == b.Rows(), "Inner dim mismatch: a.cols={}, b.rows={}", + a.Cols(), b.Rows()); + + for (size_t i = 0; i < a.Rows(); ++i) { + for (size_t j = 0; j < b.Cols(); ++j) { + auto res_poly = res.Poly(i, j); + for (size_t k = start_inner_dim; k < a.Cols(); ++k) { + auto a_poly = a.Poly(i, k); + auto b_poly = b.Poly(k, j); + + size_t total_len = res_poly.size(); + + for (size_t z = 0; z < total_len; ++z) { + res_poly[z] += a_poly[z] * b_poly[z]; + } + } + } + } +} + PolyMatrixRaw MatrixWithIdentity(const PolyMatrixRaw& p) { WEAK_ENFORCE(p.Cols() == 1U); diff --git a/psi/algorithm/spiral/poly_matrix_utils.h b/psi/algorithm/spiral/poly_matrix_utils.h index 5910c59a..4f16103e 100644 --- a/psi/algorithm/spiral/poly_matrix_utils.h +++ b/psi/algorithm/spiral/poly_matrix_utils.h @@ -45,11 +45,13 @@ void AddPoly(const Params& params, absl::Span res, void AddPolyInto(const Params& params, absl::Span res, absl::Span a); // res = -a -void InvertPoly(const Params& params, absl::Span res, +void NegatePoly(const Params& params, absl::Span res, absl::Span a); -void AutomotphPoly(const Params& params, absl::Span res, - absl::Span a, size_t t); +void AutomorphismPoly(const Params& params, absl::Span res, + absl::Span a, size_t t); +void AutomorphismPolyUncrtd(const Params& params, absl::Span res, + absl::Span a, size_t t); // in is a PolyRaw, res is a RNS void ReduceCopy(const Params& params, absl::Span res, @@ -83,6 +85,9 @@ void Multiply(const Params& params, PolyMatrixNtt& res, const PolyMatrixNtt& a, PolyMatrixNtt Multiply(const Params& params, const PolyMatrixNtt& a, const PolyMatrixNtt& b); +void MultiplyNoReduce(PolyMatrixNtt& res, const PolyMatrixNtt& a, + const PolyMatrixNtt& b, size_t start_inner_dim); + void Automorphism(const Params& params, PolyMatrixRaw& res, const PolyMatrixRaw& a, size_t t); PolyMatrixRaw Automorphism(const Params& params, const PolyMatrixRaw& a, @@ -98,11 +103,13 @@ void AddInto(const Params& params, PolyMatrixNtt& res, const PolyMatrixNtt& a); void AddIntoAt(const Params& params, PolyMatrixNtt& res, const PolyMatrixNtt& a, size_t t_row, size_t t_col); -void Invert(const Params& params, PolyMatrixRaw& res, const PolyMatrixRaw& a); -PolyMatrixRaw Invert(const Params& params, const PolyMatrixRaw& a); +void Negate(const Params& params, PolyMatrixRaw& res, const PolyMatrixRaw& a); +PolyMatrixRaw Negate(const Params& params, const PolyMatrixRaw& a); void FromNtt(const Params& params, PolyMatrixRaw& out, const PolyMatrixNtt& in); PolyMatrixRaw FromNtt(const Params& params, const PolyMatrixNtt& in); +void FromNttScratch(const Params& params, PolyMatrixRaw& out, + absl::Span scratch, const PolyMatrixNtt& in); void ToNtt(const Params& params, PolyMatrixNtt& out, const PolyMatrixRaw& in); PolyMatrixNtt ToNtt(const Params& params, const PolyMatrixRaw& in); diff --git a/psi/algorithm/spiral/spiral_client.cc b/psi/algorithm/spiral/spiral_client.cc index 383ed9f2..c4278cc2 100644 --- a/psi/algorithm/spiral/spiral_client.cc +++ b/psi/algorithm/spiral/spiral_client.cc @@ -20,6 +20,7 @@ #include "yacl/utils/parallel.h" #include "psi/algorithm/pir_interface/pir_db.h" +#include "psi/algorithm/spiral/arith/arith.h" #include "psi/algorithm/spiral/arith/ntt.h" #include "psi/algorithm/spiral/common.h" #include "psi/algorithm/spiral/gadget.h" @@ -115,8 +116,8 @@ void SpiralClient::Init() { PolyMatrixRaw::Zero(params_.PolyLen(), sk_regev_rows, sk_regev_cols); dg_ = DiscreteGaussian(params_.NoiseWidth()); - // Gen secret key for SpiralClient - GenSecretKeys(); + // Note: Secret keys are NOT generated here anymore. + // Constructors must call GenSecretKeys() explicitly. } PolyMatrixRaw SpiralClient::GetFreshGswPublicKey( @@ -128,7 +129,7 @@ PolyMatrixRaw SpiralClient::GetFreshGswPublicKey( auto a_ntt = ToNtt(params_, a); auto e = Noise(params_, n, m, dg_, rng); auto e_ntt = ToNtt(params_, e); - auto a_inv = Invert(params_, a); + auto a_inv = Negate(params_, a); auto sk_gsw_ntt = ToNtt(params_, sk_gsw_); auto b_p = Multiply(params_, sk_gsw_ntt, a_ntt); auto b = Add(params_, e_ntt, b_p); @@ -142,7 +143,7 @@ PolyMatrixNtt SpiralClient::GetRegevSample( yacl::crypto::Prg& rng_pub) const { auto a = PolyMatrixRaw::RandomPrg(params_, 1, 1, rng_pub); auto a_ntt = ToNtt(params_, a); - auto a_inv = ToNtt(params_, Invert(params_, a)); + auto a_inv = ToNtt(params_, Negate(params_, a)); auto e = Noise(params_, 1, 1, dg_, rng); auto e_ntt = ToNtt(params_, e); @@ -156,6 +157,30 @@ PolyMatrixNtt SpiralClient::GetRegevSample( return p; } +PolyMatrixNtt SpiralClient::GetScaledRegevSample( + yacl::crypto::Prg& rng, yacl::crypto::Prg& rng_pub, + uint64_t scale) const { + auto a = PolyMatrixRaw::RandomPrg(params_, 1, 1, rng_pub); + auto a_ntt = ToNtt(params_, a); + auto a_inv = ToNtt(params_, Negate(params_, a)); + auto e = Noise(params_, 1, 1, dg_, rng); + + for (size_t i = 0; i < params_.PolyLen(); ++i) { + e.Data()[i] = arith::MultiplyUintMod(e.Data()[i], scale, params_.Modulus()); + } + + auto e_ntt = ToNtt(params_, e); + auto sk_reg_ntt = ToNtt(params_, sk_reg_); + auto b_p = Multiply(params_, sk_reg_ntt, a_ntt); + auto b = Add(params_, e_ntt, b_p); + + auto p = PolyMatrixNtt::Zero(params_.CrtCount(), params_.PolyLen(), 2, 1); + p.CopyInto(a_inv, 0, 0); + p.CopyInto(b, 1, 0); + + return p; +} + PolyMatrixNtt SpiralClient::GetFreshRegevPublicKey( size_t m, yacl::crypto::Prg& rng, yacl::crypto::Prg& rng_pub) const { @@ -166,6 +191,16 @@ PolyMatrixNtt SpiralClient::GetFreshRegevPublicKey( return p; } +PolyMatrixNtt SpiralClient::GetFreshScaledRegevPublicKey( + size_t m, yacl::crypto::Prg& rng, + yacl::crypto::Prg& rng_pub, uint64_t scale) const { + auto p = PolyMatrixNtt::Zero(params_.CrtCount(), params_.PolyLen(), 2, m); + for (size_t i = 0; i < m; ++i) { + p.CopyInto(GetScaledRegevSample(rng, rng_pub, scale), 0, i); + } + return p; +} + PolyMatrixNtt SpiralClient::EncryptMatrixGsw( PolyMatrixNtt& ag, yacl::crypto::Prg& rng, yacl::crypto::Prg& rng_pub) const { @@ -187,6 +222,15 @@ PolyMatrixNtt SpiralClient::EncryptMatrixRegev( return Add(params_, p, a.PadTop(1)); } +PolyMatrixNtt SpiralClient::EncryptMatrixScaledRegev( + PolyMatrixNtt& a, yacl::crypto::Prg& rng, + yacl::crypto::Prg& rng_pub, uint64_t scale) const { + YACL_ENFORCE(sk_inited_, "Secret Key must be inited"); + auto m = a.Cols(); + auto p = GetFreshScaledRegevPublicKey(m, rng, rng_pub, scale); + return Add(params_, p, a.PadTop(1)); +} + void SpiralClient::GenSecretKeys(yacl::crypto::Prg& rng) { GenTernaryMatrix(params_, sk_gsw_, kHammingWeight, rng); GenTernaryMatrix(params_, sk_reg_, kHammingWeight, rng); @@ -221,9 +265,9 @@ PublicKeys SpiralClient::GenPublicKeys() const { auto sk_gsw_ntt = ToNtt(params_, sk_gsw_); PublicKeys pp; - uint128_t seed = yacl::crypto::SecureRandU128(); + uint128_t seed = yacl::MakeUint128(0, 10001); yacl::crypto::Prg rng(seed); - uint128_t pub_seed = yacl::crypto::SecureRandU128(); + uint128_t pub_seed = yacl::MakeUint128(0, 10002); yacl::crypto::Prg rng_pub(pub_seed); // params for packing @@ -290,12 +334,10 @@ SpiralQuery SpiralClient::GenQueryInternal(size_t pt_idx_target) const { uint64_t modulus_cr0 = params_.BarrettCr0Modulus(); uint64_t modulus_cr1 = params_.BarrettCr1Modulus(); - yacl::crypto::Prg rng(yacl::crypto::SecureRandU128()); + yacl::crypto::Prg rng(yacl::MakeUint128(0, 10003)); // a empty query SpiralQuery query; - uint128_t query_seed; - rng.Fill(absl::MakeSpan(reinterpret_cast(&query_seed), - sizeof(query_seed))); + uint128_t query_seed = yacl::MakeUint128(0, 10004); yacl::crypto::Prg rng_pub(query_seed); query.seed_ = query_seed; diff --git a/psi/algorithm/spiral/spiral_client.h b/psi/algorithm/spiral/spiral_client.h index 00d0e58c..79f3f475 100644 --- a/psi/algorithm/spiral/spiral_client.h +++ b/psi/algorithm/spiral/spiral_client.h @@ -60,7 +60,15 @@ struct SpiralQuery { class SpiralClient : public psi::pir::IndexPirClient { public: - explicit SpiralClient(Params params) : params_(std::move(params)) { Init(); } + explicit SpiralClient(Params params) : params_(std::move(params)) { + Init(); + GenSecretKeys(); // Use random seed + } + explicit SpiralClient(Params params, uint128_t seed) + : params_(std::move(params)) { + Init(); + GenSecretKeys(seed); + } SpiralClient(Params params, DatabaseMetaInfo database_info) : params_(std::move(params)), database_info_(database_info) { @@ -74,6 +82,7 @@ class SpiralClient : public psi::pir::IndexPirClient { params_.MaxByteLenOfPt(); element_size_of_pt_ = params_.ElementSizeOfPt(element_byte_len); + GenSecretKeys(); // Use random seed } PublicKeys GenPublicKeys() const; @@ -133,7 +142,7 @@ class SpiralClient : public psi::pir::IndexPirClient { pir::PirType GetPirType() const override { return pir::PirType::SPIRAL_PIR; } - protected: + // protected: SpiralQuery GenQueryInternal(size_t pt_idx_target) const; PolyMatrixRaw DecodeResponseInternal( @@ -148,9 +157,18 @@ class SpiralClient : public psi::pir::IndexPirClient { PolyMatrixNtt GetRegevSample(yacl::crypto::Prg& rng, yacl::crypto::Prg& rng_pub) const; + PolyMatrixNtt GetScaledRegevSample(yacl::crypto::Prg& rng, + yacl::crypto::Prg& rng_pub, + uint64_t scale) const; + PolyMatrixNtt GetFreshRegevPublicKey( size_t m, yacl::crypto::Prg& rng, yacl::crypto::Prg& rng_pub) const; + + PolyMatrixNtt GetFreshScaledRegevPublicKey( + size_t m, yacl::crypto::Prg& rng, + yacl::crypto::Prg& rng_pub, uint64_t scale) const; + PolyMatrixNtt DecryptMatrixRegev(const PolyMatrixNtt& a) const { auto sk_reg_full_ntt = ToNtt(GetParams(), sk_reg_full_); return Multiply(GetParams(), sk_reg_full_ntt, a); @@ -169,6 +187,11 @@ class SpiralClient : public psi::pir::IndexPirClient { yacl::crypto::Prg& rng, yacl::crypto::Prg& rng_pub) const; + PolyMatrixNtt EncryptMatrixScaledRegev(PolyMatrixNtt& a, + yacl::crypto::Prg& rng, + yacl::crypto::Prg& rng_pub, + uint64_t scale) const; + private: // core implementation void GenSecretKeys(yacl::crypto::Prg& rng); diff --git a/psi/algorithm/spiral/spiral_server.cc b/psi/algorithm/spiral/spiral_server.cc index 49a4b233..cde15792 100644 --- a/psi/algorithm/spiral/spiral_server.cc +++ b/psi/algorithm/spiral/spiral_server.cc @@ -618,7 +618,7 @@ std::vector SpiralServer::GetVFoldingNeg( // -C auto ct_gsw_inv = PolyMatrixRaw::Zero(params_.PolyLen(), 2, 2 * params_.TGsw()); - Invert(params_, ct_gsw_inv, FromNtt(params_, v_folding[i])); + Negate(params_, ct_gsw_inv, FromNtt(params_, v_folding[i])); // G_{n+1, z} - C auto ct_gsw_neg = PolyMatrixNtt::Zero(params_.CrtCount(), params_.PolyLen(), 2, 2 * params_.TGsw()); @@ -963,14 +963,14 @@ std::vector GetVneg1(const Params& params) { auto idx = params.PolyLen() - (static_cast(1) << j); auto ng1 = PolyMatrixRaw::Zero(params.PolyLen(), 1, 1); ng1.Data()[idx] = 1ULL; - v_neg1.push_back(ToNtt(params, Invert(params, ng1))); + v_neg1.push_back(ToNtt(params, Negate(params, ng1))); } return v_neg1; } std::pair> GenRandomDbAndGetItem( const Params& params, size_t item_idx) { - yacl::crypto::Prg rng(yacl::crypto::SecureRandU128()); + yacl::crypto::Prg rng(yacl::MakeUint128(0, 30001)); size_t instances = params.Instances(); size_t trials = params.N() * params.N(); size_t dim0 = 1 << params.DbDim1(); diff --git a/psi/algorithm/spiral/util.cc b/psi/algorithm/spiral/util.cc index a8202bb1..520b6689 100644 --- a/psi/algorithm/spiral/util.cc +++ b/psi/algorithm/spiral/util.cc @@ -210,4 +210,66 @@ std::vector ConvertBytesToU8Coeffs( return coeff_array; } +uint64_t ReadArbitraryBits(const std::vector& buffer, + size_t bit_offset, size_t num_bits) { + assert(num_bits > 0 && num_bits <= 64 && "num_bits must be between 1 and 64"); + + const size_t word_offset = bit_offset / 64; + const size_t bit_offset_within_word = bit_offset % 64; + const size_t byte_offset = word_offset * 8; + + if (bit_offset_within_word + num_bits <= 64) { + assert(byte_offset + 8 <= buffer.size() && "Buffer read-out-of-bounds"); + + uint64_t val; + memcpy(&val, buffer.data() + byte_offset, sizeof(uint64_t)); + const uint64_t mask = (num_bits == 64) ? ~0ULL : (1ULL << num_bits) - 1; + return (val >> bit_offset_within_word) & mask; + + } else { + assert(byte_offset + 16 <= buffer.size() && "Buffer read-out-of-bounds"); + + uint128_t val; + memcpy(&val, buffer.data() + byte_offset, sizeof(uint128_t)); + + const uint128_t mask = (static_cast(1) << num_bits) - 1; + + return static_cast((val >> bit_offset_within_word) & mask); + } +} + +void WriteArbitraryBits(std::vector& buffer, uint64_t val, + size_t bit_offset, size_t num_bits) { + assert(num_bits > 0 && num_bits <= 64 && "num_bits must be between 1 and 64"); + + const size_t word_offset = bit_offset / 64; + const size_t bit_offset_within_word = bit_offset % 64; + const size_t byte_offset = word_offset * 8; + + const uint64_t val_mask = (num_bits == 64) ? ~0ULL : (1ULL << num_bits) - 1; + val &= val_mask; + + if (bit_offset_within_word + num_bits <= 64) { + assert(byte_offset + 8 <= buffer.size() && "Buffer write-out-of-bounds"); + + uint64_t current_val; + std::memcpy(¤t_val, buffer.data() + byte_offset, sizeof(uint64_t)); + const uint64_t write_mask = val_mask << bit_offset_within_word; + current_val &= ~write_mask; + current_val |= (val << bit_offset_within_word); + std::memcpy(buffer.data() + byte_offset, ¤t_val, sizeof(uint64_t)); + + } else { + assert(byte_offset + 16 <= buffer.size() && "Buffer write-out-of-bounds"); + + uint128_t current_val; + std::memcpy(¤t_val, buffer.data() + byte_offset, sizeof(uint128_t)); + + const uint128_t wide_val_mask = (static_cast(1) << num_bits) - 1; + const uint128_t write_mask = wide_val_mask << bit_offset_within_word; + current_val &= ~write_mask; + current_val |= (static_cast(val) << bit_offset_within_word); + std::memcpy(buffer.data() + byte_offset, ¤t_val, sizeof(uint128_t)); + } +} } // namespace psi::spiral::util diff --git a/psi/algorithm/spiral/util.h b/psi/algorithm/spiral/util.h index 252d6d05..50411b41 100644 --- a/psi/algorithm/spiral/util.h +++ b/psi/algorithm/spiral/util.h @@ -49,5 +49,8 @@ std::vector ConvertCoeffsToBytes( std::vector ConvertCoeffsToBytes(absl::Span coeff_array, size_t logt); - +uint64_t ReadArbitraryBits(const std::vector& buffer, + size_t bit_offset, size_t num_bits); +void WriteArbitraryBits(std::vector& buffer, uint64_t val, + size_t bit_offset, size_t num_bits); } // namespace psi::spiral::util diff --git a/psi/algorithm/ypir/BUILD.bazel b/psi/algorithm/ypir/BUILD.bazel new file mode 100644 index 00000000..4f75ff9b --- /dev/null +++ b/psi/algorithm/ypir/BUILD.bazel @@ -0,0 +1,257 @@ +# Copyright 2025 The secretflow authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +load("//bazel:psi.bzl", "psi_cc_library", "psi_cc_test") + +package(default_visibility = ["//visibility:public"]) + +psi_cc_library( + name = "convolution", + srcs = ["convolution.cc"], + hdrs = ["convolution.h"], + deps = [ + "//psi/algorithm/spiral:poly_matrix", + "//psi/algorithm/spiral:poly_matrix_utils", + "@yacl//yacl/crypto/rand", + ], +) + +psi_cc_library( + name = "client", + srcs = ["client.cc"], + hdrs = ["client.h"], + deps = [ + ":ypir_params", + ], +) + +psi_cc_library( + name = "types", + hdrs = ["types.h"], + deps = [ + "//psi/algorithm/spiral:params", + "//psi/algorithm/spiral:poly_matrix", + "//psi/algorithm/spiral:poly_matrix_utils", + ], +) + +psi_cc_library( + name = "server", + srcs = ["server.cc"], + hdrs = ["server.h"], + deps = [ + ":ypir_params", + ], +) + +psi_cc_library( + name = "params", + srcs = ["params.cc"], + hdrs = ["params.h"], + deps = [ + "//psi/algorithm/spiral:params", + "//psi/algorithm/spiral:util", + ], +) + +psi_cc_library( + name = "ypir_params", + srcs = ["ypir_params.cc"], + hdrs = ["ypir_params.h"], + deps = [ + ":ypir_util", + "@yacl//yacl/base:exception", + ], +) + +psi_cc_library( + name = "ypir_util", + srcs = ["ypir_util.cc"], + hdrs = ["ypir_util.h"], + deps = [ + ":aes_prng", + ":hexl", + "@yacl//yacl/base:exception", + ], +) + +psi_cc_library( + name = "hexl", + srcs = ["hexl.cc"], + hdrs = ["hexl.h"], + deps = [ + "@hexl//:hexl", + "@yacl//yacl/base:exception", + ], +) + +psi_cc_library( + name = "aes_prng", + srcs = ["aes_prng.cc"], + hdrs = ["aes_prng.h"], + copts = ["-maes"], +) + +psi_cc_library( + name = "util", + srcs = [ + "matmul.cpp", + "util.cc", + ], + hdrs = ["util.h"], + deps = [ + ":types", + "//psi/algorithm/spiral:gadget", + "//psi/algorithm/spiral:params", + "//psi/algorithm/spiral:poly_matrix", + "//psi/algorithm/spiral:poly_matrix_utils", + ], +) + +psi_cc_test( + name = "util_test", + srcs = ["util_test.cc"], + deps = [ + ":util", + "//psi/algorithm/spiral:gadget", + "//psi/algorithm/spiral:params", + "//psi/algorithm/spiral:poly_matrix", + "//psi/algorithm/spiral:poly_matrix_utils", + "//psi/algorithm/spiral:spiral_client", + "//psi/algorithm/spiral:util", + "@yacl//yacl/crypto/rand", + "@yacl//yacl/crypto/tools:prg", + ], +) + +psi_cc_test( + name = "ypir_util_test", + srcs = ["byhe_util_test.cc"], + deps = [ + ":ypir_util", + ], +) + +psi_cc_test( + name = "integration_test", + srcs = ["integration_test.cc"], + deps = [ + ":client", + ":server", + "//psi/algorithm/spiral:params", + "//psi/algorithm/spiral:spiral_client", + "//psi/algorithm/spiral:util", + ], +) + +psi_cc_test( + name = "rescale_test", + srcs = ["rescale_test.cc"], + deps = [ + "//psi/algorithm/spiral:params", + "//psi/algorithm/spiral/arith", + ], +) + +psi_cc_test( + name = "scale_k_test", + srcs = ["scale_k_test.cc"], + deps = [ + ":client", + ":server", + "//psi/algorithm/spiral:params", + "//psi/algorithm/spiral/arith", + ], +) + +psi_cc_test( + name = "simplepir_minimal_test", + srcs = ["simplepir_minimal_test.cc"], + deps = [ + ":client", + ":server", + "//psi/algorithm/spiral:params", + "//psi/algorithm/spiral:spiral_client", + ], +) + +psi_cc_test( + name = "fast_dot_product_test", + srcs = ["fast_dot_product_test.cc"], + deps = [ + ":util", + "//psi/algorithm/spiral:params", + ], +) + +psi_cc_test( + name = "simplepir_basic_flow_test", + srcs = ["simplepir_basic_flow_test.cc"], + deps = [ + ":util", + "//psi/algorithm/spiral:params", + "//psi/algorithm/spiral/arith", + ], +) + +psi_cc_test( + name = "ypir_basic_flow_test", + srcs = ["ypir_basic_flow_test.cc"], + deps = [ + ":hexl", + ":ypir_params", + ":client", + ":server", + ], +) + +psi_cc_test( + name = "automorphism_test", + srcs = ["automorphism_test.cc"], + deps = [ + "//psi/algorithm/spiral:params", + "//psi/algorithm/spiral:poly_matrix_utils", + ], +) + +psi_cc_test( + name = "lwe_consistency_test", + srcs = ["lwe_consistency_test.cc"], + deps = [ + ":client", + ":convolution", + ":server", + "//psi/algorithm/spiral:params", + "//psi/algorithm/spiral:spiral_client", + ], +) + +psi_cc_test( + name = "verify_hint_computation_test", + srcs = ["verify_hint_computation_test.cc"], + deps = [ + ":client", + ":convolution", + ":params", + ], +) + +psi_cc_test( + name = "lwe_flow_test", + srcs = ["lwe_flow_test.cc"], + deps = [ + ":client", + ":params", + ], +) diff --git a/psi/algorithm/ypir/aes_prng.cc b/psi/algorithm/ypir/aes_prng.cc new file mode 100644 index 00000000..df287ecc --- /dev/null +++ b/psi/algorithm/ypir/aes_prng.cc @@ -0,0 +1,98 @@ +// Copyright 2026 The secretflow authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "psi/algorithm/ypir/aes_prng.h" + +namespace psi::ypir::byhe { + +AESCTR_PRNG::AESCTR_PRNG() { + const uint8_t key[16] = {}; + aes128_key_expansion(key); + ctr_lo_ = 0; + ctr_hi_ = 0; +} + +AESCTR_PRNG::AESCTR_PRNG(const uint8_t key[16], uint64_t seed) { + aes128_key_expansion(key); + ctr_lo_ = seed; + ctr_hi_ = 0; +} + +void AESCTR_PRNG::refresh(uint64_t seed) { + ctr_lo_ = seed; + ctr_hi_ = 0; +} + +void AESCTR_PRNG::aes128_key_expansion(const uint8_t key[16]) { + __m128i tmp1, tmp2; + tmp1 = _mm_loadu_si128(reinterpret_cast(key)); + round_keys_[0] = tmp1; + + AES_128_ASSIST(tmp1, tmp2, 0x01); + round_keys_[1] = tmp1; + AES_128_ASSIST(tmp1, tmp2, 0x02); + round_keys_[2] = tmp1; + AES_128_ASSIST(tmp1, tmp2, 0x04); + round_keys_[3] = tmp1; + AES_128_ASSIST(tmp1, tmp2, 0x08); + round_keys_[4] = tmp1; + AES_128_ASSIST(tmp1, tmp2, 0x10); + round_keys_[5] = tmp1; + AES_128_ASSIST(tmp1, tmp2, 0x20); + round_keys_[6] = tmp1; + AES_128_ASSIST(tmp1, tmp2, 0x40); + round_keys_[7] = tmp1; + AES_128_ASSIST(tmp1, tmp2, 0x80); + round_keys_[8] = tmp1; + AES_128_ASSIST(tmp1, tmp2, 0x1B); + round_keys_[9] = tmp1; + AES_128_ASSIST(tmp1, tmp2, 0x36); + round_keys_[10] = tmp1; +} + +__m128i AESCTR_PRNG::aes128_encrypt_block(__m128i block, + const __m128i round_keys[11]) { + block = _mm_xor_si128(block, round_keys[0]); + for (int i = 1; i < 10; ++i) { + block = _mm_aesenc_si128(block, round_keys[i]); + } + block = _mm_aesenclast_si128(block, round_keys[10]); + return block; +} + +__m128i AESCTR_PRNG::next_block() { + __m128i ctr_block = _mm_set_epi64x(ctr_hi_, ctr_lo_); + __m128i out = aes128_encrypt_block(ctr_block, round_keys_); + if (++ctr_lo_ == 0) { + ++ctr_hi_; + } + return out; +} + +void AESCTR_PRNG::fill_bytes(uint8_t* dst, size_t len) { + while (len >= 16) { + __m128i b = next_block(); + _mm_storeu_si128(reinterpret_cast<__m128i*>(dst), b); + dst += 16; + len -= 16; + } + if (len > 0) { + __m128i b = next_block(); + alignas(16) uint8_t tmp[16]; + _mm_store_si128(reinterpret_cast<__m128i*>(tmp), b); + std::memcpy(dst, tmp, len); + } +} + +} // namespace psi::ypir::byhe diff --git a/psi/algorithm/ypir/aes_prng.h b/psi/algorithm/ypir/aes_prng.h new file mode 100644 index 00000000..0355b295 --- /dev/null +++ b/psi/algorithm/ypir/aes_prng.h @@ -0,0 +1,51 @@ +// Copyright 2026 The secretflow authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#pragma once + +#include +#include +#include + +#include + +namespace psi::ypir::byhe { + +#define AES_128_ASSIST(t1, t2, rc) \ + t2 = _mm_aeskeygenassist_si128(t1, rc); \ + t2 = _mm_shuffle_epi32(t2, _MM_SHUFFLE(3, 3, 3, 3)); \ + t1 = _mm_xor_si128(t1, _mm_slli_si128(t1, 4)); \ + t1 = _mm_xor_si128(t1, _mm_slli_si128(t1, 4)); \ + t1 = _mm_xor_si128(t1, _mm_slli_si128(t1, 4)); \ + t1 = _mm_xor_si128(t1, t2); + +class AESCTR_PRNG { + public: + AESCTR_PRNG(); + AESCTR_PRNG(const uint8_t key[16], uint64_t seed = 0); + + void refresh(uint64_t seed); + void fill_bytes(uint8_t* dst, size_t len); + + private: + void aes128_key_expansion(const uint8_t key[16]); + __m128i aes128_encrypt_block(__m128i block, const __m128i round_keys[11]); + __m128i next_block(); + + __m128i round_keys_[11]; + uint64_t ctr_lo_ = 0; + uint64_t ctr_hi_ = 0; +}; + +} // namespace psi::ypir::byhe diff --git a/psi/algorithm/ypir/automorphism_test.cc b/psi/algorithm/ypir/automorphism_test.cc new file mode 100644 index 00000000..ae7423ee --- /dev/null +++ b/psi/algorithm/ypir/automorphism_test.cc @@ -0,0 +1,96 @@ +#include "gtest/gtest.h" +#include "spdlog/spdlog.h" + +#include "psi/algorithm/spiral/params.h" +#include "psi/algorithm/spiral/poly_matrix_utils.h" + +namespace psi::ypir { + +using namespace psi::spiral; + +TEST(AutomorphismTest, ZeroInputShouldGiveZeroOutput) { + spdlog::set_level(spdlog::level::info); + + size_t poly_len = 2048; + std::vector moduli = {268369921, 249561089}; + double noise_width = 6.4; + PolyMatrixParams poly_matrix_params; + poly_matrix_params.n_ = 2; + poly_matrix_params.pt_modulus_ = 16384; + QueryParams query_params(1, 1, 1); + + Params params(poly_len, std::move(moduli), noise_width, poly_matrix_params, + query_params); + + SPDLOG_INFO("=== Testing AutomorphismPolyUncrtd with Zero Input ==="); + + size_t dual_crt_size = params.CrtCount() * poly_len; + std::vector zero_input(dual_crt_size, 0); + std::vector output(dual_crt_size, 999); + + std::vector t_values = {65, 129, 257, 513, 1025, 2049}; + + for (size_t t : t_values) { + std::fill(output.begin(), output.end(), 999); + + AutomorphismPolyUncrtd(params, absl::MakeSpan(output), + absl::MakeConstSpan(zero_input), t); + + bool all_zero = true; + for (size_t i = 0; i < output.size(); ++i) { + if (output[i] != 0) { + all_zero = false; + if (i < 10) { + SPDLOG_ERROR("t={}: output[{}] = {} (expected 0)", t, i, output[i]); + } + } + } + + if (all_zero) { + SPDLOG_INFO("✓ t={}: All outputs are zero", t); + } else { + SPDLOG_ERROR("✗ t={}: Found non-zero outputs!", t); + } + + EXPECT_TRUE(all_zero) << "Zero input should give zero output for t=" << t; + } +} + +TEST(AutomorphismTest, NonZeroInputCheck) { + spdlog::set_level(spdlog::level::info); + + size_t poly_len = 2048; + std::vector moduli = {268369921, 249561089}; + double noise_width = 6.4; + PolyMatrixParams poly_matrix_params; + poly_matrix_params.n_ = 2; + poly_matrix_params.pt_modulus_ = 16384; + QueryParams query_params(1, 1, 1); + + Params params(poly_len, std::move(moduli), noise_width, poly_matrix_params, + query_params); + + SPDLOG_INFO( + "=== Testing AutomorphismPolyUncrtd with Simple Non-Zero Input ==="); + + size_t dual_crt_size = params.CrtCount() * poly_len; + std::vector input(dual_crt_size, 0); + std::vector output(dual_crt_size, 0); + + input[0] = 1; + + size_t t = 65; + AutomorphismPolyUncrtd(params, absl::MakeSpan(output), + absl::MakeConstSpan(input), t); + + SPDLOG_INFO("Input: first coefficient = 1, others = 0"); + SPDLOG_INFO("t = {}", t); + SPDLOG_INFO("First 10 output values:"); + for (size_t i = 0; i < 10; ++i) { + SPDLOG_INFO(" output[{}] = {}", i, output[i]); + } + + EXPECT_EQ(output[0], 1) << "output[0] should be 1"; +} + +} // namespace psi::ypir diff --git a/psi/algorithm/ypir/byhe_util_test.cc b/psi/algorithm/ypir/byhe_util_test.cc new file mode 100644 index 00000000..3b819b28 --- /dev/null +++ b/psi/algorithm/ypir/byhe_util_test.cc @@ -0,0 +1,59 @@ +#include +#include +#include +#include + +#include "gtest/gtest.h" + +#include "psi/algorithm/ypir/byhe_util.h" + +namespace psi::ypir::byhe { +namespace { + +std::vector ReferenceMatVecU8U32Mod2p32(const std::vector& A, + const std::vector& x, + size_t rows, size_t cols) { + std::vector y(rows, 0); + for (size_t r = 0; r < rows; ++r) { + uint64_t acc = 0; + for (size_t c = 0; c < cols; ++c) { + acc += static_cast(A[r * cols + c]) * x[c]; + } + y[r] = static_cast(acc); + } + return y; +} + +void RunMatVecCase(size_t rows, size_t cols) { + std::mt19937 rng(static_cast(rows * 131 + cols * 17 + 7)); + std::uniform_int_distribution a_dist(0, 255); + std::uniform_int_distribution x_dist( + 0, std::numeric_limits::max()); + + std::vector A(rows * cols, 0); + std::vector x(cols, 0); + for (auto& v : A) { + v = static_cast(a_dist(rng)); + } + for (auto& v : x) { + v = x_dist(rng); + } + + std::vector y(rows, 0); + MatVecU8U32Mod2p32(A.data(), x.data(), y.data(), rows, cols); + + const auto expected = ReferenceMatVecU8U32Mod2p32(A, x, rows, cols); + EXPECT_EQ(y, expected); +} + +} // namespace + +TEST(ByheUtilTest, MatVecU8U32Mod2p32MatchesReference) { + RunMatVecCase(1, 1); + RunMatVecCase(7, 13); + RunMatVecCase(16, 64); + RunMatVecCase(31, 255); + RunMatVecCase(64, 512); +} + +} // namespace psi::ypir::byhe diff --git a/psi/algorithm/ypir/client.cc b/psi/algorithm/ypir/client.cc new file mode 100644 index 00000000..55034788 --- /dev/null +++ b/psi/algorithm/ypir/client.cc @@ -0,0 +1,279 @@ +#include "psi/algorithm/ypir/client.h" + +#include +#include +#include +#include + +namespace psi::ypir::byhe { +namespace { + +uint64_t MakeSeedMaterial() { + const uint64_t time_seed = static_cast( + std::chrono::high_resolution_clock::now().time_since_epoch().count()); + std::random_device rd; + return time_seed ^ (static_cast(rd()) << 32) ^ rd(); +} + +std::mt19937_64& GlobalPrng() { + thread_local std::mt19937_64 rng(MakeSeedMaterial()); + return rng; +} + +uint64_t GetBase(uint64_t b, uint64_t z, uint64_t ti) { + return 1ULL << (b + ti * z); +} + +void LweEncrypt(Secret& sk, const std::vector& a, uint64_t message, + uint64_t& b, uint64_t pmod, double sig) { + const uint64_t lwe_dimension = sk.get_len(); + const uint64_t cmod = sk.get_mod(); + const long double delta = + static_cast(cmod) / static_cast(pmod); + + const uint64_t e = SampleGauss(sig, cmod, GlobalPrng()); + + std::vector tmp(lwe_dimension, 0); + EltwiseMultMod(tmp.data(), a.data(), sk.data.data(), lwe_dimension, cmod); + b = 0; + for (uint64_t i = 0; i < lwe_dimension; ++i) { + b = (b + tmp[i]) % cmod; + } + b = (b + e) % cmod; + b = (b + static_cast(message * delta)) % cmod; +} + +void LweDecrypt(Secret& sk, std::vector& a, uint64_t& message, + uint64_t& b, uint64_t pmod) { + const uint64_t lwe_dimension = sk.get_len(); + const uint64_t cmod = sk.get_mod(); + const long double delta = + static_cast(cmod) / static_cast(pmod); + + std::vector tmp(lwe_dimension, 0); + EltwiseMultMod(tmp.data(), a.data(), sk.data.data(), lwe_dimension, cmod); + for (uint64_t i = 0; i < lwe_dimension; ++i) { + b = (cmod + b - tmp[i]) % cmod; + } + + if (b > (cmod >> 1)) { + b = static_cast(std::llround((static_cast(b) - + static_cast(cmod)) / + delta)) % + pmod; + } else { + b = static_cast( + std::llround(static_cast(b) / delta)) % + pmod; + } + message = b; +} + +void PowerOfBase(const uint64_t* vec, uint64_t& num, uint64_t b, uint64_t z, + uint64_t t) { + num = 0; + for (uint64_t i = 0; i < t; ++i) { + num = (num << z) | vec[t - 1 - i]; + } + num <<= b; +} + +void RlweEncode(Secret& sk, const std::vector& a, + std::vector& message, std::vector& b, + const FheParams& fparm) { + const uint64_t poly_degree = fparm.get_poly_degree(); + const uint64_t rlwe_cmod = fparm.get_rlwe_cmod(); + const double sig = fparm.get_sig_ring(); + + ByheHexlNtt& ntt = fparm.get_ntt(); + if (!sk.get_ntt_form()) { + ntt.Forward(sk.data.data(), poly_degree); + sk.switch_ntt_format(); + } + + std::vector err(poly_degree, 0); + SampleGauss(err, sig, rlwe_cmod, GlobalPrng()); + EltwiseFMAMod(err.data(), message.data(), 1, err.data(), poly_degree, + rlwe_cmod); + ntt.Forward(err.data(), poly_degree); + + EltwiseMultMod(b.data(), sk.data.data(), a.data(), poly_degree, rlwe_cmod); + EltwiseAddMod(b.data(), err.data(), b.data(), poly_degree, rlwe_cmod); +} + +void RlweDecrypt(Secret& sk, std::vector& a, + std::vector& message, std::vector& b, + const FheParams& fparm) { + const uint64_t poly_degree = fparm.get_poly_degree(); + const uint64_t rlwe_cmod = fparm.get_rlwe_cmod(); + const uint64_t rlwe_pmod = fparm.get_rlwe_pmod(); + const uint64_t delta = rlwe_cmod / rlwe_pmod; + + ByheHexlNtt& ntt = fparm.get_ntt(); + if (!sk.get_ntt_form()) { + ntt.Forward(sk.data.data(), poly_degree); + sk.switch_ntt_format(); + } + + std::vector tmp(poly_degree, 0); + EltwiseMultMod(tmp.data(), sk.data.data(), a.data(), poly_degree, rlwe_cmod); + EltwiseSubMod(b.data(), b.data(), tmp.data(), poly_degree, rlwe_cmod); + ntt.Inverse(b.data(), poly_degree); + + message.assign(poly_degree, 0); + for (uint64_t i = 0; i < poly_degree; ++i) { + if (b[i] > (rlwe_cmod >> 1)) { + message[i] = static_cast( + std::llround((static_cast(b[i]) - + static_cast(rlwe_cmod)) / + static_cast(delta))) % + rlwe_pmod; + } else { + message[i] = static_cast( + std::llround(static_cast(b[i]) / + static_cast(delta))) % + rlwe_pmod; + } + } +} + +void MatrixReconstruct(const std::vector& vec, + std::vector>& mat, uint64_t row, + uint64_t col) { + mat.assign(row, std::vector(col, 0)); + uint64_t ptr = 0; + for (uint64_t i = 0; i < row; ++i) { + for (uint64_t j = 0; j < col; ++j, ++ptr) { + mat[i][j] = vec[ptr]; + } + } +} + +void GadgetEncrypt(Secret& sk, const std::vector>& a, + std::vector& message, + std::vector>& b, + const FheParams& fparm) { + const uint64_t b_auto = fparm.get_b_auto(); + const uint64_t z_auto = fparm.get_z_auto(); + const uint64_t t_auto = fparm.get_t_auto(); + const uint64_t poly_degree = fparm.get_poly_degree(); + const uint64_t rlwe_cmod = fparm.get_rlwe_cmod(); + + std::vector message_tmp(poly_degree, 0); + for (uint64_t i = 0; i < t_auto; ++i) { + const uint64_t base = GetBase(b_auto, z_auto, i) % rlwe_cmod; + EltwiseFMAMod(message_tmp.data(), message.data(), base, nullptr, + poly_degree, rlwe_cmod); + RlweEncode(sk, a[i], message_tmp, b[i], fparm); + } +} + +void GenerateAutokey(Secret& sk, + const std::vector>>& ksk_a, + std::vector>>& ksk_b, + const FheParams& fparm) { + const uint64_t degree = fparm.get_poly_degree(); + const uint64_t cmod = fparm.get_rlwe_cmod(); + const uint64_t expo = GetLog2(degree); + + ByheHexlNtt& ntt = fparm.get_ntt(); + if (sk.get_ntt_form()) { + ntt.Inverse(sk.data.data(), degree); + sk.switch_ntt_format(); + } + + std::vector newkey(degree, 0); + const std::vector copykey = sk.data; + for (uint64_t i = 0; i < expo; ++i) { + const uint64_t idx = (1ULL << (expo - i)) + 1; + ApplyAutoCoefForm(newkey, copykey, static_cast(idx), cmod); + GadgetEncrypt(sk, ksk_a[i], newkey, ksk_b[i], fparm); + } +} + +} // namespace + +void YpirRecover(Secret& simple_sk, Secret& double_sk, + std::vector>& res, uint64_t& message, + const FheParams& fparm, const PirParams&) { + const uint64_t degree = fparm.get_poly_degree(); + const uint64_t lwe_pmod = fparm.get_lwe_pmod(); + const uint64_t lwe_dimension = fparm.get_lwe_dimension(); + const uint64_t b = fparm.get_b_decomp(); + const uint64_t z = fparm.get_z_decomp(); + const uint64_t t = fparm.get_t_decomp(); + + std::vector pack_a_message(degree, 0); + std::vector pack_b_message(degree, 0); + RlweDecrypt(double_sk, res[0], pack_a_message, res[1], fparm); + RlweDecrypt(double_sk, res[2], pack_b_message, res[3], fparm); + + std::vector> matrix_pack_a_message; + MatrixReconstruct(pack_a_message, matrix_pack_a_message, lwe_dimension, t); + + std::vector a(lwe_dimension, 0); + for (uint64_t i = 0; i < lwe_dimension; ++i) { + PowerOfBase(matrix_pack_a_message[i].data(), a[i], b, z, t); + } + + uint64_t b_value = 0; + PowerOfBase(pack_b_message.data(), b_value, b, z, t); + LweDecrypt(simple_sk, a, message, b_value, lwe_pmod); +} + +YpirQuery Generate_query_ypir(uint64_t c_idx, uint64_t r_idx, Secret& lwe_sk, + Secret& rlwe_sk, AESCTR_PRNG& prng, + const FheParams& fparm, + const PirParams& pparm) { + YpirQuery out; + + const uint64_t cols = pparm.get_col(); + std::vector query_vec_col(cols, 0); + query_vec_col[c_idx] = 1; + + out.qu0.resize(cols); + const double sig = fparm.get_sig(); + const uint64_t lwe_pmod = fparm.get_lwe_pmod(); + const auto& matrix0 = fparm.get_persudo_matrix_simplepir(); + for (uint64_t i = 0; i < cols; ++i) { + LweEncrypt(lwe_sk, matrix0[i], query_vec_col[i], out.qu0[i], lwe_pmod, + sig); + } + + const uint64_t rows = pparm.get_row(); + const uint64_t degree = fparm.get_poly_degree(); + std::vector query_vec_row(rows, 0); + query_vec_row[r_idx] = 1; + + out.qu1.resize(rows); + const double sig_ring = fparm.get_sig_ring(); + const uint64_t rlwe_pmod = fparm.get_rlwe_pmod(); + std::vector> matrix1(rows, + std::vector(degree, 0)); + prng.refresh(kSecondDimensionSeed); + PseudorandomMatrixGenerate(matrix1, fparm.get_rlwe_cmod(), prng); + for (uint64_t i = 0; i < rows; ++i) { + LweEncrypt(rlwe_sk, matrix1[i], query_vec_row[i], out.qu1[i], rlwe_pmod, + sig_ring); + } + + const uint64_t t_auto = fparm.get_t_auto(); + const uint64_t expo = GetLog2(degree); + out.ksk_b.assign( + expo, std::vector>(t_auto, + std::vector(degree, 0))); + + std::vector>> ksk_a( + expo, + std::vector>(t_auto, + std::vector(degree, 0))); + prng.refresh(kThirdDimensionSeed); + for (uint64_t i = 0; i < expo; ++i) { + PseudorandomMatrixGenerate(ksk_a[i], fparm.get_rlwe_cmod(), prng); + } + GenerateAutokey(rlwe_sk, ksk_a, out.ksk_b, fparm); + + return out; +} + +} // namespace psi::ypir::byhe diff --git a/psi/algorithm/ypir/client.h b/psi/algorithm/ypir/client.h new file mode 100644 index 00000000..ed259ca9 --- /dev/null +++ b/psi/algorithm/ypir/client.h @@ -0,0 +1,29 @@ +#pragma once + +#include +#include + +#include "psi/algorithm/ypir/ypir_params.h" + +namespace psi::ypir { + +namespace byhe { + +struct YpirQuery { + std::vector qu0; + std::vector qu1; + std::vector>> ksk_b; +}; + +void YpirRecover(Secret& simple_sk, Secret& double_sk, + std::vector>& res, uint64_t& message, + const FheParams& fparm, const PirParams& pparm); + +YpirQuery Generate_query_ypir(uint64_t c_idx, uint64_t r_idx, Secret& lwe_sk, + Secret& rlwe_sk, AESCTR_PRNG& prng, + const FheParams& fparm, + const PirParams& pparm); + +} // namespace byhe + +} // namespace psi::ypir diff --git a/psi/algorithm/ypir/convolution.cc b/psi/algorithm/ypir/convolution.cc new file mode 100644 index 00000000..93f3f89b --- /dev/null +++ b/psi/algorithm/ypir/convolution.cc @@ -0,0 +1,157 @@ +#include "psi/algorithm/ypir/convolution.h" + +#include +#include + +#include "psi/algorithm/spiral/arith/arith.h" +#include "psi/algorithm/spiral/arith/arith_params.h" +#include "psi/algorithm/spiral/params.h" +#include "psi/algorithm/spiral/poly_matrix.h" +#include "psi/algorithm/spiral/poly_matrix_utils.h" + +namespace psi::ypir { +using namespace psi::spiral; + +psi::spiral::Params CreateParams(size_t n) { + std::size_t poly_len = n; + + std::vector moduli{268369921, 249561089}; + double noise_width = 6.4; + + psi::spiral::PolyMatrixParams poly_matrix_params(1, 2, 28, 0, 0, 0, 0); + psi::spiral::QueryParams query_params(1, 1, 1, true); + + return psi::spiral::Params(poly_len, std::move(moduli), noise_width, + std::move(poly_matrix_params), + std::move(query_params)); +} + +Convolution::Convolution(size_t n) : n_(n) { params_ = CreateParams(n); } + +std::vector Convolution::ntt(const std::vector& a) const { + assert(a.size() == n_); + + auto inp = PolyMatrixRaw::Zero(params_.PolyLen(), 1, 1); + for (size_t i = 0; i < n_; ++i) { + inp.Data()[i] = static_cast(a[i]); + } + + auto ntt_res = ToNtt(params_, inp); + + size_t out_size = params_.CrtCount() * n_; + std::vector out(out_size); + for (size_t i = 0; i < out_size; ++i) { + out[i] = static_cast(ntt_res.Data()[i]); + } + return out; +} + +std::vector Convolution::raw(const std::vector& a) const { + assert(a.size() == params_.CrtCount() * n_); + + auto inp = PolyMatrixNtt::Zero(params_.CrtCount(), params_.PolyLen(), 1, 1); + for (size_t i = 0; i < params_.CrtCount() * n_; ++i) { + inp.Data()[i] = static_cast(a[i]); + } + + auto raw_res = FromNtt(params_, inp); + + std::vector out(n_); + int64_t modulus_i64 = static_cast(params_.Modulus()); + int64_t two_pow_32 = 1LL << 32; + + for (size_t i = 0; i < n_; ++i) { + int64_t val = static_cast(raw_res.Data()[i]); + + assert(val < modulus_i64); + if (val > modulus_i64 / 2) { + val -= modulus_i64; + } + if (val < 0) { + val += (modulus_i64 / two_pow_32) * two_pow_32; + val += two_pow_32; + } + + assert(val >= 0); + out[i] = static_cast(val % two_pow_32); + } + return out; +} + +std::vector Convolution::pointwise_mul( + const std::vector& a, const std::vector& b) const { + size_t total_len = params_.CrtCount() * n_; + assert(a.size() == total_len); + assert(b.size() == total_len); + + std::vector out(total_len); + for (size_t m = 0; m < params_.CrtCount(); ++m) { + for (size_t i = 0; i < n_; ++i) { + size_t idx = m * n_ + i; + uint64_t val = + static_cast(a[idx]) * static_cast(b[idx]); + out[idx] = static_cast(arith::BarrettCoeffU64(params_, val, m)); + } + } + return out; +} + +std::vector Convolution::convolve( + const std::vector& a, const std::vector& b) const { + auto a_ntt = ntt(a); + auto b_ntt = ntt(b); + auto res = pointwise_mul(a_ntt, b_ntt); + return raw(res); +} + +std::vector NaiveNegacyclicConvolve(const std::vector& a, + const std::vector& b) { + assert(a.size() == b.size()); + size_t n = a.size(); + std::vector res(n, 0); + + for (size_t i = 0; i < n; ++i) { + for (size_t j = 0; j < n; ++j) { + size_t idx = (n + i - j) % n; + uint32_t b_val = b[idx]; + if (i < j) { + b_val = 0 - b_val; + } + res[i] += a[j] * b_val; + } + } + return res; +} + +std::vector NegacyclicMatrixU32(absl::Span b) { + size_t n = b.size(); + std::vector res(n * n, 0); + + for (size_t i = 0; i < n; ++i) { + for (size_t j = 0; j < n; ++j) { + uint32_t b_val = b[(n + i - j) % n]; + if (i < j) { + b_val = -b_val; + } + res[j * n + i] = b_val; + } + } + + return res; +} + +std::vector NegacyclicPermU32(const std::vector& a) { + size_t n = a.size(); + std::vector res(n); + + if (n > 0) { + res[0] = a[0]; + for (size_t i = 1; i < n; ++i) { + uint32_t val = a[n - i]; + res[i] = 0 - val; + } + } + return res; +} + +} // namespace psi::ypir \ No newline at end of file diff --git a/psi/algorithm/ypir/convolution.h b/psi/algorithm/ypir/convolution.h new file mode 100644 index 00000000..df45cb46 --- /dev/null +++ b/psi/algorithm/ypir/convolution.h @@ -0,0 +1,41 @@ +#pragma once + +#include +#include +#include +#include + +#include "psi/algorithm/spiral/params.h" + +namespace psi::ypir { + +using Params = spiral::Params; + +class Convolution { + public: + explicit Convolution(size_t n); + + const Params& params() const { return params_; } + + std::vector ntt(const std::vector& a) const; + std::vector raw(const std::vector& a) const; + + std::vector pointwise_mul(const std::vector& a, + const std::vector& b) const; + + std::vector convolve(const std::vector& a, + const std::vector& b) const; + + private: + size_t n_; + Params params_; +}; + +std::vector NaiveNegacyclicConvolve(const std::vector& a, + const std::vector& b); + +std::vector NegacyclicMatrixU32(const std::vector& b); + +std::vector NegacyclicPermU32(const std::vector& a); + +} // namespace psi::ypir \ No newline at end of file diff --git a/psi/algorithm/ypir/fast_dot_product_test.cc b/psi/algorithm/ypir/fast_dot_product_test.cc new file mode 100644 index 00000000..eb002396 --- /dev/null +++ b/psi/algorithm/ypir/fast_dot_product_test.cc @@ -0,0 +1,106 @@ +// Test FastBatchedDotProduct to verify correctness +#include "gtest/gtest.h" +#include "spdlog/spdlog.h" + +#include "psi/algorithm/spiral/params.h" +#include "psi/algorithm/ypir/util.h" + +namespace psi::ypir { + +using namespace psi::spiral; + +TEST(FastDotProductTest, AllZerosInput) { + // Test with all-zeros database + size_t poly_len = 2048; + std::vector moduli = {268369921, 249561089}; + double noise_width = 6.4; + + PolyMatrixParams poly_matrix_params(2, 256, 21, 4, 8, 8, 1); + QueryParams query_params(1, 1, 1); + + Params params(poly_len, std::move(moduli), noise_width, + std::move(poly_matrix_params), std::move(query_params)); + + size_t db_rows = 1ULL << (params.DbDim1() + params.PolyLenLog2()); + size_t db_cols = params.Instances() * params.PolyLen(); + + // Create all-zeros database with uint8_t + std::vector db(db_rows * db_cols, 0); + + // Create query vector (all zeros except position 0) + std::vector query(db_rows, 0); + query[0] = 1; + + // Result vector + std::vector result(db_cols, 0); + + SPDLOG_INFO("Testing FastBatchedDotProduct with all-zeros database"); + SPDLOG_INFO("db_rows={}, db_cols={}", db_rows, db_cols); + + // Call FastBatchedDotProduct + // Signature: (params, c, a, a_elems, b_t, b_rows, b_cols) + FastBatchedDotProduct(params, result.data(), query.data(), db_rows, + db.data(), db_rows, db_cols); + + SPDLOG_INFO("Result size: {}", result.size()); + + // Check result - should be all zeros since database is all zeros + bool all_zero = true; + for (size_t i = 0; i < std::min(size_t(10), result.size()); ++i) { + SPDLOG_INFO(" result[{}] = {}", i, result[i]); + if (result[i] != 0) { + all_zero = false; + } + } + + EXPECT_TRUE(all_zero) + << "FastBatchedDotProduct with all-zeros should return all zeros"; +} + +TEST(FastDotProductTest, SimplePattern) { + // Test with pattern database + size_t poly_len = 2048; + std::vector moduli = {268369921, 249561089}; + double noise_width = 6.4; + + PolyMatrixParams poly_matrix_params(2, 256, 21, 4, 8, 8, 1); + QueryParams query_params(1, 1, 1); + + Params params(poly_len, std::move(moduli), noise_width, + std::move(poly_matrix_params), std::move(query_params)); + + size_t db_rows = 1ULL << (params.DbDim1() + params.PolyLenLog2()); + size_t db_cols = params.Instances() * params.PolyLen(); + + // Create database with pattern: db[i] = i % 256 + std::vector db(db_rows * db_cols); + for (size_t col = 0; col < db_cols; ++col) { + for (size_t row = 0; row < db_rows; ++row) { + // Column-major storage: db[col * db_rows + row] + db[col * db_rows + row] = + static_cast((col * db_rows + row) % 256); + } + } + + // Create query selecting first row + std::vector query(db_rows, 0); + query[0] = 1; // Select first row + + // Result vector + std::vector result(db_cols, 0); + + SPDLOG_INFO("Testing FastBatchedDotProduct with pattern database"); + SPDLOG_INFO("db_rows={}, db_cols={}", db_rows, db_cols); + + FastBatchedDotProduct(params, result.data(), query.data(), db_rows, + db.data(), db_rows, db_cols); + + SPDLOG_INFO("Result data (first 10):"); + for (size_t i = 0; i < std::min(size_t(10), result.size()); ++i) { + // Expected value is the first element of column i (row 0) + uint64_t expected = db[i * db_rows + 0]; + SPDLOG_INFO(" result[{}] = {} (expected {})", i, result[i], expected); + } +} + +} // namespace psi::ypir diff --git a/psi/algorithm/ypir/hexl.cc b/psi/algorithm/ypir/hexl.cc new file mode 100644 index 00000000..8f2dcd13 --- /dev/null +++ b/psi/algorithm/ypir/hexl.cc @@ -0,0 +1,62 @@ +// Copyright 2026 The secretflow authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "psi/algorithm/ypir/hexl.h" + +#include "yacl/base/exception.h" + +namespace psi::ypir::byhe { + +ByheHexlNtt::ByheHexlNtt(uint64_t degree, uint64_t modulus, + uint64_t root_of_unity) + : ntt_(degree, modulus, root_of_unity), + degree_(degree), + modulus_(modulus) { + YACL_ENFORCE(degree_ > 0); + YACL_ENFORCE(modulus_ > 0); +} + +void ByheHexlNtt::Forward(uint64_t* data, size_t len) { + YACL_ENFORCE(len == degree_, + "NTT Forward expects len == degree ({} != {})", len, degree_); + ntt_.ComputeForward(data, data, 1, 1); +} + +void ByheHexlNtt::Inverse(uint64_t* data, size_t len) { + YACL_ENFORCE(len == degree_, + "NTT Inverse expects len == degree ({} != {})", len, degree_); + ntt_.ComputeInverse(data, data, 1, 1); +} + +void EltwiseMultMod(uint64_t* out, const uint64_t* a, const uint64_t* b, + size_t len, uint64_t modulus) { + intel::hexl::EltwiseMultMod(out, a, b, len, modulus, 1); +} + +void EltwiseAddMod(uint64_t* out, const uint64_t* a, const uint64_t* b, + size_t len, uint64_t modulus) { + intel::hexl::EltwiseAddMod(out, a, b, len, modulus); +} + +void EltwiseSubMod(uint64_t* out, const uint64_t* a, const uint64_t* b, + size_t len, uint64_t modulus) { + intel::hexl::EltwiseSubMod(out, a, b, len, modulus); +} + +void EltwiseFMAMod(uint64_t* out, const uint64_t* a, uint64_t scalar, + const uint64_t* add, size_t len, uint64_t modulus) { + intel::hexl::EltwiseFMAMod(out, a, scalar, add, len, modulus, 1); +} + +} // namespace psi::ypir::byhe diff --git a/psi/algorithm/ypir/hexl.h b/psi/algorithm/ypir/hexl.h new file mode 100644 index 00000000..db9d11a8 --- /dev/null +++ b/psi/algorithm/ypir/hexl.h @@ -0,0 +1,53 @@ +// Copyright 2026 The secretflow authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#pragma once + +#include +#include + +#include "hexl/hexl.hpp" + +namespace psi::ypir::byhe { + +constexpr uint64_t kCrtQ1 = 268369921ULL; +constexpr uint64_t kCrtQ2 = 249561089ULL; +constexpr uint64_t kCrtMod = kCrtQ1 * kCrtQ2; +constexpr uint64_t kRootOfUnityCrt = 38878761190133527ULL; + +class ByheHexlNtt { + public: + ByheHexlNtt(uint64_t degree, uint64_t modulus, uint64_t root_of_unity); + + void Forward(uint64_t* data, size_t len); + void Inverse(uint64_t* data, size_t len); + + intel::hexl::NTT& Raw() { return ntt_; } + + private: + intel::hexl::NTT ntt_; + uint64_t degree_ = 0; + uint64_t modulus_ = 0; +}; + +void EltwiseMultMod(uint64_t* out, const uint64_t* a, const uint64_t* b, + size_t len, uint64_t modulus); +void EltwiseAddMod(uint64_t* out, const uint64_t* a, const uint64_t* b, + size_t len, uint64_t modulus); +void EltwiseSubMod(uint64_t* out, const uint64_t* a, const uint64_t* b, + size_t len, uint64_t modulus); +void EltwiseFMAMod(uint64_t* out, const uint64_t* a, uint64_t scalar, + const uint64_t* add, size_t len, uint64_t modulus); + +} // namespace psi::ypir::byhe diff --git a/psi/algorithm/ypir/integration_test.cc b/psi/algorithm/ypir/integration_test.cc new file mode 100644 index 00000000..bbbaead1 --- /dev/null +++ b/psi/algorithm/ypir/integration_test.cc @@ -0,0 +1,758 @@ +// Copyright 2025 The secretflow authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include +#include + +#include "gtest/gtest.h" +#include "spdlog/spdlog.h" + +#include "psi/algorithm/spiral/params.h" +#include "psi/algorithm/spiral/spiral_client.h" +#include "psi/algorithm/spiral/util.h" +#include "psi/algorithm/ypir/client.h" +#include "psi/algorithm/ypir/server.h" + +using namespace psi::ypir; +using namespace psi::spiral; + +class YPIRIntegrationTest : public ::testing::Test { + protected: + void SetUp() override { spdlog::set_level(spdlog::level::info); } +}; + +TEST_F(YPIRIntegrationTest, SimplePIR_1GB) { + // Setup parameters - 1GB database test + std::size_t poly_len{2048}; + std::vector moduli{268369921, 249561089}; + double noise_width{16.042421}; + + // 1GB SimplePIR: db_dim_1=5, instances=4 + // 2^(5+11)=65536 rows × 4*2048=8192 cols = 512M elements = 1GB (uint16_t) + PolyMatrixParams poly_matrix_params(2, 16384, 21, 4, 8, 8, 4); + QueryParams query_params(5, 1, 4); // db_dim_1=5, db_dim_2=1, instances=4 + + Params params(poly_len, std::move(moduli), noise_width, + std::move(poly_matrix_params), std::move(query_params)); + + size_t db_rows = 1ULL << (params.DbDim1() + params.PolyLenLog2()); + size_t db_cols = params.Instances() * params.PolyLen(); + size_t db_size = db_rows * db_cols; + + SPDLOG_INFO( + "SimplePIR Performance Test (1GB): db_rows={}, db_cols={}, db_size={} " + "(~{} MB), pt_modulus={}", + db_rows, db_cols, db_size, (db_size * sizeof(uint16_t)) / (1024 * 1024), + params.PtModulus()); + + // SimplePIR with pt_modulus=16384 requires uint16_t database + std::vector db(db_size); + std::random_device rd; + std::mt19937 gen(42); // Fixed seed for reproducibility + std::uniform_int_distribution<> dis(0, params.PtModulus() - 1); + for (auto& val : db) { + val = static_cast(dis(gen)); + } + + // Add some known values for verification at strategic positions + db[0] = 100; + db[1] = 101; + db[100] = 200; + db[1000] = 250; + db[100000] = 300; // Test larger index + + SPDLOG_INFO( + "Known test values: db[0]={}, db[1]={}, db[100]={}, db[1000]={}, " + "db[100000]={}", + db[0], db[1], db[100], db[1000], db[100000]); + + // Create server + auto server_start = std::chrono::high_resolution_clock::now(); + YServer server(params, db, true, false, true); + auto server_elapsed = std::chrono::duration_cast( + std::chrono::high_resolution_clock::now() - server_start); + SPDLOG_INFO("Server setup: {} ms", server_elapsed.count()); + + // Offline precomputation + OfflinePrecomputedValues offline_vals; + try { + absl::Span empty_span; + std::string_view empty_path; + + auto offline_start = std::chrono::high_resolution_clock::now(); + offline_vals = + server.PerformOfflinePrecomputationSimplepir(empty_span, empty_path); + + auto offline_elapsed = + std::chrono::duration_cast( + std::chrono::high_resolution_clock::now() - offline_start); + SPDLOG_INFO("Offline precomputation: {} ms", offline_elapsed.count()); + EXPECT_GT(offline_elapsed.count(), 0); + EXPECT_GT(offline_vals.hint_0.size(), 0); + EXPECT_GT(offline_vals.prepacked_lwe.size(), 0); + } catch (const std::exception& e) { + SPDLOG_ERROR("Exception in offline precomputation: {}", e.what()); + throw; + } + + // Test querying multiple indices to verify SimplePIR correctness + // Test known values at different positions + std::vector test_indices = {0, 1, 100, 1000, 100000}; + std::vector expected_values = {100, 101, 200, 250, 300}; + + for (size_t i = 0; i < test_indices.size(); ++i) { + size_t target_idx = test_indices[i]; + uint16_t expected_value = expected_values[i]; + size_t test_row_idx = target_idx / db_cols; + size_t test_col_idx = target_idx % db_cols; + + SPDLOG_INFO("\n=== Query {}/{}: index={} (row={}, col={}), expected={} ===", + i + 1, test_indices.size(), target_idx, test_row_idx, + test_col_idx, expected_value); + + // Client generates keys and query + auto client_start = std::chrono::high_resolution_clock::now(); + uint128_t fixed_seed = yacl::MakeUint128(0, 12345); + SpiralClient spiral_client(params, fixed_seed); + YClient y_client(spiral_client, params, fixed_seed); + + auto simple_query = y_client.GenerateFullQuerySimplepir(target_idx); + + auto client_elapsed = std::chrono::duration_cast( + std::chrono::high_resolution_clock::now() - client_start); + + // Calculate query size breakdown + size_t packed_query_size = + simple_query.packed_query_row.size() * sizeof(uint32_t); + size_t pack_params_size = + simple_query.pack_pub_params_row_1s_pm.size() * sizeof(uint64_t); + size_t total_query_size = packed_query_size + pack_params_size; + + SPDLOG_INFO("Client query generation: {} ms", client_elapsed.count()); + SPDLOG_INFO( + " Query breakdown: packed_query={} KB ({} elements), pack_params={} " + "KB ({} elements), total={} KB", + packed_query_size / 1024, simple_query.packed_query_row.size(), + pack_params_size / 1024, simple_query.pack_pub_params_row_1s_pm.size(), + total_query_size / 1024); + if (i == 0) { + SPDLOG_INFO( + " NOTE: pack_params is the same for all queries from same client " + "and can be reused"); + SPDLOG_INFO( + " In practice, send pack_params once, then only send " + "packed_query (64 KB) for subsequent queries"); + } + + // Server online computation + auto online_start = std::chrono::high_resolution_clock::now(); + + std::vector> pack_params_spans; + if (!simple_query.pack_pub_params_row_1s_pm.empty()) { + pack_params_spans.push_back( + absl::MakeConstSpan(simple_query.pack_pub_params_row_1s_pm)); + } + + auto response = server.PerformOnlineComputationSimplepir( + absl::MakeConstSpan(simple_query.packed_query_row), offline_vals, + absl::MakeConstSpan(pack_params_spans)); + + auto online_elapsed = std::chrono::duration_cast( + std::chrono::high_resolution_clock::now() - online_start); + + // Calculate response size + size_t response_size = response.size(); + + SPDLOG_INFO("Server online: {} ms, Response size: {} bytes (~{} KB)", + online_elapsed.count(), response_size, response_size / 1024); + + // Client decodes response + auto decode_start = std::chrono::high_resolution_clock::now(); + YPIRClient ypir_client(params); + auto decoded_values = + ypir_client.DecodeResponseSimplepirYClient(params, y_client, response); + auto decode_elapsed = std::chrono::duration_cast( + std::chrono::high_resolution_clock::now() - decode_start); + SPDLOG_INFO("Client decode: {} ms", decode_elapsed.count()); + + // Verify correctness - SimplePIR returns entire row + EXPECT_EQ(decoded_values.size(), db_cols); + + uint64_t decoded_value = decoded_values[test_col_idx]; + SPDLOG_INFO("Decoded: {}, Expected: {}", decoded_value, expected_value); + + EXPECT_EQ(decoded_value, expected_value) + << "Query " << i + 1 << " failed at index " << target_idx; + + if (decoded_value == expected_value) { + SPDLOG_INFO("✓ Query {} passed", i + 1); + } + } + + SPDLOG_INFO("\n✓✓✓ All SimplePIR 1GB queries passed! ✓✓✓"); +} + +// DoublePIR test based on Rust scheme.rs test_ypir_basic +// This tests the full DoublePIR flow with a smaller database for testing +TEST_F(YPIRIntegrationTest, DoublePIRBasicFlow) { + SPDLOG_INFO("=== DoublePIR Basic Flow Test (Rust-aligned) ==="); + + // Align with Rust test: params_for_scenario(1 << 25, 1) + // This creates 32MB database with db_dim_1=2, db_dim_2=1 + std::size_t poly_len = 2048; + std::vector moduli = {268369921, 249561089}; + double noise_width = 6.4; + + // Parameters aligned with Rust: + // - pt_modulus = 32768 (p = 32768 in Rust) + // - q2_bits = 28 + // - t_exp_left = 3 + // - db_dim_1 = 2, db_dim_2 = 1 + PolyMatrixParams poly_matrix_params(2, 32768, 21, 4, 8, 8, 1); + QueryParams query_params(2, 1, 1); // db_dim_1=2, db_dim_2=1, instances=1 + + Params params(poly_len, std::move(moduli), noise_width, + std::move(poly_matrix_params), std::move(query_params)); + + size_t db_rows = 1ULL << (params.DbDim1() + params.PolyLenLog2()); + size_t db_cols = 1ULL << (params.DbDim2() + params.PolyLenLog2()); + size_t db_size = db_rows * db_cols; + + SPDLOG_INFO( + "DoublePIR test: db_rows={}, db_cols={}, db_size={} (~{} KB), " + "pt_modulus={}", + db_rows, db_cols, db_size, db_size / 1024, params.PtModulus()); + + // Create database counter % 256 + std::vector db(db_size); + for (size_t i = 0; i < db_size; ++i) { + db[i] = static_cast(i % 256); + } + + SPDLOG_INFO( + "Database created with sequential values (Rust-aligned): db[i] = i % " + "256"); + SPDLOG_INFO(" db[0-9]: [{}, {}, {}, {}, {}, {}, {}, {}, {}, {}]", + static_cast(db[0]), static_cast(db[1]), + static_cast(db[2]), static_cast(db[3]), + static_cast(db[4]), static_cast(db[5]), + static_cast(db[6]), static_cast(db[7]), + static_cast(db[8]), static_cast(db[9])); + SPDLOG_INFO(" Column 1 first element: db[8192]={}", + static_cast(db[8192])); + + // Create server (DoublePIR uses uint8_t database) + auto server_start = std::chrono::high_resolution_clock::now(); + YPirServer server( + params, db, false, false, + true); // is_simplepir=false, inp_transposed=false, pad_rows=true + auto server_elapsed = std::chrono::duration_cast( + std::chrono::high_resolution_clock::now() - server_start); + SPDLOG_INFO("Server setup: {} ms", server_elapsed.count()); + + // Offline precomputation + OfflinePrecomputedValues offline_vals; + auto offline_start = std::chrono::high_resolution_clock::now(); + offline_vals = server.PerformOfflinePrecomputation(); + auto offline_elapsed = std::chrono::duration_cast( + std::chrono::high_resolution_clock::now() - offline_start); + SPDLOG_INFO("Offline precomputation: {} ms", offline_elapsed.count()); + EXPECT_GT(offline_elapsed.count(), 0); + EXPECT_GT(offline_vals.hint_0.size(), 0); + EXPECT_GT(offline_vals.hint_1.size(), 0); + EXPECT_NE(offline_vals.smaller_server, nullptr); + + // Test querying index 50 (expected value: 50) - row 0, col 50 + size_t target_idx = 50; + uint8_t expected_value = db[target_idx]; + size_t target_row = target_idx / db_cols; + size_t target_col = target_idx % db_cols; + SPDLOG_INFO("Querying index {} (row={}, col={}, expected value: {})", + target_idx, target_row, target_col, + static_cast(expected_value)); + SPDLOG_INFO( + " Row-major: db[0-3]=[{}, {}, {}, {}], db[8192-8195]=[{}, {}, {}, {}]", + static_cast(db[0]), static_cast(db[1]), static_cast(db[2]), + static_cast(db[3]), static_cast(db[8192]), + static_cast(db[8193]), static_cast(db[8194]), + static_cast(db[8195])); + + // Client generates keys and query + auto client_start = std::chrono::high_resolution_clock::now(); + uint128_t fixed_seed = yacl::MakeUint128(0, 12345); + SpiralClient spiral_client(params, fixed_seed); + YClient y_client(spiral_client, params, fixed_seed); + + // Create LWE client for server-side debugging (same seed as client) + LWEParams lwe_params = LWEParams::Default(); + LWEClient debug_lwe_client = LWEClient::FromSeed(lwe_params, fixed_seed); + SPDLOG_INFO( + "Created debug LWE client with same seed for server-side decryption"); + + auto full_query = y_client.GenerateFullQuery(target_idx); + + auto client_elapsed = std::chrono::duration_cast( + std::chrono::high_resolution_clock::now() - client_start); + SPDLOG_INFO("Client query generation: {} ms", client_elapsed.count()); + + // Server online computation + auto online_start = std::chrono::high_resolution_clock::now(); + + // Prepare queries for DoublePIR + std::vector first_dim_queries_packed = full_query.packed_query_row; + + SPDLOG_INFO("First dim query size: {}", first_dim_queries_packed.size()); + SPDLOG_INFO("Second dim query col size: {}", + full_query.packed_query_col.size()); + SPDLOG_INFO("Pack pub params size: {}", + full_query.pack_pub_params_row_1s_pm.size()); + + std::vector, std::vector>> + second_dim_queries; + second_dim_queries.push_back( + {full_query.packed_query_col, full_query.pack_pub_params_row_1s_pm}); + + // Pass debug LWE client to server for verification + server.SetDebugLweClient(&debug_lwe_client); + server.SetDebugOriginalDb(db, db_rows, db_cols); + + SPDLOG_INFO("Calling PerformOnlineComputation..."); + std::vector> responses; + try { + responses = server.PerformOnlineComputation( + offline_vals, first_dim_queries_packed, second_dim_queries); + } catch (const std::exception& e) { + SPDLOG_ERROR("Exception in PerformOnlineComputation: {}", e.what()); + throw; + } + + auto online_elapsed = std::chrono::duration_cast( + std::chrono::high_resolution_clock::now() - online_start); + SPDLOG_INFO("Server online computation: {} ms", online_elapsed.count()); + + ASSERT_EQ(responses.size(), 1) << "Expected 1 response"; + + // Client decodes response + auto decode_start = std::chrono::high_resolution_clock::now(); + YPIRClient ypir_client(params); + uint64_t decoded_value = + ypir_client.DecodeResponseNormalYClient(params, y_client, responses[0]); + auto decode_elapsed = std::chrono::duration_cast( + std::chrono::high_resolution_clock::now() - decode_start); + SPDLOG_INFO("Client decode: {} ms", decode_elapsed.count()); + + // Verify correctness + SPDLOG_INFO("Decoded value: {}, Expected: {}", decoded_value, + static_cast(expected_value)); + EXPECT_EQ(decoded_value, static_cast(expected_value)) + << "Decoded value mismatch"; + + SPDLOG_INFO("✓ DoublePIR correctness verified!"); +} + +// Test DoublePIR with multiple different indices to verify robustness +TEST_F(YPIRIntegrationTest, DoublePIRMultipleIndices) { + SPDLOG_INFO("=== DoublePIR Multiple Indices Test ==="); + + std::size_t poly_len = 2048; + std::vector moduli = {268369921, 249561089}; + double noise_width = 6.4; + PolyMatrixParams poly_matrix_params(2, 32768, 21, 4, 8, 8, 1); + QueryParams query_params(2, 1, 1); + Params params(poly_len, std::move(moduli), noise_width, + std::move(poly_matrix_params), std::move(query_params)); + + size_t db_rows = 1ULL << (params.DbDim1() + params.PolyLenLog2()); + size_t db_cols = 1ULL << (params.DbDim2() + params.PolyLenLog2()); + size_t db_size = db_rows * db_cols; + + SPDLOG_INFO("Database: rows={}, cols={}, size={}", db_rows, db_cols, db_size); + + // Create database with sequential values + std::vector db(db_size); + for (size_t i = 0; i < db_size; ++i) { + db[i] = static_cast(i % 256); + } + + YPirServer server(params, db, false, false, true); + auto offline_vals = server.PerformOfflinePrecomputation(); + + uint128_t fixed_seed = yacl::MakeUint128(0, 12345); + + // Test various indices across different rows and columns + std::vector test_indices = { + 0, // First element (row=0, col=0) + 50, // Same row, different col (row=0, col=50) + }; + + // Create client once with fixed seed to ensure deterministic queries + SpiralClient spiral_client(params, fixed_seed); + YClient y_client(spiral_client, params, fixed_seed); + + for (size_t i = 0; i < test_indices.size(); ++i) { + size_t target_idx = test_indices[i]; + uint8_t expected_value = db[target_idx]; + size_t target_row = target_idx / db_cols; + size_t target_col = target_idx % db_cols; + + SPDLOG_INFO("\n--- Query {}/{}: index={} (row={}, col={}), expected={} ---", + i + 1, test_indices.size(), target_idx, target_row, target_col, + static_cast(expected_value)); + + // Fresh offline values for each query + auto offline_vals_copy = server.PerformOfflinePrecomputation(); + + auto full_query = y_client.GenerateFullQuery(target_idx); + + std::vector, std::vector>> + second_dim_queries; + second_dim_queries.push_back( + {full_query.packed_query_col, full_query.pack_pub_params_row_1s_pm}); + + auto responses = server.PerformOnlineComputation( + offline_vals_copy, full_query.packed_query_row, second_dim_queries); + + ASSERT_EQ(responses.size(), 1); + + YPIRClient ypir_client(params); + uint64_t decoded_value = + ypir_client.DecodeResponseNormalYClient(params, y_client, responses[0]); + + SPDLOG_INFO("Decoded: {}, Expected: {}", decoded_value, + static_cast(expected_value)); + + EXPECT_EQ(decoded_value, static_cast(expected_value)) + << "Query " << i + 1 << " failed at index " << target_idx; + + if (decoded_value == static_cast(expected_value)) { + SPDLOG_INFO("✓ Query {} passed", i + 1); + } else { + SPDLOG_ERROR("✗ Query {} FAILED", i + 1); + } + } + + SPDLOG_INFO("\n✓✓✓ All {} DoublePIR queries passed! ✓✓✓", + test_indices.size()); +} +/* +// Test DoublePIR with random database values +TEST_F(YPIRIntegrationTest, DoublePIRRandomDatabase) { + SPDLOG_INFO("=== DoublePIR Random Database Test ==="); + + std::size_t poly_len = 2048; + std::vector moduli = {268369921, 249561089}; + double noise_width = 6.4; + PolyMatrixParams poly_matrix_params(2, 32768, 21, 4, 8, 8, 1); + QueryParams query_params(2, 1, 1); + Params params(poly_len, std::move(moduli), noise_width, + std::move(poly_matrix_params), std::move(query_params)); + + size_t db_rows = 1ULL << (params.DbDim1() + params.PolyLenLog2()); + size_t db_cols = 1ULL << (params.DbDim2() + params.PolyLenLog2()); + size_t db_size = db_rows * db_cols; + + // Create database with random values + std::vector db(db_size); + std::mt19937 gen(42); // Fixed seed for reproducibility + std::uniform_int_distribution<> dis(0, 255); + for (auto& val : db) { + val = static_cast(dis(gen)); + } + + SPDLOG_INFO("Random database created with seed=42"); + SPDLOG_INFO("Sample values: db[0]={}, db[50]={}, db[8192]={}, db[16384]={}", + static_cast(db[0]), static_cast(db[50]), + static_cast(db[8192]), static_cast(db[16384])); + + YPirServer server(params, db, false, false, true); + + uint128_t fixed_seed = yacl::MakeUint128(0, 12345); + + // Test random indices + std::vector test_indices = {0, 50, 1000, 8192, 10000, 20000, 30000}; + + for (size_t i = 0; i < test_indices.size(); ++i) { + size_t target_idx = test_indices[i]; + uint8_t expected_value = db[target_idx]; + size_t target_row = target_idx / db_cols; + size_t target_col = target_idx % db_cols; + + SPDLOG_INFO("\n--- Query {}/{}: index={} (row={}, col={}), expected={} ---", + i + 1, test_indices.size(), target_idx, target_row, target_col, + static_cast(expected_value)); + + auto offline_vals = server.PerformOfflinePrecomputation(); + + SpiralClient spiral_client(params, fixed_seed); + YClient y_client(spiral_client, params, fixed_seed); + auto full_query = y_client.GenerateFullQuery(target_idx); + + std::vector, std::vector>> + second_dim_queries; + second_dim_queries.push_back( + {full_query.packed_query_col, full_query.pack_pub_params_row_1s_pm}); + + auto responses = server.PerformOnlineComputation( + offline_vals, full_query.packed_query_row, second_dim_queries); + + ASSERT_EQ(responses.size(), 1); + + YPIRClient ypir_client(params); + uint64_t decoded_value = + ypir_client.DecodeResponseNormalYClient(params, y_client, responses[0]); + + EXPECT_EQ(decoded_value, static_cast(expected_value)) + << "Query failed at index " << target_idx; + + if (decoded_value == static_cast(expected_value)) { + SPDLOG_INFO("✓ Query {} passed (decoded={}, expected={})", i + 1, + decoded_value, static_cast(expected_value)); + } else { + SPDLOG_ERROR("✗ Query {} FAILED (decoded={}, expected={})", i + 1, + decoded_value, static_cast(expected_value)); + } + } + + SPDLOG_INFO("\n✓✓✓ All random database queries passed! ✓✓✓"); +} + +// Test DoublePIR with larger database (different dimensions) +TEST_F(YPIRIntegrationTest, DoublePIRLargerDatabase) { + SPDLOG_INFO("=== DoublePIR Larger Database Test ==="); + + std::size_t poly_len = 2048; + std::vector moduli = {268369921, 249561089}; + double noise_width = 6.4; + PolyMatrixParams poly_matrix_params(2, 32768, 21, 4, 8, 8, 1); + // Larger database: db_dim_1=3, db_dim_2=2 -> 16384 rows × 8192 cols + QueryParams query_params(3, 2, 1); + Params params(poly_len, std::move(moduli), noise_width, + std::move(poly_matrix_params), std::move(query_params)); + + size_t db_rows = 1ULL << (params.DbDim1() + params.PolyLenLog2()); + size_t db_cols = 1ULL << (params.DbDim2() + params.PolyLenLog2()); + size_t db_size = db_rows * db_cols; + + SPDLOG_INFO("Larger database: rows={}, cols={}, size={} (~{} MB)", db_rows, + db_cols, db_size, db_size / (1024 * 1024)); + + // Create database with sequential values + std::vector db(db_size); + for (size_t i = 0; i < db_size; ++i) { + db[i] = static_cast(i % 256); + } + + YPirServer server(params, db, false, false, true); + + SPDLOG_INFO("Starting offline precomputation for larger database..."); + auto offline_start = std::chrono::high_resolution_clock::now(); + auto offline_vals = server.PerformOfflinePrecomputation(); + auto offline_elapsed = std::chrono::duration_cast( + std::chrono::high_resolution_clock::now() - offline_start); + SPDLOG_INFO("Offline precomputation completed: {} ms", + offline_elapsed.count()); + + uint128_t fixed_seed = yacl::MakeUint128(0, 12345); + + // Test strategic indices in larger database + std::vector test_indices = { + 0, // First element + 100, // Row 0 + 8192, // First col of row 1 + 16384, // First col of row 2 + 100000, // Middle of database + db_size / 2, // Halfway point + db_size - 1 // Last element + }; + + for (size_t i = 0; i < test_indices.size(); ++i) { + size_t target_idx = test_indices[i]; + if (target_idx >= db_size) continue; + + uint8_t expected_value = db[target_idx]; + size_t target_row = target_idx / db_cols; + size_t target_col = target_idx % db_cols; + + SPDLOG_INFO("\n--- Query {}/{}: index={} (row={}, col={}), expected={} ---", + i + 1, test_indices.size(), target_idx, target_row, target_col, + static_cast(expected_value)); + + auto offline_vals_copy = server.PerformOfflinePrecomputation(); + + auto query_start = std::chrono::high_resolution_clock::now(); + SpiralClient spiral_client(params, fixed_seed); + YClient y_client(spiral_client, params, fixed_seed); + auto full_query = y_client.GenerateFullQuery(target_idx); + auto query_elapsed = std::chrono::duration_cast( + std::chrono::high_resolution_clock::now() - query_start); + + auto online_start = std::chrono::high_resolution_clock::now(); + std::vector, std::vector>> + second_dim_queries; + second_dim_queries.push_back( + {full_query.packed_query_col, full_query.pack_pub_params_row_1s_pm}); + + auto responses = server.PerformOnlineComputation( + offline_vals_copy, full_query.packed_query_row, second_dim_queries); + auto online_elapsed = std::chrono::duration_cast( + std::chrono::high_resolution_clock::now() - online_start); + + ASSERT_EQ(responses.size(), 1); + + auto decode_start = std::chrono::high_resolution_clock::now(); + YPIRClient ypir_client(params); + uint64_t decoded_value = + ypir_client.DecodeResponseNormalYClient(params, y_client, responses[0]); + auto decode_elapsed = std::chrono::duration_cast( + std::chrono::high_resolution_clock::now() - decode_start); + + SPDLOG_INFO("Timings: query={} ms, online={} ms, decode={} ms", + query_elapsed.count(), online_elapsed.count(), + decode_elapsed.count()); + + EXPECT_EQ(decoded_value, static_cast(expected_value)) + << "Query failed at index " << target_idx; + + if (decoded_value == static_cast(expected_value)) { + SPDLOG_INFO("✓ Query {} passed", i + 1); + } else { + SPDLOG_ERROR("✗ Query {} FAILED", i + 1); + } + } + + SPDLOG_INFO("\n✓✓✓ All larger database queries passed! ✓✓✓"); +} +*/ + +/* +// Test DoublePIR with multiple queries in one test - query same index 3 times +TEST_F(YPIRIntegrationTest, DoublePIRMultipleQueries) { + SPDLOG_INFO("=== DoublePIR Multiple Queries Test ==="); + + std::size_t poly_len = 2048; + std::vector moduli = {268369921, 249561089}; + double noise_width = 6.4; + PolyMatrixParams poly_matrix_params(2, 32768, 21, 4, 8, 8, 1); + QueryParams query_params(1, 2, 1); + Params params(poly_len, std::move(moduli), noise_width, + std::move(poly_matrix_params), std::move(query_params)); + + size_t db_rows = 1ULL << (params.DbDim1() + params.PolyLenLog2()); + size_t db_cols = 1ULL << (params.DbDim2() + params.PolyLenLog2()); + size_t db_size = db_rows * db_cols; + + std::vector db(db_size); + std::mt19937 gen(42); + std::uniform_int_distribution<> dis(0, 255); + for (auto& val : db) { + val = static_cast(dis(gen)); + } + // Add known test values BEFORE creating server + if (db_size > 1000) { + db[0] = 42; + db[1] = 43; + db[100] = 142; + db[1000] = 200; + } + + // Set test values for multiple queries + // - index 0 (row=0, col=0): same row, first col + // - index 8192 (row=1, col=0): different row, first col + // - index 8193 (row=1, col=1): different row, second col + db[8192] = 99; // row=1, col=0 + db[8193] = 88; // row=1, col=1 + + // Create server once + YPirServer server(params, db, false, false, true); + + // Debug: Print database layout + SPDLOG_INFO("Database layout: db_rows={}, db_cols={}", db_rows, db_cols); + SPDLOG_INFO("Verify expected values: db[0]={}, db[8192]={}, db[8193]={}", + static_cast(db[0]), static_cast(db[8192]), + static_cast(db[8193])); + + // Test 3 different queries + // Need to perform offline precomputation for EACH query because + // PerformOnlineComputation modifies offline_vals.hint_1 + + std::vector test_indices = {0, 8192, 8193}; + std::vector expected_values = {42, 99, 88}; + uint128_t fixed_seed = yacl::MakeUint128(0, 12345); + + for (size_t i = 0; i < test_indices.size(); ++i) { + size_t target_idx = test_indices[i]; + uint8_t expected_value = expected_values[i]; + + size_t target_row = target_idx / db_cols; + size_t target_col = target_idx % db_cols; + + // Perform offline precomputation for each query + OfflinePrecomputedValues offline_vals = +server.PerformOfflinePrecomputation(); + + SPDLOG_INFO("Query {}/3: index={} (row={}, col={}), expected={}", + i + 1, target_idx, target_row, target_col, + static_cast(expected_value)); + + // Create new client for each query with same seed + SpiralClient spiral_client(params, fixed_seed); + YClient y_client(spiral_client, params, fixed_seed); + auto full_query = y_client.GenerateFullQuery(target_idx); + + // Debug: check if queries are actually different + SPDLOG_INFO(" Query row first 5 values: [{}, {}, {}, {}, {}]", + full_query.packed_query_row[0], +full_query.packed_query_row[1], full_query.packed_query_row[2], +full_query.packed_query_row[3], full_query.packed_query_row[4]); + SPDLOG_INFO(" Query col first 5 values: [{}, {}, {}, {}, {}]", + full_query.packed_query_col[0], +full_query.packed_query_col[1], full_query.packed_query_col[2], +full_query.packed_query_col[3], full_query.packed_query_col[4]); + + std::vector first_dim_queries_packed = + full_query.packed_query_row; + std::vector, std::vector>> + second_dim_queries; + second_dim_queries.push_back( + {full_query.packed_query_col, +full_query.pack_pub_params_row_1s_pm}); + + auto responses = server.PerformOnlineComputation( + offline_vals, first_dim_queries_packed, second_dim_queries); + ASSERT_EQ(responses.size(), 1); + + YPIRClient ypir_client(params); + uint64_t decoded_value = + ypir_client.DecodeResponseNormalYClient(params, y_client, +responses[0]); + + SPDLOG_INFO(" Decoded: {}, Expected: {}", decoded_value, + static_cast(expected_value)); + + EXPECT_EQ(decoded_value, static_cast(expected_value)) + << "Query " << i + 1 << " (index=" << target_idx << ") failed: +decoded " + << decoded_value << ", expected " << +static_cast(expected_value); + + if (decoded_value == static_cast(expected_value)) { + SPDLOG_INFO(" ✓ Query {} passed", i + 1); + } else { + SPDLOG_ERROR(" ✗ Query {} FAILED", i + 1); + } + } + + SPDLOG_INFO("✓ All 3 different queries tested!"); +} +*/ \ No newline at end of file diff --git a/psi/algorithm/ypir/matmul.cpp b/psi/algorithm/ypir/matmul.cpp new file mode 100644 index 00000000..b8114ef4 --- /dev/null +++ b/psi/algorithm/ypir/matmul.cpp @@ -0,0 +1,1556 @@ +/* +See https://github.com/ahenzinger/simplepir for original. + +MIT License + +Copyright (c) 2022, Alexandra Henzinger + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ + +// #define PROFILE + +#include +#include +#include + +#ifdef PROFILE +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +struct System { + static void profile(const std::string &name, std::function body) { + std::string filename = + name.find(".data") == std::string::npos ? (name + ".data") : name; + + // Launch profiler + pid_t pid; + std::stringstream s; + s << getpid(); + pid = fork(); + if (pid == 0) { + exit(execl("/usr/bin/perf", "perf", "stat", "-e", + "cache-references,cache-misses,cycles,instructions,branches," + "faults,migrations,l1d.replacement,l2_rqsts.all_demand_miss," + "cycle_activity.stalls_l3_miss", + "-o", filename.c_str(), "-p", s.str().c_str(), nullptr)); + } + + // Run body + body(); + + // Kill profiler + kill(pid, SIGINT); + waitpid(pid, nullptr, 0); + } + + static void profile(std::function body) { + profile("perf.data", body); + } +}; +#endif + +typedef uint32_t Elem; + +extern "C" { +void matMulVecPacked(uint32_t *out, const uint32_t *a, const uint32_t *b, + size_t aRows, size_t aCols); + +void matMulVecPacked2(Elem *out, const Elem *a, const Elem *b_full, + size_t aRows, size_t aCols); + +void matMulVecPacked4(Elem *out, const Elem *a, const Elem *b_full, + size_t aRows, size_t aCols); + +void matMulVecPacked6(Elem *out, const Elem *a, const Elem *b_full, + size_t aRows, size_t aCols); + +void matMulVecPacked8(Elem *out, const Elem *a, const Elem *b_full, + size_t aRows, size_t aCols); + +void matMulVecPacked8Alt(Elem *out, const Elem *a, const Elem *b_full, + size_t aRows, size_t aCols); + +void matMulVecPacked8Orig(Elem *out, const Elem *a, const Elem *b_full, + size_t aRows, size_t aCols); +} + +// Hard-coded, to allow for compiler optimizations: +#define COMPRESSION 4 +#define BASIS 8 +#define BASIS2 16 +#define BASIS3 24 +#define MASK 0xff + +void matMulVecPacked(uint32_t *out, const uint32_t *a, const uint32_t *b, + size_t aRows, size_t aCols) { + uint32_t db, db2, db3, db4, db5, db6, db7, db8; + uint32_t val, val2, val3, val4, val5, val6, val7, val8; + uint32_t tmp, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, tmp8; + size_t index = 0; + size_t index2; + + for (size_t i = 0; i < aRows; i += 8) { + tmp = 0; + tmp2 = 0; + tmp3 = 0; + tmp4 = 0; + tmp5 = 0; + tmp6 = 0; + tmp7 = 0; + tmp8 = 0; + + index2 = 0; + for (size_t j = 0; j < aCols; j++) { + db = a[index]; + db2 = a[index + 1 * aCols]; + db3 = a[index + 2 * aCols]; + db4 = a[index + 3 * aCols]; + db5 = a[index + 4 * aCols]; + db6 = a[index + 5 * aCols]; + db7 = a[index + 6 * aCols]; + db8 = a[index + 7 * aCols]; + + val = db & MASK; + val2 = db2 & MASK; + val3 = db3 & MASK; + val4 = db4 & MASK; + val5 = db5 & MASK; + val6 = db6 & MASK; + val7 = db7 & MASK; + val8 = db8 & MASK; + tmp += val * b[index2]; + tmp2 += val2 * b[index2]; + tmp3 += val3 * b[index2]; + tmp4 += val4 * b[index2]; + tmp5 += val5 * b[index2]; + tmp6 += val6 * b[index2]; + tmp7 += val7 * b[index2]; + tmp8 += val8 * b[index2]; + index2 += 1; + + val = (db >> BASIS) & MASK; + val2 = (db2 >> BASIS) & MASK; + val3 = (db3 >> BASIS) & MASK; + val4 = (db4 >> BASIS) & MASK; + val5 = (db5 >> BASIS) & MASK; + val6 = (db6 >> BASIS) & MASK; + val7 = (db7 >> BASIS) & MASK; + val8 = (db8 >> BASIS) & MASK; + tmp += val * b[index2]; + tmp2 += val2 * b[index2]; + tmp3 += val3 * b[index2]; + tmp4 += val4 * b[index2]; + tmp5 += val5 * b[index2]; + tmp6 += val6 * b[index2]; + tmp7 += val7 * b[index2]; + tmp8 += val8 * b[index2]; + index2 += 1; + + val = (db >> BASIS2) & MASK; + val2 = (db2 >> BASIS2) & MASK; + val3 = (db3 >> BASIS2) & MASK; + val4 = (db4 >> BASIS2) & MASK; + val5 = (db5 >> BASIS2) & MASK; + val6 = (db6 >> BASIS2) & MASK; + val7 = (db7 >> BASIS2) & MASK; + val8 = (db8 >> BASIS2) & MASK; + tmp += val * b[index2]; + tmp2 += val2 * b[index2]; + tmp3 += val3 * b[index2]; + tmp4 += val4 * b[index2]; + tmp5 += val5 * b[index2]; + tmp6 += val6 * b[index2]; + tmp7 += val7 * b[index2]; + tmp8 += val8 * b[index2]; + index2 += 1; + + val = (db >> BASIS3) & MASK; + val2 = (db2 >> BASIS3) & MASK; + val3 = (db3 >> BASIS3) & MASK; + val4 = (db4 >> BASIS3) & MASK; + val5 = (db5 >> BASIS3) & MASK; + val6 = (db6 >> BASIS3) & MASK; + val7 = (db7 >> BASIS3) & MASK; + val8 = (db8 >> BASIS3) & MASK; + tmp += val * b[index2]; + tmp2 += val2 * b[index2]; + tmp3 += val3 * b[index2]; + tmp4 += val4 * b[index2]; + tmp5 += val5 * b[index2]; + tmp6 += val6 * b[index2]; + tmp7 += val7 * b[index2]; + tmp8 += val8 * b[index2]; + index2 += 1; + index += 1; + } + out[i] += tmp; + out[i + 1] += tmp2; + out[i + 2] += tmp3; + out[i + 3] += tmp4; + out[i + 4] += tmp5; + out[i + 5] += tmp6; + out[i + 6] += tmp7; + out[i + 7] += tmp8; + index += aCols * 7; + } +} + +void matMulVecPacked2(Elem *out, const Elem *a, const Elem *b_full, + size_t aRows, size_t aCols) { + // in this variant, b has 2 columns + + Elem db, db2, db3, db4, db5, db6, db7, db8; + Elem val, val2, val3, val4, val5, val6, val7, val8; + Elem tmp, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, tmp8; + Elem x_tmp, x_tmp2, x_tmp3, x_tmp4, x_tmp5, x_tmp6, x_tmp7, x_tmp8; + size_t index = 0; + size_t index2; + + const Elem *b = b_full; + const Elem *b2 = b_full + aCols * COMPRESSION; + + for (size_t i = 0; i < aRows; i += 8) { + tmp = 0; + tmp2 = 0; + tmp3 = 0; + tmp4 = 0; + tmp5 = 0; + tmp6 = 0; + tmp7 = 0; + tmp8 = 0; + + x_tmp = 0; + x_tmp2 = 0; + x_tmp3 = 0; + x_tmp4 = 0; + x_tmp5 = 0; + x_tmp6 = 0; + x_tmp7 = 0; + x_tmp8 = 0; + + index2 = 0; + for (size_t j = 0; j < aCols; j++) { + db = a[index]; + db2 = a[index + 1 * aCols]; + db3 = a[index + 2 * aCols]; + db4 = a[index + 3 * aCols]; + db5 = a[index + 4 * aCols]; + db6 = a[index + 5 * aCols]; + db7 = a[index + 6 * aCols]; + db8 = a[index + 7 * aCols]; + + val = db & MASK; + val2 = db2 & MASK; + val3 = db3 & MASK; + val4 = db4 & MASK; + val5 = db5 & MASK; + val6 = db6 & MASK; + val7 = db7 & MASK; + val8 = db8 & MASK; + tmp += val * b[index2]; + tmp2 += val2 * b[index2]; + tmp3 += val3 * b[index2]; + tmp4 += val4 * b[index2]; + tmp5 += val5 * b[index2]; + tmp6 += val6 * b[index2]; + tmp7 += val7 * b[index2]; + tmp8 += val8 * b[index2]; + x_tmp += val * b2[index2]; + x_tmp2 += val2 * b2[index2]; + x_tmp3 += val3 * b2[index2]; + x_tmp4 += val4 * b2[index2]; + x_tmp5 += val5 * b2[index2]; + x_tmp6 += val6 * b2[index2]; + x_tmp7 += val7 * b2[index2]; + x_tmp8 += val8 * b2[index2]; + index2 += 1; + + val = (db >> BASIS) & MASK; + val2 = (db2 >> BASIS) & MASK; + val3 = (db3 >> BASIS) & MASK; + val4 = (db4 >> BASIS) & MASK; + val5 = (db5 >> BASIS) & MASK; + val6 = (db6 >> BASIS) & MASK; + val7 = (db7 >> BASIS) & MASK; + val8 = (db8 >> BASIS) & MASK; + tmp += val * b[index2]; + tmp2 += val2 * b[index2]; + tmp3 += val3 * b[index2]; + tmp4 += val4 * b[index2]; + tmp5 += val5 * b[index2]; + tmp6 += val6 * b[index2]; + tmp7 += val7 * b[index2]; + tmp8 += val8 * b[index2]; + x_tmp += val * b2[index2]; + x_tmp2 += val2 * b2[index2]; + x_tmp3 += val3 * b2[index2]; + x_tmp4 += val4 * b2[index2]; + x_tmp5 += val5 * b2[index2]; + x_tmp6 += val6 * b2[index2]; + x_tmp7 += val7 * b2[index2]; + x_tmp8 += val8 * b2[index2]; + index2 += 1; + + val = (db >> BASIS2) & MASK; + val2 = (db2 >> BASIS2) & MASK; + val3 = (db3 >> BASIS2) & MASK; + val4 = (db4 >> BASIS2) & MASK; + val5 = (db5 >> BASIS2) & MASK; + val6 = (db6 >> BASIS2) & MASK; + val7 = (db7 >> BASIS2) & MASK; + val8 = (db8 >> BASIS2) & MASK; + tmp += val * b[index2]; + tmp2 += val2 * b[index2]; + tmp3 += val3 * b[index2]; + tmp4 += val4 * b[index2]; + tmp5 += val5 * b[index2]; + tmp6 += val6 * b[index2]; + tmp7 += val7 * b[index2]; + tmp8 += val8 * b[index2]; + x_tmp += val * b2[index2]; + x_tmp2 += val2 * b2[index2]; + x_tmp3 += val3 * b2[index2]; + x_tmp4 += val4 * b2[index2]; + x_tmp5 += val5 * b2[index2]; + x_tmp6 += val6 * b2[index2]; + x_tmp7 += val7 * b2[index2]; + x_tmp8 += val8 * b2[index2]; + index2 += 1; + + val = (db >> BASIS3) & MASK; + val2 = (db2 >> BASIS3) & MASK; + val3 = (db3 >> BASIS3) & MASK; + val4 = (db4 >> BASIS3) & MASK; + val5 = (db5 >> BASIS3) & MASK; + val6 = (db6 >> BASIS3) & MASK; + val7 = (db7 >> BASIS3) & MASK; + val8 = (db8 >> BASIS3) & MASK; + tmp += val * b[index2]; + tmp2 += val2 * b[index2]; + tmp3 += val3 * b[index2]; + tmp4 += val4 * b[index2]; + tmp5 += val5 * b[index2]; + tmp6 += val6 * b[index2]; + tmp7 += val7 * b[index2]; + tmp8 += val8 * b[index2]; + x_tmp += val * b2[index2]; + x_tmp2 += val2 * b2[index2]; + x_tmp3 += val3 * b2[index2]; + x_tmp4 += val4 * b2[index2]; + x_tmp5 += val5 * b2[index2]; + x_tmp6 += val6 * b2[index2]; + x_tmp7 += val7 * b2[index2]; + x_tmp8 += val8 * b2[index2]; + index2 += 1; + + index += 1; + } + out[2 * i] += tmp; + out[2 * i + 1] += x_tmp; + out[2 * i + 2] += tmp2; + out[2 * i + 3] += x_tmp2; + out[2 * i + 4] += tmp3; + out[2 * i + 5] += x_tmp3; + out[2 * i + 6] += tmp4; + out[2 * i + 7] += x_tmp4; + out[2 * i + 8] += tmp5; + out[2 * i + 9] += x_tmp5; + out[2 * i + 10] += tmp6; + out[2 * i + 11] += x_tmp6; + out[2 * i + 12] += tmp7; + out[2 * i + 13] += x_tmp7; + out[2 * i + 14] += tmp8; + out[2 * i + 15] += x_tmp8; + index += aCols * 7; + } +} + +void trueMatMulVecPacked4(Elem *out, const Elem *a, const Elem *b_full, + size_t aRows, size_t aCols) { + // in this variant, b has 4 columns + + Elem db, db2, db3, db4, db5, db6, db7, db8; + Elem val, val2, val3, val4, val5, val6, val7, val8; + Elem tmp, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, tmp8; + Elem x_tmp, x_tmp2, x_tmp3, x_tmp4, x_tmp5, x_tmp6, x_tmp7, x_tmp8; + Elem y_tmp, y_tmp2, y_tmp3, y_tmp4, y_tmp5, y_tmp6, y_tmp7, y_tmp8; + Elem z_tmp, z_tmp2, z_tmp3, z_tmp4, z_tmp5, z_tmp6, z_tmp7, z_tmp8; + size_t index = 0; + size_t index2; + + const Elem *b = b_full; + const Elem *b2 = b_full + aCols * COMPRESSION; + const Elem *b3 = b_full + 2 * aCols * COMPRESSION; + const Elem *b4 = b_full + 3 * aCols * COMPRESSION; + + for (size_t i = 0; i < aRows; i += 8) { + tmp = 0; + tmp2 = 0; + tmp3 = 0; + tmp4 = 0; + tmp5 = 0; + tmp6 = 0; + tmp7 = 0; + tmp8 = 0; + + x_tmp = 0; + x_tmp2 = 0; + x_tmp3 = 0; + x_tmp4 = 0; + x_tmp5 = 0; + x_tmp6 = 0; + x_tmp7 = 0; + x_tmp8 = 0; + + y_tmp = 0; + y_tmp2 = 0; + y_tmp3 = 0; + y_tmp4 = 0; + y_tmp5 = 0; + y_tmp6 = 0; + y_tmp7 = 0; + y_tmp8 = 0; + + z_tmp = 0; + z_tmp2 = 0; + z_tmp3 = 0; + z_tmp4 = 0; + z_tmp5 = 0; + z_tmp6 = 0; + z_tmp7 = 0; + z_tmp8 = 0; + + index2 = 0; + for (size_t j = 0; j < aCols; j++) { + db = a[index]; + db2 = a[index + 1 * aCols]; + db3 = a[index + 2 * aCols]; + db4 = a[index + 3 * aCols]; + db5 = a[index + 4 * aCols]; + db6 = a[index + 5 * aCols]; + db7 = a[index + 6 * aCols]; + db8 = a[index + 7 * aCols]; + + val = db & MASK; + val2 = db2 & MASK; + val3 = db3 & MASK; + val4 = db4 & MASK; + val5 = db5 & MASK; + val6 = db6 & MASK; + val7 = db7 & MASK; + val8 = db8 & MASK; + tmp += val * b[index2]; + tmp2 += val2 * b[index2]; + tmp3 += val3 * b[index2]; + tmp4 += val4 * b[index2]; + tmp5 += val5 * b[index2]; + tmp6 += val6 * b[index2]; + tmp7 += val7 * b[index2]; + tmp8 += val8 * b[index2]; + x_tmp += val * b2[index2]; + x_tmp2 += val2 * b2[index2]; + x_tmp3 += val3 * b2[index2]; + x_tmp4 += val4 * b2[index2]; + x_tmp5 += val5 * b2[index2]; + x_tmp6 += val6 * b2[index2]; + x_tmp7 += val7 * b2[index2]; + x_tmp8 += val8 * b2[index2]; + + y_tmp += val * b3[index2]; + y_tmp2 += val2 * b3[index2]; + y_tmp3 += val3 * b3[index2]; + y_tmp4 += val4 * b3[index2]; + y_tmp5 += val5 * b3[index2]; + y_tmp6 += val6 * b3[index2]; + y_tmp7 += val7 * b3[index2]; + y_tmp8 += val8 * b3[index2]; + + z_tmp += val * b4[index2]; + z_tmp2 += val2 * b4[index2]; + z_tmp3 += val3 * b4[index2]; + z_tmp4 += val4 * b4[index2]; + z_tmp5 += val5 * b4[index2]; + z_tmp6 += val6 * b4[index2]; + z_tmp7 += val7 * b4[index2]; + z_tmp8 += val8 * b4[index2]; + + index2 += 1; + + val = (db >> BASIS) & MASK; + val2 = (db2 >> BASIS) & MASK; + val3 = (db3 >> BASIS) & MASK; + val4 = (db4 >> BASIS) & MASK; + val5 = (db5 >> BASIS) & MASK; + val6 = (db6 >> BASIS) & MASK; + val7 = (db7 >> BASIS) & MASK; + val8 = (db8 >> BASIS) & MASK; + tmp += val * b[index2]; + tmp2 += val2 * b[index2]; + tmp3 += val3 * b[index2]; + tmp4 += val4 * b[index2]; + tmp5 += val5 * b[index2]; + tmp6 += val6 * b[index2]; + tmp7 += val7 * b[index2]; + tmp8 += val8 * b[index2]; + x_tmp += val * b2[index2]; + x_tmp2 += val2 * b2[index2]; + x_tmp3 += val3 * b2[index2]; + x_tmp4 += val4 * b2[index2]; + x_tmp5 += val5 * b2[index2]; + x_tmp6 += val6 * b2[index2]; + x_tmp7 += val7 * b2[index2]; + x_tmp8 += val8 * b2[index2]; + + y_tmp += val * b3[index2]; + y_tmp2 += val2 * b3[index2]; + y_tmp3 += val3 * b3[index2]; + y_tmp4 += val4 * b3[index2]; + y_tmp5 += val5 * b3[index2]; + y_tmp6 += val6 * b3[index2]; + y_tmp7 += val7 * b3[index2]; + y_tmp8 += val8 * b3[index2]; + + z_tmp += val * b4[index2]; + z_tmp2 += val2 * b4[index2]; + z_tmp3 += val3 * b4[index2]; + z_tmp4 += val4 * b4[index2]; + z_tmp5 += val5 * b4[index2]; + z_tmp6 += val6 * b4[index2]; + z_tmp7 += val7 * b4[index2]; + z_tmp8 += val8 * b4[index2]; + + index2 += 1; + + val = (db >> BASIS2) & MASK; + val2 = (db2 >> BASIS2) & MASK; + val3 = (db3 >> BASIS2) & MASK; + val4 = (db4 >> BASIS2) & MASK; + val5 = (db5 >> BASIS2) & MASK; + val6 = (db6 >> BASIS2) & MASK; + val7 = (db7 >> BASIS2) & MASK; + val8 = (db8 >> BASIS2) & MASK; + tmp += val * b[index2]; + tmp2 += val2 * b[index2]; + tmp3 += val3 * b[index2]; + tmp4 += val4 * b[index2]; + tmp5 += val5 * b[index2]; + tmp6 += val6 * b[index2]; + tmp7 += val7 * b[index2]; + tmp8 += val8 * b[index2]; + x_tmp += val * b2[index2]; + x_tmp2 += val2 * b2[index2]; + x_tmp3 += val3 * b2[index2]; + x_tmp4 += val4 * b2[index2]; + x_tmp5 += val5 * b2[index2]; + x_tmp6 += val6 * b2[index2]; + x_tmp7 += val7 * b2[index2]; + x_tmp8 += val8 * b2[index2]; + + y_tmp += val * b3[index2]; + y_tmp2 += val2 * b3[index2]; + y_tmp3 += val3 * b3[index2]; + y_tmp4 += val4 * b3[index2]; + y_tmp5 += val5 * b3[index2]; + y_tmp6 += val6 * b3[index2]; + y_tmp7 += val7 * b3[index2]; + y_tmp8 += val8 * b3[index2]; + + z_tmp += val * b4[index2]; + z_tmp2 += val2 * b4[index2]; + z_tmp3 += val3 * b4[index2]; + z_tmp4 += val4 * b4[index2]; + z_tmp5 += val5 * b4[index2]; + z_tmp6 += val6 * b4[index2]; + z_tmp7 += val7 * b4[index2]; + z_tmp8 += val8 * b4[index2]; + + index2 += 1; + + val = (db >> BASIS3) & MASK; + val2 = (db2 >> BASIS3) & MASK; + val3 = (db3 >> BASIS3) & MASK; + val4 = (db4 >> BASIS3) & MASK; + val5 = (db5 >> BASIS3) & MASK; + val6 = (db6 >> BASIS3) & MASK; + val7 = (db7 >> BASIS3) & MASK; + val8 = (db8 >> BASIS3) & MASK; + tmp += val * b[index2]; + tmp2 += val2 * b[index2]; + tmp3 += val3 * b[index2]; + tmp4 += val4 * b[index2]; + tmp5 += val5 * b[index2]; + tmp6 += val6 * b[index2]; + tmp7 += val7 * b[index2]; + tmp8 += val8 * b[index2]; + x_tmp += val * b2[index2]; + x_tmp2 += val2 * b2[index2]; + x_tmp3 += val3 * b2[index2]; + x_tmp4 += val4 * b2[index2]; + x_tmp5 += val5 * b2[index2]; + x_tmp6 += val6 * b2[index2]; + x_tmp7 += val7 * b2[index2]; + x_tmp8 += val8 * b2[index2]; + + y_tmp += val * b3[index2]; + y_tmp2 += val2 * b3[index2]; + y_tmp3 += val3 * b3[index2]; + y_tmp4 += val4 * b3[index2]; + y_tmp5 += val5 * b3[index2]; + y_tmp6 += val6 * b3[index2]; + y_tmp7 += val7 * b3[index2]; + y_tmp8 += val8 * b3[index2]; + + z_tmp += val * b4[index2]; + z_tmp2 += val2 * b4[index2]; + z_tmp3 += val3 * b4[index2]; + z_tmp4 += val4 * b4[index2]; + z_tmp5 += val5 * b4[index2]; + z_tmp6 += val6 * b4[index2]; + z_tmp7 += val7 * b4[index2]; + z_tmp8 += val8 * b4[index2]; + + index2 += 1; + + index += 1; + } + out[4 * i] += tmp; + out[4 * i + 1] += x_tmp; + out[4 * i + 2] += y_tmp; + out[4 * i + 3] += z_tmp; + out[4 * i + 4] += tmp2; + out[4 * i + 5] += x_tmp2; + out[4 * i + 6] += y_tmp2; + out[4 * i + 7] += z_tmp2; + out[4 * i + 8] += tmp3; + out[4 * i + 9] += x_tmp3; + out[4 * i + 10] += y_tmp3; + out[4 * i + 11] += z_tmp3; + out[4 * i + 12] += tmp4; + out[4 * i + 13] += x_tmp4; + out[4 * i + 14] += y_tmp4; + out[4 * i + 15] += z_tmp4; + out[4 * i + 16] += tmp5; + out[4 * i + 17] += x_tmp5; + out[4 * i + 18] += y_tmp5; + out[4 * i + 19] += z_tmp5; + out[4 * i + 20] += tmp6; + out[4 * i + 21] += x_tmp6; + out[4 * i + 22] += y_tmp6; + out[4 * i + 23] += z_tmp6; + out[4 * i + 24] += tmp7; + out[4 * i + 25] += x_tmp7; + out[4 * i + 26] += y_tmp7; + out[4 * i + 27] += z_tmp7; + out[4 * i + 28] += tmp8; + out[4 * i + 29] += x_tmp8; + out[4 * i + 30] += y_tmp8; + out[4 * i + 31] += z_tmp8; + index += aCols * 7; + } +} + +void matMulVecPacked4(Elem *out, const Elem *a, const Elem *b_full, + size_t aRows, size_t aCols) { +#ifdef PROFILE + System::profile("matmul4", [&]() { +#endif + trueMatMulVecPacked4(out, a, b_full, aRows, aCols); + +#ifdef PROFILE + }); +#endif +} + +void matMulVecPacked6(Elem *__restrict__ out, const Elem *__restrict__ a, + const Elem *__restrict__ b_full, size_t aRows, + size_t aCols) { + // in this variant, b has 6 columns + + Elem db, db2, db3, db4, db5, db6, db7, db8; + Elem val, val2, val3, val4, val5, val6, val7, val8; + Elem tmp, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, tmp8; + Elem x_tmp, x_tmp2, x_tmp3, x_tmp4, x_tmp5, x_tmp6, x_tmp7, x_tmp8; + Elem y_tmp, y_tmp2, y_tmp3, y_tmp4, y_tmp5, y_tmp6, y_tmp7, y_tmp8; + Elem z_tmp, z_tmp2, z_tmp3, z_tmp4, z_tmp5, z_tmp6, z_tmp7, z_tmp8; + Elem r_tmp, r_tmp2, r_tmp3, r_tmp4, r_tmp5, r_tmp6, r_tmp7, r_tmp8; + Elem s_tmp, s_tmp2, s_tmp3, s_tmp4, s_tmp5, s_tmp6, s_tmp7, s_tmp8; + size_t index = 0; + size_t index2; + + const Elem *b = b_full; + const Elem *b2 = b_full + aCols * COMPRESSION; + const Elem *b3 = b_full + 2 * aCols * COMPRESSION; + const Elem *b4 = b_full + 3 * aCols * COMPRESSION; + const Elem *b5 = b_full + 4 * aCols * COMPRESSION; + const Elem *b6 = b_full + 5 * aCols * COMPRESSION; + + for (size_t i = 0; i < aRows; i += 8) { + tmp = 0; + tmp2 = 0; + tmp3 = 0; + tmp4 = 0; + tmp5 = 0; + tmp6 = 0; + tmp7 = 0; + tmp8 = 0; + + x_tmp = 0; + x_tmp2 = 0; + x_tmp3 = 0; + x_tmp4 = 0; + x_tmp5 = 0; + x_tmp6 = 0; + x_tmp7 = 0; + x_tmp8 = 0; + + y_tmp = 0; + y_tmp2 = 0; + y_tmp3 = 0; + y_tmp4 = 0; + y_tmp5 = 0; + y_tmp6 = 0; + y_tmp7 = 0; + y_tmp8 = 0; + + z_tmp = 0; + z_tmp2 = 0; + z_tmp3 = 0; + z_tmp4 = 0; + z_tmp5 = 0; + z_tmp6 = 0; + z_tmp7 = 0; + z_tmp8 = 0; + + r_tmp = 0; + r_tmp2 = 0; + r_tmp3 = 0; + r_tmp4 = 0; + r_tmp5 = 0; + r_tmp6 = 0; + r_tmp7 = 0; + r_tmp8 = 0; + + s_tmp = 0; + s_tmp2 = 0; + s_tmp3 = 0; + s_tmp4 = 0; + s_tmp5 = 0; + s_tmp6 = 0; + s_tmp7 = 0; + s_tmp8 = 0; + + index2 = 0; + for (size_t j = 0; j < aCols; j++) { + db = a[index]; + db2 = a[index + 1 * aCols]; + db3 = a[index + 2 * aCols]; + db4 = a[index + 3 * aCols]; + db5 = a[index + 4 * aCols]; + db6 = a[index + 5 * aCols]; + db7 = a[index + 6 * aCols]; + db8 = a[index + 7 * aCols]; + + val = db & MASK; + val2 = db2 & MASK; + val3 = db3 & MASK; + val4 = db4 & MASK; + val5 = db5 & MASK; + val6 = db6 & MASK; + val7 = db7 & MASK; + val8 = db8 & MASK; + tmp += val * b[index2]; + tmp2 += val2 * b[index2]; + tmp3 += val3 * b[index2]; + tmp4 += val4 * b[index2]; + tmp5 += val5 * b[index2]; + tmp6 += val6 * b[index2]; + tmp7 += val7 * b[index2]; + tmp8 += val8 * b[index2]; + x_tmp += val * b2[index2]; + x_tmp2 += val2 * b2[index2]; + x_tmp3 += val3 * b2[index2]; + x_tmp4 += val4 * b2[index2]; + x_tmp5 += val5 * b2[index2]; + x_tmp6 += val6 * b2[index2]; + x_tmp7 += val7 * b2[index2]; + x_tmp8 += val8 * b2[index2]; + y_tmp += val * b3[index2]; + y_tmp2 += val2 * b3[index2]; + y_tmp3 += val3 * b3[index2]; + y_tmp4 += val4 * b3[index2]; + y_tmp5 += val5 * b3[index2]; + y_tmp6 += val6 * b3[index2]; + y_tmp7 += val7 * b3[index2]; + y_tmp8 += val8 * b3[index2]; + z_tmp += val * b4[index2]; + z_tmp2 += val2 * b4[index2]; + z_tmp3 += val3 * b4[index2]; + z_tmp4 += val4 * b4[index2]; + z_tmp5 += val5 * b4[index2]; + z_tmp6 += val6 * b4[index2]; + z_tmp7 += val7 * b4[index2]; + z_tmp8 += val8 * b4[index2]; + r_tmp += val * b5[index2]; + r_tmp2 += val2 * b5[index2]; + r_tmp3 += val3 * b5[index2]; + r_tmp4 += val4 * b5[index2]; + r_tmp5 += val5 * b5[index2]; + r_tmp6 += val6 * b5[index2]; + r_tmp7 += val7 * b5[index2]; + r_tmp8 += val8 * b5[index2]; + s_tmp += val * b6[index2]; + s_tmp2 += val2 * b6[index2]; + s_tmp3 += val3 * b6[index2]; + s_tmp4 += val4 * b6[index2]; + s_tmp5 += val5 * b6[index2]; + s_tmp6 += val6 * b6[index2]; + s_tmp7 += val7 * b6[index2]; + s_tmp8 += val8 * b6[index2]; + index2 += 1; + + val = (db >> BASIS) & MASK; + val2 = (db2 >> BASIS) & MASK; + val3 = (db3 >> BASIS) & MASK; + val4 = (db4 >> BASIS) & MASK; + val5 = (db5 >> BASIS) & MASK; + val6 = (db6 >> BASIS) & MASK; + val7 = (db7 >> BASIS) & MASK; + val8 = (db8 >> BASIS) & MASK; + tmp += val * b[index2]; + tmp2 += val2 * b[index2]; + tmp3 += val3 * b[index2]; + tmp4 += val4 * b[index2]; + tmp5 += val5 * b[index2]; + tmp6 += val6 * b[index2]; + tmp7 += val7 * b[index2]; + tmp8 += val8 * b[index2]; + x_tmp += val * b2[index2]; + x_tmp2 += val2 * b2[index2]; + x_tmp3 += val3 * b2[index2]; + x_tmp4 += val4 * b2[index2]; + x_tmp5 += val5 * b2[index2]; + x_tmp6 += val6 * b2[index2]; + x_tmp7 += val7 * b2[index2]; + x_tmp8 += val8 * b2[index2]; + y_tmp += val * b3[index2]; + y_tmp2 += val2 * b3[index2]; + y_tmp3 += val3 * b3[index2]; + y_tmp4 += val4 * b3[index2]; + y_tmp5 += val5 * b3[index2]; + y_tmp6 += val6 * b3[index2]; + y_tmp7 += val7 * b3[index2]; + y_tmp8 += val8 * b3[index2]; + z_tmp += val * b4[index2]; + z_tmp2 += val2 * b4[index2]; + z_tmp3 += val3 * b4[index2]; + z_tmp4 += val4 * b4[index2]; + z_tmp5 += val5 * b4[index2]; + z_tmp6 += val6 * b4[index2]; + z_tmp7 += val7 * b4[index2]; + z_tmp8 += val8 * b4[index2]; + r_tmp += val * b5[index2]; + r_tmp2 += val2 * b5[index2]; + r_tmp3 += val3 * b5[index2]; + r_tmp4 += val4 * b5[index2]; + r_tmp5 += val5 * b5[index2]; + r_tmp6 += val6 * b5[index2]; + r_tmp7 += val7 * b5[index2]; + r_tmp8 += val8 * b5[index2]; + s_tmp += val * b6[index2]; + s_tmp2 += val2 * b6[index2]; + s_tmp3 += val3 * b6[index2]; + s_tmp4 += val4 * b6[index2]; + s_tmp5 += val5 * b6[index2]; + s_tmp6 += val6 * b6[index2]; + s_tmp7 += val7 * b6[index2]; + s_tmp8 += val8 * b6[index2]; + index2 += 1; + + val = (db >> BASIS2) & MASK; + val2 = (db2 >> BASIS2) & MASK; + val3 = (db3 >> BASIS2) & MASK; + val4 = (db4 >> BASIS2) & MASK; + val5 = (db5 >> BASIS2) & MASK; + val6 = (db6 >> BASIS2) & MASK; + val7 = (db7 >> BASIS2) & MASK; + val8 = (db8 >> BASIS2) & MASK; + tmp += val * b[index2]; + tmp2 += val2 * b[index2]; + tmp3 += val3 * b[index2]; + tmp4 += val4 * b[index2]; + tmp5 += val5 * b[index2]; + tmp6 += val6 * b[index2]; + tmp7 += val7 * b[index2]; + tmp8 += val8 * b[index2]; + x_tmp += val * b2[index2]; + x_tmp2 += val2 * b2[index2]; + x_tmp3 += val3 * b2[index2]; + x_tmp4 += val4 * b2[index2]; + x_tmp5 += val5 * b2[index2]; + x_tmp6 += val6 * b2[index2]; + x_tmp7 += val7 * b2[index2]; + x_tmp8 += val8 * b2[index2]; + y_tmp += val * b3[index2]; + y_tmp2 += val2 * b3[index2]; + y_tmp3 += val3 * b3[index2]; + y_tmp4 += val4 * b3[index2]; + y_tmp5 += val5 * b3[index2]; + y_tmp6 += val6 * b3[index2]; + y_tmp7 += val7 * b3[index2]; + y_tmp8 += val8 * b3[index2]; + z_tmp += val * b4[index2]; + z_tmp2 += val2 * b4[index2]; + z_tmp3 += val3 * b4[index2]; + z_tmp4 += val4 * b4[index2]; + z_tmp5 += val5 * b4[index2]; + z_tmp6 += val6 * b4[index2]; + z_tmp7 += val7 * b4[index2]; + z_tmp8 += val8 * b4[index2]; + r_tmp += val * b5[index2]; + r_tmp2 += val2 * b5[index2]; + r_tmp3 += val3 * b5[index2]; + r_tmp4 += val4 * b5[index2]; + r_tmp5 += val5 * b5[index2]; + r_tmp6 += val6 * b5[index2]; + r_tmp7 += val7 * b5[index2]; + r_tmp8 += val8 * b5[index2]; + s_tmp += val * b6[index2]; + s_tmp2 += val2 * b6[index2]; + s_tmp3 += val3 * b6[index2]; + s_tmp4 += val4 * b6[index2]; + s_tmp5 += val5 * b6[index2]; + s_tmp6 += val6 * b6[index2]; + s_tmp7 += val7 * b6[index2]; + s_tmp8 += val8 * b6[index2]; + index2 += 1; + + val = (db >> BASIS3) & MASK; + val2 = (db2 >> BASIS3) & MASK; + val3 = (db3 >> BASIS3) & MASK; + val4 = (db4 >> BASIS3) & MASK; + val5 = (db5 >> BASIS3) & MASK; + val6 = (db6 >> BASIS3) & MASK; + val7 = (db7 >> BASIS3) & MASK; + val8 = (db8 >> BASIS3) & MASK; + tmp += val * b[index2]; + tmp2 += val2 * b[index2]; + tmp3 += val3 * b[index2]; + tmp4 += val4 * b[index2]; + tmp5 += val5 * b[index2]; + tmp6 += val6 * b[index2]; + tmp7 += val7 * b[index2]; + tmp8 += val8 * b[index2]; + x_tmp += val * b2[index2]; + x_tmp2 += val2 * b2[index2]; + x_tmp3 += val3 * b2[index2]; + x_tmp4 += val4 * b2[index2]; + x_tmp5 += val5 * b2[index2]; + x_tmp6 += val6 * b2[index2]; + x_tmp7 += val7 * b2[index2]; + x_tmp8 += val8 * b2[index2]; + y_tmp += val * b3[index2]; + y_tmp2 += val2 * b3[index2]; + y_tmp3 += val3 * b3[index2]; + y_tmp4 += val4 * b3[index2]; + y_tmp5 += val5 * b3[index2]; + y_tmp6 += val6 * b3[index2]; + y_tmp7 += val7 * b3[index2]; + y_tmp8 += val8 * b3[index2]; + z_tmp += val * b4[index2]; + z_tmp2 += val2 * b4[index2]; + z_tmp3 += val3 * b4[index2]; + z_tmp4 += val4 * b4[index2]; + z_tmp5 += val5 * b4[index2]; + z_tmp6 += val6 * b4[index2]; + z_tmp7 += val7 * b4[index2]; + z_tmp8 += val8 * b4[index2]; + r_tmp += val * b5[index2]; + r_tmp2 += val2 * b5[index2]; + r_tmp3 += val3 * b5[index2]; + r_tmp4 += val4 * b5[index2]; + r_tmp5 += val5 * b5[index2]; + r_tmp6 += val6 * b5[index2]; + r_tmp7 += val7 * b5[index2]; + r_tmp8 += val8 * b5[index2]; + s_tmp += val * b6[index2]; + s_tmp2 += val2 * b6[index2]; + s_tmp3 += val3 * b6[index2]; + s_tmp4 += val4 * b6[index2]; + s_tmp5 += val5 * b6[index2]; + s_tmp6 += val6 * b6[index2]; + s_tmp7 += val7 * b6[index2]; + s_tmp8 += val8 * b6[index2]; + index2 += 1; + + index += 1; + } + out[6 * i + 0] += tmp; + out[6 * i + 1] += x_tmp; + out[6 * i + 2] += y_tmp; + out[6 * i + 3] += z_tmp; + out[6 * i + 4] += r_tmp; + out[6 * i + 5] += s_tmp; + out[6 * i + 6] += tmp2; + out[6 * i + 7] += x_tmp2; + out[6 * i + 8] += y_tmp2; + out[6 * i + 9] += z_tmp2; + out[6 * i + 10] += r_tmp2; + out[6 * i + 11] += s_tmp2; + out[6 * i + 12] += tmp3; + out[6 * i + 13] += x_tmp3; + out[6 * i + 14] += y_tmp3; + out[6 * i + 15] += z_tmp3; + out[6 * i + 16] += r_tmp3; + out[6 * i + 17] += s_tmp3; + out[6 * i + 18] += tmp4; + out[6 * i + 19] += x_tmp4; + out[6 * i + 20] += y_tmp4; + out[6 * i + 21] += z_tmp4; + out[6 * i + 22] += r_tmp4; + out[6 * i + 23] += s_tmp4; + out[6 * i + 24] += tmp5; + out[6 * i + 25] += x_tmp5; + out[6 * i + 26] += y_tmp5; + out[6 * i + 27] += z_tmp5; + out[6 * i + 28] += r_tmp5; + out[6 * i + 29] += s_tmp5; + out[6 * i + 30] += tmp6; + out[6 * i + 31] += x_tmp6; + out[6 * i + 32] += y_tmp6; + out[6 * i + 33] += z_tmp6; + out[6 * i + 34] += r_tmp6; + out[6 * i + 35] += s_tmp6; + out[6 * i + 36] += tmp7; + out[6 * i + 37] += x_tmp7; + out[6 * i + 38] += y_tmp7; + out[6 * i + 39] += z_tmp7; + out[6 * i + 40] += r_tmp7; + out[6 * i + 41] += s_tmp7; + out[6 * i + 42] += tmp8; + out[6 * i + 43] += x_tmp8; + out[6 * i + 44] += y_tmp8; + out[6 * i + 45] += z_tmp8; + out[6 * i + 46] += r_tmp8; + out[6 * i + 47] += s_tmp8; + index += aCols * 7; + } +} + +void trueMatMulVecPacked8( + Elem *__restrict__ out, const Elem *__restrict__ a, + const Elem *__restrict__ b, const Elem *__restrict__ b2, + const Elem *__restrict__ b3, const Elem *__restrict__ b4, + const Elem *__restrict__ b5, const Elem *__restrict__ b6, + const Elem *__restrict__ b7, const Elem *__restrict__ b8, size_t aRows, + size_t aCols) { + // in this variant, b has 8 columns + + Elem db, db2, db3, db4, db5, db6, db7, db8; + Elem val, val2, val3, val4, val5, val6, val7, val8; + Elem tmp, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, tmp8; + Elem x_tmp, x_tmp2, x_tmp3, x_tmp4, x_tmp5, x_tmp6, x_tmp7, x_tmp8; + Elem y_tmp, y_tmp2, y_tmp3, y_tmp4, y_tmp5, y_tmp6, y_tmp7, y_tmp8; + Elem z_tmp, z_tmp2, z_tmp3, z_tmp4, z_tmp5, z_tmp6, z_tmp7, z_tmp8; + Elem r_tmp, r_tmp2, r_tmp3, r_tmp4, r_tmp5, r_tmp6, r_tmp7, r_tmp8; + Elem s_tmp, s_tmp2, s_tmp3, s_tmp4, s_tmp5, s_tmp6, s_tmp7, s_tmp8; + Elem t_tmp, t_tmp2, t_tmp3, t_tmp4, t_tmp5, t_tmp6, t_tmp7, t_tmp8; + Elem u_tmp, u_tmp2, u_tmp3, u_tmp4, u_tmp5, u_tmp6, u_tmp7, u_tmp8; + size_t index = 0; + size_t index2; + + for (size_t i = 0; i < aRows; i += 8) { + tmp = 0; + tmp2 = 0; + tmp3 = 0; + tmp4 = 0; + tmp5 = 0; + tmp6 = 0; + tmp7 = 0; + tmp8 = 0; + + x_tmp = 0; + x_tmp2 = 0; + x_tmp3 = 0; + x_tmp4 = 0; + x_tmp5 = 0; + x_tmp6 = 0; + x_tmp7 = 0; + x_tmp8 = 0; + + y_tmp = 0; + y_tmp2 = 0; + y_tmp3 = 0; + y_tmp4 = 0; + y_tmp5 = 0; + y_tmp6 = 0; + y_tmp7 = 0; + y_tmp8 = 0; + + z_tmp = 0; + z_tmp2 = 0; + z_tmp3 = 0; + z_tmp4 = 0; + z_tmp5 = 0; + z_tmp6 = 0; + z_tmp7 = 0; + z_tmp8 = 0; + + r_tmp = 0; + r_tmp2 = 0; + r_tmp3 = 0; + r_tmp4 = 0; + r_tmp5 = 0; + r_tmp6 = 0; + r_tmp7 = 0; + r_tmp8 = 0; + + s_tmp = 0; + s_tmp2 = 0; + s_tmp3 = 0; + s_tmp4 = 0; + s_tmp5 = 0; + s_tmp6 = 0; + s_tmp7 = 0; + s_tmp8 = 0; + + t_tmp = 0; + t_tmp2 = 0; + t_tmp3 = 0; + t_tmp4 = 0; + t_tmp5 = 0; + t_tmp6 = 0; + t_tmp7 = 0; + t_tmp8 = 0; + + u_tmp = 0; + u_tmp2 = 0; + u_tmp3 = 0; + u_tmp4 = 0; + u_tmp5 = 0; + u_tmp6 = 0; + u_tmp7 = 0; + u_tmp8 = 0; + + index2 = 0; + for (size_t j = 0; j < aCols; j++) { + db = a[index]; + db2 = a[index + 1 * aCols]; + db3 = a[index + 2 * aCols]; + db4 = a[index + 3 * aCols]; + db5 = a[index + 4 * aCols]; + db6 = a[index + 5 * aCols]; + db7 = a[index + 6 * aCols]; + db8 = a[index + 7 * aCols]; + + val = db & MASK; + val2 = db2 & MASK; + val3 = db3 & MASK; + val4 = db4 & MASK; + val5 = db5 & MASK; + val6 = db6 & MASK; + val7 = db7 & MASK; + val8 = db8 & MASK; + tmp += val * b[index2]; + tmp2 += val2 * b[index2]; + tmp3 += val3 * b[index2]; + tmp4 += val4 * b[index2]; + tmp5 += val5 * b[index2]; + tmp6 += val6 * b[index2]; + tmp7 += val7 * b[index2]; + tmp8 += val8 * b[index2]; + x_tmp += val * b2[index2]; + x_tmp2 += val2 * b2[index2]; + x_tmp3 += val3 * b2[index2]; + x_tmp4 += val4 * b2[index2]; + x_tmp5 += val5 * b2[index2]; + x_tmp6 += val6 * b2[index2]; + x_tmp7 += val7 * b2[index2]; + x_tmp8 += val8 * b2[index2]; + y_tmp += val * b3[index2]; + y_tmp2 += val2 * b3[index2]; + y_tmp3 += val3 * b3[index2]; + y_tmp4 += val4 * b3[index2]; + y_tmp5 += val5 * b3[index2]; + y_tmp6 += val6 * b3[index2]; + y_tmp7 += val7 * b3[index2]; + y_tmp8 += val8 * b3[index2]; + z_tmp += val * b4[index2]; + z_tmp2 += val2 * b4[index2]; + z_tmp3 += val3 * b4[index2]; + z_tmp4 += val4 * b4[index2]; + z_tmp5 += val5 * b4[index2]; + z_tmp6 += val6 * b4[index2]; + z_tmp7 += val7 * b4[index2]; + z_tmp8 += val8 * b4[index2]; + r_tmp += val * b5[index2]; + r_tmp2 += val2 * b5[index2]; + r_tmp3 += val3 * b5[index2]; + r_tmp4 += val4 * b5[index2]; + r_tmp5 += val5 * b5[index2]; + r_tmp6 += val6 * b5[index2]; + r_tmp7 += val7 * b5[index2]; + r_tmp8 += val8 * b5[index2]; + s_tmp += val * b6[index2]; + s_tmp2 += val2 * b6[index2]; + s_tmp3 += val3 * b6[index2]; + s_tmp4 += val4 * b6[index2]; + s_tmp5 += val5 * b6[index2]; + s_tmp6 += val6 * b6[index2]; + s_tmp7 += val7 * b6[index2]; + s_tmp8 += val8 * b6[index2]; + t_tmp += val * b7[index2]; + t_tmp2 += val2 * b7[index2]; + t_tmp3 += val3 * b7[index2]; + t_tmp4 += val4 * b7[index2]; + t_tmp5 += val5 * b7[index2]; + t_tmp6 += val6 * b7[index2]; + t_tmp7 += val7 * b7[index2]; + t_tmp8 += val8 * b7[index2]; + u_tmp += val * b8[index2]; + u_tmp2 += val2 * b8[index2]; + u_tmp3 += val3 * b8[index2]; + u_tmp4 += val4 * b8[index2]; + u_tmp5 += val5 * b8[index2]; + u_tmp6 += val6 * b8[index2]; + u_tmp7 += val7 * b8[index2]; + u_tmp8 += val8 * b8[index2]; + + index2 += 1; + + val = (db >> BASIS) & MASK; + val2 = (db2 >> BASIS) & MASK; + val3 = (db3 >> BASIS) & MASK; + val4 = (db4 >> BASIS) & MASK; + val5 = (db5 >> BASIS) & MASK; + val6 = (db6 >> BASIS) & MASK; + val7 = (db7 >> BASIS) & MASK; + val8 = (db8 >> BASIS) & MASK; + tmp += val * b[index2]; + tmp2 += val2 * b[index2]; + tmp3 += val3 * b[index2]; + tmp4 += val4 * b[index2]; + tmp5 += val5 * b[index2]; + tmp6 += val6 * b[index2]; + tmp7 += val7 * b[index2]; + tmp8 += val8 * b[index2]; + x_tmp += val * b2[index2]; + x_tmp2 += val2 * b2[index2]; + x_tmp3 += val3 * b2[index2]; + x_tmp4 += val4 * b2[index2]; + x_tmp5 += val5 * b2[index2]; + x_tmp6 += val6 * b2[index2]; + x_tmp7 += val7 * b2[index2]; + x_tmp8 += val8 * b2[index2]; + y_tmp += val * b3[index2]; + y_tmp2 += val2 * b3[index2]; + y_tmp3 += val3 * b3[index2]; + y_tmp4 += val4 * b3[index2]; + y_tmp5 += val5 * b3[index2]; + y_tmp6 += val6 * b3[index2]; + y_tmp7 += val7 * b3[index2]; + y_tmp8 += val8 * b3[index2]; + z_tmp += val * b4[index2]; + z_tmp2 += val2 * b4[index2]; + z_tmp3 += val3 * b4[index2]; + z_tmp4 += val4 * b4[index2]; + z_tmp5 += val5 * b4[index2]; + z_tmp6 += val6 * b4[index2]; + z_tmp7 += val7 * b4[index2]; + z_tmp8 += val8 * b4[index2]; + r_tmp += val * b5[index2]; + r_tmp2 += val2 * b5[index2]; + r_tmp3 += val3 * b5[index2]; + r_tmp4 += val4 * b5[index2]; + r_tmp5 += val5 * b5[index2]; + r_tmp6 += val6 * b5[index2]; + r_tmp7 += val7 * b5[index2]; + r_tmp8 += val8 * b5[index2]; + s_tmp += val * b6[index2]; + s_tmp2 += val2 * b6[index2]; + s_tmp3 += val3 * b6[index2]; + s_tmp4 += val4 * b6[index2]; + s_tmp5 += val5 * b6[index2]; + s_tmp6 += val6 * b6[index2]; + s_tmp7 += val7 * b6[index2]; + s_tmp8 += val8 * b6[index2]; + t_tmp += val * b7[index2]; + t_tmp2 += val2 * b7[index2]; + t_tmp3 += val3 * b7[index2]; + t_tmp4 += val4 * b7[index2]; + t_tmp5 += val5 * b7[index2]; + t_tmp6 += val6 * b7[index2]; + t_tmp7 += val7 * b7[index2]; + t_tmp8 += val8 * b7[index2]; + u_tmp += val * b8[index2]; + u_tmp2 += val2 * b8[index2]; + u_tmp3 += val3 * b8[index2]; + u_tmp4 += val4 * b8[index2]; + u_tmp5 += val5 * b8[index2]; + u_tmp6 += val6 * b8[index2]; + u_tmp7 += val7 * b8[index2]; + u_tmp8 += val8 * b8[index2]; + + index2 += 1; + + val = (db >> BASIS2) & MASK; + val2 = (db2 >> BASIS2) & MASK; + val3 = (db3 >> BASIS2) & MASK; + val4 = (db4 >> BASIS2) & MASK; + val5 = (db5 >> BASIS2) & MASK; + val6 = (db6 >> BASIS2) & MASK; + val7 = (db7 >> BASIS2) & MASK; + val8 = (db8 >> BASIS2) & MASK; + tmp += val * b[index2]; + tmp2 += val2 * b[index2]; + tmp3 += val3 * b[index2]; + tmp4 += val4 * b[index2]; + tmp5 += val5 * b[index2]; + tmp6 += val6 * b[index2]; + tmp7 += val7 * b[index2]; + tmp8 += val8 * b[index2]; + x_tmp += val * b2[index2]; + x_tmp2 += val2 * b2[index2]; + x_tmp3 += val3 * b2[index2]; + x_tmp4 += val4 * b2[index2]; + x_tmp5 += val5 * b2[index2]; + x_tmp6 += val6 * b2[index2]; + x_tmp7 += val7 * b2[index2]; + x_tmp8 += val8 * b2[index2]; + y_tmp += val * b3[index2]; + y_tmp2 += val2 * b3[index2]; + y_tmp3 += val3 * b3[index2]; + y_tmp4 += val4 * b3[index2]; + y_tmp5 += val5 * b3[index2]; + y_tmp6 += val6 * b3[index2]; + y_tmp7 += val7 * b3[index2]; + y_tmp8 += val8 * b3[index2]; + z_tmp += val * b4[index2]; + z_tmp2 += val2 * b4[index2]; + z_tmp3 += val3 * b4[index2]; + z_tmp4 += val4 * b4[index2]; + z_tmp5 += val5 * b4[index2]; + z_tmp6 += val6 * b4[index2]; + z_tmp7 += val7 * b4[index2]; + z_tmp8 += val8 * b4[index2]; + r_tmp += val * b5[index2]; + r_tmp2 += val2 * b5[index2]; + r_tmp3 += val3 * b5[index2]; + r_tmp4 += val4 * b5[index2]; + r_tmp5 += val5 * b5[index2]; + r_tmp6 += val6 * b5[index2]; + r_tmp7 += val7 * b5[index2]; + r_tmp8 += val8 * b5[index2]; + s_tmp += val * b6[index2]; + s_tmp2 += val2 * b6[index2]; + s_tmp3 += val3 * b6[index2]; + s_tmp4 += val4 * b6[index2]; + s_tmp5 += val5 * b6[index2]; + s_tmp6 += val6 * b6[index2]; + s_tmp7 += val7 * b6[index2]; + s_tmp8 += val8 * b6[index2]; + t_tmp += val * b7[index2]; + t_tmp2 += val2 * b7[index2]; + t_tmp3 += val3 * b7[index2]; + t_tmp4 += val4 * b7[index2]; + t_tmp5 += val5 * b7[index2]; + t_tmp6 += val6 * b7[index2]; + t_tmp7 += val7 * b7[index2]; + t_tmp8 += val8 * b7[index2]; + u_tmp += val * b8[index2]; + u_tmp2 += val2 * b8[index2]; + u_tmp3 += val3 * b8[index2]; + u_tmp4 += val4 * b8[index2]; + u_tmp5 += val5 * b8[index2]; + u_tmp6 += val6 * b8[index2]; + u_tmp7 += val7 * b8[index2]; + u_tmp8 += val8 * b8[index2]; + + index2 += 1; + + val = (db >> BASIS3) & MASK; + val2 = (db2 >> BASIS3) & MASK; + val3 = (db3 >> BASIS3) & MASK; + val4 = (db4 >> BASIS3) & MASK; + val5 = (db5 >> BASIS3) & MASK; + val6 = (db6 >> BASIS3) & MASK; + val7 = (db7 >> BASIS3) & MASK; + val8 = (db8 >> BASIS3) & MASK; + tmp += val * b[index2]; + tmp2 += val2 * b[index2]; + tmp3 += val3 * b[index2]; + tmp4 += val4 * b[index2]; + tmp5 += val5 * b[index2]; + tmp6 += val6 * b[index2]; + tmp7 += val7 * b[index2]; + tmp8 += val8 * b[index2]; + x_tmp += val * b2[index2]; + x_tmp2 += val2 * b2[index2]; + x_tmp3 += val3 * b2[index2]; + x_tmp4 += val4 * b2[index2]; + x_tmp5 += val5 * b2[index2]; + x_tmp6 += val6 * b2[index2]; + x_tmp7 += val7 * b2[index2]; + x_tmp8 += val8 * b2[index2]; + y_tmp += val * b3[index2]; + y_tmp2 += val2 * b3[index2]; + y_tmp3 += val3 * b3[index2]; + y_tmp4 += val4 * b3[index2]; + y_tmp5 += val5 * b3[index2]; + y_tmp6 += val6 * b3[index2]; + y_tmp7 += val7 * b3[index2]; + y_tmp8 += val8 * b3[index2]; + z_tmp += val * b4[index2]; + z_tmp2 += val2 * b4[index2]; + z_tmp3 += val3 * b4[index2]; + z_tmp4 += val4 * b4[index2]; + z_tmp5 += val5 * b4[index2]; + z_tmp6 += val6 * b4[index2]; + z_tmp7 += val7 * b4[index2]; + z_tmp8 += val8 * b4[index2]; + r_tmp += val * b5[index2]; + r_tmp2 += val2 * b5[index2]; + r_tmp3 += val3 * b5[index2]; + r_tmp4 += val4 * b5[index2]; + r_tmp5 += val5 * b5[index2]; + r_tmp6 += val6 * b5[index2]; + r_tmp7 += val7 * b5[index2]; + r_tmp8 += val8 * b5[index2]; + s_tmp += val * b6[index2]; + s_tmp2 += val2 * b6[index2]; + s_tmp3 += val3 * b6[index2]; + s_tmp4 += val4 * b6[index2]; + s_tmp5 += val5 * b6[index2]; + s_tmp6 += val6 * b6[index2]; + s_tmp7 += val7 * b6[index2]; + s_tmp8 += val8 * b6[index2]; + t_tmp += val * b7[index2]; + t_tmp2 += val2 * b7[index2]; + t_tmp3 += val3 * b7[index2]; + t_tmp4 += val4 * b7[index2]; + t_tmp5 += val5 * b7[index2]; + t_tmp6 += val6 * b7[index2]; + t_tmp7 += val7 * b7[index2]; + t_tmp8 += val8 * b7[index2]; + u_tmp += val * b8[index2]; + u_tmp2 += val2 * b8[index2]; + u_tmp3 += val3 * b8[index2]; + u_tmp4 += val4 * b8[index2]; + u_tmp5 += val5 * b8[index2]; + u_tmp6 += val6 * b8[index2]; + u_tmp7 += val7 * b8[index2]; + u_tmp8 += val8 * b8[index2]; + + index2 += 1; + + index += 1; + } + out[8 * i + 0] += tmp; + out[8 * i + 1] += x_tmp; + out[8 * i + 2] += y_tmp; + out[8 * i + 3] += z_tmp; + out[8 * i + 4] += r_tmp; + out[8 * i + 5] += s_tmp; + out[8 * i + 6] += t_tmp; + out[8 * i + 7] += u_tmp; + out[8 * i + 8] += tmp2; + out[8 * i + 9] += x_tmp2; + out[8 * i + 10] += y_tmp2; + out[8 * i + 11] += z_tmp2; + out[8 * i + 12] += r_tmp2; + out[8 * i + 13] += s_tmp2; + out[8 * i + 14] += t_tmp2; + out[8 * i + 15] += u_tmp2; + out[8 * i + 16] += tmp3; + out[8 * i + 17] += x_tmp3; + out[8 * i + 18] += y_tmp3; + out[8 * i + 19] += z_tmp3; + out[8 * i + 20] += r_tmp3; + out[8 * i + 21] += s_tmp3; + out[8 * i + 22] += t_tmp3; + out[8 * i + 23] += u_tmp3; + out[8 * i + 24] += tmp4; + out[8 * i + 25] += x_tmp4; + out[8 * i + 26] += y_tmp4; + out[8 * i + 27] += z_tmp4; + out[8 * i + 28] += r_tmp4; + out[8 * i + 29] += s_tmp4; + out[8 * i + 30] += t_tmp4; + out[8 * i + 31] += u_tmp4; + out[8 * i + 32] += tmp5; + out[8 * i + 33] += x_tmp5; + out[8 * i + 34] += y_tmp5; + out[8 * i + 35] += z_tmp5; + out[8 * i + 36] += r_tmp5; + out[8 * i + 37] += s_tmp5; + out[8 * i + 38] += t_tmp5; + out[8 * i + 39] += u_tmp5; + out[8 * i + 40] += tmp6; + out[8 * i + 41] += x_tmp6; + out[8 * i + 42] += y_tmp6; + out[8 * i + 43] += z_tmp6; + out[8 * i + 44] += r_tmp6; + out[8 * i + 45] += s_tmp6; + out[8 * i + 46] += t_tmp6; + out[8 * i + 47] += u_tmp6; + out[8 * i + 48] += tmp7; + out[8 * i + 49] += x_tmp7; + out[8 * i + 50] += y_tmp7; + out[8 * i + 51] += z_tmp7; + out[8 * i + 52] += r_tmp7; + out[8 * i + 53] += s_tmp7; + out[8 * i + 54] += t_tmp7; + out[8 * i + 55] += u_tmp7; + out[8 * i + 56] += tmp8; + out[8 * i + 57] += x_tmp8; + out[8 * i + 58] += y_tmp8; + out[8 * i + 59] += z_tmp8; + out[8 * i + 60] += r_tmp8; + out[8 * i + 61] += s_tmp8; + out[8 * i + 62] += t_tmp8; + out[8 * i + 63] += u_tmp8; + index += aCols * 7; + } +} + +void matMulVecPacked8(Elem *__restrict__ out, const Elem *__restrict__ a, + const Elem *__restrict__ b_full, size_t aRows, + size_t aCols) { +#ifdef PROFILE + System::profile("matmul4", [&]() { +#endif + trueMatMulVecPacked8( + out, a, b_full, b_full + (1 * aCols * COMPRESSION), + b_full + (2 * aCols * COMPRESSION), b_full + (3 * aCols * COMPRESSION), + b_full + (4 * aCols * COMPRESSION), b_full + (5 * aCols * COMPRESSION), + b_full + (6 * aCols * COMPRESSION), b_full + (7 * aCols * COMPRESSION), + aRows, aCols); + +#ifdef PROFILE + }); +#endif +} \ No newline at end of file diff --git a/psi/algorithm/ypir/params.cc b/psi/algorithm/ypir/params.cc new file mode 100644 index 00000000..b756571c --- /dev/null +++ b/psi/algorithm/ypir/params.cc @@ -0,0 +1,37 @@ +// Copyright 2025 The secretflow authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "psi/algorithm/ypir/params.h" + +#include "psi/algorithm/spiral/params.h" +#include "psi/algorithm/spiral/util.h" + +namespace psi::ypir { + +psi::spiral::Params CreateParamsForScenarioSimplePIR( + uint64_t /*num_items*/, uint64_t /*item_size_bits*/) { + // For now, use the fast expansion testing params as a reasonable default + // In production, you would calculate optimal parameters based on num_items + // and item_size_bits + return psi::spiral::util::GetFastExpansionTestingParam(); +} + +psi::spiral::Params CreateParamsForScenario(uint64_t /*num_items*/, + uint64_t /*item_size_bits*/) { + // For now, use the fast expansion testing params for DoublePIR too + // In production, you would use different parameters optimized for DoublePIR + return psi::spiral::util::GetFastExpansionTestingParam(); +} + +} // namespace psi::ypir diff --git a/psi/algorithm/ypir/params.h b/psi/algorithm/ypir/params.h new file mode 100644 index 00000000..0f08cada --- /dev/null +++ b/psi/algorithm/ypir/params.h @@ -0,0 +1,53 @@ +// Copyright 2025 The secretflow authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#pragma once + +#include +#include + +#include "psi/algorithm/spiral/common.h" +#include "psi/algorithm/spiral/params.h" + +namespace psi::ypir { + +struct LWEParams { + size_t n = 1024; + uint64_t modulus = 1ULL << 32; + uint64_t pt_modulus = 1ULL << 8; + size_t q2_bits = 28; + double noise_width = 27.57291103; + + uint64_t ScaleK() const { return modulus / pt_modulus; } + static LWEParams Default() { return LWEParams(); } + uint64_t GetQPrime2() const { + const size_t modulus_bits = + static_cast(std::ceil(std::log2(static_cast(modulus)))); + if (q2_bits == modulus_bits) { + return modulus; + } else { + return psi::spiral::kQ2Values[q2_bits]; + } + } +}; + +// Create parameters for SimplePIR scenario +psi::spiral::Params CreateParamsForScenarioSimplePIR(uint64_t num_items, + uint64_t item_size_bits); + +// Create parameters for DoublePIR scenario +psi::spiral::Params CreateParamsForScenario(uint64_t num_items, + uint64_t item_size_bits); + +} // namespace psi::ypir diff --git a/psi/algorithm/ypir/rescale_test.cc b/psi/algorithm/ypir/rescale_test.cc new file mode 100644 index 00000000..51fa11cd --- /dev/null +++ b/psi/algorithm/ypir/rescale_test.cc @@ -0,0 +1,58 @@ +#include "gtest/gtest.h" + +#include "psi/algorithm/spiral/arith/arith.h" +#include "psi/algorithm/spiral/params.h" + +namespace psi::ypir { + +using namespace psi::spiral; + +TEST(RescaleTest, SimplePIRRescale) { + // SimplePIR parameters + uint64_t q = 66974689739603969ULL; // modulus + uint64_t pt_modulus = 256; + uint64_t scale_k = q / pt_modulus; // 261619881795328 + + // Test: encode db value 100, then decode + uint8_t db_value = 100; + + // When query encrypts scale_k at position i, and we compute dot product + // with db, we get approximately: scale_k * db_value (plus noise) + uint64_t encoded = scale_k * db_value; + + // After decryption, rescale should recover the original value + uint64_t decoded = arith::Rescale(encoded, q, pt_modulus); + + EXPECT_EQ(decoded, db_value) + << "Rescale failed: expected " << (int)db_value << ", got " << decoded; + + // Test multiple values + for (uint8_t val : {0, 1, 100, 101, 200, 250, 255}) { + uint64_t enc = scale_k * val; + uint64_t dec = arith::Rescale(enc, q, pt_modulus); + EXPECT_EQ(dec, val) << "Failed for value " << (int)val; + } +} + +TEST(RescaleTest, WithNoise) { + uint64_t q = 66974689739603969ULL; + uint64_t pt_modulus = 256; + uint64_t scale_k = q / pt_modulus; + + uint8_t db_value = 100; + uint64_t encoded = scale_k * db_value; + + // Add small noise (simulating LWE noise) + // Noise should be << q / (2 * pt_modulus) to decode correctly + for (int64_t noise = -1000; noise <= 1000; noise += 100) { + uint64_t noisy = + static_cast(static_cast(encoded) + noise); + uint64_t decoded = arith::Rescale(noisy, q, pt_modulus); + + EXPECT_EQ(decoded, db_value) + << "Failed with noise=" << noise << ", encoded=" << encoded + << ", noisy=" << noisy << ", decoded=" << decoded; + } +} + +} // namespace psi::ypir diff --git a/psi/algorithm/ypir/scale_k_test.cc b/psi/algorithm/ypir/scale_k_test.cc new file mode 100644 index 00000000..c80c9e78 --- /dev/null +++ b/psi/algorithm/ypir/scale_k_test.cc @@ -0,0 +1,38 @@ +#include "gtest/gtest.h" + +#include "psi/algorithm/ypir/client.h" +#include "psi/algorithm/ypir/params.h" +#include "psi/algorithm/ypir/server.h" + +namespace psi::ypir { + +TEST(ScaleKTest, VerifyScaleK) { + // SimplePIR parameters + size_t poly_len = 2048; + std::vector moduli{268369921, 249561089}; + double noise_width = 16.042421; + PolyMatrixParams poly_matrix_params(2, 16384, 21, 4, 8, 8, 1); + QueryParams query_params(1, 1, 1); + + Params params(poly_len, std::move(moduli), noise_width, + std::move(poly_matrix_params), std::move(query_params)); + + uint64_t modulus = params.Modulus(); + uint64_t pt_modulus = params.PtModulus(); + uint64_t scale_k = params.ScaleK(); + + // Verify scale_k ≈ modulus / pt_modulus + uint64_t expected_scale_k = modulus / pt_modulus; + EXPECT_EQ(scale_k, expected_scale_k); + + // Test rescale + uint64_t test_value = 100; + uint64_t scaled = scale_k * test_value; + + // Rescale back + uint64_t rescaled = arith::Rescale(scaled, modulus, pt_modulus); + + EXPECT_EQ(rescaled, test_value); +} + +} // namespace psi::ypir diff --git a/psi/algorithm/ypir/server.cc b/psi/algorithm/ypir/server.cc new file mode 100644 index 00000000..85a93c30 --- /dev/null +++ b/psi/algorithm/ypir/server.cc @@ -0,0 +1,160 @@ +#include "psi/algorithm/ypir/server.h" + +#include + +namespace psi::ypir::byhe { +namespace { + +void DoublepirAnswer(const uint8_t* db, uint32_t* qu0, + std::vector& qu1, + std::vector>& server_hint, + std::vector& h2, + std::vector>& h3, + std::vector& h4, const FheParams& fparm, + const PirParams& pparm) { + const uint64_t row = pparm.get_row(); + const uint64_t col = pparm.get_col(); + const uint64_t rlwe_cmod = fparm.get_rlwe_cmod(); + const uint64_t b = fparm.get_b_decomp(); + const uint64_t z = fparm.get_z_decomp(); + const uint64_t t = fparm.get_t_decomp(); + + std::vector simple_res(row, 0); + MatVecU8U32Mod2p32(db, qu0, simple_res.data(), row, col); + + std::vector> trans_simple_res_decomp; + VectorColDecompose(simple_res, trans_simple_res_decomp, b, z, t); + + const uint64_t* matrix_d2_flat = fparm.get_persudo_matrix_doublepir_flat(); + const uint64_t poly_degree = fparm.get_poly_degree(); + + MatrixVectorFirstDimension(h2, server_hint, qu1, rlwe_cmod); + + MatrixMultiplicationFlatU16(h3, trans_simple_res_decomp, matrix_d2_flat, + poly_degree, rlwe_cmod); + + MatrixVectorMultiplicationU16(h4, trans_simple_res_decomp, qu1, rlwe_cmod); +} + +} // namespace + +void YpirHintGenerate(std::vector>& db, + std::vector& h0, + std::vector>& double_server_hint, + std::vector>>& decomp_buf, + AESCTR_PRNG& prng, + const FheParams& fparm, const PirParams& pparm) { + const uint64_t lwe_dimension = fparm.get_lwe_dimension(); + const uint64_t poly_degree = fparm.get_poly_degree(); + const uint64_t rlwe_cmod = fparm.get_rlwe_cmod(); + const uint64_t t_auto = fparm.get_t_auto(); + const uint64_t t_decomp = fparm.get_t_decomp(); + const uint64_t expo = GetLog2(poly_degree); + const uint64_t pack_num = lwe_dimension * t_decomp; + + std::vector> double_client_hint( + lwe_dimension * t_decomp, std::vector(poly_degree, 0)); + + const uint64_t* matrix_flat = fparm.get_persudo_matrix_simplepir_flat(); + std::vector> simple_hint( + pparm.get_row(), std::vector(lwe_dimension, 0)); + MatrixMultiplicationFlat(simple_hint, db, matrix_flat, lwe_dimension, + fparm.get_lwe_cmod()); + + std::vector> matrix_decomp; + MatrixRowDecompose(simple_hint, matrix_decomp, fparm.get_b_decomp(), + fparm.get_z_decomp(), fparm.get_t_decomp()); + MatrixTranspose(matrix_decomp, double_server_hint); + + const uint64_t* matrix_d2_flat = fparm.get_persudo_matrix_doublepir_flat(); + MatrixMultiplicationFlat(double_client_hint, double_server_hint, + matrix_d2_flat, poly_degree, rlwe_cmod); + + std::vector>> ksk_a( + expo, + std::vector>(t_auto, + std::vector(poly_degree))); + prng.refresh(kThirdDimensionSeed); + for (uint64_t i = 0; i < expo; ++i) { + PseudorandomMatrixGenerate(ksk_a[i], rlwe_cmod, prng); + } + + const uint64_t mod_inv = ModInverse(static_cast(pack_num), + static_cast(rlwe_cmod)); + ByheHexlNtt& ntt = fparm.get_ntt(); + for (uint64_t i = 0; i < pack_num; ++i) { + Cdks21Lwe2RlweInplace(double_client_hint[i].data(), poly_degree, rlwe_cmod, + ntt); + EltwiseFMAMod(double_client_hint[i].data(), double_client_hint[i].data(), + mod_inv, nullptr, poly_degree, rlwe_cmod); + } + + h0 = PackrlwePreprocess(double_client_hint, GetLog2(pack_num), + GetLog2(poly_degree) - GetLog2(pack_num), ksk_a, + decomp_buf, fparm); +} + +void YpirAnswer(const uint8_t* db, uint32_t* qu0, std::vector& qu1, + const std::vector>>& ksk_b, + std::vector>>& decomp_buf, + std::vector>& server_hint, + std::vector>& res, + const FheParams& fparm, const PirParams& pparm) { + const uint64_t lwe_dimension = fparm.get_lwe_dimension(); + const uint64_t poly_degree = fparm.get_poly_degree(); + const uint64_t rlwe_cmod = fparm.get_rlwe_cmod(); + const uint64_t t_decomp = fparm.get_t_decomp(); + const uint64_t pack_num = lwe_dimension * t_decomp; + const uint64_t mod_inv = ModInverse(static_cast(pack_num), + static_cast(rlwe_cmod)); + const uint64_t pack_num_log2 = GetLog2(pack_num); + const uint64_t t_decomp_log2 = GetLog2(t_decomp); + const uint64_t poly_degree_log2 = GetLog2(poly_degree); + + res.reserve(res.size() + 3); + + std::vector> h3(t_decomp, + std::vector(poly_degree, 0)); + std::vector h2(lwe_dimension * t_decomp, 0); + std::vector h4(t_decomp, 0); + + DoublepirAnswer(db, qu0, qu1, server_hint, h2, h3, h4, fparm, pparm); + + for (uint64_t i = 0; i < pack_num; ++i) { + h2[i] = + (static_cast(h2[i]) * mod_inv) % rlwe_cmod; + } + + uint64_t ptr = 0; + res.push_back(PackrlweOnlineConstantRows( + h2, pack_num_log2, poly_degree_log2 - pack_num_log2, ksk_b, decomp_buf, + ptr, fparm)); + + std::vector> h4_matrix( + t_decomp, std::vector(poly_degree, 0)); + const uint64_t mod_inv_2 = ModInverse(static_cast(t_decomp), + static_cast(rlwe_cmod)); + ByheHexlNtt& ntt = fparm.get_ntt(); + + for (uint64_t i = 0; i < t_decomp; ++i) { + Cdks21Lwe2RlweInplace(h3[i].data(), poly_degree, rlwe_cmod, ntt); + h4_matrix[i][0] = h4[i]; + ntt.Forward(h4_matrix[i].data(), poly_degree); + EltwiseFMAMod(h3[i].data(), h3[i].data(), mod_inv_2, nullptr, poly_degree, + rlwe_cmod); + EltwiseFMAMod(h4_matrix[i].data(), h4_matrix[i].data(), mod_inv_2, nullptr, + poly_degree, rlwe_cmod); + } + + const auto& ksk_a = fparm.get_persudo_hcube_ypir(); + std::vector>> decomp_b_buf; + ptr = 0; + res.push_back(PackrlwePreprocess(h3, t_decomp_log2, + poly_degree_log2 - t_decomp_log2, ksk_a, + decomp_b_buf, fparm)); + res.push_back(PackrlweOnline(h4_matrix, t_decomp_log2, + poly_degree_log2 - t_decomp_log2, ksk_b, + decomp_b_buf, ptr, fparm)); +} + +} // namespace psi::ypir::byhe diff --git a/psi/algorithm/ypir/server.h b/psi/algorithm/ypir/server.h new file mode 100644 index 00000000..fa3b4fdd --- /dev/null +++ b/psi/algorithm/ypir/server.h @@ -0,0 +1,24 @@ +#pragma once + +#include +#include + +#include "psi/algorithm/ypir/ypir_params.h" + +namespace psi::ypir::byhe { + +void YpirAnswer(const uint8_t* db, uint32_t* qu0, std::vector& qu1, + const std::vector>>& ksk_b, + std::vector>>& decomp_buf, + std::vector>& server_hint, + std::vector>& res, + const FheParams& fparm, const PirParams& pparm); + +void YpirHintGenerate(std::vector>& db, + std::vector& H0, + std::vector>& double_server_hint, + std::vector>>& decomp_buf, + AESCTR_PRNG& prng, + const FheParams& fparm, const PirParams& pparm); + +} // namespace psi::ypir::byhe diff --git a/psi/algorithm/ypir/server.rs b/psi/algorithm/ypir/server.rs new file mode 100644 index 00000000..6a0bfc15 --- /dev/null +++ b/psi/algorithm/ypir/server.rs @@ -0,0 +1,1377 @@ +#[cfg(target_feature = "avx2")] +use std::arch::x86_64::*; +use std::{marker::PhantomData, ops::Range, time::Instant}; + +use log::debug; +use log::info; +use rand::{Rng, SeedableRng}; +use rand_chacha::ChaCha20Rng; + +use spiral_rs::aligned_memory::AlignedMemory64; +use spiral_rs::{arith::*, client::*, params::*, poly::*}; + +use crate::measurement::Measurement; +use crate::serialize::*; + +use super::{ + bits::*, + client::*, + constants::*, + convolution::{negacyclic_perm_u32, Convolution}, + kernel::*, + lwe::*, + matmul::matmul_vec_packed, + modulus_switch::ModulusSwitch, + packing::*, + params::*, + transpose::*, + util::*, +}; + +pub fn generate_y_constants<'a>( + params: &'a Params, +) -> (Vec>, Vec>) { + let mut y_constants = Vec::new(); + let mut neg_y_constants = Vec::new(); + for num_cts_log2 in 1..params.poly_len_log2 + 1 { + let num_cts = 1 << num_cts_log2; + + // Y = X^(poly_len / num_cts) + let mut y_raw = PolyMatrixRaw::zero(params, 1, 1); + y_raw.data[params.poly_len / num_cts] = 1; + let y = y_raw.ntt(); + + let mut neg_y_raw = PolyMatrixRaw::zero(params, 1, 1); + neg_y_raw.data[params.poly_len / num_cts] = params.modulus - 1; + let neg_y = neg_y_raw.ntt(); + + y_constants.push(y); + neg_y_constants.push(neg_y); + } + + (y_constants, neg_y_constants) +} + +/// Takes a matrix of u64s and returns a matrix of T's. +/// +/// Input is row x cols u64's. +/// Output is out_rows x cols T's. +pub fn split_alloc( + buf: &[u64], + special_bit_offs: usize, + rows: usize, + cols: usize, + out_rows: usize, + inp_mod_bits: usize, + pt_bits: usize, +) -> Vec { + let mut out = vec![0u16; out_rows * cols]; + + assert!(out_rows >= rows); + assert!(inp_mod_bits >= pt_bits); + + for j in 0..cols { + let mut bytes_tmp = vec![0u8; out_rows * inp_mod_bits / 8]; + + // read this column + let mut bit_offs = 0; + for i in 0..rows { + let inp = buf[i * cols + j]; + // if j < 10 { + // debug!("({},{}) inp: {}", i, j, inp); + // } + + if i == rows - 1 { + bit_offs = special_bit_offs; + } + + // if j == 4095 { + // debug!("write: {}/{} {}/{}", j, cols, i, rows); + // } + write_bits(&mut bytes_tmp, inp, bit_offs, inp_mod_bits); + bit_offs += inp_mod_bits; + } + + // debug!("stretch: {}", j); + + // now, 'stretch' the column vertically + let mut bit_offs = 0; + for i in 0..out_rows { + // if j == 4095 { + // debug!("stretch: {}/{}", i, out_rows); + // debug!("reading at offs: {}, {} bits", bit_offs, pt_bits); + // debug!("into byte buffer of len: {}", bytes_tmp.len()); + // debug!("writing at {} in out of len {}", i * cols + j, out.len()); + // } + let out_val = read_bits(&bytes_tmp, bit_offs, pt_bits); + out[i * cols + j] = out_val as u16; + // if j == 4095 { + // debug!("wrote at {} in out of len {}", i * cols + j, out.len()); + // } + bit_offs += pt_bits; + if bit_offs >= out_rows * inp_mod_bits { + break; + } + } + + // debug!("here {}", j); + // debug!( + // "out {}", + // out[(special_bit_offs / pt_bits) * cols + j].to_u64() + // ); + // debug!("buf {}", buf[(rows - 1) * cols + j] & ((1 << pt_bits) - 1)); + + assert_eq!( + out[(special_bit_offs / pt_bits) * cols + j] as u64, + buf[(rows - 1) * cols + j] & ((1 << pt_bits) - 1) + ); + } + + out +} + +pub fn generate_fake_pack_pub_params<'a>(params: &'a Params) -> Vec> { + let pack_pub_params = raw_generate_expansion_params( + ¶ms, + &PolyMatrixRaw::zero(¶ms, 1, 1), + params.poly_len_log2, + params.t_exp_left, + &mut ChaCha20Rng::from_entropy(), + &mut ChaCha20Rng::from_seed(STATIC_SEED_2), + ); + pack_pub_params +} + +#[derive(Clone)] +pub struct YServer<'a, T> { + params: &'a Params, + smaller_params: Params, + db_buf_aligned: AlignedMemory64, // db_buf: Vec, // stored transposed + phantom: PhantomData, + pad_rows: bool, + ypir_params: YPIRParams, +} + +impl<'a, T> YServer<'a, T> +where + T: Sized + Copy + ToU64 + Default, + *const T: ToM512 + ToU64, +{ + pub fn new<'b, I>( + params: &'a Params, + mut db: I, + is_simplepir: bool, + inp_transposed: bool, + pad_rows: bool, + ) -> Self + where + I: Iterator, + { + // TODO: hack + // let lwe_params = LWEParams::default(); + let mut ypir_params = YPIRParams::default(); + ypir_params.is_simplepir = is_simplepir; + let bytes_per_pt_el = std::mem::size_of::(); //1; //((lwe_params.pt_modulus as f64).log2() / 8.).ceil() as usize; + + let db_rows = 1 << (params.db_dim_1 + params.poly_len_log2); + let db_rows_padded = if pad_rows { + params.db_rows_padded() + } else { + db_rows + }; + let db_cols = if is_simplepir { + params.instances * params.poly_len + } else { + 1 << (params.db_dim_2 + params.poly_len_log2) + }; + + let sz_bytes = db_rows_padded * db_cols * bytes_per_pt_el; + + let mut db_buf_aligned = AlignedMemory64::new(sz_bytes / 8); + let db_buf_mut = as_bytes_mut(&mut db_buf_aligned); + let db_buf_ptr = db_buf_mut.as_mut_ptr() as *mut T; + + for i in 0..db_rows { + for j in 0..db_cols { + let idx = if inp_transposed { + i * db_cols + j + } else { + j * db_rows_padded + i + }; + + unsafe { + *db_buf_ptr.add(idx) = db.next().unwrap(); + // *db_buf_ptr.add(idx) = if i < db_rows { + // db.next().unwrap() + // } else { + // T::default() + // }; + } + } + } + + // Parameters for the second round (the "DoublePIR" round) + let smaller_params = if is_simplepir { + params.clone() + } else { + let lwe_params = LWEParams::default(); + let pt_bits = (params.pt_modulus as f64).log2().floor() as usize; + let blowup_factor = lwe_params.q2_bits as f64 / pt_bits as f64; + let mut smaller_params = params.clone(); + smaller_params.db_dim_1 = params.db_dim_2; + smaller_params.db_dim_2 = ((blowup_factor * (lwe_params.n + 1) as f64) + / params.poly_len as f64) + .log2() + .ceil() as usize; + + let out_rows = 1 << (smaller_params.db_dim_2 + params.poly_len_log2); + assert_eq!(smaller_params.db_dim_1, params.db_dim_2); + assert!(out_rows as f64 >= (blowup_factor * (lwe_params.n + 1) as f64)); + smaller_params + }; + + Self { + params, + smaller_params, + db_buf_aligned, + phantom: PhantomData, + pad_rows, + ypir_params, + } + } + + pub fn db_rows(&self) -> usize { + 1 << (self.params.db_dim_1 + self.params.poly_len_log2) + } + + pub fn db_rows_padded(&self) -> usize { + if self.pad_rows { + self.params.db_rows_padded() + } else { + 1 << (self.params.db_dim_1 + self.params.poly_len_log2) + } + } + + pub fn db_cols(&self) -> usize { + if self.ypir_params.is_simplepir { + self.params.instances * self.params.poly_len + } else { + 1 << (self.params.db_dim_2 + self.params.poly_len_log2) + } + } + + pub fn multiply_batched_with_db_packed( + &self, + aligned_query_packed: &[u64], + query_rows: usize, + ) -> AlignedMemory64 { + // let db_rows = 1 << (self.params.db_dim_1 + self.params.poly_len_log2); + let db_rows_padded = self.db_rows_padded(); + let db_cols = self.db_cols(); + assert_eq!(aligned_query_packed.len(), K * query_rows * db_rows_padded); + assert_eq!(query_rows, 1); + + let now = Instant::now(); + let mut result = AlignedMemory64::new(K * db_cols); + fast_batched_dot_product::( + self.params, + result.as_mut_slice(), + aligned_query_packed, + db_rows_padded, + &self.db(), + db_rows_padded, + db_cols, + ); + debug!("Fast dot product in {} us", now.elapsed().as_micros()); + + result + } + + pub fn lwe_multiply_batched_with_db_packed( + &self, + aligned_query_packed: &[u32], + ) -> Vec { + let _db_rows = 1 << (self.params.db_dim_1 + self.params.poly_len_log2); + let db_cols = self.db_cols(); + let db_rows_padded = self.db_rows_padded(); + assert_eq!(aligned_query_packed.len(), K * db_rows_padded); + // assert_eq!(aligned_query_packed[db_rows + 1], 0); + + let mut result = vec![0u32; (db_cols + 8) * K]; + let now = Instant::now(); + // let mut result = AlignedMemory64::new(K * db_cols + 8); + // lwe_fast_batched_dot_product::( + // self.params, + // result.as_mut_slice(), + // aligned_query_packed, + // db_rows, + // &self.db(), + // db_rows, + // db_cols, + // ); + let a_rows = db_cols; + let a_true_cols = db_rows_padded; + let a_cols = a_true_cols / 4; // order is inverted on purpose, because db is transposed + let b_rows = a_true_cols; + let b_cols = K; + matmul_vec_packed( + result.as_mut_slice(), + self.db_u32(), + aligned_query_packed, + a_rows, + a_cols, + b_rows, + b_cols, + ); + let t = Instant::now(); + let result = transpose_generic(&result, db_cols, K); + debug!("Transpose in {} us", t.elapsed().as_micros()); + debug!("Fast dot product in {} us", now.elapsed().as_micros()); + + result + } + + pub fn multiply_with_db_ring( + &self, + preprocessed_query: &[PolyMatrixNTT], + col_range: Range, + seed_idx: u8, + ) -> Vec { + let db_rows_poly = 1 << (self.params.db_dim_1); + let db_rows = 1 << (self.params.db_dim_1 + self.params.poly_len_log2); + assert_eq!(preprocessed_query.len(), db_rows_poly); + + // assert_eq!(db_rows_poly, 1); // temporary restriction + + // let mut preprocessed_query = Vec::new(); + // for query_el in query { + // let query_raw = query_el.raw(); + // let query_raw_transformed = + // negacyclic_perm(query_raw.get_poly(0, 0), 0, self.params.modulus); + // let mut query_transformed_pol = PolyMatrixRaw::zero(self.params, 1, 1); + // query_transformed_pol + // .as_mut_slice() + // .copy_from_slice(&query_raw_transformed); + // preprocessed_query.push(query_transformed_pol.ntt()); + // } + + let mut result = Vec::new(); + let db = self.db(); + + let mut prod = PolyMatrixNTT::zero(self.params, 1, 1); + let mut db_elem_poly = PolyMatrixRaw::zero(self.params, 1, 1); + let mut db_elem_ntt = PolyMatrixNTT::zero(self.params, 1, 1); + + for col in col_range.clone() { + let mut sum = PolyMatrixNTT::zero(self.params, 1, 1); + + for row in 0..db_rows_poly { + for z in 0..self.params.poly_len { + db_elem_poly.data[z] = + db[col * db_rows + row * self.params.poly_len + z].to_u64(); + } + to_ntt(&mut db_elem_ntt, &db_elem_poly); + + multiply(&mut prod, &preprocessed_query[row], &db_elem_ntt); + + if row == db_rows_poly - 1 { + add_into(&mut sum, &prod); + } else { + add_into_no_reduce(&mut sum, &prod); + } + } + + let sum_raw = sum.raw(); + + // do negacyclic permutation (for first mul only) + if seed_idx == SEED_0 && !self.ypir_params.is_simplepir { + let sum_raw_transformed = + negacyclic_perm(sum_raw.get_poly(0, 0), 0, self.params.modulus); + result.extend(&sum_raw_transformed); + } else { + result.extend(sum_raw.as_slice()); + } + } + + // result + let now = Instant::now(); + let res = transpose_generic(&result, col_range.len(), self.params.poly_len); + debug!("transpose in {} us", now.elapsed().as_micros()); + res + } + + pub fn generate_pseudorandom_query(&self, public_seed_idx: u8) -> Vec> { + let mut client = Client::init(&self.params); + client.generate_secret_keys(); + let y_client = YClient::new(&mut client, &self.params); + let query = y_client.generate_query_impl(public_seed_idx, self.params.db_dim_1, true, 0); + let query_mapped = query + .iter() + .map(|x| x.submatrix(0, 0, 1, 1)) + .collect::>(); + + let mut preprocessed_query = Vec::new(); + for query_raw in query_mapped { + // let query_raw_transformed = + // negacyclic_perm(query_raw.get_poly(0, 0), 0, self.params.modulus); + // let query_raw_transformed = query_raw.get_poly(0, 0); + let query_raw_transformed = if public_seed_idx == SEED_0 { + negacyclic_perm(query_raw.get_poly(0, 0), 0, self.params.modulus) + // query_raw.get_poly(0, 0).to_owned() + } else { + negacyclic_perm(query_raw.get_poly(0, 0), 0, self.params.modulus) + }; + let mut query_transformed_pol = PolyMatrixRaw::zero(self.params, 1, 1); + query_transformed_pol + .as_mut_slice() + .copy_from_slice(&query_raw_transformed); + preprocessed_query.push(query_transformed_pol.ntt()); + } + + preprocessed_query + } + + pub fn answer_hint_ring(&self, public_seed_idx: u8, cols: usize) -> Vec { + let preprocessed_query = self.generate_pseudorandom_query(public_seed_idx); + + let res = self.multiply_with_db_ring(&preprocessed_query, 0..cols, public_seed_idx); + + res + } + + pub fn generate_hint_0(&self) -> Vec { + let _db_rows = 1 << (self.params.db_dim_1 + self.params.poly_len_log2); + let db_cols = self.db_cols(); + + let mut rng_pub = ChaCha20Rng::from_seed(get_seed(SEED_0)); + let lwe_params = LWEParams::default(); + + // pseudorandom LWE query is n x db_rows + let psuedorandom_query = + generate_matrix_ring(&mut rng_pub, lwe_params.n, lwe_params.n, db_cols); + + // db is db_cols x db_rows (!!!) + // hint_0 is n x db_cols + let hint_0 = naive_multiply_matrices( + &psuedorandom_query, + lwe_params.n, + db_cols, + &self.db(), + self.db_rows_padded(), // TODO: doesn't quite work + db_cols, + true, + ); + hint_0.iter().map(|&x| x as u64).collect::>() + } + + pub fn generate_hint_0_ring(&self) -> Vec { + let db_rows = 1 << (self.params.db_dim_1 + self.params.poly_len_log2); + let db_cols = self.db_cols(); + + let lwe_params = LWEParams::default(); + let n = lwe_params.n; + let conv = Convolution::new(n); + + let mut hint_0 = vec![0u64; n * db_cols]; + + let convd_len = conv.params().crt_count * conv.params().poly_len; + + let mut rng_pub = ChaCha20Rng::from_seed(get_seed(SEED_0)); + + let mut v_nega_perm_a = Vec::new(); + for _ in 0..db_rows / n { + let mut a = vec![0u32; n]; + for idx in 0..n { + a[idx] = rng_pub.sample::(rand::distributions::Standard); + } + let nega_perm_a = negacyclic_perm_u32(&a); + let nega_perm_a_ntt = conv.ntt(&nega_perm_a); + v_nega_perm_a.push(nega_perm_a_ntt); + } + + // limit on the number of times we can add results modulo M before we wrap + let log2_conv_output = + log2(lwe_params.modulus) + log2(lwe_params.n as u64) + log2(lwe_params.pt_modulus); + let log2_modulus = log2(conv.params().modulus); + let log2_max_adds = log2_modulus - log2_conv_output - 1; + assert!(log2_max_adds > 0); + let max_adds = 1 << log2_max_adds; + + for col in 0..db_cols { + let mut tmp_col = vec![0u64; convd_len]; + for outer_row in 0..db_rows / n { + let start_idx = col * self.db_rows_padded() + outer_row * n; + let pt_col = &self.db()[start_idx..start_idx + n]; + let pt_col_u32 = pt_col + .iter() + .map(|&x| x.to_u64() as u32) + .collect::>(); + assert_eq!(pt_col_u32.len(), n); + let pt_ntt = conv.ntt(&pt_col_u32); + + let convolved_ntt = conv.pointwise_mul(&v_nega_perm_a[outer_row], &pt_ntt); + + for r in 0..convd_len { + tmp_col[r] += convolved_ntt[r] as u64; + } + + if outer_row % max_adds == max_adds - 1 || outer_row == db_rows / n - 1 { + let mut col_poly_u32 = vec![0u32; convd_len]; + for i in 0..conv.params().crt_count { + for j in 0..conv.params().poly_len { + let val = barrett_coeff_u64( + conv.params(), + tmp_col[i * conv.params().poly_len + j], + i, + ); + col_poly_u32[i * conv.params().poly_len + j] = val as u32; + } + } + let col_poly_raw = conv.raw(&col_poly_u32); + for i in 0..n { + hint_0[i * db_cols + col] += col_poly_raw[i] as u64; + hint_0[i * db_cols + col] %= 1u64 << 32; + } + tmp_col.fill(0); + } + } + } + + hint_0 + } + + pub fn answer_query(&self, aligned_query_packed: &[u64]) -> AlignedMemory64 { + self.multiply_batched_with_db_packed::<1>(aligned_query_packed, 1) + } + + pub fn answer_batched_queries( + &self, + aligned_queries_packed: &[u64], + ) -> AlignedMemory64 { + self.multiply_batched_with_db_packed::(aligned_queries_packed, 1) + } + + pub fn perform_offline_precomputation_simplepir( + &self, + measurement: Option<&mut Measurement>, + hint_0_load: Option<&Vec>, + hint_0_store: Option<&String>, + ) -> OfflinePrecomputedValues<'a> { + // Set up some parameters + + let params = self.params; + assert!(self.ypir_params.is_simplepir); + + let db_cols = params.instances * params.poly_len; + let num_rlwe_outputs = db_cols / params.poly_len; + + // Begin offline precomputation + + let now = Instant::now(); + let hint_0 = if let Some(hint_0_load) = hint_0_load { + hint_0_load.to_vec() + } else { + let hint_0_res = self.answer_hint_ring(SEED_0, db_cols); + if let Some(hint_0_store) = hint_0_store { + write_vec_u64_to_file(hint_0_store, &hint_0_res); + } + hint_0_res + }; + // hint_0 is poly_len x db_cols + let simplepir_prep_time_ms = now.elapsed().as_millis(); + if let Some(measurement) = measurement { + measurement.offline.simplepir_prep_time_ms = simplepir_prep_time_ms as usize; + } + + let now = Instant::now(); + let y_constants = generate_y_constants(¶ms); + + let combined = [&hint_0[..], &vec![0u64; db_cols]].concat(); + assert_eq!(combined.len(), db_cols * (params.poly_len + 1)); + let prepacked_lwe = prep_pack_many_lwes(¶ms, &combined, num_rlwe_outputs); + + let fake_pack_pub_params = generate_fake_pack_pub_params(¶ms); + + let mut precomp: Precomp = Vec::new(); + for i in 0..prepacked_lwe.len() { + let tup = precompute_pack( + params, + params.poly_len_log2, + &prepacked_lwe[i], + &fake_pack_pub_params, + &y_constants, + ); + precomp.push(tup); + } + debug!("Precomp in {} us", now.elapsed().as_micros()); + + OfflinePrecomputedValues { + hint_0, + hint_1: vec![], + pseudorandom_query_1: vec![], + y_constants, + smaller_server: None, + prepacked_lwe, + fake_pack_pub_params, + precomp, + } + } + + pub fn perform_offline_precomputation( + &self, + measurement: Option<&mut Measurement>, + ) -> OfflinePrecomputedValues { + // Set up some parameters + + let params = self.params; + let lwe_params = LWEParams::default(); + assert!(!self.ypir_params.is_simplepir); + + let db_cols = 1 << (params.db_dim_2 + params.poly_len_log2); + + // LWE reduced moduli + let lwe_q_prime_bits = lwe_params.q2_bits as usize; + let lwe_q_prime = lwe_params.get_q_prime_2(); + + // The number of bits represented by a plaintext RLWE coefficient + let pt_bits = (params.pt_modulus as f64).log2().floor() as usize; + // assert_eq!(pt_bits, 16); + + // The factor by which ciphertext values are bigger than plaintext values + let blowup_factor = lwe_q_prime_bits as f64 / pt_bits as f64; + debug!("blowup_factor: {}", blowup_factor); + // assert!(blowup_factor.ceil() - blowup_factor >= 0.05); + + // The starting index of the final value (the '1' in lwe_params.n + 1) + // This is rounded to start on a pt_bits boundary + let special_offs = + ((lwe_params.n * lwe_q_prime_bits) as f64 / pt_bits as f64).ceil() as usize; + let special_bit_offs = special_offs * pt_bits; + + // Parameters for the second round (the "DoublePIR" round) + let mut smaller_params = params.clone(); + smaller_params.db_dim_1 = params.db_dim_2; + smaller_params.db_dim_2 = ((blowup_factor * (lwe_params.n + 1) as f64) + / params.poly_len as f64) + .log2() + .ceil() as usize; + + let out_rows = 1 << (smaller_params.db_dim_2 + params.poly_len_log2); + let rho = 1 << smaller_params.db_dim_2; + assert_eq!(smaller_params.db_dim_1, params.db_dim_2); + assert!(out_rows as f64 >= (blowup_factor * (lwe_params.n + 1) as f64)); + + debug!( + "the first {} LWE output ciphertexts of the DoublePIR round (out of {} total) are query-indepednent", + special_offs, out_rows + ); + debug!( + "the next {} LWE output ciphertexts are query-dependent", + blowup_factor.ceil() as usize + ); + debug!("the rest are zero"); + + // Begin offline precomputation + + let now = Instant::now(); + let hint_0: Vec = self.generate_hint_0_ring(); + // hint_0 is n x db_cols + let simplepir_prep_time_ms = now.elapsed().as_millis(); + if let Some(measurement) = measurement { + measurement.offline.simplepir_prep_time_ms = simplepir_prep_time_ms as usize; + } + debug!("Answered hint (ring) in {} us", now.elapsed().as_micros()); + + // compute (most of) the secondary hint + let intermediate_cts = [&hint_0[..], &vec![0u64; db_cols]].concat(); + let intermediate_cts_rescaled = intermediate_cts + .iter() + .map(|x| rescale(*x, lwe_params.modulus, lwe_q_prime)) + .collect::>(); + + // split and do a second PIR over intermediate_cts + // split into blowup_factor=q/p instances (so that all values are now mod p) + // the second PIR is over a database of db_cols x (blowup_factor * (lwe_params.n + 1)) values mod p + + // inp: (lwe_params.n + 1, db_cols) + // out: (out_rows >= (lwe_params.n + 1) * blowup_factor, db_cols) + // we are 'stretching' the columns (and padding) + + debug!("Splitting intermediate cts..."); + + let smaller_db = split_alloc( + &intermediate_cts_rescaled, + special_bit_offs, + lwe_params.n + 1, + db_cols, + out_rows, + lwe_q_prime_bits, + pt_bits, + ); + assert_eq!(smaller_db.len(), db_cols * out_rows); + + debug!("Done splitting intermediate cts."); + + // This is the 'intermediate' db after the first pass of PIR and expansion + let smaller_server: YServer = YServer::::new( + &self.smaller_params, + smaller_db.into_iter(), + false, + true, + false, + ); + debug!("gen'd smaller server."); + + let hint_1 = smaller_server.answer_hint_ring( + SEED_1, + 1 << (smaller_server.params.db_dim_2 + smaller_server.params.poly_len_log2), + ); + assert_eq!(hint_1.len(), params.poly_len * out_rows); + assert_eq!(hint_1[special_offs], 0); + assert_eq!(hint_1[special_offs + 1], 0); + + let pseudorandom_query_1 = smaller_server.generate_pseudorandom_query(SEED_1); + let y_constants = generate_y_constants(¶ms); + + let combined = [&hint_1[..], &vec![0u64; out_rows]].concat(); + assert_eq!(combined.len(), out_rows * (params.poly_len + 1)); + let prepacked_lwe = prep_pack_many_lwes(¶ms, &combined, rho); + + let now = Instant::now(); + let fake_pack_pub_params = generate_fake_pack_pub_params(¶ms); + + let mut precomp: Precomp = Vec::new(); + for i in 0..prepacked_lwe.len() { + let tup = precompute_pack( + params, + params.poly_len_log2, + &prepacked_lwe[i], + &fake_pack_pub_params, + &y_constants, + ); + precomp.push(tup); + } + debug!("Precomp in {} us", now.elapsed().as_micros()); + + OfflinePrecomputedValues { + hint_0, + hint_1, + pseudorandom_query_1, + y_constants, + smaller_server: Some(smaller_server), + prepacked_lwe, + fake_pack_pub_params, + precomp, + } + } + + /// Perform SimplePIR-style YPIR + pub fn perform_online_computation_simplepir( + &self, + first_dim_queries_packed: &[u64], + offline_vals: &OfflinePrecomputedValues<'a>, + pack_pub_params_row_1s: &[&[u64]], + mut measurement: Option<&mut Measurement>, + ) -> Vec { + assert!(self.ypir_params.is_simplepir); + + // Set up some parameters + + let params = self.params; + + let y_constants = &offline_vals.y_constants; + let prepacked_lwe = &offline_vals.prepacked_lwe; + let precomp = &offline_vals.precomp; + + // RLWE reduced moduli + let rlwe_q_prime_1 = params.get_q_prime_1(); + let rlwe_q_prime_2 = params.get_q_prime_2(); + + let db_rows = 1 << (params.db_dim_1 + params.poly_len_log2); + let db_cols = params.instances * params.poly_len; + + assert_eq!(first_dim_queries_packed.len(), params.db_rows_padded()); + + // Begin online computation + + let first_pass = Instant::now(); + // debug!("Performing mul..."); + let mut intermediate = AlignedMemory64::new(db_cols); + fast_batched_dot_product::<1, T>( + ¶ms, + intermediate.as_mut_slice(), + first_dim_queries_packed, + db_rows, + self.db(), + db_rows, + db_cols, + ); + // debug!("Done w mul..."); + let first_pass_time_ms = first_pass.elapsed().as_millis(); + if let Some(ref mut m) = measurement { + m.online.first_pass_time_ms = first_pass_time_ms as usize; + } + + let ring_packing = Instant::now(); + let num_rlwe_outputs = db_cols / params.poly_len; + let pack_pub_params_row_1s_pms = + unpack_vec_pm(¶ms, 1, params.t_exp_left, pack_pub_params_row_1s[0]); + let packed = pack_many_lwes( + ¶ms, + &prepacked_lwe, + &precomp, + intermediate.as_slice(), + num_rlwe_outputs, + &pack_pub_params_row_1s_pms, + &y_constants, + ); + // debug!("Packed..."); + if let Some(m) = measurement { + m.online.ring_packing_time_ms = ring_packing.elapsed().as_millis() as usize; + } + + let mut packed_mod_switched = Vec::with_capacity(packed.len()); + for ct in packed.iter() { + let res = ct.raw(); + let res_switched = res.switch(rlwe_q_prime_1, rlwe_q_prime_2); + packed_mod_switched.push(res_switched); + } + + assert_eq!(packed_mod_switched.len(), num_rlwe_outputs); + + let concated = packed_mod_switched + .iter() + .map(|x| x.as_slice()) + .flatten() + .copied() + .collect::>(); + + concated + } + + pub fn perform_online_computation( + &self, + offline_vals: &mut OfflinePrecomputedValues<'a>, + first_dim_queries_packed: &[u32], + second_dim_queries: &[(&[u64], &[u64])], + mut measurement: Option<&mut Measurement>, + ) -> Vec> { + // Set up some parameters + + let params = self.params; + let lwe_params = LWEParams::default(); + + let db_cols = self.db_cols(); + + // RLWE reduced moduli + let rlwe_q_prime_1 = params.get_q_prime_1(); + let rlwe_q_prime_2 = params.get_q_prime_2(); + + // LWE reduced moduli + let lwe_q_prime_bits = lwe_params.q2_bits as usize; + let lwe_q_prime = lwe_params.get_q_prime_2(); + + // The number of bits represented by a plaintext RLWE coefficient + let pt_bits = (params.pt_modulus as f64).log2().floor() as usize; + // assert_eq!(pt_bits, 16); + + // The factor by which ciphertext values are bigger than plaintext values + let blowup_factor = lwe_q_prime_bits as f64 / pt_bits as f64; + debug!("blowup_factor: {}", blowup_factor); + // assert!(blowup_factor.ceil() - blowup_factor >= 0.05); + + // The starting index of the final value (the '1' in lwe_params.n + 1) + // This is rounded to start on a pt_bits boundary + let special_offs = + ((lwe_params.n * lwe_q_prime_bits) as f64 / pt_bits as f64).ceil() as usize; + + // Parameters for the second round (the "DoublePIR" round) + let mut smaller_params = params.clone(); + smaller_params.db_dim_1 = params.db_dim_2; + smaller_params.db_dim_2 = ((blowup_factor * (lwe_params.n + 1) as f64) + / params.poly_len as f64) + .log2() + .ceil() as usize; + + let out_rows = 1 << (smaller_params.db_dim_2 + params.poly_len_log2); + let rho = 1 << smaller_params.db_dim_2; + assert_eq!(smaller_params.db_dim_1, params.db_dim_2); + assert!(out_rows as f64 >= (blowup_factor * (lwe_params.n + 1) as f64)); + + // Load offline precomputed values + let hint_1_combined = &mut offline_vals.hint_1; + let pseudorandom_query_1 = &offline_vals.pseudorandom_query_1; + let y_constants = &offline_vals.y_constants; + let smaller_server = offline_vals.smaller_server.as_mut().unwrap(); + let prepacked_lwe = &offline_vals.prepacked_lwe; + let fake_pack_pub_params = &offline_vals.fake_pack_pub_params; + let precomp = &offline_vals.precomp; + + // Begin online computation + + let online_phase = Instant::now(); + let first_pass = Instant::now(); + let intermediate = self.lwe_multiply_batched_with_db_packed::(first_dim_queries_packed); + let simplepir_resp_bytes = intermediate.len() / K * (lwe_q_prime_bits as usize) / 8; + debug!("simplepir_resp_bytes {} bytes", simplepir_resp_bytes); + let first_pass_time_ms = first_pass.elapsed().as_millis(); + debug!("First pass took {} us", first_pass.elapsed().as_micros()); + + if let Some(ref mut m) = measurement { + m.online.first_pass_time_ms = first_pass_time_ms as usize; + m.online.simplepir_resp_bytes = simplepir_resp_bytes; + } + + debug!("intermediate.len(): {}", intermediate.len()); + let mut second_pass_time_ms = 0; + let mut ring_packing_time_ms = 0; + let mut responses = Vec::new(); + for (intermediate_chunk, (packed_query_col, pack_pub_params_row_1s)) in intermediate + .as_slice() + .chunks(db_cols) + .zip(second_dim_queries.iter()) + { + let second_pass = Instant::now(); + let intermediate_cts_rescaled = intermediate_chunk + .iter() + .map(|x| rescale(*x as u64, lwe_params.modulus, lwe_q_prime)) + .collect::>(); + assert_eq!(intermediate_cts_rescaled.len(), db_cols); + debug!( + "intermediate_cts_rescaled[0] = {}", + intermediate_cts_rescaled[0] + ); + + let now = Instant::now(); + // modify the smaller_server db to include the intermediate values + // let mut smaller_server_clone = smaller_server.clone(); + { + // remember, this is stored in 'transposed' form + // so it is out_cols x db_cols + let smaller_db_mut: &mut [u16] = smaller_server.db_mut(); + for j in 0..db_cols { + // new value to write into the db + let val = intermediate_cts_rescaled[j]; + + for m in 0..blowup_factor.ceil() as usize { + // index in the transposed db + let out_idx = (special_offs + m) * db_cols + j; + + // part of the value to write into the db + let val_part = ((val >> (m * pt_bits)) & ((1 << pt_bits) - 1)) as u16; + + // assert_eq!(smaller_db_mut[out_idx], DoubleType::default()); + smaller_db_mut[out_idx] = val_part; + } + } + } + debug!("load secondary hint {} us", now.elapsed().as_micros()); + + let now = Instant::now(); + { + let blowup_factor_ceil = blowup_factor.ceil() as usize; + + let phase = Instant::now(); + let secondary_hint = smaller_server.multiply_with_db_ring( + &pseudorandom_query_1, + special_offs..special_offs + blowup_factor_ceil, + SEED_1, + ); + debug!( + "multiply_with_db_ring took: {} us", + phase.elapsed().as_micros() + ); + // let phase = Instant::now(); + // let secondary_hint = + // smaller_server_clone.answer_hint(SEED_1, special_offs..special_offs + blowup_factor_ceil); + // debug!( + // "traditional answer_hint took: {} us", + // phase.elapsed().as_micros() + // ); + + assert_eq!(secondary_hint.len(), params.poly_len * blowup_factor_ceil); + + for i in 0..params.poly_len { + for j in 0..blowup_factor_ceil { + let inp_idx = i * blowup_factor_ceil + j; + let out_idx = i * out_rows + special_offs + j; + + // assert_eq!(hint_1_combined[out_idx], 0); // we no longer clone for each query, just overwrite + hint_1_combined[out_idx] = secondary_hint[inp_idx]; + } + } + } + debug!("compute secondary hint in {} us", now.elapsed().as_micros()); + + assert_eq!(hint_1_combined.len(), params.poly_len * out_rows); + + let response: AlignedMemory64 = smaller_server.answer_query(packed_query_col); + + second_pass_time_ms += second_pass.elapsed().as_millis(); + let ring_packing = Instant::now(); + let now = Instant::now(); + assert_eq!(response.len(), 1 * out_rows); + + // combined is now (poly_len + 1) * (out_rows) + // let combined = [&hint_1_combined[..], response.as_slice()].concat(); + let mut excess_cts = Vec::with_capacity(blowup_factor.ceil() as usize); + for j in special_offs..special_offs + blowup_factor.ceil() as usize { + let mut rlwe_ct = PolyMatrixRaw::zero(¶ms, 2, 1); + + // 'a' vector + // put this in negacyclic order + let mut poly = Vec::new(); + for k in 0..params.poly_len { + poly.push(hint_1_combined[k * out_rows + j]); + } + let nega = negacyclic_perm(&poly, 0, params.modulus); + + rlwe_ct.get_poly_mut(0, 0).copy_from_slice(&nega); + + // for k in 0..params.poly_len { + // rlwe_ct.get_poly_mut(0, 0)[k] = nega[k]; + // } + + // let j_within_last = j % params.poly_len; + // prepacked_lwe_mut.last_mut().unwrap()[j_within_last] = rlwe_ct.ntt(); + excess_cts.push(rlwe_ct.ntt()); + } + debug!("in between: {} us", now.elapsed().as_micros()); + + // assert_eq!(pack_pub_params_row_1s[0].rows, 1); + + let pack_pub_params_row_1s_pms = + unpack_vec_pm(¶ms, 1, params.t_exp_left, pack_pub_params_row_1s); + let mut packed = pack_many_lwes( + ¶ms, + &prepacked_lwe, + &precomp, + response.as_slice(), + rho, + &pack_pub_params_row_1s_pms, + &y_constants, + ); + + let now = Instant::now(); + let mut pack_pub_params = fake_pack_pub_params.clone(); + for i in 0..pack_pub_params.len() { + let uncondensed = uncondense_matrix(params, &pack_pub_params_row_1s_pms[i]); + pack_pub_params[i].copy_into(&uncondensed, 1, 0); + } + debug!("uncondense pub params: {} us", now.elapsed().as_micros()); + let now = Instant::now(); + let other_packed = + pack_using_single_with_offset(¶ms, &pack_pub_params, &excess_cts, special_offs); + add_into(&mut packed[0], &other_packed); + debug!( + "pack_using_single_with_offset: {} us", + now.elapsed().as_micros() + ); + + let now = Instant::now(); + let mut packed_mod_switched = Vec::with_capacity(packed.len()); + for ct in packed.iter() { + let res = ct.raw(); + let res_switched = res.switch(rlwe_q_prime_1, rlwe_q_prime_2); + packed_mod_switched.push(res_switched); + } + debug!("switching: {} us", now.elapsed().as_micros()); + // debug!("Preprocessing pack in {} us", now.elapsed().as_micros()); + // debug!(""); + ring_packing_time_ms += ring_packing.elapsed().as_millis(); + + // packed is blowup_factor ring ct's + // these encode, contiguously [poly_len + 1, blowup_factor] + // (and some padding) + assert_eq!(packed.len(), rho); + + let concated = packed_mod_switched + .into_iter() + .flat_map(|x| x.into_iter()) + .collect::>(); + + responses.push(concated); + } + debug!( + "Total online time: {} us", + online_phase.elapsed().as_micros() + ); + debug!(""); + + if let Some(ref mut m) = measurement { + m.online.second_pass_time_ms = second_pass_time_ms as usize; + m.online.ring_packing_time_ms = ring_packing_time_ms as usize; + } + + assert_eq!(responses.len(), K); + + responses + } + + pub fn perform_full_online_computation( + &self, + offline_vals: &mut OfflinePrecomputedValues<'a>, + query: &[u8], + ) -> Vec { + let first_dim_bytes_sz = self.params.db_rows_padded() * std::mem::size_of::(); + let second_dim_bytes_sz = self.db_cols() * std::mem::size_of::(); + let pub_param_bytes_sz = self.params.poly_len_log2 + * self.params.t_exp_left + * self.params.poly_len + * std::mem::size_of::(); + assert_eq!( + query.len(), + first_dim_bytes_sz + second_dim_bytes_sz + pub_param_bytes_sz + ); + + let first_dim_bytes = &query[..first_dim_bytes_sz]; + let second_dim_bytes = &query[first_dim_bytes_sz..first_dim_bytes_sz + second_dim_bytes_sz]; + let pub_param_bytes = &query[first_dim_bytes_sz + second_dim_bytes_sz..]; + + let first_dim = Vec::::from_bytes(first_dim_bytes); + let second_dim = AlignedMemory64::from_bytes(second_dim_bytes); + let pub_params = AlignedMemory64::from_bytes(pub_param_bytes); + + self.perform_online_computation::<1>( + offline_vals, + &first_dim, + &[(second_dim.as_slice(), pub_params.as_slice())], + None, + ) + .remove(0) + } + + pub fn perform_full_online_computation_simplepir( + &self, + offline_vals: &OfflinePrecomputedValues<'a>, + query: &[u8], + ) -> Vec { + let first_dim_bytes_sz = self.params.db_rows() * std::mem::size_of::(); + let pub_param_bytes_sz = self.params.poly_len_log2 + * self.params.t_exp_left + * self.params.poly_len + * std::mem::size_of::(); + assert_eq!(query.len(), first_dim_bytes_sz + pub_param_bytes_sz); + + let first_dim_bytes = &query[..first_dim_bytes_sz]; + let pub_param_bytes = &query[first_dim_bytes_sz..]; + + let first_dim = AlignedMemory64::from_bytes(first_dim_bytes); + let pub_params = AlignedMemory64::from_bytes(pub_param_bytes); + + self.perform_online_computation_simplepir( + first_dim.as_slice(), + offline_vals, + &[pub_params.as_slice()], + None, + ) + } + + // generic function that returns a u8 or u16: + pub fn db(&self) -> &[T] { + unsafe { + std::slice::from_raw_parts( + self.db_buf_aligned.as_ptr() as *const T, + self.db_buf_aligned.len() * 8 / std::mem::size_of::(), + ) + } + } + + pub fn db_mut(&mut self) -> &mut [T] { + unsafe { + std::slice::from_raw_parts_mut( + self.db_buf_aligned.as_ptr() as *mut T, + self.db_buf_aligned.len() * 8 / std::mem::size_of::(), + ) + } + } + + pub fn db_u16(&self) -> &[u16] { + unsafe { + std::slice::from_raw_parts( + self.db_buf_aligned.as_ptr() as *const u16, + self.db_buf_aligned.len() * 8 / std::mem::size_of::(), + ) + } + } + + pub fn db_u32(&self) -> &[u32] { + unsafe { + std::slice::from_raw_parts( + self.db_buf_aligned.as_ptr() as *const u32, + self.db_buf_aligned.len() * 8 / std::mem::size_of::(), + ) + } + } + + pub fn get_elem(&self, target_idx: usize) -> T { + let db_cols = self.db_cols(); + let (target_row, target_col) = (target_idx / db_cols, target_idx % db_cols); + self.get_elem_row_col(target_row, target_col) + } + + pub fn get_elem_row_col(&self, row: usize, col: usize) -> T { + self.db()[col * self.db_rows_padded() + row] // stored transposed + } + + pub fn get_row(&self, row: usize) -> Vec { + let db_cols = self.db_cols(); + let mut res = Vec::with_capacity(db_cols); + for col in 0..db_cols { + res.push(self.get_elem_row_col(row, col)); + } + res + // // convert to u8 contiguously + // let mut res_u8 = Vec::with_capacity(db_cols * std::mem::size_of::()); + // for &x in res.iter() { + // res_u8.extend_from_slice(&x.to_u64().to_le_bytes()[..std::mem::size_of::()]); + // } + // res_u8 + } +} + +#[cfg(not(target_feature = "avx2"))] +#[allow(non_camel_case_types)] +type __m512i = u64; + +pub trait ToM512 { + fn to_m512(self) -> __m512i; +} + +#[cfg(feature = "explicit_avx512")] +mod m512_impl { + use super::*; + + impl ToM512 for *const u8 { + #[inline(always)] + fn to_m512(self) -> __m512i { + unsafe { _mm512_cvtepu8_epi64(_mm_loadl_epi64(self as *const _)) } + } + } + + impl ToM512 for *const u16 { + #[inline(always)] + fn to_m512(self) -> __m512i { + unsafe { _mm512_cvtepu16_epi64(_mm_load_si128(self as *const _)) } + } + } + + impl ToM512 for *const u32 { + #[inline(always)] + fn to_m512(self) -> __m512i { + unsafe { _mm512_cvtepu32_epi64(_mm256_load_si256(self as *const _)) } + } + } +} + +#[cfg(not(feature = "explicit_avx512"))] +mod m512_impl { + use super::*; + + impl ToM512 for *const u8 { + #[inline(always)] + fn to_m512(self) -> __m512i { + panic!("AVX512 implementation not being used") + } + } + + impl ToM512 for *const u16 { + #[inline(always)] + fn to_m512(self) -> __m512i { + panic!("AVX512 implementation not being used") + } + } + + impl ToM512 for *const u32 { + #[inline(always)] + fn to_m512(self) -> __m512i { + panic!("AVX512 implementation not being used") + } + } +} + +pub trait ToU64 { + fn to_u64(self) -> u64; +} + +impl ToU64 for u8 { + fn to_u64(self) -> u64 { + self as u64 + } +} + +impl ToU64 for u16 { + fn to_u64(self) -> u64 { + self as u64 + } +} + +impl ToU64 for u32 { + fn to_u64(self) -> u64 { + self as u64 + } +} + +impl ToU64 for u64 { + fn to_u64(self) -> u64 { + self + } +} + +impl ToU64 for *const u8 { + fn to_u64(self) -> u64 { + (unsafe { *self }) as u64 + } +} + +impl ToU64 for *const u16 { + fn to_u64(self) -> u64 { + (unsafe { *self }) as u64 + } +} + +impl ToU64 for *const u64 { + fn to_u64(self) -> u64 { + unsafe { *self } + } +} + +pub fn naive_multiply_matrices( + a: &[u32], + a_rows: usize, + a_cols: usize, + b_t: &[T], // transposed + b_rows: usize, + b_cols: usize, + is_b_transposd: bool, +) -> Vec { + // performs wrapping arithmetic + + assert_eq!(a_cols, b_rows); + + // debug!("Multiplying {}x{} by {}x{}", a_rows, a_cols, b_rows, b_cols); + + let mut result = vec![0u32; a_rows * b_cols]; + for i in 0..a_rows { + for j in 0..b_cols { + for k in 0..a_cols { + let a_idx = i * a_cols + k; + let b_idx = if is_b_transposd { + j * b_rows + k // on purpose, since transposed + } else { + k * b_cols + j + }; + let res_idx = i * b_cols + j; + + unsafe { + let a_val = *a.get_unchecked(a_idx); + let b_val = (b_t.get_unchecked(b_idx)).to_u64() as u32; + + result[res_idx] = result[res_idx].wrapping_add(a_val.wrapping_mul(b_val)); + } + } + } + } + + result +} diff --git a/psi/algorithm/ypir/simplepir_basic_flow_test.cc b/psi/algorithm/ypir/simplepir_basic_flow_test.cc new file mode 100644 index 00000000..134eaf5a --- /dev/null +++ b/psi/algorithm/ypir/simplepir_basic_flow_test.cc @@ -0,0 +1,135 @@ +// Basic flow test - test individual components +#include "gtest/gtest.h" +#include "spdlog/spdlog.h" + +#include "psi/algorithm/spiral/params.h" +#include "psi/algorithm/ypir/util.h" + +namespace psi::ypir { + +using namespace psi::spiral; + +TEST(SimplePIRBasicFlowTest, TestQueryDatabaseMatrixMultiplication) { + // Test the basic matrix multiplication: query * database + size_t poly_len = 2048; + std::vector moduli = {268369921, 249561089}; + double noise_width = 16.042421; + + PolyMatrixParams poly_matrix_params(2, 16384, 21, 4, 8, 8, 1); + QueryParams query_params(1, 1, 1); + + Params params(poly_len, std::move(moduli), noise_width, + std::move(poly_matrix_params), std::move(query_params)); + + size_t db_rows = 1ULL << (params.DbDim1() + params.PolyLenLog2()); + size_t db_cols = params.Instances() * params.PolyLen(); + + SPDLOG_INFO("=== Basic Flow Test ==="); + SPDLOG_INFO("db_rows={}, db_cols={}", db_rows, db_cols); + + // Create all-zeros database + std::vector db(db_rows * db_cols, 0); + + // Create simple query - select first row + std::vector query(db_rows, 0); + query[0] = params.ScaleK(); // scale_k at position 0 + + SPDLOG_INFO("Query[0] = {} (scale_k)", query[0]); + + // Pack query for FastBatchedDotProduct + std::vector query_packed(db_rows); + const uint64_t m0 = params.Moduli(0); + const uint64_t m1 = params.Moduli(1); + + for (size_t i = 0; i < db_rows; ++i) { + query_packed[i] = (query[i] % m0) | ((query[i] % m1) << 32); + } + + SPDLOG_INFO("Packed query[0] = 0x{:016x}", query_packed[0]); + + // Result + std::vector result(db_cols, 0); + + // Call FastBatchedDotProduct + FastBatchedDotProduct(params, result.data(), query_packed.data(), + db_rows, db.data(), db_rows, db_cols); + + SPDLOG_INFO("Result after dot product (first 10):"); + bool all_zero = true; + for (size_t i = 0; i < std::min(size_t(10), result.size()); ++i) { + SPDLOG_INFO(" result[{}] = {}", i, result[i]); + if (result[i] != 0) { + all_zero = false; + } + } + + if (all_zero) { + SPDLOG_INFO("✓ All results are zero as expected"); + } else { + SPDLOG_ERROR("✗ Got non-zero results for zero database!"); + } + + EXPECT_TRUE(all_zero) << "Result should be all zeros for zero database"; +} + +TEST(SimplePIRBasicFlowTest, TestQueryDatabaseWithData) { + // Test with non-zero database + size_t poly_len = 2048; + std::vector moduli = {268369921, 249561089}; + double noise_width = 16.042421; + + PolyMatrixParams poly_matrix_params(2, 16384, 21, 4, 8, 8, 1); + QueryParams query_params(1, 1, 1); + + Params params(poly_len, std::move(moduli), noise_width, + std::move(poly_matrix_params), std::move(query_params)); + + size_t db_rows = 1ULL << (params.DbDim1() + params.PolyLenLog2()); + size_t db_cols = params.Instances() * params.PolyLen(); + + SPDLOG_INFO("=== Basic Flow Test with Data ==="); + + // Create database with pattern + std::vector db(db_rows * db_cols); + for (size_t col = 0; col < db_cols; ++col) { + for (size_t row = 0; row < db_rows; ++row) { + // Column-major: db[col * db_rows + row] + db[col * db_rows + row] = static_cast((row + col) % 100); + } + } + + SPDLOG_INFO("DB[0,0] = {}, DB[0,1] = {}, DB[1,0] = {}", db[0], db[1], + db[db_rows]); + + // Query for row 0 + std::vector query(db_rows, 0); + query[0] = params.ScaleK(); + + // Pack query + std::vector query_packed(db_rows); + const uint64_t m0 = params.Moduli(0); + const uint64_t m1 = params.Moduli(1); + + for (size_t i = 0; i < db_rows; ++i) { + query_packed[i] = (query[i] % m0) | ((query[i] % m1) << 32); + } + + // Result + std::vector result(db_cols, 0); + + FastBatchedDotProduct(params, result.data(), query_packed.data(), + db_rows, db.data(), db_rows, db_cols); + + SPDLOG_INFO("Result after dot product (first 10):"); + for (size_t i = 0; i < std::min(size_t(10), result.size()); ++i) { + // Rescale result back to plaintext space + uint64_t rescaled = + arith::Rescale(result[i], params.Modulus(), params.PtModulus()); + uint16_t expected = db[i * db_rows + 0]; // First row, column i + SPDLOG_INFO(" result[{}] = {} (rescaled: {}), expected: {}", i, result[i], + rescaled, expected); + } + std::cout << "test" << std::endl; +} + +} // namespace psi::ypir diff --git a/psi/algorithm/ypir/types.h b/psi/algorithm/ypir/types.h new file mode 100644 index 00000000..f565aced --- /dev/null +++ b/psi/algorithm/ypir/types.h @@ -0,0 +1,55 @@ +// Copyright 2024 Ant Group Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#pragma once + +#include +#include +#include + +#include "psi/algorithm/spiral/poly_matrix.h" + +namespace psi::ypir { + +using namespace psi::spiral; + +// Precomputation tuple type for packing operations +using Precomp = + std::vector, + std::vector>>>; + +// Forward declaration for YPirServer template class +template +class YPirServer; + +// Convenience alias for the most common type +using YServer = YPirServer; + +// Offline precomputation values for SimplePIR and DoublePIR +struct OfflinePrecomputedValues { + // SimplePIR fields + std::vector hint_0; // First hint + // DoublePIR fields + std::vector hint_1; // Second dimension hint + std::vector + pseudorandom_query_1; // Pseudorandom query for second dimension + std::pair, std::vector> y_constants; + std::shared_ptr smaller_server; + // Packing-related fields + std::vector> prepacked_lwe; + std::vector fake_pack_pub_params; + Precomp precomp; +}; + +} // namespace psi::ypir diff --git a/psi/algorithm/ypir/util.cc b/psi/algorithm/ypir/util.cc new file mode 100644 index 00000000..6e073202 --- /dev/null +++ b/psi/algorithm/ypir/util.cc @@ -0,0 +1,1130 @@ +#include "psi/algorithm/ypir/util.h" + +#include +#include +#include + +#include "../spiral/arith/arith_params.h" +#include "../spiral/arith/ntt.h" +#include "../spiral/discrete_gaussian.h" +#include "../spiral/gadget.h" +#include "../spiral/poly_matrix_utils.h" +#include "yacl/base/int128.h" + +#include "psi/algorithm/spiral/params.h" +#include "psi/algorithm/spiral/poly_matrix.h" +#include "psi/algorithm/spiral/util.h" + +namespace psi::ypir { + +using namespace psi::spiral; + +std::vector ConcatHorizontal( + const std::vector>& v_a, size_t a_rows, + size_t a_cols) { + if (v_a.empty()) { + return {}; + } + + size_t num_vecs = v_a.size(); + + std::vector out(a_rows * a_cols * num_vecs); + size_t out_stride = num_vecs * a_cols; + + for (size_t i = 0; i < a_rows; ++i) { + for (size_t k = 0; k < num_vecs; ++k) { + auto src_begin = v_a[k].begin() + (i * a_cols); + auto src_end = src_begin + a_cols; + size_t dest_offset = (i * out_stride) + (k * a_cols); + + std::copy(src_begin, src_end, out.begin() + dest_offset); + } + } + + return out; +} + +extern "C" { +void matMulVecPacked(uint32_t* out, const uint32_t* a, const uint32_t* b, + size_t aRows, size_t aCols); + +void matMulVecPacked2(uint32_t* out, const uint32_t* a, const uint32_t* b_full, + size_t aRows, size_t aCols); + +void matMulVecPacked4(uint32_t* out, const uint32_t* a, const uint32_t* b_full, + size_t aRows, size_t aCols); + +void matMulVecPacked8(uint32_t* out, const uint32_t* a, const uint32_t* b_full, + size_t aRows, size_t aCols); +} + +// Wrapper function that matches the Rust signature +void MatMulVecPacked(uint32_t* out, const uint32_t* a, const uint32_t* b, + size_t a_rows, size_t a_cols, size_t b_rows, + size_t b_cols) { + // Debug output (equivalent to Rust's debug! macro) + + // Assertions + assert(a_rows * a_cols == a_rows * a_cols); // a.len() == a_rows * a_cols + assert(b_rows * b_cols == b_rows * b_cols); // b.len() == b_rows * b_cols + assert(a_cols * 4 == b_rows); + // Note: out.len() >= a_rows + 8 should be checked by caller + + // Dispatch based on b_cols + if (b_cols == 1) { + matMulVecPacked(out, a, b, a_rows, a_cols); + } else if (b_cols == 2) { + matMulVecPacked2(out, a, b, a_rows, a_cols); + } else if (b_cols == 4) { + matMulVecPacked4(out, a, b, a_rows, a_cols); + } else if (b_cols == 8) { + matMulVecPacked8(out, a, b, a_rows, a_cols); + } else { + fprintf(stderr, "Error: b_cols must be 1, 2, 4, or 8, got %zu\n", b_cols); + assert(false && "b_cols must be 1, 2, 4, or 8"); + } +} + +PolyMatrixNtt HomomorphicAutomorph(const Params& params, size_t t, size_t t_exp, + const PolyMatrixNtt& ct, + const PolyMatrixNtt& pub_param) { + YACL_ENFORCE(ct.Rows() == static_cast(2)); + YACL_ENFORCE(ct.Cols() == static_cast(1)); + + auto ct_raw = PolyMatrixRaw::Zero(params.PolyLen(), 2, 1); + FromNtt(params, ct_raw, ct); + auto ct_auto = Automorphism(params, ct_raw, t); + + auto ginv_ct = PolyMatrixRaw::Zero(params.PolyLen(), t_exp, 1); + psi::spiral::util::GadgetInvertRdim(params, ginv_ct, ct_auto, 1); + + auto ginv_ct_ntt = + PolyMatrixNtt::Zero(params.CrtCount(), params.PolyLen(), t_exp, 1); + for (size_t i = 1; i < t_exp; ++i) { + auto pol_src = ginv_ct.Poly(i, 0); + auto pol_dst = ginv_ct_ntt.Poly(i, 0); + ReduceCopy(params, pol_dst, pol_src); + arith::NttForward(params, pol_dst); + } + + auto w_times_ginv_ct = Multiply(params, pub_param, ginv_ct_ntt); + + auto ct_auto_1 = PolyMatrixRaw::Zero(params.PolyLen(), 1, 1); + + std::memcpy(ct_auto_1.Data().data(), + ct_auto.Data().data() + ct_auto.PolyStartIndex(1, 0), + sizeof(uint64_t) * ct_auto.NumWords()); + auto ct_auto_1_ntt = ToNtt(params, ct_auto_1); + + auto res = Add(params, ct_auto_1_ntt.PadTop(1), w_times_ginv_ct); + return res; +} + +PolyMatrixNtt RingPackLwesInner( + const Params& params, size_t ell, size_t start_idx, + const std::vector& rlwe_cts, + const std::vector& pub_params, + const std::pair, std::vector>& + y_constants) { + YACL_ENFORCE_EQ(pub_params.size(), params.PolyLenLog2()); + + if (ell == 0) { + return rlwe_cts[start_idx]; + } + + size_t step = 1ULL << (params.PolyLenLog2() - ell); + size_t even = start_idx; + size_t odd = start_idx + step; + + auto ct_even = RingPackLwesInner(params, ell - 1, even, rlwe_cts, pub_params, + y_constants); + auto ct_odd = RingPackLwesInner(params, ell - 1, odd, rlwe_cts, pub_params, + y_constants); + + const auto& y = y_constants.first[ell - 1]; + const auto& neg_y = y_constants.second[ell - 1]; + + auto y_times_ct_odd = ScalarMultiply(params, y, ct_odd); + auto neg_y_times_ct_odd = ScalarMultiply(params, neg_y, ct_odd); + + auto ct_sum_1 = ct_even; + AddInto(params, ct_sum_1, neg_y_times_ct_odd); + AddInto(params, ct_even, y_times_ct_odd); + + size_t t = (1ULL << ell) + 1; + const auto& pub_param = pub_params[params.PolyLenLog2() - 1 - (ell - 1)]; + auto ct_sum_1_automorphed = + HomomorphicAutomorph(params, t, params.TExpLeft(), ct_sum_1, pub_param); + + return Add(params, ct_even, ct_sum_1_automorphed); +} + +std::pair, std::vector> GenYConstants( + const Params& params) { + std::vector y_constants; + std::vector neg_y_constants; + + for (size_t num_cts_log2 = 1; num_cts_log2 <= params.PolyLenLog2(); + ++num_cts_log2) { + size_t num_cts = 1ULL << num_cts_log2; + + auto y_raw = PolyMatrixRaw::Zero(params.PolyLen(), 1, 1); + size_t idx = params.PolyLen() / num_cts; + y_raw.Data()[idx] = 1ULL; + auto y = ToNtt(params, y_raw); + + auto neg_y_raw = PolyMatrixRaw::Zero(params.PolyLen(), 1, 1); + neg_y_raw.Data()[idx] = params.Modulus() - 1; + auto neg_y = ToNtt(params, neg_y_raw); + + y_constants.push_back(y); + neg_y_constants.push_back(neg_y); + } + + return std::make_pair(y_constants, neg_y_constants); +} + +PolyMatrixNtt RingPackLwes( + const Params& params, const std::vector& b_values, + const std::vector& rlwe_cts, size_t num_cts, + const std::vector& pub_params, + const std::pair, std::vector>& + y_constants) { + YACL_ENFORCE_EQ(b_values.size(), num_cts); + YACL_ENFORCE_EQ(rlwe_cts.size(), num_cts); + + size_t ell = params.PolyLenLog2(); + auto out = + RingPackLwesInner(params, ell, 0, rlwe_cts, pub_params, y_constants); + + auto out_raw = FromNtt(params, out); + for (size_t z = 0; z < params.PolyLen(); ++z) { + uint128_t b_val_u128 = static_cast(b_values[z]); + uint128_t poly_len_u128 = static_cast(params.PolyLen()); + uint128_t prod = b_val_u128 * poly_len_u128; + uint64_t val = arith::BarrettReductionU128(params, prod); + + size_t idx = out_raw.PolyStartIndex(1, 0) + z; + uint64_t sum = out_raw.Data()[idx] + val; + out_raw.Data()[idx] = arith::BarrettU64(params, sum); + } + + return ToNtt(params, out_raw); +} + +std::vector NegacyclicPerm(absl::Span a, size_t shift, + uint64_t modulus) { + size_t n = a.size(); + std::vector out(n); + + for (size_t i = 0; i <= shift; ++i) { + out[i] = a[shift - i]; + } + + for (size_t i = shift + 1; i < n; ++i) { + size_t src_idx = n - (i - shift); + uint64_t val = a[src_idx] % modulus; + if (val == 0) { + out[i] = 0; + } else { + out[i] = modulus - val; + } + } + + return out; +} + +std::vector NegacyclicMatrix(absl::Span a, + uint64_t modulus) { + size_t n = a.size(); + std::vector out(n * n, 0); + + for (size_t i = 0; i < n; ++i) { + std::vector perm = NegacyclicPerm(a, i, modulus); + for (size_t j = 0; j < n; ++j) { + out[j * n + i] = perm[j]; + } + } + + return out; +} + +PolyMatrixNtt CondenseMatrix(const Params& params, const PolyMatrixNtt& a) { + PolyMatrixNtt res = PolyMatrixNtt::Zero(params.CrtCount(), params.PolyLen(), + a.Rows(), a.Cols()); + for (size_t i = 0; i < a.Rows(); ++i) { + for (size_t j = 0; j < a.Cols(); ++j) { + auto res_poly = res.Poly(i, j); + const auto a_poly = a.Poly(i, j); + if (a_poly.size() < 2 * params.PolyLen()) { + continue; + } + for (size_t z = 0; z < params.PolyLen(); ++z) { + res_poly[z] = a_poly[z] | (a_poly[z + params.PolyLen()] << 32); + } + } + } + + return res; +} + +// from ypir/packing.rs +PolyMatrixNtt RotationPoly(const Params& params, size_t amount) { + PolyMatrixRaw res = PolyMatrixRaw::Zero(params.PolyLen(), 1, 1); + + if (amount < res.Data().size()) { + res.Data()[amount] = 1; + } else { + YACL_THROW("Rotation amount exceeds polynomial length"); + } + + return ToNtt(params, res); +} +PolyMatrixNtt PackSingleLwe(const Params& params, + const std::vector& pub_params, + const PolyMatrixNtt& lwe_ct) { + PolyMatrixNtt cur_r = lwe_ct; + + size_t log_n = params.PolyLenLog2(); + + for (size_t i = 0; i < log_n; ++i) { + size_t t = (params.PolyLen() / (1ULL << i)) + 1; + + const auto& pub_param = pub_params[i]; + + auto tau_of_r = + HomomorphicAutomorph(params, t, params.TExpLeft(), cur_r, pub_param); + AddInto(params, cur_r, tau_of_r); + } + + return cur_r; +} + +PolyMatrixNtt PackUsingSingleWithOffset( + const Params& params, const std::vector& pub_params, + const std::vector& cts, size_t offset) { + PolyMatrixNtt res = + PolyMatrixNtt::Zero(params.CrtCount(), params.PolyLen(), 2, 1); + + SPDLOG_INFO( + "PackUsingSingleWithOffset: offset={}, cts.size()={}, poly_len={}", + offset, cts.size(), params.PolyLen()); + + for (size_t i = 0; i < cts.size(); ++i) { + PolyMatrixNtt packed_single = PackSingleLwe(params, pub_params, cts[i]); + + size_t rotation_amount = offset + i; + if (rotation_amount >= params.PolyLen()) { + SPDLOG_ERROR("ERROR: rotation_amount {} >= poly_len {} (offset={}, i={})", + rotation_amount, params.PolyLen(), offset, i); + YACL_THROW( + "Rotation amount exceeds polynomial length in " + "PackUsingSingleWithOffset"); + } + + PolyMatrixNtt rotation = RotationPoly(params, rotation_amount); + PolyMatrixNtt rotated = ScalarMultiply(params, rotation, packed_single); + + AddInto(params, res, rotated); + } + + return res; +} + +std::vector PrepPackLwes(const Params& params, + absl::Span lwe_cts, + size_t cols_to_do) { + size_t poly_len = params.PolyLen(); + size_t expected_size = poly_len * (poly_len + 1); + + if (lwe_cts.size() != expected_size) { + throw std::runtime_error("PrepPackLwes: lwe_cts size mismatch"); + } + if (cols_to_do != poly_len) { + throw std::runtime_error("PrepPackLwes: cols_to_do must equal poly_len"); + } + + std::vector rlwe_cts; + rlwe_cts.reserve(cols_to_do); + + for (size_t i = 0; i < cols_to_do; ++i) { + auto rlwe_ct = PolyMatrixRaw::Zero(params.PolyLen(), 2, 1); + std::vector poly; + poly.reserve(poly_len); + for (size_t j = 0; j < poly_len; ++j) { + poly.push_back(lwe_cts[j * poly_len + i]); + } + + auto nega = NegacyclicPerm(poly, 0, params.Modulus()); + + // Use Poly(0, 0) to get the first polynomial + auto first_poly = rlwe_ct.Poly(0, 0); + for (size_t j = 0; j < poly_len; ++j) { + first_poly[j] = nega[j]; + } + + rlwe_cts.push_back(ToNtt(params, rlwe_ct)); + } + + return rlwe_cts; +} + +std::vector> PrepPackManyLwes( + const Params& params, absl::Span lwe_cts, + size_t num_rlwe_outputs) { + size_t poly_len = params.PolyLen(); + + size_t expected_total_size = (poly_len + 1) * (num_rlwe_outputs * poly_len); + + if (lwe_cts.size() != expected_total_size) { + throw std::runtime_error("PrepPackManyLwes: Total size mismatch"); + } + + std::vector> vecs; + vecs.reserve(num_rlwe_outputs); + + for (size_t i = 0; i < num_rlwe_outputs; ++i) { + std::vector v; + // 每个 chunk 的大小应该是 poly_len * (poly_len + 1) + v.reserve(poly_len * (poly_len + 1)); + for (size_t j = 0; j < poly_len + 1; ++j) { + size_t start_idx = j * (num_rlwe_outputs * poly_len) + i * poly_len; + for (size_t k = 0; k < poly_len; ++k) { + v.push_back(lwe_cts[start_idx + k]); + } + } + vecs.push_back(std::move(v)); + } + std::vector> res; + res.reserve(num_rlwe_outputs); + + for (size_t i = 0; i < num_rlwe_outputs; ++i) { + res.push_back(PrepPackLwes(params, vecs[i], poly_len)); + } + + return res; +} + +std::vector> GenerateAutomorphTablesBruteForce( + const Params& params) { + std::vector> tables; + + tables.reserve(params.PolyLenLog2()); + + for (size_t i = params.PolyLenLog2(); i >= 1; --i) { + size_t poly_len = params.PolyLen(); + std::vector table_candidate(poly_len); + while (true) { + uint64_t t = (1ULL << i) + 1; + PolyMatrixRaw poly = PolyMatrixRaw::Random(params, 1, 1); + PolyMatrixNtt poly_ntt = ToNtt(params, poly); + PolyMatrixRaw poly_auto(params.PolyLen(), 1, 1); + Automorphism(params, poly_auto, poly, t); + PolyMatrixNtt poly_auto_ntt = ToNtt(params, poly_auto); + auto pol_orig = poly_ntt.Poly(0, 0); + auto pol_auto = poly_auto_ntt.Poly(0, 0); + bool must_redo = false; + for (size_t src_idx = 0; src_idx < poly_len; ++src_idx) { + uint64_t target_val = pol_orig[src_idx]; + int found_count = 0; + size_t found_pos = 0; + for (size_t dest_idx = 0; dest_idx < poly_len; ++dest_idx) { + if (pol_auto[dest_idx] == target_val) { + found_count++; + found_pos = dest_idx; + } + } + if (found_count != 1) { + must_redo = true; + break; + } + table_candidate[found_pos] = src_idx; + } + + if (!must_redo) { + break; + } + } + tables.push_back(std::move(table_candidate)); + } + + return tables; +} + +std::tuple, + std::vector>> +PrecomputePack(const Params& params, size_t poly_len_log2, + const std::vector& prepacked, + const std::vector& pub_params, + const std::pair, + std::vector>& y_constants) { + YACL_ENFORCE_EQ(pub_params.size(), params.PolyLenLog2(), + "pub_params size must match poly_len_log2"); + YACL_ENFORCE_EQ(params.CrtCount(), 2UL, "CRT count must be 2"); + + std::vector working_set = prepacked; + PolyMatrixNtt y_times_ct_odd = + PolyMatrixNtt::Zero(params.CrtCount(), params.PolyLen(), 2, 1); + + PolyMatrixNtt neg_y_times_ct_odd = + PolyMatrixNtt::Zero(params.CrtCount(), params.PolyLen(), 2, 1); + PolyMatrixNtt ct_sum_1 = + PolyMatrixNtt::Zero(params.CrtCount(), params.PolyLen(), 2, 1); + + PolyMatrixRaw ct_raw = PolyMatrixRaw::Zero(params.PolyLen(), 1, 1); + PolyMatrixRaw ct_auto = PolyMatrixRaw::Zero(params.PolyLen(), 1, 1); + + size_t t_exp = params.TExpLeft(); + PolyMatrixRaw ginv_ct = + PolyMatrixRaw::Zero(params.PolyLen(), t_exp, 1); // Fixed: poly_len first + PolyMatrixNtt ginv_ct_ntt = + PolyMatrixNtt::Zero(params.CrtCount(), params.PolyLen(), t_exp, 1); + + PolyMatrixNtt ct_auto_1_ntt = + PolyMatrixNtt::Zero(params.CrtCount(), params.PolyLen(), 1, 1); + PolyMatrixNtt w_times_ginv_ct = + PolyMatrixNtt::Zero(params.CrtCount(), params.PolyLen(), 2, 1); + PolyMatrixNtt scratch = + PolyMatrixNtt::Zero(params.CrtCount(), params.PolyLen(), 2, 1); + std::vector v_trgsw; + v_trgsw.reserve(poly_len_log2); + + for (size_t cur_ell = 1; cur_ell <= poly_len_log2; ++cur_ell) { + size_t num_in = 1ULL << (poly_len_log2 - cur_ell + 1); + size_t num_out = num_in >> 1; + + const auto& y = y_constants.first[cur_ell - 1]; + const auto& neg_y = y_constants.second[cur_ell - 1]; + + for (size_t i = 0; i < num_out; ++i) { + auto& ct_even = working_set[i]; + const auto& ct_odd = working_set[i + num_out]; + + // y_times_ct_odd = y * ct_odd + ScalarMultiply(params, y_times_ct_odd, y, ct_odd); + // neg_y_times_ct_odd = -y * ct_odd + ScalarMultiply(params, neg_y_times_ct_odd, neg_y, ct_odd); + + // ct_sum_1 = ct_even + neg_y * ct_odd + ct_sum_1.CopyInto(ct_even, 0, 0); + AddInto(params, ct_sum_1, neg_y_times_ct_odd); + + AddInto(params, ct_even, y_times_ct_odd); + + uint64_t t = (1ULL << cur_ell) + 1; + FromNttScratch(params, ct_raw, scratch.Data(), ct_sum_1); + + Automorphism(params, ct_auto, ct_raw, t); + util::GadgetInvertRdim(params, ginv_ct, ct_auto, 1); + ToNtt(params, ginv_ct_ntt, ginv_ct); + + auto scratch_poly = scratch.Poly(0, 0); // Get the stored 2nd row data + AutomorphismPolyUncrtd(params, ct_auto_1_ntt.Data(), scratch_poly, t); + arith::NttForward(params, ct_auto_1_ntt.Data()); + + v_trgsw.push_back(CondenseMatrix(params, ginv_ct_ntt)); + + size_t param_idx = poly_len_log2 - cur_ell; + const auto& pub_param = pub_params[param_idx]; + + // W * Ginv + std::fill(w_times_ginv_ct.Data().begin(), w_times_ginv_ct.Data().end(), + 0); + MultiplyNoReduce(w_times_ginv_ct, pub_param, ginv_ct_ntt, 0); + + AddIntoAt(params, ct_even, ct_auto_1_ntt, 1, 0); + + AddInto(params, ct_even, w_times_ginv_ct); + } + } + + auto combined_hints = GenerateAutomorphTablesBruteForce(params); + return std::make_tuple(working_set[0], v_trgsw, combined_hints); +} + +inline uint64_t FastBarrettRawU64(uint64_t input, uint64_t const_ratio_1, + uint64_t modulus) { + uint128_t mul = static_cast(input) * const_ratio_1; + uint64_t tmp = static_cast(mul >> 64); + uint64_t res = input - tmp * modulus; + return res; +} + +void FastAddInto(const Params& params, PolyMatrixNtt& res, + const PolyMatrixNtt& a) { + if (res.Rows() != a.Rows() || res.Cols() != a.Cols()) { + throw std::runtime_error("FastAddInto: Dimension mismatch"); + } + + size_t poly_len = params.PolyLen(); + size_t crt_count = params.CrtCount(); + + uint64_t* res_ptr = const_cast(res.Data().data()); + const uint64_t* a_ptr = a.Data().data(); + size_t num_polys = res.Rows() * res.Cols(); + + for (size_t p = 0; p < num_polys; ++p) { + for (size_t c = 0; c < crt_count; ++c) { + size_t poly_offset = p * (crt_count * poly_len); + size_t crt_offset = poly_offset + c * poly_len; + + for (size_t i = 0; i < poly_len; ++i) { + size_t idx = crt_offset + i; + uint64_t val = res_ptr[idx] + a_ptr[idx]; + res_ptr[idx] = + FastBarrettRawU64(val, params.BarrettCr1(c), params.Moduli(c)); + } + } + } +} + +void FastAddIntoNoReduce(PolyMatrixNtt& res, const PolyMatrixNtt& a) { + if (res.Rows() != a.Rows() || res.Cols() != a.Cols()) { + throw std::runtime_error("FastAddIntoNoReduce: Dimension mismatch"); + } + size_t len = res.Data().size(); + for (size_t i = 0; i < len; ++i) { + res.Data()[i] += a.Data()[i]; + } +} + +void MultiplyPolyAvx(uint64_t* res, const uint64_t* a, const uint64_t* b, + size_t len) { + for (size_t i = 0; i < len; ++i) { + uint64_t x = static_cast(static_cast(a[i])); + uint64_t y = static_cast(static_cast(b[i])); + res[i] = x * y; + } +} + +void ScalarMultiplyAvx(const Params& params, PolyMatrixNtt& res, + const PolyMatrixNtt& a, const PolyMatrixNtt& b) { + if (a.Rows() != 1 || a.Cols() != 1) { + throw std::runtime_error( + "ScalarMultiplyAvx: 'a' must be a 1x1 matrix (scalar)"); + } + + if (res.Rows() != b.Rows() || res.Cols() != b.Cols()) { + throw std::runtime_error( + "ScalarMultiplyAvx: 'res' and 'b' dimension mismatch"); + } + + // poly_size = poly_len * crt_count + size_t poly_size = params.PolyLen() * params.CrtCount(); + + const uint64_t* pol2_ptr = a.Data().data(); + + const uint64_t* b_ptr = b.Data().data(); + + uint64_t* res_ptr = const_cast(res.Data().data()); + + size_t total_polys = b.Rows() * b.Cols(); + + for (size_t i = 0; i < total_polys; ++i) { + size_t offset = i * poly_size; + + const uint64_t* pol1_ptr = b_ptr + offset; + + uint64_t* res_poly_ptr = res_ptr + offset; + + MultiplyPolyAvx(res_poly_ptr, pol1_ptr, pol2_ptr, poly_size); + } +} + +void FastMultiplyNoReduce(const Params& params, PolyMatrixNtt& res, + const PolyMatrixNtt& a, const PolyMatrixNtt& b, + size_t /*start_inner_dim*/) { + if (res.Rows() != 1 || res.Cols() != 1) { + throw std::runtime_error("FastMultiplyNoReduce: Result must be 1x1"); + } + if (res.Rows() != a.Rows() || res.Cols() != b.Cols()) { + throw std::runtime_error( + "FastMultiplyNoReduce: Dimension mismatch (Result)"); + } + if (a.Cols() != b.Rows()) { + throw std::runtime_error( + "FastMultiplyNoReduce: Dimension mismatch (Inner)"); + } + + if (params.CrtCount() != 2) { + throw std::runtime_error("FastMultiplyNoReduce: Requires CRT count = 2"); + } + + uint64_t* res_ptr = const_cast(res.Data().data()); + const uint64_t* a_ptr = a.Data().data(); + const uint64_t* b_ptr = b.Data().data(); + + size_t pol_sz = params.PolyLen(); + size_t k_dim = a.Cols(); + + for (size_t idx = 0; idx < pol_sz; ++idx) { + uint64_t sum_lo = 0; + uint64_t sum_hi = 0; + + for (size_t k = 0; k < k_dim; ++k) { + size_t offset = k * 2 * pol_sz + idx; + + uint64_t x = a_ptr[offset]; + uint64_t y = b_ptr[offset]; + + uint64_t x_lo = x & 0xFFFFFFFF; + uint64_t x_hi = x >> 32; + + uint64_t y_lo = y & 0xFFFFFFFF; + uint64_t y_hi = y >> 32; + + sum_lo += x_lo * y_lo; + sum_hi += x_hi * y_hi; + } + + res_ptr[idx] = sum_lo; + res_ptr[pol_sz + idx] = sum_hi; + } +} + +void ApplyAutomorphNttRaw(const Params& params, const uint64_t* poly, + uint64_t* out, size_t t, + const std::vector>& tables) { + size_t poly_len = params.PolyLen(); + if (t <= 1) throw std::runtime_error("ApplyAutomorphNttRaw: t must be > 1"); + + size_t val = poly_len / (t - 1); + // C++20 + // size_t table_idx = std::countr_zero(val); + size_t table_idx = __builtin_ctzll(val); + + if (table_idx >= tables.size()) { + throw std::runtime_error("ApplyAutomorphNttRaw: Table index out of bounds"); + } + + const std::vector& table = tables[table_idx]; + + for (size_t i = 0; i < poly_len; ++i) { + out[i] += poly[table[i]]; + } +} + +void ApplyAutomorphNtt(const Params& params, + const std::vector>& tables, + const PolyMatrixNtt& mat, PolyMatrixNtt& res, size_t t) { + if (mat.Rows() != res.Rows() || mat.Cols() != res.Cols()) { + throw std::runtime_error("ApplyAutomorphNtt: Dimension mismatch"); + } + + const uint64_t* mat_ptr = mat.Data().data(); + + uint64_t* res_ptr = const_cast(res.Data().data()); + + size_t poly_len = params.PolyLen(); + size_t total_elements = mat.Data().size(); + + for (size_t offset = 0; offset < total_elements; offset += poly_len) { + ApplyAutomorphNttRaw(params, mat_ptr + offset, res_ptr + offset, t, tables); + } +} + +void FastReduce(const Params& params, PolyMatrixNtt& res) { + size_t crt_count = params.CrtCount(); + size_t poly_len = params.PolyLen(); + + for (size_t m = 0; m < crt_count; ++m) { + for (size_t i = 0; i < poly_len; ++i) { + size_t idx = m * poly_len + i; + res.Data()[idx] = arith::BarrettCoeffU64(params, res.Data()[idx], m); + } + } +} + +PolyMatrixNtt PackUsingPrecompVals( + const Params& params, size_t ell, + absl::Span pub_params, + absl::Span b_values, const PolyMatrixNtt& precomp_res, + absl::Span precomp_vals, + const std::vector>& precomp_tables, + const std::pair, std::vector>& + y_constants) { + size_t initial_capacity = 1ULL << (ell - 1); + std::vector working_set; + working_set.reserve(initial_capacity); + + for (size_t i = 0; i < initial_capacity; ++i) { + working_set.push_back( + PolyMatrixNtt::Zero(params.CrtCount(), params.PolyLen(), 1, 1)); + } + + auto y_times_ct_odd = + PolyMatrixNtt::Zero(params.CrtCount(), params.PolyLen(), 1, 1); + auto neg_y_times_ct_odd = + PolyMatrixNtt::Zero(params.CrtCount(), params.PolyLen(), 1, 1); + auto ct_sum_1 = + PolyMatrixNtt::Zero(params.CrtCount(), params.PolyLen(), 1, 1); + auto w_times_ginv_ct = + PolyMatrixNtt::Zero(params.CrtCount(), params.PolyLen(), 1, 1); + + size_t idx_precomp = 0; + + for (size_t cur_ell = 1; cur_ell <= ell; ++cur_ell) { + size_t num_in = 1ULL << (ell - cur_ell + 1); + size_t num_out = num_in >> 1; + + if (num_in == params.PolyLen()) { + num_in = num_out; + } + + for (size_t i = 0; i < num_out; ++i) { + PolyMatrixNtt& ct_even = working_set[i]; + + const auto& y = y_constants.first[cur_ell - 1]; + const auto& neg_y = y_constants.second[cur_ell - 1]; + + if (cur_ell > 1) { + PolyMatrixNtt& ct_odd = working_set[num_out + i]; + ScalarMultiplyAvx(params, y_times_ct_odd, y, ct_odd); + ScalarMultiplyAvx(params, neg_y_times_ct_odd, neg_y, ct_odd); + } + + if (cur_ell > 1) { + std::copy(ct_even.Data().begin(), ct_even.Data().end(), + const_cast(ct_sum_1.Data().data())); + + FastAddIntoNoReduce(ct_sum_1, neg_y_times_ct_odd); + FastAddIntoNoReduce(ct_even, y_times_ct_odd); + } + + const PolyMatrixNtt* ct_ptr = &ct_sum_1; + size_t t = (1ULL << cur_ell) + 1; + + const auto& cur_ginv_ct_ntt = precomp_vals[idx_precomp]; + idx_precomp++; + + size_t w_idx = params.PolyLenLog2() - cur_ell; + const auto& w = pub_params[w_idx]; + + FastMultiplyNoReduce(params, w_times_ginv_ct, w, cur_ginv_ct_ntt, 0); + + if (cur_ell > 1) { + ApplyAutomorphNtt(params, precomp_tables, *ct_ptr, ct_even, t); + + if (i < num_out / 2 && ((cur_ell - 1) % 5 != 0)) { + FastAddIntoNoReduce(ct_even, w_times_ginv_ct); + } else { + FastAddInto(params, ct_even, w_times_ginv_ct); + } + } else { + if (i < num_out / 2) { + FastAddIntoNoReduce(ct_even, w_times_ginv_ct); + } else { + FastAddInto(params, ct_even, w_times_ginv_ct); + } + } + } + } + + if (idx_precomp != precomp_vals.size()) { + throw std::runtime_error("PackUsingPrecompVals: idx_precomp mismatch"); + } + + PolyMatrixNtt resulting_row_1 = working_set[0]; + FastReduce(params, resulting_row_1); + + PolyMatrixNtt res = precomp_res; + + size_t poly_len = params.PolyLen(); + size_t crt_count = params.CrtCount(); + size_t row_1_offset_ntt = crt_count * poly_len; + + uint64_t* res_data = const_cast(res.Data().data()); + const uint64_t* row_1_src = resulting_row_1.Data().data(); + + std::copy(row_1_src, row_1_src + (crt_count * poly_len), + res_data + row_1_offset_ntt); + + PolyMatrixRaw out_raw = FromNtt(params, res); + uint64_t modulus = params.Modulus(); + + for (size_t z = 0; z < poly_len; ++z) { + uint128_t val_u128 = static_cast(b_values[z]) * poly_len; + uint64_t val = arith::BarrettReductionU128(params, val_u128); + + size_t idx = poly_len + z; + + out_raw.Data()[idx] += val; + if (out_raw.Data()[idx] >= modulus) { + out_raw.Data()[idx] -= modulus; + } + } + + return ToNtt(params, out_raw); +} + +std::vector PackManyLwes( + const Params& params, + const std::vector>& prep_rlwe_cts, + const Precomp& precomp, absl::Span b_values, + size_t num_rlwe_outputs, + const std::vector& pack_pub_params_row_1s, + const std::pair, std::vector>& + y_constants) { + if (prep_rlwe_cts.size() != num_rlwe_outputs) { + throw std::runtime_error("PackManyLwes: prep_rlwe_cts size mismatch"); + } + + if (!prep_rlwe_cts.empty() && prep_rlwe_cts[0].size() != params.PolyLen()) { + throw std::runtime_error("PackManyLwes: prep_rlwe_cts inner size mismatch"); + } + + if (b_values.size() != num_rlwe_outputs * params.PolyLen()) { + throw std::runtime_error("PackManyLwes: b_values size mismatch"); + } + + if (precomp.size() != num_rlwe_outputs) { + throw std::runtime_error("PackManyLwes: precomp size mismatch"); + } + + std::vector res; + res.reserve(num_rlwe_outputs); + + size_t poly_len = params.PolyLen(); + size_t poly_len_log2 = params.PolyLenLog2(); + + for (size_t i = 0; i < num_rlwe_outputs; ++i) { + const auto& [precomp_res, precomp_vals, precomp_tables] = precomp[i]; + + auto b_values_slice = b_values.subspan(i * poly_len, poly_len); + + PolyMatrixNtt packed = PackUsingPrecompVals( + params, poly_len_log2, + absl::MakeConstSpan(pack_pub_params_row_1s), // Vector -> Span + b_values_slice, precomp_res, + absl::MakeConstSpan(precomp_vals), // Vector -> Span + precomp_tables, y_constants); + + res.push_back(std::move(packed)); + } + + return res; +} + +PolyMatrixNtt GetRegevSample(const Params& params, const PolyMatrixRaw& sk_reg, + yacl::crypto::Prg& rng, + yacl::crypto::Prg& rng_pub) { + auto a = PolyMatrixRaw::RandomPrg(params, 1, 1, rng_pub); + auto a_ntt = ToNtt(params, a); + auto a_inv = ToNtt(params, Negate(params, a)); + DiscreteGaussian dg(params.NoiseWidth()); + auto e = Noise(params, 1, 1, dg, rng); + + auto e_ntt = ToNtt(params, e); + auto sk_reg_ntt = ToNtt(params, sk_reg); + auto b_p = Multiply(params, sk_reg_ntt, a_ntt); + auto b = Add(params, e_ntt, b_p); + auto p = PolyMatrixNtt::Zero(params.CrtCount(), params.PolyLen(), 2, 1); + p.CopyInto(a_inv, 0, 0); + p.CopyInto(b, 1, 0); + + return p; +} + +PolyMatrixNtt GetFreshRegevPublicKey(const Params& params, + const PolyMatrixRaw& sk_reg, size_t m, + yacl::crypto::Prg& rng, + yacl::crypto::Prg& rng_pub) { + auto p = PolyMatrixNtt::Zero(params.CrtCount(), params.PolyLen(), 2, m); + for (size_t i = 0; i < m; ++i) { + p.CopyInto(GetRegevSample(params, sk_reg, rng, rng_pub), 0, i); + } + return p; +} + +std::vector RawGenerateExpansionParams( + const Params& params, const PolyMatrixRaw& sk_reg, size_t num_exp, + size_t m_exp, yacl::crypto::Prg& rng, + yacl::crypto::Prg& rng_pub) { + auto g_exp = util::BuildGadget(params, 1, m_exp); + auto g_exp_ntt = ToNtt(params, g_exp); + + std::vector res; + res.reserve(num_exp); + + for (size_t i = 0; i < num_exp; ++i) { + size_t t = (params.PolyLen() / (1ULL << i)) + 1; + auto tau_sk_reg = Automorphism(params, sk_reg, t); + auto tau_sk_reg_ntt = ToNtt(params, tau_sk_reg); + auto prod = Multiply(params, tau_sk_reg_ntt, g_exp_ntt); + auto sample = GetFreshRegevPublicKey(params, sk_reg, m_exp, rng, rng_pub); + + PolyMatrixNtt padded_prod = prod.PadTop(1); + auto w_exp_i = Add(params, sample, padded_prod); + res.push_back(std::move(w_exp_i)); + } + return res; +} + +// from kernal.rs + +template +void FastBatchedDotProduct(const Params& params, uint64_t* c, const uint64_t* a, + size_t a_elems, const T* b_t, size_t b_rows, + size_t b_cols) { + if (a_elems != b_rows) { + throw std::runtime_error("FastBatchedDotProduct: Dimension mismatch"); + } + + const size_t chunk_size = std::min(65536, a_elems); + const size_t num_chunks = a_elems / chunk_size; + + for (size_t k_outer = 0; k_outer < num_chunks; ++k_outer) { + const uint64_t* a_chunk_ptr = a + (k_outer * chunk_size); + for (size_t j = 0; j < b_cols; ++j) { + const T* b_ptr = b_t + (j * b_rows) + (k_outer * chunk_size); + uint64_t total_sum_lo = 0; + uint64_t total_sum_hi = 0; + for (size_t k_inner = 0; k_inner < chunk_size; ++k_inner) { + uint64_t a_val = a_chunk_ptr[k_inner]; + uint64_t b_val = static_cast(b_ptr[k_inner]); + uint64_t a_lo = a_val & 0xFFFFFFFF; + uint64_t a_hi = a_val >> 32; + total_sum_lo += a_lo * b_val; + total_sum_hi += a_hi * b_val; + } + + uint64_t lo = arith::BarrettCoeffU64(params, total_sum_lo, 0); + uint64_t hi = arith::BarrettCoeffU64(params, total_sum_hi, 1); + + uint64_t res = params.CrtCompose2(lo, hi); + + uint64_t sum = c[j] + res; + c[j] = arith::BarrettU64(params, sum); + } + } +} + +// from serialize.rs +std::vector UnpackVecPm(const Params& params, size_t rows, + size_t cols, + absl::Span data) { + if (params.CrtCount() != 2) { + throw std::runtime_error("UnpackVecPm: Params CRT count must be 2"); + } + + size_t poly_len = params.PolyLen(); + size_t chunk_size = rows * cols * poly_len; + + if (chunk_size == 0) { + return {}; + } + + if (data.size() % chunk_size != 0) { + throw std::runtime_error( + "UnpackVecPm: Data size not aligned with matrix dimensions"); + } + + size_t num_matrices = data.size() / chunk_size; + std::vector v_cts; + v_cts.reserve(num_matrices); + + for (size_t i = 0; i < num_matrices; ++i) { + const uint64_t* in_data_ptr = data.data() + (i * chunk_size); + + auto ct = + PolyMatrixNtt::Zero(params.CrtCount(), params.PolyLen(), rows, cols); + + uint64_t* out_data_ptr = const_cast(ct.Data().data()); + + for (size_t row = 0; row < rows; ++row) { + for (size_t col = 0; col < cols; ++col) { + size_t in_offs = (row * cols + col) * poly_len; + + size_t out_offs = (row * cols + col) * 2 * poly_len; + + for (size_t z = 0; z < poly_len; ++z) { + out_data_ptr[out_offs + z] = in_data_ptr[in_offs + z]; + } + } + } + v_cts.push_back(std::move(ct)); + } + + return v_cts; +} +PolyMatrixNtt UncondenseMatrix(const Params& params, const PolyMatrixNtt& a) { + size_t rows = a.Rows(); + size_t cols = a.Cols(); + size_t poly_len = params.PolyLen(); + + PolyMatrixNtt res = + PolyMatrixNtt::Zero(params.CrtCount(), params.PolyLen(), rows, cols); + + for (size_t i = 0; i < rows; ++i) { + for (size_t j = 0; j < cols; ++j) { + auto res_poly = res.Poly(i, j); + const auto a_poly = a.Poly(i, j); + + for (size_t z = 0; z < poly_len; ++z) { + uint64_t val = a_poly[z]; + res_poly[z] = val & 0xFFFFFFFFULL; + res_poly[z + poly_len] = val >> 32; + } + } + } + + return res; +} +// from modulus switch.rs +std::vector ModulusSwitch(const Params& params, + const PolyMatrixRaw& poly_matrix, + uint64_t q_prime_1, uint64_t q_prime_2) { + if (poly_matrix.Rows() != 2 || poly_matrix.Cols() != 1) { + throw std::runtime_error("ModulusSwitch: Matrix must be 2x1"); + } + size_t poly_len = params.PolyLen(); + uint64_t current_modulus = params.Modulus(); + + size_t bits_for_row0 = static_cast(std::ceil(std::log2(q_prime_2))); + size_t bits_for_row1 = static_cast(std::ceil(std::log2(q_prime_1))); + + size_t total_sz_bits = (bits_for_row0 + bits_for_row1) * poly_len; + size_t total_sz_bytes = (total_sz_bits + 7) / 8; + + std::vector res(total_sz_bytes, 0); + + size_t bit_offs = 0; + + const uint64_t* row_0_ptr = poly_matrix.Data().data(); + + for (size_t z = 0; z < poly_len; ++z) { + uint64_t val = row_0_ptr[z]; + uint64_t val_rescaled = arith::Rescale(val, current_modulus, q_prime_2); + + util::WriteArbitraryBits(res, val_rescaled, bit_offs, bits_for_row0); + bit_offs += bits_for_row0; + } + + const uint64_t* row_1_ptr = poly_matrix.Data().data() + poly_len; + + for (size_t z = 0; z < poly_len; ++z) { + uint64_t val = row_1_ptr[z]; + uint64_t val_rescaled = arith::Rescale(val, current_modulus, q_prime_1); + + util::WriteArbitraryBits(res, val_rescaled, bit_offs, bits_for_row1); + bit_offs += bits_for_row1; + } + + return res; +} + +// Explicit instantiation of template functions +template void FastBatchedDotProduct(const Params& params, uint64_t* c, + const uint64_t* a, size_t a_elems, + const uint8_t* b_t, size_t b_rows, + size_t b_cols); +template void FastBatchedDotProduct(const Params& params, uint64_t* c, + const uint64_t* a, size_t a_elems, + const uint16_t* b_t, + size_t b_rows, size_t b_cols); +template void FastBatchedDotProduct(const Params& params, uint64_t* c, + const uint64_t* a, size_t a_elems, + const uint32_t* b_t, + size_t b_rows, size_t b_cols); + +} // namespace psi::ypir diff --git a/psi/algorithm/ypir/util.h b/psi/algorithm/ypir/util.h new file mode 100644 index 00000000..544d294c --- /dev/null +++ b/psi/algorithm/ypir/util.h @@ -0,0 +1,128 @@ +#pragma once + +#include + +#include "../spiral/params.h" +#include "../spiral/poly_matrix.h" + +#include "psi/algorithm/ypir/types.h" +namespace psi::ypir { + +using namespace psi::spiral; +std::vector ConcatHorizontal( + const std::vector>& v_a, size_t a_rows, + size_t a_cols); + +void MatMulVecPacked(uint32_t* out, const uint32_t* a, const uint32_t* b, + size_t a_rows, size_t a_cols, size_t b_rows, + size_t b_cols); + +PolyMatrixNtt HomomorphicAutomorph(const Params& params, size_t t, size_t t_exp, + const PolyMatrixNtt& ct, + const PolyMatrixNtt& pub_param); + +PolyMatrixNtt RingPackLwesInner( + const Params& params, size_t ell, size_t start_idx, + const std::vector& rlwe_cts, + const std::vector& pub_params, + const std::pair, std::vector>& + y_constants); + +std::pair, std::vector> GenYConstants( + const Params& params); + +PolyMatrixNtt RingPackLwes( + const Params& params, const std::vector& b_values, + const std::vector& rlwe_cts, size_t num_cts, + const std::vector& pub_params, + const std::pair, std::vector>& + y_constants); + +std::vector NegacyclicPerm(absl::Span a, size_t shift, + uint64_t modulus); +std::vector NegacyclicMatrix(absl::Span a, + uint64_t modulus); +PolyMatrixNtt CondenseMatrix(const Params& params, const PolyMatrixNtt& a); +PolyMatrixNtt UncondenseMatrix(const Params& params, const PolyMatrixNtt& a); +PolyMatrixNtt PackUsingSingleWithOffset( + const Params& params, const std::vector& pub_params, + const std::vector& cts, size_t offset); + +std::vector PrepPackLwes(const Params& params, + absl::Span lwe_cts, + size_t cols_to_do); + +std::vector> PrepPackManyLwes( + const Params& params, absl::Span lwe_cts, + size_t num_rlwe_outputs); + +std::vector> GenerateAutomorphTablesBruteForce( + const Params& params); + +std::tuple, + std::vector>> +PrecomputePack(const Params& params, size_t poly_len_log2, + const std::vector& prepacked, + const std::vector& pub_params, + const std::pair, + std::vector>& y_constants); +void FastAddIntoNoReduce(PolyMatrixNtt& res, const PolyMatrixNtt& a); +void MultiplyPolyAvx(uint64_t* res, const uint64_t* a, const uint64_t* b, + size_t len); +void ScalarMultiplyAvx(const Params& params, PolyMatrixNtt& res, + const PolyMatrixNtt& a, const PolyMatrixNtt& b); + +void FastMultiplyNoReduce(const Params& params, PolyMatrixNtt& res, + const PolyMatrixNtt& a, const PolyMatrixNtt& b, + size_t start_inner_dim = 0); +void ApplyAutomorphNttRaw(const Params& params, const uint64_t* poly, + uint64_t* out, size_t t, + const std::vector>& tables); +void ApplyAutomorphNtt(const Params& params, + const std::vector>& tables, + const PolyMatrixNtt& mat, PolyMatrixNtt& res, size_t t); +void FastReduce(const Params& params, PolyMatrixNtt& res); +PolyMatrixNtt PackUsingPrecompVals( + const Params& params, + size_t ell, // params.poly_len_log2 + absl::Span pub_params, + absl::Span b_values, const PolyMatrixNtt& precomp_res, + absl::Span precomp_vals, + const std::vector>& precomp_tables, + const std::pair, std::vector>& + y_constants); + +std::vector PackManyLwes( + const Params& params, + const std::vector>& prep_rlwe_cts, + const Precomp& precomp, absl::Span b_values, + size_t num_rlwe_outputs, + const std::vector& pack_pub_params_row_1s, + const std::pair, std::vector>& + y_constants); + +PolyMatrixNtt GetRegevSample(const Params& params, const PolyMatrixRaw& sk_reg, + yacl::crypto::Prg& rng, + yacl::crypto::Prg& rng_pub); +PolyMatrixNtt GetFreshRegevPublicKey(const Params& params, + const PolyMatrixRaw& sk_reg, size_t m, + yacl::crypto::Prg& rng, + yacl::crypto::Prg& rng_pub); +std::vector RawGenerateExpansionParams( + const Params& params, const PolyMatrixRaw& sk_reg, size_t num_exp, + size_t m_exp, yacl::crypto::Prg& rng, + yacl::crypto::Prg& rng_pub); + +template +void FastBatchedDotProduct(const Params& params, uint64_t* c, const uint64_t* a, + size_t a_elems, const T* b_t, size_t b_rows, + size_t b_cols); + +std::vector UnpackVecPm(const Params& params, size_t rows, + size_t cols, + absl::Span data); + +std::vector ModulusSwitch(const Params& params, + const PolyMatrixRaw& poly_matrix, + uint64_t q_prime_1, uint64_t q_prime_2); +} // namespace psi::ypir \ No newline at end of file diff --git a/psi/algorithm/ypir/util_test.cc b/psi/algorithm/ypir/util_test.cc new file mode 100644 index 00000000..fa1e3d83 --- /dev/null +++ b/psi/algorithm/ypir/util_test.cc @@ -0,0 +1,201 @@ +#include "../spiral/util.h" + +#include "../spiral/arith/arith.h" +#include "../spiral/arith/number_theory.h" +#include "../spiral/gadget.h" +#include "../spiral/poly_matrix.h" +#include "../spiral/poly_matrix_utils.h" +#include "../spiral/public_keys.h" +#include "../spiral/spiral_client.h" +#include "gtest/gtest.h" +#include "yacl/crypto/rand/rand.h" +#include "yacl/crypto/tools/prg.h" + +#include "psi/algorithm/ypir/util.h" + +namespace psi::ypir { +TEST(RLWETest, EncDecTest) { + auto params = spiral::util::GetFastExpansionTestingParam(); + + uint64_t p = params.PtModulus(); + uint64_t q = params.Modulus(); + uint64_t scale_k = params.ScaleK(); + auto sigma_raw = spiral::PolyMatrixRaw::Zero(params.PolyLen(), 1, 1); + auto pt_seed = yacl::crypto::SecureRandU128(); + yacl::crypto::Prg pt_rng(pt_seed); + std::vector m_enc(params.PolyLen()); + for (size_t i = 0; i < params.PolyLen(); ++i) { + m_enc[i] = pt_rng() % p; + sigma_raw.Data()[i] = (m_enc[i] * scale_k) % q; + } + auto sigma_ntt = spiral::ToNtt(params, sigma_raw); + + class ClientDerive : public spiral::SpiralClient { + public: + using spiral::SpiralClient::DecryptMatrixRegev; + using spiral::SpiralClient::EncryptMatrixRegev; + using spiral::SpiralClient::SpiralClient; + }; + ClientDerive client(params); + + auto seed = yacl::crypto::SecureRandU128(); + yacl::crypto::Prg rng(seed); + auto pub_seed = yacl::crypto::SecureRandU128(); + yacl::crypto::Prg rng_pub(pub_seed); + + auto ct = client.EncryptMatrixRegev(sigma_ntt, rng, rng_pub); + auto dec_ntt = client.DecryptMatrixRegev(ct); + auto dec_raw = spiral::FromNtt(params, dec_ntt); + + ASSERT_EQ(dec_raw.Data().size(), sigma_raw.Data().size()); + for (size_t i = 0; i < sigma_raw.Data().size(); ++i) { + uint64_t v_rescaled = spiral::arith::Rescale( + dec_raw.Data()[i], params.Modulus(), params.PtModulus()); + uint64_t v_exp = m_enc[i]; + ASSERT_EQ(v_rescaled, v_exp) << "mismatch at coeff " << i; + } +} + +TEST(RLWETest, AutomorphismTest) { + auto params = spiral::util::GetFastExpansionTestingParam(); + + uint64_t p = params.PtModulus(); + uint64_t q = params.Modulus(); + uint64_t scale_k = params.ScaleK(); + auto sigma_raw = spiral::PolyMatrixRaw::Zero(params.PolyLen(), 1, 1); + auto pt_seed = yacl::crypto::SecureRandU128(); + yacl::crypto::Prg pt_rng(pt_seed); + std::vector m_enc(params.PolyLen()); + for (size_t i = 0; i < params.PolyLen(); ++i) { + m_enc[i] = pt_rng() % p; + sigma_raw.Data()[i] = (m_enc[i] * scale_k) % q; + } + auto sigma_ntt = spiral::ToNtt(params, sigma_raw); + + class ClientDerive : public spiral::SpiralClient { + public: + using spiral::SpiralClient::DecryptMatrixRegev; + using spiral::SpiralClient::EncryptMatrixRegev; + using spiral::SpiralClient::GenPublicKeys; + using spiral::SpiralClient::SpiralClient; + }; + ClientDerive client(params); + auto pp = client.GenPublicKeys(); + + auto seed = yacl::crypto::SecureRandU128(); + yacl::crypto::Prg rng(seed); + auto pub_seed = yacl::crypto::SecureRandU128(); + yacl::crypto::Prg rng_pub(pub_seed); + + auto ct = client.EncryptMatrixRegev(sigma_ntt, rng, rng_pub); + + for (size_t i = 0; i < pp.v_expansion_right_.size(); ++i) { + size_t t = (params.PolyLen() / (1 << i)) + 1; + size_t t_exp = params.TExpRight(); + + const auto& pub_param = pp.v_expansion_right_[i]; + + auto ct_auto_ntt = HomomorphicAutomorph(params, t, t_exp, ct, pub_param); + + auto dec_auto_ntt = client.DecryptMatrixRegev(ct_auto_ntt); + auto dec_auto_raw = spiral::FromNtt(params, dec_auto_ntt); + + auto sigma_auto_raw = spiral::Automorphism(params, sigma_raw, t); + + auto sigma_auto_ntt = spiral::ToNtt(params, sigma_auto_raw); + + ASSERT_EQ(dec_auto_raw.Data().size(), sigma_auto_raw.Data().size()); + for (size_t j = 0; j < sigma_auto_raw.Data().size(); ++j) { + uint64_t v_rescaled = spiral::arith::Rescale( + dec_auto_raw.Data()[j], params.Modulus(), params.PtModulus()); + uint64_t v_exp_scaled = sigma_auto_raw.Data()[j]; + uint64_t v_exp = spiral::arith::Rescale(v_exp_scaled, params.Modulus(), + params.PtModulus()); + ASSERT_EQ(v_rescaled, v_exp) + << "mismatch at coeff " << j << " for expansion level " << i; + } + } +} + +TEST(RLWETest, PackingTest) { + auto params = spiral::util::GetFastExpansionTestingParam(); + + class ClientDerive : public spiral::SpiralClient { + public: + using spiral::SpiralClient::DecryptMatrixRegev; + using spiral::SpiralClient::EncryptMatrixRegev; + using spiral::SpiralClient::GenPublicKeys; + using spiral::SpiralClient::GetSkRegev; + using spiral::SpiralClient::SpiralClient; + }; + ClientDerive client(params); + auto pp = client.GenPublicKeys(); + + auto y_constants = GenYConstants(params); + + auto pack_seed = yacl::crypto::SecureRandU128(); + yacl::crypto::Prg pack_rng(yacl::crypto::SecureRandU128()); + yacl::crypto::Prg pack_rng_pub(pack_seed); + auto pack_pub_params = RawGenerateExpansionParams( + params, client.GetSkRegev(), params.PolyLenLog2(), params.TExpLeft(), + pack_rng, pack_rng_pub); + + auto cts_seed = yacl::crypto::SecureRandU128(); + yacl::crypto::Prg ct_rng(cts_seed); + auto ct_pub_seed = yacl::crypto::SecureRandU128(); + yacl::crypto::Prg ct_rng_pub(ct_pub_seed); + + std::vector v_ct; + std::vector b_values; + v_ct.reserve(params.PolyLen()); + b_values.reserve(params.PolyLen()); + + uint64_t p = params.PtModulus(); + uint64_t scale_k = params.ScaleK(); + uint64_t mod_inv = spiral::arith::InvertUintMod( + static_cast(params.PolyLen()), params.Modulus()); + + for (size_t i = 0; i < params.PolyLen(); ++i) { + auto pt = spiral::PolyMatrixRaw::Zero(params.PolyLen(), 1, 1); + uint64_t val = i % p; + uint64_t val_to_enc = spiral::arith::MultiplyUintMod(val * scale_k, mod_inv, + params.Modulus()); + pt.Data()[0] = val_to_enc; + + auto pt_ntt = spiral::ToNtt(params, pt); + auto ct = client.EncryptMatrixRegev(pt_ntt, ct_rng, ct_rng_pub); + auto ct_raw = spiral::FromNtt(params, ct); + + b_values.push_back(ct_raw.Data()[ct_raw.PolyStartIndex(1, 0)]); + + std::fill( + ct_raw.Data().begin() + ct_raw.PolyStartIndex(1, 0), + ct_raw.Data().begin() + ct_raw.PolyStartIndex(1, 0) + params.PolyLen(), + 0ULL); + v_ct.push_back(spiral::ToNtt(params, ct_raw)); + } + + auto packed = RingPackLwes(params, b_values, v_ct, params.PolyLen(), + pack_pub_params, y_constants); + + auto dec = client.DecryptMatrixRegev(packed); + auto dec_raw = spiral::FromNtt(params, dec); + + auto rescaled = spiral::PolyMatrixRaw::Zero(params.PolyLen(), 1, 1); + for (size_t i = 0; i < params.PolyLen(); ++i) { + rescaled.Data()[i] = spiral::arith::Rescale( + dec_raw.Data()[i], params.Modulus(), params.PtModulus()); + } + + auto gold = spiral::PolyMatrixRaw::Zero(params.PolyLen(), 1, 1); + for (size_t i = 0; i < params.PolyLen(); ++i) { + gold.Data()[i] = i % p; + } + + ASSERT_EQ(rescaled.Data().size(), gold.Data().size()); + for (size_t i = 0; i < gold.Data().size(); ++i) { + ASSERT_EQ(rescaled.Data()[i], gold.Data()[i]) << "mismatch at coeff " << i; + } +} + +} // namespace psi::ypir \ No newline at end of file diff --git a/psi/algorithm/ypir/ypir_basic_flow_test.cc b/psi/algorithm/ypir/ypir_basic_flow_test.cc new file mode 100644 index 00000000..7ab5b1a7 --- /dev/null +++ b/psi/algorithm/ypir/ypir_basic_flow_test.cc @@ -0,0 +1,138 @@ +#include "gtest/gtest.h" + +#include +#include +#include + +#include "psi/algorithm/ypir/client.h" +#include "psi/algorithm/ypir/hexl.h" +#include "psi/algorithm/ypir/ypir_params.h" +#include "psi/algorithm/ypir/server.h" + +namespace psi::ypir { + +namespace { + +static psi::ypir::byhe::ByheHexlNtt* g_ntt = nullptr; + +void NttForwardWrapper(uint64_t* data, size_t len) { + g_ntt->Forward(data, len); +} + +template +double MeasureElapsedMs(Fn&& fn) { + const auto start = std::chrono::steady_clock::now(); + fn(); + const auto end = std::chrono::steady_clock::now(); + return std::chrono::duration(end - start).count(); +} + +} // namespace + +TEST(YPIRBasicFlowTest, ByheYpirFlowSmoke) { + using namespace psi::ypir::byhe; + srand(1235); + std::cout << std::fixed << std::setprecision(3); + + const uint64_t lwe_dimension = 1024; + const uint64_t lwe_pmod = (1 << 8); + const uint64_t lwe_cmod = (1ULL << 32); + const uint64_t rlwe_degree = 2048; + const uint64_t rlwe_pmod = (1 << 16); + const uint64_t rlwe_cmod = kCrtMod; + const double sigma = 3.19; + const double sigma_ring = 3.19; + const AutoParams auto_params{20, 18, 2}; + const DecompParams decomp_params{16, 16, 1}; + + FheParams fparm(rlwe_degree, rlwe_cmod, rlwe_pmod, lwe_dimension, lwe_cmod, + lwe_pmod, sigma, sigma_ring, auto_params, decomp_params); + + const uint64_t db_row = 1 << 12; + const uint64_t db_col = 1 << 12; + PirParams pparm(db_row, db_col); + + g_ntt = &fparm.get_ntt(); + fparm.SetNttForward(&NttForwardWrapper); + + fparm.set_persudo_matrix_simplepir(pparm.get_col()); + fparm.set_persudo_matrix_doublepir(pparm.get_row()); + fparm.set_persudo_hcube_ypir(); + + const uint64_t expo = GetLog2(rlwe_degree); + std::vector auto_idx; + for (uint64_t i = 1; i <= expo; ++i) { + auto_idx.push_back((1ULL << i) + 1); + } + fparm.set_automap(auto_idx); + fparm.set_precomputed_pt(expo); + + // Build a small database and flatten to bytes. + std::vector> db( + pparm.get_row(), std::vector(pparm.get_col(), 0)); + for (uint64_t i = 0; i < pparm.get_row(); ++i) { + for (uint64_t j = 0; j < pparm.get_col(); ++j) { + db[i][j] = static_cast((i + j) % lwe_pmod); + } + } + + std::vector db8(pparm.get_row() * pparm.get_col(), 0); + for (uint64_t i = 0; i < pparm.get_row(); ++i) { + for (uint64_t j = 0; j < pparm.get_col(); ++j) { + db8[i * pparm.get_col() + j] = static_cast(db[i][j]); + } + } + + std::vector H0(rlwe_degree, 0); + std::vector> double_server_hint; + std::vector>> decomp_buf; + AESCTR_PRNG prng; + const double hint_generate_ms = MeasureElapsedMs([&] { + psi::ypir::byhe::YpirHintGenerate(db, H0, double_server_hint, decomp_buf, + prng, fparm, pparm); + }); + std::cout << "YpirHintGenerate took " << hint_generate_ms << " ms" + << std::endl; + + std::vector> mat_tmp; + MatrixTranspose(double_server_hint, mat_tmp); + + const uint64_t r_idx = rand() % db_row; + const uint64_t c_idx = rand() % db_col; + Secret simple_sk(lwe_dimension, lwe_cmod); + Secret double_sk(rlwe_degree, rlwe_cmod); + + YpirQuery query; + const double query_generate_ms = MeasureElapsedMs([&] { + query = psi::ypir::byhe::Generate_query_ypir(c_idx, r_idx, simple_sk, + double_sk, prng, fparm, + pparm); + }); + std::cout << "Generate_query_ypir took " << query_generate_ms << " ms" + << std::endl; + + std::vector qu0_32(query.qu0.size(), 0); + for (size_t i = 0; i < query.qu0.size(); ++i) { + qu0_32[i] = static_cast(query.qu0[i]); + } + + std::vector> res; + res.push_back(H0); + const double answer_ms = MeasureElapsedMs([&] { + psi::ypir::byhe::YpirAnswer(db8.data(), qu0_32.data(), query.qu1, + query.ksk_b, decomp_buf, mat_tmp, res, fparm, + pparm); + }); + std::cout << "YpirAnswer took " << answer_ms << " ms" << std::endl; + + uint64_t message = 0; + const double recover_ms = MeasureElapsedMs([&] { + psi::ypir::byhe::YpirRecover(simple_sk, double_sk, res, message, fparm, + pparm); + }); + std::cout << "YpirRecover took " << recover_ms << " ms" << std::endl; + std::cout << message << " " << db[r_idx][c_idx] << std::endl; + EXPECT_EQ(message, db[r_idx][c_idx]); +} + +} // namespace psi::ypir diff --git a/psi/algorithm/ypir/ypir_params.cc b/psi/algorithm/ypir/ypir_params.cc new file mode 100644 index 00000000..f1ab1166 --- /dev/null +++ b/psi/algorithm/ypir/ypir_params.cc @@ -0,0 +1,454 @@ +// Copyright 2026 The secretflow authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "psi/algorithm/ypir/ypir_params.h" + +#include +#include +#include +#include +#include "yacl/base/exception.h" + +namespace psi::ypir::byhe { +namespace { + +uint64_t Log2Exact(uint64_t n) { + uint64_t r = 0; + while (n > 1) { + n >>= 1; + ++r; + } + return r; +} + +// Thread-local buffer pool for PackrlweOnline* recursive functions. +// Each recursion depth gets 6 dedicated scratch vectors: +// 0=tmp, 1=tmp1, 2=tmp2, 3=result, 4=b_e (left child result), 5=b_o (right child result) +// Slots 4/5 eliminate the ~1022 × 16 KB heap copies for b_e/b_o in +// PackrlweOnlineConstantRowsImpl. +struct PackrlwePool { + static constexpr size_t kMaxDepth = 16; + static constexpr size_t kSlots = 6; + size_t len = 0; + std::array, kSlots>, kMaxDepth> v; + + void Init(size_t length) { + if (len == length) return; + len = length; + for (auto& row : v) + for (auto& buf : row) + buf.resize(length); + } + + std::vector& Get(size_t depth, size_t slot) { + return v[depth][slot]; + } +}; + +thread_local PackrlwePool g_packrlwe_pool; + +} // namespace + +Secret::Secret(uint64_t length, uint64_t cmod) : len_(length), mod_(cmod) { + std::mt19937_64 rng( + static_cast(std::chrono::high_resolution_clock::now() + .time_since_epoch() + .count())); + std::uniform_int_distribution dist(-1, 1); + data.reserve(length); + for (uint64_t i = 0; i < length; ++i) { + int tmp = dist(rng); + if (tmp == -1) { + data.push_back(cmod - 1); + } else { + data.push_back(static_cast(tmp)); + } + } + is_ntt_ = false; +} + +FheParams::FheParams(uint64_t rlwe_degree, uint64_t rlwe_ct_modulus, + uint64_t rlwe_pt_modulus, uint64_t lwe_dimension, + uint64_t lwe_ct_modulus, uint64_t lwe_pt_modulus, + double sigma, double sigma_ring, AutoParams auto_params, + DecompParams decomp_params) + : rlwe_degree_(rlwe_degree), + rlwe_ct_modulus_(rlwe_ct_modulus), + rlwe_pt_modulus_(rlwe_pt_modulus), + lwe_dimension_(lwe_dimension), + lwe_ct_modulus_(lwe_ct_modulus), + lwe_pt_modulus_(lwe_pt_modulus), + sigma_(sigma), + sigma_ring_(sigma_ring), + auto_params_(auto_params), + decomp_params_(decomp_params), + ntt_(rlwe_degree, rlwe_ct_modulus, kRootOfUnityCrt) { + YACL_ENFORCE(rlwe_degree_ > 0); + YACL_ENFORCE(lwe_dimension_ > 0); + YACL_ENFORCE(rlwe_ct_modulus_ > 0); + YACL_ENFORCE(lwe_ct_modulus_ > 0); + YACL_ENFORCE(rlwe_pt_modulus_ > 0); + YACL_ENFORCE(lwe_pt_modulus_ > 0); + YACL_ENFORCE(byhe::IsPowerOfTwo(rlwe_degree_), + "rlwe_degree must be power of two"); + + rlwe_degree_log2_ = Log2Exact(rlwe_degree_); +} + +void FheParams::set_persudo_matrix_simplepir(uint64_t row) { + SetPseudorandomMatrixSimplepir(persudo_matrix_simplepir_, + persudo_matrix_simplepir_flat_, row, + lwe_dimension_, lwe_ct_modulus_, prg_); +} + +void FheParams::set_persudo_matrix_doublepir(uint64_t row) { + SetPseudorandomMatrixDoublepir(persudo_matrix_doublepir_, + persudo_matrix_doublepir_flat_, row, + rlwe_degree_, rlwe_ct_modulus_, prg_); +} + +void FheParams::set_persudo_hcube_ypir() { + uint64_t expo = rlwe_degree_log2_; + SetPseudorandomHypercubeYpir(persudo_hcube_ypir_, expo, auto_params_.t, + rlwe_degree_, rlwe_ct_modulus_, prg_); +} + +void FheParams::set_automap(std::vector& idx) { + SetAutomap(automap_, rlwe_degree_, idx); +} + +void FheParams::set_precomputed_pt(uint64_t max_lh) { + SetPrecomputedPt(precomputed_pt_, rlwe_degree_, max_lh, ntt_forward_); +} + +PirParams::PirParams(uint64_t rows, uint64_t cols) + : rows_(rows), cols_(cols) { + YACL_ENFORCE(rows_ > 0); + YACL_ENFORCE(cols_ > 0); +} + +// ====================================================================== +// Byhe utilities that depend on FheParams (moved from byhe_util.cc) +// ====================================================================== + +void ApplyAutoNttForm(const std::vector& vec, + std::vector& result, uint64_t idx, + const FheParams& fparm) { + const uint64_t length = vec.size(); + idx = idx % (2 * length); + const auto& automap = fparm.get_automap(GetLog2(idx - 1) - 1); + + if (vec.data() == result.data()) { + static thread_local std::vector scratch; + scratch.resize(length); + std::copy(vec.begin(), vec.end(), scratch.begin()); + for (uint64_t i = 0; i < length; ++i) { + result[i] = scratch[automap[i]]; + } + return; + } + + if (result.size() != length) { + result.resize(length); + } + for (uint64_t i = 0; i < length; ++i) { + result[i] = vec[automap[i]]; + } +} + +void KeyswitchPreprocess( + const std::vector>& ksk_a, + std::vector& a_in, std::vector& a_out, + std::vector>>& decomp_buf, + const FheParams& fparm) { + const uint64_t z = fparm.get_z_auto(); + const uint64_t t = fparm.get_t_auto(); + const uint64_t b = fparm.get_b_auto(); + const uint64_t length = fparm.get_poly_degree(); + const uint64_t modulus = fparm.get_rlwe_cmod(); + + ByheHexlNtt& ntt = fparm.get_ntt(); + std::vector> decomp_a(t, + std::vector(length, 0)); + ntt.Inverse(a_in.data(), length); + for (uint64_t i = 0; i < length; ++i) { + uint64_t val = a_in[i] >> b; + for (uint64_t j = 0; j < t; ++j) { + decomp_a[j][i] = val & ((1ULL << z) - 1); + val >>= z; + } + } + for (uint64_t i = 0; i < t; ++i) { + ntt.Forward(decomp_a[i].data(), length); + } + + decomp_buf.push_back(std::move(decomp_a)); + if (a_out.size() != length) { + a_out.resize(length); + } + std::fill(a_out.begin(), a_out.end(), 0); + std::vector tmp(length, 0); + for (uint64_t i = 0; i < t; ++i) { + EltwiseMultMod(tmp.data(), ksk_a[i].data(), decomp_buf.back()[i].data(), + length, + modulus); + EltwiseSubMod(a_out.data(), a_out.data(), tmp.data(), length, modulus); + } +} + +void KeyswitchOnline(const std::vector>& ksk_b, + std::vector& b_in, + std::vector& b_out, + std::vector>& decomp_buf, + const FheParams& fparm) { + const uint64_t t = fparm.get_t_auto(); + const uint64_t length = fparm.get_poly_degree(); + const uint64_t modulus = fparm.get_rlwe_cmod(); + // Skip copy if b_in and b_out are already the same object (in-place call). + if (b_out.data() != b_in.data()) { + b_out = b_in; + } + // Reuse a thread-local buffer to avoid repeated heap allocation. + // EltwiseMultMod fully overwrites tmp, so no zero-init needed. + static thread_local std::vector tmp; + if (tmp.size() < length) tmp.resize(length); + for (uint64_t i = 0; i < t; ++i) { + EltwiseMultMod(tmp.data(), ksk_b[i].data(), decomp_buf[i].data(), length, + modulus); + EltwiseSubMod(b_out.data(), b_out.data(), tmp.data(), length, modulus); + } +} + +namespace { +void EvalAutoPreprocess(std::vector& a_in, std::vector& a_out, + const std::vector>& ksk_a, + uint64_t idx, + std::vector>>& decomp_buf, + const FheParams& fparm) { + ApplyAutoNttForm(a_in, a_in, idx, fparm); + KeyswitchPreprocess(ksk_a, a_in, a_out, decomp_buf, fparm); +} + +void EvalAutoOnline(std::vector& b_in, std::vector& b_out, + const std::vector>& ksk_b, + uint64_t idx, std::vector>& decomp_buf, + const FheParams& fparm) { + // Permute b_in into b_out (out-of-place: no scratch copy needed). + // Then key-switch b_out in place, avoiding the extra copy in KeyswitchOnline. + ApplyAutoNttForm(b_in, b_out, idx, fparm); + KeyswitchOnline(ksk_b, b_out, b_out, decomp_buf, fparm); +} + +std::vector PackrlwePreprocessImpl( + const std::vector>& a, uint64_t start, + uint64_t stride, uint64_t l, uint64_t h, + const std::vector>>& ksk_a, + std::vector>>& decomp_buf, + const FheParams& fparm) { + if (l == 0) { + return a[start]; + } + + const uint64_t length = fparm.get_poly_degree(); + const uint64_t modulus = fparm.get_rlwe_cmod(); + const uint64_t expo = GetLog2(length); + + std::vector a_e = + PackrlwePreprocessImpl(a, start, stride << 1, l - 1, h, ksk_a, + decomp_buf, fparm); + std::vector a_o = + PackrlwePreprocessImpl(a, start + stride, stride << 1, l - 1, h, ksk_a, + decomp_buf, fparm); + + const std::vector& pt = fparm.get_precomputed_pt(l + h); + std::vector tmp(length, 0); + std::vector tmp1(length, 0); + std::vector tmp2(length, 0); + std::vector result(length, 0); + + EltwiseMultMod(tmp.data(), pt.data(), a_o.data(), length, modulus); + EltwiseAddMod(result.data(), a_e.data(), tmp.data(), length, modulus); + EltwiseSubMod(tmp1.data(), a_e.data(), tmp.data(), length, modulus); + + EvalAutoPreprocess( + tmp1, tmp2, + ksk_a[GetAutokeyIdx((1ULL << (l + h)) + 1, expo)], + (1ULL << (l + h)) + 1, decomp_buf, fparm); + EltwiseAddMod(result.data(), result.data(), tmp2.data(), length, modulus); + return result; +} + +std::vector PackrlweOnlineImpl( + const std::vector>& b, uint64_t start, + uint64_t stride, uint64_t l, uint64_t h, + const std::vector>>& ksk_b, + std::vector>>& decomp_buf, uint64_t& ptr, + const FheParams& fparm, uint64_t depth = 0) { + if (l == 0) { + return b[start]; + } + + const uint64_t length = fparm.get_poly_degree(); + const uint64_t modulus = fparm.get_rlwe_cmod(); + const uint64_t expo = GetLog2(length); + + std::vector b_e = + PackrlweOnlineImpl(b, start, stride << 1, l - 1, h, ksk_b, decomp_buf, + ptr, fparm, depth + 1); + std::vector b_o = + PackrlweOnlineImpl(b, start + stride, stride << 1, l - 1, h, ksk_b, + decomp_buf, ptr, fparm, depth + 1); + + const std::vector& pt = fparm.get_precomputed_pt(l + h); + + g_packrlwe_pool.Init(length); + auto& tmp = g_packrlwe_pool.Get(depth, 0); + auto& tmp1 = g_packrlwe_pool.Get(depth, 1); + auto& tmp2 = g_packrlwe_pool.Get(depth, 2); + auto& result = g_packrlwe_pool.Get(depth, 3); + + EltwiseMultMod(tmp.data(), pt.data(), b_o.data(), length, modulus); + EltwiseAddMod(result.data(), b_e.data(), tmp.data(), length, modulus); + EltwiseSubMod(tmp1.data(), b_e.data(), tmp.data(), length, modulus); + + EvalAutoOnline( + tmp1, tmp2, + ksk_b[GetAutokeyIdx((1ULL << (l + h)) + 1, expo)], + (1ULL << (l + h)) + 1, decomp_buf[ptr++], fparm); + EltwiseAddMod(result.data(), result.data(), tmp2.data(), length, modulus); + return result; +} + +// Output-parameter variant: writes result directly into `output` (a pool slot +// owned by the parent frame), eliminating the ~16 KB copy-on-return that the +// previous return-by-value version produced at each of 1023 recursive calls. +void PackrlweOnlineConstantRowsImpl( + std::vector& output, + const std::vector& b, uint64_t start, uint64_t stride, + uint64_t l, uint64_t h, + const std::vector>>& ksk_b, + std::vector>>& decomp_buf, uint64_t& ptr, + const FheParams& fparm, uint64_t depth = 0) { + const uint64_t length = fparm.get_poly_degree(); + g_packrlwe_pool.Init(length); + + if (l == 0) { + std::fill(output.begin(), output.end(), b[start]); + return; + } + + const uint64_t modulus = fparm.get_rlwe_cmod(); + const uint64_t expo = GetLog2(length); + + // Pool slots at this depth: + // 0=tmp, 1=tmp1, 2=tmp2 (scratch) + // 4=b_e (left child writes here), 5=b_o (right child writes here) + // `output` is provided by the parent (or the top-level wrapper). + auto& tmp = g_packrlwe_pool.Get(depth, 0); + auto& tmp1 = g_packrlwe_pool.Get(depth, 1); + auto& tmp2 = g_packrlwe_pool.Get(depth, 2); + + if (l == 1) { + const std::vector& pt = fparm.get_precomputed_pt(l + h); + EltwiseFMAMod(tmp.data(), pt.data(), b[start + stride], nullptr, length, + modulus); + const uint64_t scalar = b[start]; + for (uint64_t i = 0; i < length; ++i) { + output[i] = scalar + tmp[i]; + if (output[i] >= modulus) output[i] -= modulus; + tmp1[i] = scalar >= tmp[i] ? scalar - tmp[i] : scalar + modulus - tmp[i]; + } + EvalAutoOnline( + tmp1, tmp2, + ksk_b[GetAutokeyIdx((1ULL << (l + h)) + 1, expo)], + (1ULL << (l + h)) + 1, decomp_buf[ptr++], fparm); + EltwiseAddMod(output.data(), output.data(), tmp2.data(), length, modulus); + return; + } + + // Recurse: children write directly into pool slots 4 and 5 at this depth, + // avoiding any heap allocation or copy for the intermediate results. + auto& b_e = g_packrlwe_pool.Get(depth, 4); + auto& b_o = g_packrlwe_pool.Get(depth, 5); + + PackrlweOnlineConstantRowsImpl(b_e, b, start, stride << 1, l - 1, h, + ksk_b, decomp_buf, ptr, fparm, depth + 1); + PackrlweOnlineConstantRowsImpl(b_o, b, start + stride, stride << 1, l - 1, + h, ksk_b, decomp_buf, ptr, fparm, depth + 1); + + const std::vector& pt = fparm.get_precomputed_pt(l + h); + + EltwiseMultMod(tmp.data(), pt.data(), b_o.data(), length, modulus); + EltwiseAddMod(output.data(), b_e.data(), tmp.data(), length, modulus); + EltwiseSubMod(tmp1.data(), b_e.data(), tmp.data(), length, modulus); + + EvalAutoOnline( + tmp1, tmp2, + ksk_b[GetAutokeyIdx((1ULL << (l + h)) + 1, expo)], + (1ULL << (l + h)) + 1, decomp_buf[ptr++], fparm); + EltwiseAddMod(output.data(), output.data(), tmp2.data(), length, modulus); +} +} // namespace + +std::vector PackrlwePreprocess( + std::vector>& a, uint64_t l, uint64_t h, + const std::vector>>& ksk_a, + std::vector>>& decomp_buf, + const FheParams& fparm) { + return PackrlwePreprocessImpl(a, 0, 1, l, h, ksk_a, decomp_buf, fparm); +} + +std::vector PackrlweOnline( + std::vector>& b, uint64_t l, uint64_t h, + const std::vector>>& ksk_b, + std::vector>>& decomp_buf, uint64_t& ptr, + const FheParams& fparm) { + return PackrlweOnlineImpl(b, 0, 1, l, h, ksk_b, decomp_buf, ptr, fparm); +} + +std::vector PackrlweOnlineConstantRows( + const std::vector& b, uint64_t l, uint64_t h, + const std::vector>>& ksk_b, + std::vector>>& decomp_buf, uint64_t& ptr, + const FheParams& fparm) { + g_packrlwe_pool.Init(fparm.get_poly_degree()); + // Use the depth-0 result slot as output; one final copy on return. + auto& result = g_packrlwe_pool.Get(0, 3); + PackrlweOnlineConstantRowsImpl(result, b, 0, 1, l, h, ksk_b, decomp_buf, + ptr, fparm, 0); + return result; +} + +void Cdks21Lwe2RlweInplace(uint64_t* lwe_a, uint64_t degree, uint64_t cmod, + ByheHexlNtt& ntt) { + uint64_t a0 = lwe_a[0]; + + for (uint64_t i = 1; i < (degree + 1) / 2; ++i) { + uint64_t left_val = lwe_a[i]; + uint64_t right_val = lwe_a[degree - i]; + lwe_a[i] = right_val ? cmod - right_val : 0; + lwe_a[degree - i] = left_val ? cmod - left_val : 0; + } + + if (degree % 2 == 0) { + uint64_t mid = degree / 2; + uint64_t val = lwe_a[mid]; + lwe_a[mid] = val ? cmod - val : 0; + } + + lwe_a[0] = a0; + ntt.Forward(lwe_a, degree); +} + +} // namespace psi::ypir::byhe diff --git a/psi/algorithm/ypir/ypir_params.h b/psi/algorithm/ypir/ypir_params.h new file mode 100644 index 00000000..d37c9f5f --- /dev/null +++ b/psi/algorithm/ypir/ypir_params.h @@ -0,0 +1,155 @@ +// Copyright 2026 The secretflow authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#pragma once + +#include +#include + +#include "psi/algorithm/ypir/ypir_util.h" + +namespace psi::ypir::byhe { + +class Secret { + public: + Secret() = default; + Secret(uint64_t length, uint64_t cmod); + + uint64_t get_data_i(uint64_t idx) const { return data[idx]; } + uint64_t get_len() const { return len_; } + uint64_t get_mod() const { return mod_; } + bool get_ntt_form() const { return is_ntt_; } + + void switch_ntt_format() { is_ntt_ = !is_ntt_; } + + std::vector data; + + private: + uint64_t len_ = 0; + uint64_t mod_ = 0; + bool is_ntt_ = false; +}; + +struct AutoParams { + uint64_t b = 0; + uint64_t z = 0; + uint64_t t = 0; +}; + +struct DecompParams { + uint64_t b = 0; + uint64_t z = 0; + uint64_t t = 0; +}; + +class FheParams { + public: + FheParams(uint64_t rlwe_degree, uint64_t rlwe_ct_modulus, + uint64_t rlwe_pt_modulus, uint64_t lwe_dimension, + uint64_t lwe_ct_modulus, uint64_t lwe_pt_modulus, double sigma, + double sigma_ring, AutoParams auto_params, + DecompParams decomp_params); + + // byhe-style getters + uint64_t get_poly_degree() const { return rlwe_degree_; } + uint64_t get_rlwe_cmod() const { return rlwe_ct_modulus_; } + uint64_t get_rlwe_pmod() const { return rlwe_pt_modulus_; } + uint64_t get_lwe_dimension() const { return lwe_dimension_; } + uint64_t get_lwe_cmod() const { return lwe_ct_modulus_; } + uint64_t get_lwe_pmod() const { return lwe_pt_modulus_; } + uint64_t get_b_auto() const { return auto_params_.b; } + uint64_t get_z_auto() const { return auto_params_.z; } + uint64_t get_t_auto() const { return auto_params_.t; } + uint64_t get_b_decomp() const { return decomp_params_.b; } + uint64_t get_z_decomp() const { return decomp_params_.z; } + uint64_t get_t_decomp() const { return decomp_params_.t; } + double get_sig() const { return sigma_; } + double get_sig_ring() const { return sigma_ring_; } + ByheHexlNtt& get_ntt() const noexcept { return ntt_; } + + const std::vector>& get_persudo_matrix_simplepir() + const noexcept { + return persudo_matrix_simplepir_; + } + const std::vector>& get_persudo_matrix_doublepir() + const noexcept { + return persudo_matrix_doublepir_; + } + const std::vector>>& + get_persudo_hcube_ypir() const noexcept { + return persudo_hcube_ypir_; + } + const uint64_t* get_persudo_matrix_simplepir_flat() const noexcept { + return persudo_matrix_simplepir_flat_.data(); + } + const uint64_t* get_persudo_matrix_doublepir_flat() const noexcept { + return persudo_matrix_doublepir_flat_.data(); + } + + void set_persudo_matrix_simplepir(uint64_t row); + void set_persudo_matrix_doublepir(uint64_t row); + void set_persudo_hcube_ypir(); + void set_automap(std::vector& idx); + const std::vector& get_automap(uint64_t idx) const noexcept { + return automap_[idx]; + } + void set_precomputed_pt(uint64_t max_lh); + const std::vector& get_precomputed_pt(uint64_t lh) const noexcept { + return precomputed_pt_[lh]; + } + + void SetNttForward(NttForwardFn fn) { ntt_forward_ = fn; } + + private: + uint64_t rlwe_degree_ = 0; + uint64_t rlwe_ct_modulus_ = 0; + uint64_t rlwe_pt_modulus_ = 0; + + uint64_t lwe_dimension_ = 0; + uint64_t lwe_ct_modulus_ = 0; + uint64_t lwe_pt_modulus_ = 0; + + double sigma_ = 0.0; + double sigma_ring_ = 0.0; + + AutoParams auto_params_; + DecompParams decomp_params_; + + uint64_t rlwe_degree_log2_ = 0; + mutable ByheHexlNtt ntt_; + + std::vector> persudo_matrix_simplepir_; + std::vector> persudo_matrix_doublepir_; + std::vector>> persudo_hcube_ypir_; + std::vector persudo_matrix_simplepir_flat_; + std::vector persudo_matrix_doublepir_flat_; + std::vector> automap_; + std::vector> precomputed_pt_; + AESCTR_PRNG prg_; + NttForwardFn ntt_forward_ = nullptr; +}; + +class PirParams { + public: + PirParams(uint64_t rows, uint64_t cols); + + uint64_t get_row() const { return rows_; } + uint64_t get_col() const { return cols_; } + + private: + uint64_t rows_ = 0; + uint64_t cols_ = 0; +}; + +} // namespace psi::ypir::byhe diff --git a/psi/algorithm/ypir/ypir_util.cc b/psi/algorithm/ypir/ypir_util.cc new file mode 100644 index 00000000..d165ec76 --- /dev/null +++ b/psi/algorithm/ypir/ypir_util.cc @@ -0,0 +1,519 @@ +// Copyright 2026 The secretflow authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "psi/algorithm/ypir/ypir_util.h" + +#include +#include +#include +#include "yacl/base/exception.h" + +#if defined(__x86_64__) || defined(_M_X64) +#include +#endif + + +namespace psi::ypir::byhe { +namespace { + +int64_t ExGcd(int64_t a, int64_t b, int64_t& x, int64_t& y) { + if (b == 0) { + x = 1; + y = 0; + return a; + } + int64_t x1 = 0; + int64_t y1 = 0; + int64_t d = ExGcd(b, a % b, x1, y1); + x = y1; + y = x1 - (a / b) * y1; + return d; +} + +unsigned char ReverseByte(unsigned char x) { + static const unsigned char table[] = { + 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, 0x10, 0x90, 0x50, + 0xd0, 0x30, 0xb0, 0x70, 0xf0, 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, + 0x68, 0xe8, 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8, 0x04, + 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4, 0x14, 0x94, 0x54, 0xd4, + 0x34, 0xb4, 0x74, 0xf4, 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, + 0xec, 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc, 0x02, 0x82, + 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2, 0x12, 0x92, 0x52, 0xd2, 0x32, + 0xb2, 0x72, 0xf2, 0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea, + 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa, 0x06, 0x86, 0x46, + 0xc6, 0x26, 0xa6, 0x66, 0xe6, 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, + 0x76, 0xf6, 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee, 0x1e, + 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe, 0x01, 0x81, 0x41, 0xc1, + 0x21, 0xa1, 0x61, 0xe1, 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, + 0xf1, 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9, 0x19, 0x99, + 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9, 0x05, 0x85, 0x45, 0xc5, 0x25, + 0xa5, 0x65, 0xe5, 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5, + 0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed, 0x1d, 0x9d, 0x5d, + 0xdd, 0x3d, 0xbd, 0x7d, 0xfd, 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, + 0x63, 0xe3, 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3, 0x0b, + 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb, 0x1b, 0x9b, 0x5b, 0xdb, + 0x3b, 0xbb, 0x7b, 0xfb, 0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, + 0xe7, 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7, 0x0f, 0x8f, + 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef, 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, + 0xbf, 0x7f, 0xff, + }; + return table[x]; +} + +uint32_t ReverseBits(uint32_t num, uint32_t msb) { + static const int shift_trick[] = {0, 7, 6, 5, 4, 3, 2, 1}; + uint32_t msbb = (msb >> 3) + ((msb & 0x7) ? 1 : 0); + switch (msbb) { + case 1: + return (ReverseByte(num & 0xff) >> shift_trick[msb & 0x7]); + case 2: + return (ReverseByte(num & 0xff) << 8 | + ReverseByte((num >> 8) & 0xff)) >> + shift_trick[msb & 0x7]; + case 3: + return (ReverseByte(num & 0xff) << 16 | + ReverseByte((num >> 8) & 0xff) << 8 | + ReverseByte((num >> 16) & 0xff)) >> + shift_trick[msb & 0x7]; + case 4: + return (ReverseByte(num & 0xff) << 24 | + ReverseByte((num >> 8) & 0xff) << 16 | + ReverseByte((num >> 16) & 0xff) << 8 | + ReverseByte((num >> 24) & 0xff)) >> + shift_trick[msb & 0x7]; + default: + YACL_ENFORCE(false, "ReverseBits msb out of range"); + } +} + +#if defined(__x86_64__) || defined(_M_X64) +#if defined(__GNUC__) || defined(__clang__) +__attribute__((target("avx512f,avx512bw,avx512vl"))) +void MatVecU8U32Mod2p32Avx512(const uint8_t* A, const uint32_t* x, + uint32_t* y, size_t rows, size_t cols) { + constexpr size_t kLanes = 16; + + for (size_t r = 0; r < rows; ++r) { + const uint8_t* row = A + r * cols; + __m512i acc0 = _mm512_setzero_si512(); + __m512i acc1 = _mm512_setzero_si512(); + + size_t c = 0; + for (; c + 2 * kLanes <= cols; c += 2 * kLanes) { + const __m128i bytes0 = + _mm_loadu_si128(reinterpret_cast(row + c)); + const __m128i bytes1 = + _mm_loadu_si128(reinterpret_cast(row + c + kLanes)); + const __m512i a0 = _mm512_cvtepu8_epi32(bytes0); + const __m512i a1 = _mm512_cvtepu8_epi32(bytes1); + const __m512i x0 = + _mm512_loadu_si512(reinterpret_cast(x + c)); + const __m512i x1 = + _mm512_loadu_si512(reinterpret_cast(x + c + kLanes)); + acc0 = _mm512_add_epi32(acc0, _mm512_mullo_epi32(a0, x0)); + acc1 = _mm512_add_epi32(acc1, _mm512_mullo_epi32(a1, x1)); + } + + __m512i acc = _mm512_add_epi32(acc0, acc1); + for (; c + kLanes <= cols; c += kLanes) { + const __m128i bytes = + _mm_loadu_si128(reinterpret_cast(row + c)); + const __m512i a = _mm512_cvtepu8_epi32(bytes); + const __m512i xv = + _mm512_loadu_si512(reinterpret_cast(x + c)); + acc = _mm512_add_epi32(acc, _mm512_mullo_epi32(a, xv)); + } + + alignas(64) uint32_t lanes[kLanes]; + _mm512_storeu_si512(reinterpret_cast(lanes), acc); + uint32_t sum = 0; + for (size_t i = 0; i < kLanes; ++i) { + sum += lanes[i]; + } + for (; c < cols; ++c) { + sum += static_cast(row[c]) * x[c]; + } + y[r] = sum; + } +} + +__attribute__((target("avx512f,avx512bw,avx512vl"))) +void MatrixVectorMultiplicationU16Avx512( + std::vector& result, + const std::vector>& matrix, + const std::vector& vec, uint64_t mod) { + const uint64_t mat_row = matrix.size(); + const uint64_t mat_col = mat_row == 0 ? 0 : matrix[0].size(); + result.assign(mat_row, 0); + if (mat_row == 0 || mat_col == 0) { + return; + } + + std::vector row64(mat_col, 0); + std::vector tmp(mat_col, 0); + constexpr uint64_t kBlock = 128; + + for (uint64_t i = 0; i < mat_row; ++i) { + for (uint64_t j = 0; j < mat_col; ++j) { + row64[j] = static_cast(matrix[i][j]); + } + + EltwiseMultMod(tmp.data(), row64.data(), vec.data(), mat_col, mod); + + uint64_t sum_mod = 0; + for (uint64_t base = 0; base < mat_col; base += kBlock) { + const uint64_t end = std::min(base + kBlock, mat_col); + __m512i acc0 = _mm512_setzero_si512(); + __m512i acc1 = _mm512_setzero_si512(); + uint64_t j = base; + for (; j + 16 <= end; j += 16) { + const __m512i v0 = _mm512_loadu_si512( + reinterpret_cast(tmp.data() + j)); + const __m512i v1 = _mm512_loadu_si512( + reinterpret_cast(tmp.data() + j + 8)); + acc0 = _mm512_add_epi64(acc0, v0); + acc1 = _mm512_add_epi64(acc1, v1); + } + + const __m512i acc = _mm512_add_epi64(acc0, acc1); + alignas(64) uint64_t buf[8]; + _mm512_store_si512(reinterpret_cast<__m512i*>(buf), acc); + + unsigned __int128 acc128 = 0; + for (uint64_t k = 0; k < 8; ++k) { + acc128 += buf[k]; + } + for (; j < end; ++j) { + acc128 += tmp[j]; + } + sum_mod = (sum_mod + static_cast(acc128 % mod)) % mod; + } + result[i] = sum_mod; + } +} +#endif +#endif + +void MatVecU8U32Mod2p32Scalar(const uint8_t* A, const uint32_t* x, uint32_t* y, + size_t rows, size_t cols) { + for (size_t r = 0; r < rows; ++r) { + uint64_t acc = 0; + const uint8_t* row = A + r * cols; + for (size_t c = 0; c < cols; ++c) { + acc += static_cast(row[c]) * x[c]; + } + y[r] = static_cast(acc); + } +} + +} // namespace + +uint64_t GetLog2(uint64_t num) { + uint64_t result = 0; + while (num > 1) { + num >>= 1; + ++result; + } + return result; +} + +bool IsPowerOfTwo(uint64_t num) { return num != 0 && (num & (num - 1)) == 0; } + +uint64_t SampleGauss(double st_dev, uint64_t modulus, std::mt19937_64& rng) { + std::normal_distribution gaussian_sampler(0.0, st_dev); + int64_t tmp = static_cast(std::llround(gaussian_sampler(rng))); + if (tmp < 0) { + return static_cast(modulus + tmp); + } + return static_cast(tmp); +} + +void SampleGauss(std::vector& err, double st_dev, uint64_t modulus, + std::mt19937_64& rng) { + std::normal_distribution gaussian_sampler(0.0, st_dev); + for (auto& v : err) { + int64_t tmp = static_cast(std::llround(gaussian_sampler(rng))); + if (tmp < 0) { + v = static_cast(modulus + tmp); + } else { + v = static_cast(tmp); + } + } +} + +int64_t ModInverse(int64_t a, int64_t modulus) { + int64_t x = 0; + int64_t y = 0; + int64_t g = ExGcd(a, modulus, x, y); + if (g != 1) { + return -1; + } + int64_t res = (x % modulus + modulus) % modulus; + return res; +} + +void ApplyAutoCoefForm(std::vector& result, + const std::vector& input, int32_t index, + uint64_t modulus) { + const uint64_t length = input.size(); + result.assign(length, 0); + for (size_t i = 0; i < length; ++i) { + uint64_t destination = (static_cast(i) * index) % (2 * length); + if (destination >= length) { + result[destination - length] = (modulus - input[i]) % modulus; + } else { + result[destination] = input[i]; + } + } +} + +void MatrixTranspose(const std::vector>& matrix, + std::vector>& trans_matrix) { + const uint64_t rows = matrix.size(); + const uint64_t cols = rows == 0 ? 0 : matrix[0].size(); + trans_matrix.assign(cols, std::vector(rows, 0)); + constexpr uint64_t kBlock = 64; + for (uint64_t ii = 0; ii < cols; ii += kBlock) { + for (uint64_t jj = 0; jj < rows; jj += kBlock) { + uint64_t i_end = std::min(ii + kBlock, cols); + uint64_t j_end = std::min(jj + kBlock, rows); + for (uint64_t i = ii; i < i_end; ++i) { + for (uint64_t j = jj; j < j_end; ++j) { + trans_matrix[i][j] = matrix[j][i]; + } + } + } + } +} + +void BitDecomp(uint64_t num, std::vector& vec, uint64_t b, uint64_t z, + uint64_t t) { + num >>= b; + vec.assign(t, 0); + const uint64_t mask = (1ULL << z) - 1; + for (uint64_t i = 0; i < t; ++i) { + vec[i] = num & mask; + num >>= z; + } +} + +void PrecomputeAutomap(uint32_t length, uint32_t idx, + std::vector& automap) { + const uint32_t m = length << 1; + const uint32_t logm = static_cast(std::llround(std::log2(m))); + const uint32_t logn = static_cast(std::llround(std::log2(length))); + automap.assign(length, 0); + for (uint32_t j = 0; j < length; ++j) { + uint32_t j_tmp = ((j << 1) + 1); + uint32_t index = ((j_tmp * idx) - (((j_tmp * idx) >> logm) << logm)) >> 1; + uint32_t j_rev = ReverseBits(j, logn); + uint32_t idx_rev = ReverseBits(index, logn); + automap[j_rev] = idx_rev; + } +} + +void PseudorandomMatrixGenerate(std::vector>& matrix, + uint64_t modulus, AESCTR_PRNG& prng) { + const uint64_t rows = matrix.size(); + const uint64_t cols = rows == 0 ? 0 : matrix[0].size(); + for (uint64_t i = 0; i < rows; ++i) { + uint8_t* ptr = reinterpret_cast(matrix[i].data()); + prng.fill_bytes(ptr, sizeof(uint64_t) * cols); + } + for (uint64_t i = 0; i < rows; ++i) + for (uint64_t j = 0; j < cols; ++j) + matrix[i][j] %= modulus; +} + +void SetPseudorandomMatrixSimplepir(std::vector>& matrix, + std::vector& matrix_flat, + uint64_t rows, uint64_t cols, + uint64_t modulus, AESCTR_PRNG& prng) { + matrix.assign(rows, std::vector(cols, 0)); + prng.refresh(kFirstDimensionSeed); + PseudorandomMatrixGenerate(matrix, modulus, prng); + matrix_flat.resize(rows * cols); + for (uint64_t i = 0; i < rows; ++i) { + std::memcpy(&matrix_flat[i * cols], matrix[i].data(), + cols * sizeof(uint64_t)); + } +} + +void SetPseudorandomMatrixDoublepir(std::vector>& matrix, + std::vector& matrix_flat, + uint64_t rows, uint64_t cols, + uint64_t modulus, AESCTR_PRNG& prng) { + matrix.assign(rows, std::vector(cols, 0)); + prng.refresh(kSecondDimensionSeed); + PseudorandomMatrixGenerate(matrix, modulus, prng); + matrix_flat.resize(rows * cols); + for (uint64_t i = 0; i < rows; ++i) { + std::memcpy(&matrix_flat[i * cols], matrix[i].data(), + cols * sizeof(uint64_t)); + } +} + +void SetPseudorandomHypercubeYpir( + std::vector>>& cube, uint64_t layers, + uint64_t rows, uint64_t cols, uint64_t modulus, AESCTR_PRNG& prng) { + cube.assign(layers, + std::vector>(rows, + std::vector(cols))); + prng.refresh(kThirdDimensionSeed); + for (uint64_t i = 0; i < layers; ++i) { + PseudorandomMatrixGenerate(cube[i], modulus, prng); + } +} + +void SetAutomap(std::vector>& automap, uint64_t degree, + const std::vector& idx) { + automap.assign(idx.size(), std::vector(degree, 0)); + for (size_t i = 0; i < idx.size(); ++i) { + PrecomputeAutomap(static_cast(degree), + static_cast(idx[i]), automap[i]); + } +} + +void SetPrecomputedPt(std::vector>& precomputed_pt, + uint64_t poly_degree, uint64_t max_lh, + NttForwardFn ntt_forward) { + precomputed_pt.assign(max_lh + 1, std::vector(poly_degree, 0)); + for (uint64_t lh = 2; lh <= max_lh; ++lh) { + precomputed_pt[lh][poly_degree / (1ULL << lh)] = 1; + if (ntt_forward != nullptr) { + ntt_forward(precomputed_pt[lh].data(), precomputed_pt[lh].size()); + } + } +} + +uint64_t GetAutokeyIdx(uint64_t idx, uint64_t expo) { + return expo - GetLog2(idx - 1); +} + +void VectorColDecompose(const std::vector& vec, + std::vector>& decomp_matrix, + uint64_t b, uint64_t z, uint64_t t) { + const uint64_t row = vec.size(); + const uint64_t mask = (1ULL << z) - 1; + decomp_matrix.assign(t, std::vector(row, 0)); + for (uint64_t i = 0; i < t; ++i) { + for (uint64_t j = 0; j < row; ++j) { + decomp_matrix[i][j] = + static_cast((vec[j] >> (b + i * z)) & mask); + } + } +} + +void MatrixRowDecompose(const std::vector>& matrix, + std::vector>& decomp_matrix, + uint64_t b, uint64_t z, uint64_t t) { + const uint64_t row = matrix.size(); + const uint64_t col = row == 0 ? 0 : matrix[0].size(); + decomp_matrix.assign(row, std::vector(col * t, 0)); + for (uint64_t i = 0; i < row; ++i) { + std::vector tmp(t, 0); + uint64_t ptr = 0; + for (uint64_t j = 0; j < col; ++j) { + BitDecomp(matrix[i][j], tmp, b, z, t); + for (uint64_t k = 0; k < t; ++k, ++ptr) { + decomp_matrix[i][ptr] = tmp[k]; + } + } + } +} + +void MatrixVectorFirstDimension(std::vector& result, + const std::vector>& matrix, + const std::vector& vec, + uint64_t mod) { + const uint64_t rows = matrix.size(); + const uint64_t cols = rows == 0 ? 0 : matrix[0].size(); + result.assign(cols, 0); + for (uint64_t r = 0; r < rows; ++r) { + EltwiseFMAMod(result.data(), matrix[r].data(), vec[r], result.data(), cols, + mod); + } +} + +void MatrixMultiplicationFlat( + std::vector>& db_mul_matrix, + const std::vector>& db, const uint64_t* matrix_flat, + uint64_t matrix_col, uint64_t mod) { + const uint64_t db_row = db.size(); + const uint64_t db_col = db_row == 0 ? 0 : db[0].size(); + db_mul_matrix.assign(db_row, std::vector(matrix_col, 0)); + for (uint64_t i = 0; i < db_row; ++i) { + uint64_t* res = db_mul_matrix[i].data(); + for (uint64_t k = 0; k < db_col; ++k) + EltwiseFMAMod(res, matrix_flat + k * matrix_col, db[i][k], res, + matrix_col, mod); + } +} + + +void MatrixMultiplicationFlatU16( + std::vector>& db_mul_matrix, + const std::vector>& db, const uint64_t* matrix_flat, + uint64_t matrix_col, uint64_t mod) { + const uint64_t db_row = db.size(); + const uint64_t db_col = db_row == 0 ? 0 : db[0].size(); + db_mul_matrix.assign(db_row, std::vector(matrix_col, 0)); + for (uint64_t i = 0; i < db_row; ++i) { + uint64_t* res = db_mul_matrix[i].data(); + const uint16_t* row = db[i].data(); + for (uint64_t k = 0; k < db_col; ++k) { + const uint64_t s = row[k]; + if (s == 0) continue; + EltwiseFMAMod(res, matrix_flat + k * matrix_col, s, res, matrix_col, mod); + } + } +} + +void MatrixVectorMultiplicationU16( + std::vector& result, + const std::vector>& matrix, + const std::vector& vec, uint64_t mod) { +#if defined(__x86_64__) || defined(_M_X64) +#if defined(__GNUC__) || defined(__clang__) + MatrixVectorMultiplicationU16Avx512(result, matrix, vec, mod); + return; +#endif +#endif + const uint64_t mat_row = matrix.size(); + const uint64_t mat_col = mat_row == 0 ? 0 : matrix[0].size(); + result.assign(mat_row, 0); + for (uint64_t i = 0; i < mat_row; ++i) { + unsigned __int128 sum = 0; + for (uint64_t j = 0; j < mat_col; ++j) { + sum += static_cast(matrix[i][j]) * vec[j]; + if ((j & 127U) == 127U) { + sum %= mod; + } + } + result[i] = static_cast(sum % mod); + } +} + +void MatVecU8U32Mod2p32(const uint8_t* A, const uint32_t* x, uint32_t* y, + size_t rows, size_t cols) { +#if defined(__x86_64__) || defined(_M_X64) +#if defined(__GNUC__) || defined(__clang__) + MatVecU8U32Mod2p32Avx512(A, x, y, rows, cols); + return; +#endif +#endif + MatVecU8U32Mod2p32Scalar(A, x, y, rows, cols); +} + +} // namespace psi::ypir::byhe diff --git a/psi/algorithm/ypir/ypir_util.h b/psi/algorithm/ypir/ypir_util.h new file mode 100644 index 00000000..86bd4fa7 --- /dev/null +++ b/psi/algorithm/ypir/ypir_util.h @@ -0,0 +1,134 @@ +// Copyright 2026 The secretflow authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#pragma once + +#include +#include +#include +#include + +#include "psi/algorithm/ypir/aes_prng.h" +#include "psi/algorithm/ypir/hexl.h" + +namespace psi::ypir::byhe { + +class FheParams; + +constexpr uint64_t kFirstDimensionSeed = 1; +constexpr uint64_t kSecondDimensionSeed = 1ULL << 16; +constexpr uint64_t kThirdDimensionSeed = 1ULL << 16; + +uint64_t GetLog2(uint64_t num); +bool IsPowerOfTwo(uint64_t num); +uint64_t GetAutokeyIdx(uint64_t idx, uint64_t expo); + +uint64_t SampleGauss(double st_dev, uint64_t modulus, + std::mt19937_64& rng); +void SampleGauss(std::vector& err, double st_dev, uint64_t modulus, + std::mt19937_64& rng); + +int64_t ModInverse(int64_t a, int64_t modulus); + +void ApplyAutoCoefForm(std::vector& result, + const std::vector& input, int32_t index, + uint64_t modulus); + +void MatrixTranspose(const std::vector>& matrix, + std::vector>& trans_matrix); + +void PrecomputeAutomap(uint32_t length, uint32_t idx, + std::vector& automap); + +void PseudorandomMatrixGenerate(std::vector>& matrix, + uint64_t modulus, AESCTR_PRNG& prng); + +// Helpers for byhe-style precomputation buffers. +void SetPseudorandomMatrixSimplepir(std::vector>& matrix, + std::vector& matrix_flat, + uint64_t rows, uint64_t cols, + uint64_t modulus, AESCTR_PRNG& prng); + +void SetPseudorandomMatrixDoublepir(std::vector>& matrix, + std::vector& matrix_flat, + uint64_t rows, uint64_t cols, + uint64_t modulus, AESCTR_PRNG& prng); + +void SetPseudorandomHypercubeYpir( + std::vector>>& cube, uint64_t layers, + uint64_t rows, uint64_t cols, uint64_t modulus, AESCTR_PRNG& prng); + +void SetAutomap(std::vector>& automap, uint64_t degree, + const std::vector& idx); + +using NttForwardFn = void (*)(uint64_t* data, size_t len); + +// If ntt_forward is nullptr, precomputed polynomials stay in coefficient form. +void SetPrecomputedPt(std::vector>& precomputed_pt, + uint64_t poly_degree, uint64_t max_lh, + NttForwardFn ntt_forward); + +// byhe server-side helpers +void VectorColDecompose(const std::vector& vec, + std::vector>& decomp_matrix, + uint64_t b, uint64_t z, uint64_t t); + +void MatrixRowDecompose(const std::vector>& matrix, + std::vector>& decomp_matrix, + uint64_t b, uint64_t z, uint64_t t); + +void MatrixVectorFirstDimension(std::vector& result, + const std::vector>& matrix, + const std::vector& vec, + uint64_t mod); + +void MatrixMultiplicationFlat( + std::vector>& db_mul_matrix, + const std::vector>& db, const uint64_t* matrix_flat, + uint64_t matrix_col, uint64_t mod); + +void MatrixMultiplicationFlatU16( + std::vector>& db_mul_matrix, + const std::vector>& db, const uint64_t* matrix_flat, + uint64_t matrix_col, uint64_t mod); + +void MatrixVectorMultiplicationU16( + std::vector& result, const std::vector>& matrix, + const std::vector& vec, uint64_t mod); + +void MatVecU8U32Mod2p32(const uint8_t* A, const uint32_t* x, uint32_t* y, + size_t rows, size_t cols); + +std::vector PackrlwePreprocess( + std::vector>& a, uint64_t l, uint64_t h, + const std::vector>>& ksk_a, + std::vector>>& decomp_buf, + const FheParams& fparm); + +std::vector PackrlweOnline( + std::vector>& b, uint64_t l, uint64_t h, + const std::vector>>& ksk_b, + std::vector>>& decomp_buf, uint64_t& ptr, + const FheParams& fparm); + +std::vector PackrlweOnlineConstantRows( + const std::vector& b, uint64_t l, uint64_t h, + const std::vector>>& ksk_b, + std::vector>>& decomp_buf, uint64_t& ptr, + const FheParams& fparm); + +void Cdks21Lwe2RlweInplace(uint64_t* lwe_a, uint64_t degree, uint64_t cmod, + ByheHexlNtt& ntt); + +} // namespace psi::ypir::byhe From 82cdca03b57643723e24f38d6e3d0ddeb04cd4d8 Mon Sep 17 00:00:00 2001 From: sh1k4u Date: Wed, 25 Mar 2026 13:05:58 +0800 Subject: [PATCH 02/12] Integrate ypir interface refactor --- docs/user_guide/pir.rst | 2 + psi/algorithm/pir_interface/pir_type.proto | 1 + psi/algorithm/ypir/BUILD.bazel | 277 ++-- psi/algorithm/ypir/automorphism_test.cc | 96 -- psi/algorithm/ypir/byhe_util_test.cc | 59 - psi/algorithm/ypir/client.cc | 299 +--- psi/algorithm/ypir/client.h | 50 +- psi/algorithm/ypir/client_test.cc | 48 + psi/algorithm/ypir/convolution.cc | 157 -- psi/algorithm/ypir/convolution.h | 41 - psi/algorithm/ypir/entry.cc | 241 +++ psi/algorithm/ypir/entry.h | 36 + psi/algorithm/ypir/entry_test.cc | 164 ++ psi/algorithm/ypir/fast_dot_product_test.cc | 106 -- psi/algorithm/ypir/integration_test.cc | 758 --------- psi/algorithm/ypir/{ => legacy}/aes_prng.cc | 6 +- psi/algorithm/ypir/{ => legacy}/aes_prng.h | 4 +- psi/algorithm/ypir/legacy/client.cc | 279 ++++ psi/algorithm/ypir/legacy/client.h | 25 + psi/algorithm/ypir/{ => legacy}/hexl.cc | 12 +- psi/algorithm/ypir/{ => legacy}/hexl.h | 8 +- psi/algorithm/ypir/{ => legacy}/matmul.cpp | 0 psi/algorithm/ypir/legacy/server.cc | 160 ++ psi/algorithm/ypir/legacy/server.h | 24 + psi/algorithm/ypir/legacy/types.h | 57 + psi/algorithm/ypir/legacy/util.cc | 1130 ++++++++++++++ psi/algorithm/ypir/legacy/util.h | 130 ++ .../ypir/{ => legacy}/ypir_params.cc | 15 +- psi/algorithm/ypir/{ => legacy}/ypir_params.h | 12 +- psi/algorithm/ypir/{ => legacy}/ypir_util.cc | 6 +- psi/algorithm/ypir/{ => legacy}/ypir_util.h | 14 +- psi/algorithm/ypir/params.cc | 151 +- psi/algorithm/ypir/params.h | 59 +- psi/algorithm/ypir/params_test.cc | 51 + psi/algorithm/ypir/pir_interface_test.cc | 95 ++ psi/algorithm/ypir/rescale_test.cc | 58 - psi/algorithm/ypir/scale_k_test.cc | 38 - psi/algorithm/ypir/serialize.cc | 140 ++ psi/algorithm/ypir/serialize.h | 16 + psi/algorithm/ypir/serialize_test.cc | 43 + psi/algorithm/ypir/server.cc | 296 ++-- psi/algorithm/ypir/server.h | 61 +- psi/algorithm/ypir/server.rs | 1377 ----------------- psi/algorithm/ypir/server_test.cc | 52 + .../ypir/simplepir_basic_flow_test.cc | 135 -- psi/algorithm/ypir/simplepir_flow_test.cc | 52 + psi/algorithm/ypir/smoke_test.cc | 25 + psi/algorithm/ypir/types.h | 63 +- psi/algorithm/ypir/util.cc | 1134 +------------- psi/algorithm/ypir/util.h | 128 +- psi/algorithm/ypir/util_test.cc | 201 --- psi/algorithm/ypir/ypir_basic_flow_test.cc | 138 -- psi/algorithm/ypir/ypir_flow_test.cc | 44 + psi/algorithm/ypir/ypir_internal_client.cc | 53 + psi/algorithm/ypir/ypir_internal_client.h | 25 + psi/algorithm/ypir/ypir_internal_params.cc | 58 + psi/algorithm/ypir/ypir_internal_params.h | 18 + psi/algorithm/ypir/ypir_internal_server.cc | 71 + psi/algorithm/ypir/ypir_internal_server.h | 21 + psi/apps/psi_launcher/BUILD.bazel | 23 + psi/apps/psi_launcher/launch.h | 6 + psi/apps/psi_launcher/main.cc | 12 + psi/apps/psi_launcher/ypir_launch.cc | 49 + psi/apps/psi_launcher/ypir_launch.h | 17 + psi/apps/psi_launcher/ypir_test.cc | 150 ++ psi/proto/entry.proto | 4 + psi/proto/pir.proto | 45 +- 67 files changed, 4028 insertions(+), 5098 deletions(-) delete mode 100644 psi/algorithm/ypir/automorphism_test.cc delete mode 100644 psi/algorithm/ypir/byhe_util_test.cc create mode 100644 psi/algorithm/ypir/client_test.cc delete mode 100644 psi/algorithm/ypir/convolution.cc delete mode 100644 psi/algorithm/ypir/convolution.h create mode 100644 psi/algorithm/ypir/entry.cc create mode 100644 psi/algorithm/ypir/entry.h create mode 100644 psi/algorithm/ypir/entry_test.cc delete mode 100644 psi/algorithm/ypir/fast_dot_product_test.cc delete mode 100644 psi/algorithm/ypir/integration_test.cc rename psi/algorithm/ypir/{ => legacy}/aes_prng.cc (95%) rename psi/algorithm/ypir/{ => legacy}/aes_prng.h (95%) create mode 100644 psi/algorithm/ypir/legacy/client.cc create mode 100644 psi/algorithm/ypir/legacy/client.h rename psi/algorithm/ypir/{ => legacy}/hexl.cc (86%) rename psi/algorithm/ypir/{ => legacy}/hexl.h (90%) rename psi/algorithm/ypir/{ => legacy}/matmul.cpp (100%) create mode 100644 psi/algorithm/ypir/legacy/server.cc create mode 100644 psi/algorithm/ypir/legacy/server.h create mode 100644 psi/algorithm/ypir/legacy/types.h create mode 100644 psi/algorithm/ypir/legacy/util.cc create mode 100644 psi/algorithm/ypir/legacy/util.h rename psi/algorithm/ypir/{ => legacy}/ypir_params.cc (97%) rename psi/algorithm/ypir/{ => legacy}/ypir_params.h (95%) rename psi/algorithm/ypir/{ => legacy}/ypir_util.cc (99%) rename psi/algorithm/ypir/{ => legacy}/ypir_util.h (94%) create mode 100644 psi/algorithm/ypir/params_test.cc create mode 100644 psi/algorithm/ypir/pir_interface_test.cc delete mode 100644 psi/algorithm/ypir/rescale_test.cc delete mode 100644 psi/algorithm/ypir/scale_k_test.cc create mode 100644 psi/algorithm/ypir/serialize.cc create mode 100644 psi/algorithm/ypir/serialize.h create mode 100644 psi/algorithm/ypir/serialize_test.cc delete mode 100644 psi/algorithm/ypir/server.rs create mode 100644 psi/algorithm/ypir/server_test.cc delete mode 100644 psi/algorithm/ypir/simplepir_basic_flow_test.cc create mode 100644 psi/algorithm/ypir/simplepir_flow_test.cc create mode 100644 psi/algorithm/ypir/smoke_test.cc delete mode 100644 psi/algorithm/ypir/util_test.cc delete mode 100644 psi/algorithm/ypir/ypir_basic_flow_test.cc create mode 100644 psi/algorithm/ypir/ypir_flow_test.cc create mode 100644 psi/algorithm/ypir/ypir_internal_client.cc create mode 100644 psi/algorithm/ypir/ypir_internal_client.h create mode 100644 psi/algorithm/ypir/ypir_internal_params.cc create mode 100644 psi/algorithm/ypir/ypir_internal_params.h create mode 100644 psi/algorithm/ypir/ypir_internal_server.cc create mode 100644 psi/algorithm/ypir/ypir_internal_server.h create mode 100644 psi/apps/psi_launcher/ypir_launch.cc create mode 100644 psi/apps/psi_launcher/ypir_launch.h create mode 100644 psi/apps/psi_launcher/ypir_test.cc diff --git a/docs/user_guide/pir.rst b/docs/user_guide/pir.rst index e7923919..26aba993 100644 --- a/docs/user_guide/pir.rst +++ b/docs/user_guide/pir.rst @@ -13,6 +13,8 @@ Supported Protocols +----------------+-------------+---------------+ | APSI | Keyword PIR | Single Server | +----------------+-------------+---------------+ +| YPIR | Index PIR | Single Server | ++----------------+-------------+---------------+ At this moment, SealPIR is under development. diff --git a/psi/algorithm/pir_interface/pir_type.proto b/psi/algorithm/pir_interface/pir_type.proto index fb8cde26..37d13812 100644 --- a/psi/algorithm/pir_interface/pir_type.proto +++ b/psi/algorithm/pir_interface/pir_type.proto @@ -21,6 +21,7 @@ enum PirType { INVALID = 0; SEAL_PIR = 1; SPIRAL_PIR = 2; + YPIR_PIR = 3; } message PirTypeProto { diff --git a/psi/algorithm/ypir/BUILD.bazel b/psi/algorithm/ypir/BUILD.bazel index 4f75ff9b..6511efeb 100644 --- a/psi/algorithm/ypir/BUILD.bazel +++ b/psi/algorithm/ypir/BUILD.bazel @@ -1,58 +1,62 @@ -# Copyright 2025 The secretflow authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Copyright 2026 The secretflow authors. load("//bazel:psi.bzl", "psi_cc_library", "psi_cc_test") package(default_visibility = ["//visibility:public"]) psi_cc_library( - name = "convolution", - srcs = ["convolution.cc"], - hdrs = ["convolution.h"], - deps = [ - "//psi/algorithm/spiral:poly_matrix", - "//psi/algorithm/spiral:poly_matrix_utils", - "@yacl//yacl/crypto/rand", + name = "legacy_ypir_impl", + srcs = [ + "legacy/aes_prng.cc", + "legacy/client.cc", + "legacy/hexl.cc", + "legacy/server.cc", + "legacy/ypir_params.cc", + "legacy/ypir_util.cc", + ], + hdrs = [ + "legacy/aes_prng.h", + "legacy/client.h", + "legacy/hexl.h", + "legacy/server.h", + "legacy/ypir_params.h", + "legacy/ypir_util.h", ], -) - -psi_cc_library( - name = "client", - srcs = ["client.cc"], - hdrs = ["client.h"], + copts = ["-maes"], deps = [ - ":ypir_params", + "@hexl//:hexl", + "@yacl//yacl/base:exception", ], ) psi_cc_library( - name = "types", - hdrs = ["types.h"], + name = "legacy_simplepir", + srcs = [ + "legacy/matmul.cpp", + "legacy/util.cc", + ], + hdrs = [ + "legacy/types.h", + "legacy/util.h", + ], deps = [ + "//psi/algorithm/spiral:discrete_gaussian", + "//psi/algorithm/spiral:gadget", "//psi/algorithm/spiral:params", "//psi/algorithm/spiral:poly_matrix", "//psi/algorithm/spiral:poly_matrix_utils", + "//psi/algorithm/spiral:util", + "@abseil-cpp//absl/types:span", + "@yacl//yacl/base:int128", + "@yacl//yacl/crypto/rand", + "@yacl//yacl/crypto/tools:prg", + "@yacl//yacl/utils:parallel", ], ) psi_cc_library( - name = "server", - srcs = ["server.cc"], - hdrs = ["server.h"], - deps = [ - ":ypir_params", - ], + name = "types", + hdrs = ["types.h"], ) psi_cc_library( @@ -60,198 +64,189 @@ psi_cc_library( srcs = ["params.cc"], hdrs = ["params.h"], deps = [ + ":types", "//psi/algorithm/spiral:params", - "//psi/algorithm/spiral:util", + "@yacl//yacl/base:exception", ], ) psi_cc_library( - name = "ypir_params", - srcs = ["ypir_params.cc"], - hdrs = ["ypir_params.h"], + name = "util", + srcs = ["util.cc"], + hdrs = ["util.h"], deps = [ - ":ypir_util", + ":params", + "//psi/algorithm/spiral/arith", "@yacl//yacl/base:exception", ], ) psi_cc_library( - name = "ypir_util", - srcs = ["ypir_util.cc"], - hdrs = ["ypir_util.h"], + name = "serialize", + srcs = ["serialize.cc"], + hdrs = ["serialize.h"], deps = [ - ":aes_prng", - ":hexl", + ":types", + "@yacl//yacl/base:buffer", + "@yacl//yacl/base:byte_container_view", "@yacl//yacl/base:exception", ], ) psi_cc_library( - name = "hexl", - srcs = ["hexl.cc"], - hdrs = ["hexl.h"], + name = "ypir_internal_params", + srcs = ["ypir_internal_params.cc"], + hdrs = ["ypir_internal_params.h"], deps = [ - "@hexl//:hexl", + ":legacy_ypir_impl", + ":params", "@yacl//yacl/base:exception", ], ) psi_cc_library( - name = "aes_prng", - srcs = ["aes_prng.cc"], - hdrs = ["aes_prng.h"], - copts = ["-maes"], -) - -psi_cc_library( - name = "util", - srcs = [ - "matmul.cpp", - "util.cc", - ], - hdrs = ["util.h"], + name = "ypir_internal_client", + srcs = ["ypir_internal_client.cc"], + hdrs = ["ypir_internal_client.h"], deps = [ + ":ypir_internal_params", + ":legacy_ypir_impl", ":types", - "//psi/algorithm/spiral:gadget", - "//psi/algorithm/spiral:params", - "//psi/algorithm/spiral:poly_matrix", - "//psi/algorithm/spiral:poly_matrix_utils", - ], -) - -psi_cc_test( - name = "util_test", - srcs = ["util_test.cc"], - deps = [ ":util", - "//psi/algorithm/spiral:gadget", - "//psi/algorithm/spiral:params", - "//psi/algorithm/spiral:poly_matrix", - "//psi/algorithm/spiral:poly_matrix_utils", - "//psi/algorithm/spiral:spiral_client", - "//psi/algorithm/spiral:util", - "@yacl//yacl/crypto/rand", - "@yacl//yacl/crypto/tools:prg", + "@yacl//yacl/base:exception", ], ) -psi_cc_test( - name = "ypir_util_test", - srcs = ["byhe_util_test.cc"], +psi_cc_library( + name = "ypir_internal_server", + srcs = ["ypir_internal_server.cc"], + hdrs = ["ypir_internal_server.h"], deps = [ - ":ypir_util", + ":ypir_internal_params", + ":legacy_ypir_impl", + ":types", + "@yacl//yacl/base:exception", ], ) -psi_cc_test( - name = "integration_test", - srcs = ["integration_test.cc"], +psi_cc_library( + name = "client", + srcs = ["client.cc"], + hdrs = ["client.h"], deps = [ - ":client", - ":server", - "//psi/algorithm/spiral:params", - "//psi/algorithm/spiral:spiral_client", - "//psi/algorithm/spiral:util", + "//psi/algorithm/pir_interface:index_pir", + "//psi/algorithm/pir_interface:pir_db", + ":ypir_internal_client", + ":params", + ":serialize", + ":util", + "@yacl//yacl/base:buffer", + "@yacl//yacl/base:byte_container_view", + "@yacl//yacl/base:exception", ], ) -psi_cc_test( - name = "rescale_test", - srcs = ["rescale_test.cc"], +psi_cc_library( + name = "server", + srcs = ["server.cc"], + hdrs = ["server.h"], deps = [ - "//psi/algorithm/spiral:params", - "//psi/algorithm/spiral/arith", + ":ypir_internal_server", + ":legacy_simplepir", + ":params", + ":serialize", + "//psi/algorithm/pir_interface:pir_db", + "@yacl//yacl/base:buffer", + "@yacl//yacl/base:byte_container_view", + "@yacl//yacl/base:exception", ], ) -psi_cc_test( - name = "scale_k_test", - srcs = ["scale_k_test.cc"], +psi_cc_library( + name = "entry", + srcs = ["entry.cc"], + hdrs = ["entry.h"], deps = [ ":client", + ":params", ":server", - "//psi/algorithm/spiral:params", - "//psi/algorithm/spiral/arith", + "//psi/algorithm/pir_interface:pir_db", + "@abseil-cpp//absl/strings", + "@yacl//yacl/link:context", ], ) psi_cc_test( - name = "simplepir_minimal_test", - srcs = ["simplepir_minimal_test.cc"], + name = "smoke_test", + srcs = ["smoke_test.cc"], deps = [ ":client", ":server", - "//psi/algorithm/spiral:params", - "//psi/algorithm/spiral:spiral_client", ], ) psi_cc_test( - name = "fast_dot_product_test", - srcs = ["fast_dot_product_test.cc"], - deps = [ - ":util", - "//psi/algorithm/spiral:params", - ], + name = "params_test", + srcs = ["params_test.cc"], + deps = [":params"], ) psi_cc_test( - name = "simplepir_basic_flow_test", - srcs = ["simplepir_basic_flow_test.cc"], - deps = [ - ":util", - "//psi/algorithm/spiral:params", - "//psi/algorithm/spiral/arith", - ], + name = "serialize_test", + srcs = ["serialize_test.cc"], + deps = [":serialize"], ) psi_cc_test( - name = "ypir_basic_flow_test", - srcs = ["ypir_basic_flow_test.cc"], + name = "client_test", + srcs = ["client_test.cc"], deps = [ - ":hexl", - ":ypir_params", ":client", + ":serialize", ":server", ], ) psi_cc_test( - name = "automorphism_test", - srcs = ["automorphism_test.cc"], + name = "server_test", + srcs = ["server_test.cc"], + deps = [":server"], +) + +psi_cc_test( + name = "pir_interface_test", + srcs = ["pir_interface_test.cc"], deps = [ - "//psi/algorithm/spiral:params", - "//psi/algorithm/spiral:poly_matrix_utils", + ":client", + ":server", + "//psi/algorithm/pir_interface:index_pir", ], ) psi_cc_test( - name = "lwe_consistency_test", - srcs = ["lwe_consistency_test.cc"], + name = "simplepir_flow_test", + srcs = ["simplepir_flow_test.cc"], deps = [ ":client", - ":convolution", ":server", - "//psi/algorithm/spiral:params", - "//psi/algorithm/spiral:spiral_client", ], ) psi_cc_test( - name = "verify_hint_computation_test", - srcs = ["verify_hint_computation_test.cc"], + name = "ypir_flow_test", + srcs = ["ypir_flow_test.cc"], deps = [ ":client", - ":convolution", - ":params", + ":server", ], ) psi_cc_test( - name = "lwe_flow_test", - srcs = ["lwe_flow_test.cc"], + name = "entry_test", + srcs = ["entry_test.cc"], deps = [ - ":client", - ":params", + ":entry", + "@abseil-cpp//absl/strings", + "@yacl//yacl/link:test_util", ], ) diff --git a/psi/algorithm/ypir/automorphism_test.cc b/psi/algorithm/ypir/automorphism_test.cc deleted file mode 100644 index ae7423ee..00000000 --- a/psi/algorithm/ypir/automorphism_test.cc +++ /dev/null @@ -1,96 +0,0 @@ -#include "gtest/gtest.h" -#include "spdlog/spdlog.h" - -#include "psi/algorithm/spiral/params.h" -#include "psi/algorithm/spiral/poly_matrix_utils.h" - -namespace psi::ypir { - -using namespace psi::spiral; - -TEST(AutomorphismTest, ZeroInputShouldGiveZeroOutput) { - spdlog::set_level(spdlog::level::info); - - size_t poly_len = 2048; - std::vector moduli = {268369921, 249561089}; - double noise_width = 6.4; - PolyMatrixParams poly_matrix_params; - poly_matrix_params.n_ = 2; - poly_matrix_params.pt_modulus_ = 16384; - QueryParams query_params(1, 1, 1); - - Params params(poly_len, std::move(moduli), noise_width, poly_matrix_params, - query_params); - - SPDLOG_INFO("=== Testing AutomorphismPolyUncrtd with Zero Input ==="); - - size_t dual_crt_size = params.CrtCount() * poly_len; - std::vector zero_input(dual_crt_size, 0); - std::vector output(dual_crt_size, 999); - - std::vector t_values = {65, 129, 257, 513, 1025, 2049}; - - for (size_t t : t_values) { - std::fill(output.begin(), output.end(), 999); - - AutomorphismPolyUncrtd(params, absl::MakeSpan(output), - absl::MakeConstSpan(zero_input), t); - - bool all_zero = true; - for (size_t i = 0; i < output.size(); ++i) { - if (output[i] != 0) { - all_zero = false; - if (i < 10) { - SPDLOG_ERROR("t={}: output[{}] = {} (expected 0)", t, i, output[i]); - } - } - } - - if (all_zero) { - SPDLOG_INFO("✓ t={}: All outputs are zero", t); - } else { - SPDLOG_ERROR("✗ t={}: Found non-zero outputs!", t); - } - - EXPECT_TRUE(all_zero) << "Zero input should give zero output for t=" << t; - } -} - -TEST(AutomorphismTest, NonZeroInputCheck) { - spdlog::set_level(spdlog::level::info); - - size_t poly_len = 2048; - std::vector moduli = {268369921, 249561089}; - double noise_width = 6.4; - PolyMatrixParams poly_matrix_params; - poly_matrix_params.n_ = 2; - poly_matrix_params.pt_modulus_ = 16384; - QueryParams query_params(1, 1, 1); - - Params params(poly_len, std::move(moduli), noise_width, poly_matrix_params, - query_params); - - SPDLOG_INFO( - "=== Testing AutomorphismPolyUncrtd with Simple Non-Zero Input ==="); - - size_t dual_crt_size = params.CrtCount() * poly_len; - std::vector input(dual_crt_size, 0); - std::vector output(dual_crt_size, 0); - - input[0] = 1; - - size_t t = 65; - AutomorphismPolyUncrtd(params, absl::MakeSpan(output), - absl::MakeConstSpan(input), t); - - SPDLOG_INFO("Input: first coefficient = 1, others = 0"); - SPDLOG_INFO("t = {}", t); - SPDLOG_INFO("First 10 output values:"); - for (size_t i = 0; i < 10; ++i) { - SPDLOG_INFO(" output[{}] = {}", i, output[i]); - } - - EXPECT_EQ(output[0], 1) << "output[0] should be 1"; -} - -} // namespace psi::ypir diff --git a/psi/algorithm/ypir/byhe_util_test.cc b/psi/algorithm/ypir/byhe_util_test.cc deleted file mode 100644 index 3b819b28..00000000 --- a/psi/algorithm/ypir/byhe_util_test.cc +++ /dev/null @@ -1,59 +0,0 @@ -#include -#include -#include -#include - -#include "gtest/gtest.h" - -#include "psi/algorithm/ypir/byhe_util.h" - -namespace psi::ypir::byhe { -namespace { - -std::vector ReferenceMatVecU8U32Mod2p32(const std::vector& A, - const std::vector& x, - size_t rows, size_t cols) { - std::vector y(rows, 0); - for (size_t r = 0; r < rows; ++r) { - uint64_t acc = 0; - for (size_t c = 0; c < cols; ++c) { - acc += static_cast(A[r * cols + c]) * x[c]; - } - y[r] = static_cast(acc); - } - return y; -} - -void RunMatVecCase(size_t rows, size_t cols) { - std::mt19937 rng(static_cast(rows * 131 + cols * 17 + 7)); - std::uniform_int_distribution a_dist(0, 255); - std::uniform_int_distribution x_dist( - 0, std::numeric_limits::max()); - - std::vector A(rows * cols, 0); - std::vector x(cols, 0); - for (auto& v : A) { - v = static_cast(a_dist(rng)); - } - for (auto& v : x) { - v = x_dist(rng); - } - - std::vector y(rows, 0); - MatVecU8U32Mod2p32(A.data(), x.data(), y.data(), rows, cols); - - const auto expected = ReferenceMatVecU8U32Mod2p32(A, x, rows, cols); - EXPECT_EQ(y, expected); -} - -} // namespace - -TEST(ByheUtilTest, MatVecU8U32Mod2p32MatchesReference) { - RunMatVecCase(1, 1); - RunMatVecCase(7, 13); - RunMatVecCase(16, 64); - RunMatVecCase(31, 255); - RunMatVecCase(64, 512); -} - -} // namespace psi::ypir::byhe diff --git a/psi/algorithm/ypir/client.cc b/psi/algorithm/ypir/client.cc index 55034788..e4180731 100644 --- a/psi/algorithm/ypir/client.cc +++ b/psi/algorithm/ypir/client.cc @@ -1,279 +1,80 @@ #include "psi/algorithm/ypir/client.h" -#include -#include -#include -#include +#include +#include -namespace psi::ypir::byhe { -namespace { +#include "yacl/base/exception.h" -uint64_t MakeSeedMaterial() { - const uint64_t time_seed = static_cast( - std::chrono::high_resolution_clock::now().time_since_epoch().count()); - std::random_device rd; - return time_seed ^ (static_cast(rd()) << 32) ^ rd(); -} - -std::mt19937_64& GlobalPrng() { - thread_local std::mt19937_64 rng(MakeSeedMaterial()); - return rng; -} - -uint64_t GetBase(uint64_t b, uint64_t z, uint64_t ti) { - return 1ULL << (b + ti * z); -} +#include "psi/algorithm/ypir/serialize.h" +#include "psi/algorithm/ypir/util.h" -void LweEncrypt(Secret& sk, const std::vector& a, uint64_t message, - uint64_t& b, uint64_t pmod, double sig) { - const uint64_t lwe_dimension = sk.get_len(); - const uint64_t cmod = sk.get_mod(); - const long double delta = - static_cast(cmod) / static_cast(pmod); +namespace psi::ypir { - const uint64_t e = SampleGauss(sig, cmod, GlobalPrng()); - - std::vector tmp(lwe_dimension, 0); - EltwiseMultMod(tmp.data(), a.data(), sk.data.data(), lwe_dimension, cmod); - b = 0; - for (uint64_t i = 0; i < lwe_dimension; ++i) { - b = (b + tmp[i]) % cmod; +YpirClient::YpirClient(YpirParameters params) : params_(std::move(params)) { + if (params_.mode == YpirMode::kDoublepir) { + ypir_context_ = std::make_unique( + internal::ypir::CreateContext(params_)); } - b = (b + e) % cmod; - b = (b + static_cast(message * delta)) % cmod; } -void LweDecrypt(Secret& sk, std::vector& a, uint64_t& message, - uint64_t& b, uint64_t pmod) { - const uint64_t lwe_dimension = sk.get_len(); - const uint64_t cmod = sk.get_mod(); - const long double delta = - static_cast(cmod) / static_cast(pmod); - - std::vector tmp(lwe_dimension, 0); - EltwiseMultMod(tmp.data(), a.data(), sk.data.data(), lwe_dimension, cmod); - for (uint64_t i = 0; i < lwe_dimension; ++i) { - b = (cmod + b - tmp[i]) % cmod; - } - - if (b > (cmod >> 1)) { - b = static_cast(std::llround((static_cast(b) - - static_cast(cmod)) / - delta)) % - pmod; - } else { - b = static_cast( - std::llround(static_cast(b) / delta)) % - pmod; - } - message = b; -} +yacl::Buffer YpirClient::GeneratePksBuffer() const { return yacl::Buffer(); } -void PowerOfBase(const uint64_t* vec, uint64_t& num, uint64_t b, uint64_t z, - uint64_t t) { - num = 0; - for (uint64_t i = 0; i < t; ++i) { - num = (num << z) | vec[t - 1 - i]; - } - num <<= b; -} +std::string YpirClient::GeneratePksString() const { return {}; } -void RlweEncode(Secret& sk, const std::vector& a, - std::vector& message, std::vector& b, - const FheParams& fparm) { - const uint64_t poly_degree = fparm.get_poly_degree(); - const uint64_t rlwe_cmod = fparm.get_rlwe_cmod(); - const double sig = fparm.get_sig_ring(); +YpirQuery YpirClient::GenerateQuery(uint64_t raw_idx) const { + YACL_ENFORCE_LT(raw_idx, params_.NumItems()); - ByheHexlNtt& ntt = fparm.get_ntt(); - if (!sk.get_ntt_form()) { - ntt.Forward(sk.data.data(), poly_degree); - sk.switch_ntt_format(); + if (params_.mode == YpirMode::kSimplepir) { + YpirQuery query; + query.mode = YpirMode::kSimplepir; + query.packed_query_row = BuildPackedSimplepirQuery(params_, raw_idx); + return query; } - std::vector err(poly_degree, 0); - SampleGauss(err, sig, rlwe_cmod, GlobalPrng()); - EltwiseFMAMod(err.data(), message.data(), 1, err.data(), poly_degree, - rlwe_cmod); - ntt.Forward(err.data(), poly_degree); - - EltwiseMultMod(b.data(), sk.data.data(), a.data(), poly_degree, rlwe_cmod); - EltwiseAddMod(b.data(), err.data(), b.data(), poly_degree, rlwe_cmod); + YACL_ENFORCE(ypir_context_ != nullptr); + return internal::ypir::GenerateQuery(raw_idx, params_, client_secrets_, + *ypir_context_); } -void RlweDecrypt(Secret& sk, std::vector& a, - std::vector& message, std::vector& b, - const FheParams& fparm) { - const uint64_t poly_degree = fparm.get_poly_degree(); - const uint64_t rlwe_cmod = fparm.get_rlwe_cmod(); - const uint64_t rlwe_pmod = fparm.get_rlwe_pmod(); - const uint64_t delta = rlwe_cmod / rlwe_pmod; - - ByheHexlNtt& ntt = fparm.get_ntt(); - if (!sk.get_ntt_form()) { - ntt.Forward(sk.data.data(), poly_degree); - sk.switch_ntt_format(); - } - - std::vector tmp(poly_degree, 0); - EltwiseMultMod(tmp.data(), sk.data.data(), a.data(), poly_degree, rlwe_cmod); - EltwiseSubMod(b.data(), b.data(), tmp.data(), poly_degree, rlwe_cmod); - ntt.Inverse(b.data(), poly_degree); - - message.assign(poly_degree, 0); - for (uint64_t i = 0; i < poly_degree; ++i) { - if (b[i] > (rlwe_cmod >> 1)) { - message[i] = static_cast( - std::llround((static_cast(b[i]) - - static_cast(rlwe_cmod)) / - static_cast(delta))) % - rlwe_pmod; - } else { - message[i] = static_cast( - std::llround(static_cast(b[i]) / - static_cast(delta))) % - rlwe_pmod; - } - } +yacl::Buffer YpirClient::GenerateQueryBuffer(uint64_t raw_idx) const { + return SerializeQuery(GenerateQuery(raw_idx)); } -void MatrixReconstruct(const std::vector& vec, - std::vector>& mat, uint64_t row, - uint64_t col) { - mat.assign(row, std::vector(col, 0)); - uint64_t ptr = 0; - for (uint64_t i = 0; i < row; ++i) { - for (uint64_t j = 0; j < col; ++j, ++ptr) { - mat[i][j] = vec[ptr]; - } - } +yacl::Buffer YpirClient::GenerateIndexQuery(uint64_t raw_idx) const { + return GenerateQueryBuffer(raw_idx); } -void GadgetEncrypt(Secret& sk, const std::vector>& a, - std::vector& message, - std::vector>& b, - const FheParams& fparm) { - const uint64_t b_auto = fparm.get_b_auto(); - const uint64_t z_auto = fparm.get_z_auto(); - const uint64_t t_auto = fparm.get_t_auto(); - const uint64_t poly_degree = fparm.get_poly_degree(); - const uint64_t rlwe_cmod = fparm.get_rlwe_cmod(); - - std::vector message_tmp(poly_degree, 0); - for (uint64_t i = 0; i < t_auto; ++i) { - const uint64_t base = GetBase(b_auto, z_auto, i) % rlwe_cmod; - EltwiseFMAMod(message_tmp.data(), message.data(), base, nullptr, - poly_degree, rlwe_cmod); - RlweEncode(sk, a[i], message_tmp, b[i], fparm); - } +std::string YpirClient::GenerateIndexQueryStr(uint64_t raw_idx) const { + auto buffer = GenerateQueryBuffer(raw_idx); + return std::string(static_cast(buffer)); } -void GenerateAutokey(Secret& sk, - const std::vector>>& ksk_a, - std::vector>>& ksk_b, - const FheParams& fparm) { - const uint64_t degree = fparm.get_poly_degree(); - const uint64_t cmod = fparm.get_rlwe_cmod(); - const uint64_t expo = GetLog2(degree); - - ByheHexlNtt& ntt = fparm.get_ntt(); - if (sk.get_ntt_form()) { - ntt.Inverse(sk.data.data(), degree); - sk.switch_ntt_format(); +std::vector YpirClient::DecodeResponse(const YpirResponse& response, + uint64_t raw_idx) const { + YACL_ENFORCE_LT(raw_idx, params_.NumItems()); + YACL_ENFORCE(response.mode == params_.mode); + + if (params_.mode == YpirMode::kSimplepir) { + YACL_ENFORCE_EQ(response.simplepir_response.size(), params_.db_cols); + const uint64_t col_idx = raw_idx % params_.db_cols; + const uint64_t decoded = + DecodeSimplepirValue(params_, response.simplepir_response[col_idx]); + return EncodeIntegerValue(decoded, params_.value_bytes); } - std::vector newkey(degree, 0); - const std::vector copykey = sk.data; - for (uint64_t i = 0; i < expo; ++i) { - const uint64_t idx = (1ULL << (expo - i)) + 1; - ApplyAutoCoefForm(newkey, copykey, static_cast(idx), cmod); - GadgetEncrypt(sk, ksk_a[i], newkey, ksk_b[i], fparm); - } + YACL_ENFORCE(ypir_context_ != nullptr); + return internal::ypir::RecoverResponse(response, params_, client_secrets_, + *ypir_context_); } -} // namespace - -void YpirRecover(Secret& simple_sk, Secret& double_sk, - std::vector>& res, uint64_t& message, - const FheParams& fparm, const PirParams&) { - const uint64_t degree = fparm.get_poly_degree(); - const uint64_t lwe_pmod = fparm.get_lwe_pmod(); - const uint64_t lwe_dimension = fparm.get_lwe_dimension(); - const uint64_t b = fparm.get_b_decomp(); - const uint64_t z = fparm.get_z_decomp(); - const uint64_t t = fparm.get_t_decomp(); - - std::vector pack_a_message(degree, 0); - std::vector pack_b_message(degree, 0); - RlweDecrypt(double_sk, res[0], pack_a_message, res[1], fparm); - RlweDecrypt(double_sk, res[2], pack_b_message, res[3], fparm); - - std::vector> matrix_pack_a_message; - MatrixReconstruct(pack_a_message, matrix_pack_a_message, lwe_dimension, t); - - std::vector a(lwe_dimension, 0); - for (uint64_t i = 0; i < lwe_dimension; ++i) { - PowerOfBase(matrix_pack_a_message[i].data(), a[i], b, z, t); - } - - uint64_t b_value = 0; - PowerOfBase(pack_b_message.data(), b_value, b, z, t); - LweDecrypt(simple_sk, a, message, b_value, lwe_pmod); +std::vector YpirClient::DecodeResponseBuffer( + const yacl::ByteContainerView& response_buffer, uint64_t raw_idx) const { + return DecodeResponse(DeserializeResponse(response_buffer), raw_idx); } -YpirQuery Generate_query_ypir(uint64_t c_idx, uint64_t r_idx, Secret& lwe_sk, - Secret& rlwe_sk, AESCTR_PRNG& prng, - const FheParams& fparm, - const PirParams& pparm) { - YpirQuery out; - - const uint64_t cols = pparm.get_col(); - std::vector query_vec_col(cols, 0); - query_vec_col[c_idx] = 1; - - out.qu0.resize(cols); - const double sig = fparm.get_sig(); - const uint64_t lwe_pmod = fparm.get_lwe_pmod(); - const auto& matrix0 = fparm.get_persudo_matrix_simplepir(); - for (uint64_t i = 0; i < cols; ++i) { - LweEncrypt(lwe_sk, matrix0[i], query_vec_col[i], out.qu0[i], lwe_pmod, - sig); - } - - const uint64_t rows = pparm.get_row(); - const uint64_t degree = fparm.get_poly_degree(); - std::vector query_vec_row(rows, 0); - query_vec_row[r_idx] = 1; - - out.qu1.resize(rows); - const double sig_ring = fparm.get_sig_ring(); - const uint64_t rlwe_pmod = fparm.get_rlwe_pmod(); - std::vector> matrix1(rows, - std::vector(degree, 0)); - prng.refresh(kSecondDimensionSeed); - PseudorandomMatrixGenerate(matrix1, fparm.get_rlwe_cmod(), prng); - for (uint64_t i = 0; i < rows; ++i) { - LweEncrypt(rlwe_sk, matrix1[i], query_vec_row[i], out.qu1[i], rlwe_pmod, - sig_ring); - } - - const uint64_t t_auto = fparm.get_t_auto(); - const uint64_t expo = GetLog2(degree); - out.ksk_b.assign( - expo, std::vector>(t_auto, - std::vector(degree, 0))); - - std::vector>> ksk_a( - expo, - std::vector>(t_auto, - std::vector(degree, 0))); - prng.refresh(kThirdDimensionSeed); - for (uint64_t i = 0; i < expo; ++i) { - PseudorandomMatrixGenerate(ksk_a[i], fparm.get_rlwe_cmod(), prng); - } - GenerateAutokey(rlwe_sk, ksk_a, out.ksk_b, fparm); - - return out; +std::vector YpirClient::DecodeIndexResponse( + const yacl::ByteContainerView& response_buffer, uint64_t raw_idx) const { + return DecodeResponseBuffer(response_buffer, raw_idx); } -} // namespace psi::ypir::byhe +} // namespace psi::ypir diff --git a/psi/algorithm/ypir/client.h b/psi/algorithm/ypir/client.h index ed259ca9..981e6fab 100644 --- a/psi/algorithm/ypir/client.h +++ b/psi/algorithm/ypir/client.h @@ -1,29 +1,47 @@ #pragma once -#include +#include +#include #include -#include "psi/algorithm/ypir/ypir_params.h" +#include "yacl/base/buffer.h" +#include "yacl/base/byte_container_view.h" + +#include "psi/algorithm/pir_interface/index_pir.h" +#include "psi/algorithm/ypir/ypir_internal_client.h" +#include "psi/algorithm/ypir/params.h" +#include "psi/algorithm/ypir/types.h" namespace psi::ypir { -namespace byhe { +class YpirClient : public psi::pir::IndexPirClient { + public: + explicit YpirClient(YpirParameters params); -struct YpirQuery { - std::vector qu0; - std::vector qu1; - std::vector>> ksk_b; -}; + const YpirParameters& GetParameters() const { return params_; } + + pir::PirType GetPirType() const override { return pir::PirType::YPIR_PIR; } -void YpirRecover(Secret& simple_sk, Secret& double_sk, - std::vector>& res, uint64_t& message, - const FheParams& fparm, const PirParams& pparm); + yacl::Buffer GeneratePksBuffer() const override; + std::string GeneratePksString() const override; -YpirQuery Generate_query_ypir(uint64_t c_idx, uint64_t r_idx, Secret& lwe_sk, - Secret& rlwe_sk, AESCTR_PRNG& prng, - const FheParams& fparm, - const PirParams& pparm); + YpirQuery GenerateQuery(uint64_t raw_idx) const; + yacl::Buffer GenerateQueryBuffer(uint64_t raw_idx) const; + yacl::Buffer GenerateIndexQuery(uint64_t raw_idx) const override; + std::string GenerateIndexQueryStr(uint64_t raw_idx) const override; -} // namespace byhe + std::vector DecodeResponse(const YpirResponse& response, + uint64_t raw_idx) const; + std::vector DecodeResponseBuffer( + const yacl::ByteContainerView& response_buffer, uint64_t raw_idx) const; + std::vector DecodeIndexResponse( + const yacl::ByteContainerView& response_buffer, + uint64_t raw_idx) const override; + + private: + YpirParameters params_; + mutable std::unique_ptr ypir_context_; + mutable internal::ypir::ClientSecrets client_secrets_; +}; } // namespace psi::ypir diff --git a/psi/algorithm/ypir/client_test.cc b/psi/algorithm/ypir/client_test.cc new file mode 100644 index 00000000..0064ff04 --- /dev/null +++ b/psi/algorithm/ypir/client_test.cc @@ -0,0 +1,48 @@ +#include "psi/algorithm/ypir/client.h" +#include "psi/algorithm/ypir/serialize.h" + +#include + +#include "gtest/gtest.h" + +namespace psi::ypir { +namespace { + +TEST(YpirClientTest, SimplepirQueryUsesPackedRowShape) { + auto params = CreateSmallTestParamsSimplePIR(); + YpirClient client(params); + + const auto query = client.GenerateQuery(123ULL * params.db_cols + 456ULL); + EXPECT_EQ(query.mode, YpirMode::kSimplepir); + EXPECT_EQ(query.packed_query_row.size(), params.db_rows); + EXPECT_TRUE(query.qu0.empty()); + EXPECT_TRUE(query.qu1.empty()); + EXPECT_TRUE(query.ksk_b.empty()); + + const auto buffer = client.GenerateQueryBuffer(7); + const auto decoded = DeserializeQuery(buffer); + EXPECT_EQ(decoded.mode, YpirMode::kSimplepir); + EXPECT_EQ(decoded.packed_query_row.size(), params.db_rows); +} + +TEST(YpirClientTest, DoublepirQueryContainsLegacyInternalPayload) { + auto params = CreateSmallTestParamsDoublePIR(); + YpirClient client(params); + + const auto query = client.GenerateQuery(111ULL * params.db_cols + 222ULL); + EXPECT_EQ(query.mode, YpirMode::kDoublepir); + EXPECT_TRUE(query.packed_query_row.empty()); + EXPECT_FALSE(query.qu0.empty()); + EXPECT_FALSE(query.qu1.empty()); + EXPECT_FALSE(query.ksk_b.empty()); + + const auto buffer = client.GenerateQueryBuffer(3); + const auto decoded = DeserializeQuery(buffer); + EXPECT_EQ(decoded.mode, YpirMode::kDoublepir); + EXPECT_FALSE(decoded.qu0.empty()); + EXPECT_FALSE(decoded.qu1.empty()); + EXPECT_FALSE(decoded.ksk_b.empty()); +} + +} // namespace +} // namespace psi::ypir diff --git a/psi/algorithm/ypir/convolution.cc b/psi/algorithm/ypir/convolution.cc deleted file mode 100644 index 93f3f89b..00000000 --- a/psi/algorithm/ypir/convolution.cc +++ /dev/null @@ -1,157 +0,0 @@ -#include "psi/algorithm/ypir/convolution.h" - -#include -#include - -#include "psi/algorithm/spiral/arith/arith.h" -#include "psi/algorithm/spiral/arith/arith_params.h" -#include "psi/algorithm/spiral/params.h" -#include "psi/algorithm/spiral/poly_matrix.h" -#include "psi/algorithm/spiral/poly_matrix_utils.h" - -namespace psi::ypir { -using namespace psi::spiral; - -psi::spiral::Params CreateParams(size_t n) { - std::size_t poly_len = n; - - std::vector moduli{268369921, 249561089}; - double noise_width = 6.4; - - psi::spiral::PolyMatrixParams poly_matrix_params(1, 2, 28, 0, 0, 0, 0); - psi::spiral::QueryParams query_params(1, 1, 1, true); - - return psi::spiral::Params(poly_len, std::move(moduli), noise_width, - std::move(poly_matrix_params), - std::move(query_params)); -} - -Convolution::Convolution(size_t n) : n_(n) { params_ = CreateParams(n); } - -std::vector Convolution::ntt(const std::vector& a) const { - assert(a.size() == n_); - - auto inp = PolyMatrixRaw::Zero(params_.PolyLen(), 1, 1); - for (size_t i = 0; i < n_; ++i) { - inp.Data()[i] = static_cast(a[i]); - } - - auto ntt_res = ToNtt(params_, inp); - - size_t out_size = params_.CrtCount() * n_; - std::vector out(out_size); - for (size_t i = 0; i < out_size; ++i) { - out[i] = static_cast(ntt_res.Data()[i]); - } - return out; -} - -std::vector Convolution::raw(const std::vector& a) const { - assert(a.size() == params_.CrtCount() * n_); - - auto inp = PolyMatrixNtt::Zero(params_.CrtCount(), params_.PolyLen(), 1, 1); - for (size_t i = 0; i < params_.CrtCount() * n_; ++i) { - inp.Data()[i] = static_cast(a[i]); - } - - auto raw_res = FromNtt(params_, inp); - - std::vector out(n_); - int64_t modulus_i64 = static_cast(params_.Modulus()); - int64_t two_pow_32 = 1LL << 32; - - for (size_t i = 0; i < n_; ++i) { - int64_t val = static_cast(raw_res.Data()[i]); - - assert(val < modulus_i64); - if (val > modulus_i64 / 2) { - val -= modulus_i64; - } - if (val < 0) { - val += (modulus_i64 / two_pow_32) * two_pow_32; - val += two_pow_32; - } - - assert(val >= 0); - out[i] = static_cast(val % two_pow_32); - } - return out; -} - -std::vector Convolution::pointwise_mul( - const std::vector& a, const std::vector& b) const { - size_t total_len = params_.CrtCount() * n_; - assert(a.size() == total_len); - assert(b.size() == total_len); - - std::vector out(total_len); - for (size_t m = 0; m < params_.CrtCount(); ++m) { - for (size_t i = 0; i < n_; ++i) { - size_t idx = m * n_ + i; - uint64_t val = - static_cast(a[idx]) * static_cast(b[idx]); - out[idx] = static_cast(arith::BarrettCoeffU64(params_, val, m)); - } - } - return out; -} - -std::vector Convolution::convolve( - const std::vector& a, const std::vector& b) const { - auto a_ntt = ntt(a); - auto b_ntt = ntt(b); - auto res = pointwise_mul(a_ntt, b_ntt); - return raw(res); -} - -std::vector NaiveNegacyclicConvolve(const std::vector& a, - const std::vector& b) { - assert(a.size() == b.size()); - size_t n = a.size(); - std::vector res(n, 0); - - for (size_t i = 0; i < n; ++i) { - for (size_t j = 0; j < n; ++j) { - size_t idx = (n + i - j) % n; - uint32_t b_val = b[idx]; - if (i < j) { - b_val = 0 - b_val; - } - res[i] += a[j] * b_val; - } - } - return res; -} - -std::vector NegacyclicMatrixU32(absl::Span b) { - size_t n = b.size(); - std::vector res(n * n, 0); - - for (size_t i = 0; i < n; ++i) { - for (size_t j = 0; j < n; ++j) { - uint32_t b_val = b[(n + i - j) % n]; - if (i < j) { - b_val = -b_val; - } - res[j * n + i] = b_val; - } - } - - return res; -} - -std::vector NegacyclicPermU32(const std::vector& a) { - size_t n = a.size(); - std::vector res(n); - - if (n > 0) { - res[0] = a[0]; - for (size_t i = 1; i < n; ++i) { - uint32_t val = a[n - i]; - res[i] = 0 - val; - } - } - return res; -} - -} // namespace psi::ypir \ No newline at end of file diff --git a/psi/algorithm/ypir/convolution.h b/psi/algorithm/ypir/convolution.h deleted file mode 100644 index df45cb46..00000000 --- a/psi/algorithm/ypir/convolution.h +++ /dev/null @@ -1,41 +0,0 @@ -#pragma once - -#include -#include -#include -#include - -#include "psi/algorithm/spiral/params.h" - -namespace psi::ypir { - -using Params = spiral::Params; - -class Convolution { - public: - explicit Convolution(size_t n); - - const Params& params() const { return params_; } - - std::vector ntt(const std::vector& a) const; - std::vector raw(const std::vector& a) const; - - std::vector pointwise_mul(const std::vector& a, - const std::vector& b) const; - - std::vector convolve(const std::vector& a, - const std::vector& b) const; - - private: - size_t n_; - Params params_; -}; - -std::vector NaiveNegacyclicConvolve(const std::vector& a, - const std::vector& b); - -std::vector NegacyclicMatrixU32(const std::vector& b); - -std::vector NegacyclicPermU32(const std::vector& a); - -} // namespace psi::ypir \ No newline at end of file diff --git a/psi/algorithm/ypir/entry.cc b/psi/algorithm/ypir/entry.cc new file mode 100644 index 00000000..58291773 --- /dev/null +++ b/psi/algorithm/ypir/entry.cc @@ -0,0 +1,241 @@ +#include "psi/algorithm/ypir/entry.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "absl/strings/escaping.h" +#include "fmt/format.h" +#include "spdlog/spdlog.h" +#include "yacl/base/byte_container_view.h" +#include "yacl/base/exception.h" + +#include "psi/algorithm/pir_interface/pir_db.h" +#include "psi/algorithm/ypir/client.h" +#include "psi/algorithm/ypir/params.h" +#include "psi/algorithm/ypir/server.h" + +namespace psi::ypir { +namespace { + +constexpr char kQueryCountTag[] = "ypir/query_count"; + +std::string TrimAscii(std::string_view text) { + size_t begin = 0; + size_t end = text.size(); + while (begin < end && + std::isspace(static_cast(text[begin])) != 0) { + ++begin; + } + while (end > begin && + std::isspace(static_cast(text[end - 1])) != 0) { + --end; + } + return std::string(text.substr(begin, end - begin)); +} + +uint8_t ParseHexNibble(char ch) { + if (ch >= '0' && ch <= '9') { + return static_cast(ch - '0'); + } + if (ch >= 'a' && ch <= 'f') { + return static_cast(10 + ch - 'a'); + } + if (ch >= 'A' && ch <= 'F') { + return static_cast(10 + ch - 'A'); + } + YACL_THROW("invalid hex character: {}", ch); +} + +std::vector ParseHexBytes(std::string text, size_t value_bytes) { + if (text.size() >= 2 && text[0] == '0' && + (text[1] == 'x' || text[1] == 'X')) { + text = text.substr(2); + } + YACL_ENFORCE_EQ(text.size(), value_bytes * 2, + "hex value width mismatch, expect {} bytes", value_bytes); + std::vector out(value_bytes, 0); + for (size_t i = 0; i < value_bytes; ++i) { + out[i] = static_cast((ParseHexNibble(text[2 * i]) << 4) | + ParseHexNibble(text[2 * i + 1])); + } + return out; +} + +std::vector ReadLines(const std::string& path) { + std::ifstream input(path); + YACL_ENFORCE(input.is_open(), "failed to open file: {}", path); + + std::vector lines; + std::string line; + while (std::getline(input, line)) { + auto trimmed = TrimAscii(line); + if (!trimmed.empty()) { + lines.push_back(std::move(trimmed)); + } + } + return lines; +} + +void WriteLines(const std::string& path, const std::vector& lines) { + std::ofstream output(path, std::ios::out | std::ios::trunc); + YACL_ENFORCE(output.is_open(), "failed to open output file: {}", path); + for (const auto& line : lines) { + output << line << '\n'; + } +} + +template +yacl::Buffer SerializeScalar(T value) { + yacl::Buffer out(sizeof(T)); + std::memcpy(out.data(), &value, sizeof(T)); + return out; +} + +template +T DeserializeScalar(const yacl::ByteContainerView& buffer) { + YACL_ENFORCE_EQ(buffer.size(), sizeof(T)); + T out = 0; + std::memcpy(&out, buffer.data(), sizeof(T)); + return out; +} + +std::string QueryTag(uint64_t idx) { return fmt::format("ypir/query/{}", idx); } + +std::string ResponseTag(uint64_t idx) { + return fmt::format("ypir/response/{}", idx); +} + +YpirParameters BuildParameters(YpirMode mode, uint64_t db_rows, uint64_t db_cols, + uint64_t item_size_bits) { + YACL_ENFORCE_GT(db_rows, 0U); + YACL_ENFORCE_GT(db_cols, 0U); + YACL_ENFORCE_GT(item_size_bits, 0U); + + if (mode == YpirMode::kSimplepir) { + return CreateParamsForShapeSimplePIR(db_rows, db_cols, item_size_bits); + } + return CreateParamsForShapeDoublePIR(db_rows, db_cols, item_size_bits); +} + +std::vector> LoadDatabaseRows(const std::string& db_file, + size_t value_bytes, + uint64_t num_items) { + const auto lines = ReadLines(db_file); + YACL_ENFORCE_EQ(lines.size(), num_items, + "db_file must contain exactly {} values", num_items); + + std::vector> rows; + rows.reserve(lines.size()); + for (const auto& line : lines) { + rows.push_back(ParseHexBytes(line, value_bytes)); + } + return rows; +} + +std::vector LoadQueryIndices(const std::string& query_file, + uint64_t num_items) { + const auto lines = ReadLines(query_file); + std::vector indices; + indices.reserve(lines.size()); + for (const auto& line : lines) { + uint64_t raw_idx = std::stoull(line); + YACL_ENFORCE_LT(raw_idx, num_items, "query index out of range"); + indices.push_back(raw_idx); + } + return indices; +} + +std::vector EncodeOutputLines( + const std::vector>& values) { + std::vector out; + out.reserve(values.size()); + for (const auto& value : values) { + out.push_back( + absl::BytesToHexString(absl::string_view( + reinterpret_cast(value.data()), value.size()))); + } + return out; +} + +template +int RunSenderWithServer(const YpirParameters& params, + const YpirSenderOptions& options, + std::shared_ptr lctx) { + YpirServer server(params); + server.GenerateFromRawData(psi::pir::RawDatabase( + LoadDatabaseRows(options.db_file, params.value_bytes, params.NumItems()))); + + lctx->ConnectToMesh(); + const uint64_t query_count = + DeserializeScalar(lctx->Recv(lctx->NextRank(), kQueryCountTag)); + for (uint64_t idx = 0; idx < query_count; ++idx) { + auto query = lctx->Recv(lctx->NextRank(), QueryTag(idx)); + auto response = server.Response(query, yacl::Buffer()); + lctx->Send(lctx->NextRank(), response, ResponseTag(idx)); + } + return 0; +} + +} // namespace + +int SenderOnline(const YpirSenderOptions& options, + std::shared_ptr lctx) { + YACL_ENFORCE(lctx != nullptr, "link context is required for YPIR sender"); + const auto params = BuildParameters(options.mode, options.db_rows, + options.db_cols, options.item_size_bits); + + SPDLOG_INFO("Starting YPIR sender, mode={}, db_rows={}, db_cols={}", + params.mode == YpirMode::kSimplepir ? "simplepir" : "doublepir", + params.db_rows, params.db_cols); + + if (params.mode == YpirMode::kSimplepir) { + YACL_ENFORCE_LE(params.value_bytes, sizeof(uint16_t), + "SimplePIR launcher currently supports up to 16-bit values"); + if (params.value_bytes == 1) { + return RunSenderWithServer(params, options, std::move(lctx)); + } + return RunSenderWithServer(params, options, std::move(lctx)); + } + + YACL_ENFORCE_EQ(params.value_bytes, 1U, + "DoublePIR launcher currently supports 8-bit values"); + return RunSenderWithServer(params, options, std::move(lctx)); +} + +int ReceiverOnline(const YpirReceiverOptions& options, + std::shared_ptr lctx) { + YACL_ENFORCE(lctx != nullptr, "link context is required for YPIR receiver"); + const auto params = BuildParameters(options.mode, options.db_rows, + options.db_cols, options.item_size_bits); + const auto query_indices = LoadQueryIndices(options.query_file, params.NumItems()); + + SPDLOG_INFO("Starting YPIR receiver, mode={}, query_count={}", + params.mode == YpirMode::kSimplepir ? "simplepir" : "doublepir", + query_indices.size()); + + YpirClient client(params); + lctx->ConnectToMesh(); + lctx->Send(lctx->NextRank(), SerializeScalar(query_indices.size()), + kQueryCountTag); + + std::vector> decoded_values; + decoded_values.reserve(query_indices.size()); + for (size_t idx = 0; idx < query_indices.size(); ++idx) { + const auto raw_idx = query_indices[idx]; + auto query = client.GenerateIndexQuery(raw_idx); + lctx->Send(lctx->NextRank(), query, QueryTag(idx)); + auto response = lctx->Recv(lctx->NextRank(), ResponseTag(idx)); + decoded_values.push_back(client.DecodeIndexResponse(response, raw_idx)); + } + + WriteLines(options.output_file, EncodeOutputLines(decoded_values)); + return 0; +} + +} // namespace psi::ypir diff --git a/psi/algorithm/ypir/entry.h b/psi/algorithm/ypir/entry.h new file mode 100644 index 00000000..6c273573 --- /dev/null +++ b/psi/algorithm/ypir/entry.h @@ -0,0 +1,36 @@ +#pragma once + +#include +#include +#include + +#include "yacl/link/context.h" + +#include "psi/algorithm/ypir/types.h" + +namespace psi::ypir { + +struct YpirSenderOptions { + YpirMode mode = YpirMode::kSimplepir; + uint64_t db_rows = 0; + uint64_t db_cols = 0; + uint64_t item_size_bits = 0; + std::string db_file; +}; + +struct YpirReceiverOptions { + YpirMode mode = YpirMode::kSimplepir; + uint64_t db_rows = 0; + uint64_t db_cols = 0; + uint64_t item_size_bits = 0; + std::string query_file; + std::string output_file; +}; + +int SenderOnline(const YpirSenderOptions& options, + std::shared_ptr lctx); + +int ReceiverOnline(const YpirReceiverOptions& options, + std::shared_ptr lctx); + +} // namespace psi::ypir diff --git a/psi/algorithm/ypir/entry_test.cc b/psi/algorithm/ypir/entry_test.cc new file mode 100644 index 00000000..994d8b0c --- /dev/null +++ b/psi/algorithm/ypir/entry_test.cc @@ -0,0 +1,164 @@ +#include "psi/algorithm/ypir/entry.h" + +#include +#include +#include +#include +#include + +#include "absl/strings/escaping.h" +#include "gtest/gtest.h" +#include "yacl/link/test_util.h" + +#include "psi/algorithm/ypir/params.h" + +namespace psi::ypir { +namespace { + +std::string HexByte(uint64_t value) { + std::vector bytes = {static_cast(value)}; + return absl::BytesToHexString(absl::string_view( + reinterpret_cast(bytes.data()), bytes.size())); +} + +std::string HexUint16(uint64_t value) { + const uint16_t narrowed = static_cast(value); + return absl::BytesToHexString(absl::string_view( + reinterpret_cast(&narrowed), sizeof(narrowed))); +} + +void WriteLines(const std::filesystem::path& path, + const std::vector& lines) { + std::ofstream output(path, std::ios::out | std::ios::trunc); + ASSERT_TRUE(output.is_open()); + for (const auto& line : lines) { + output << line << '\n'; + } +} + +std::vector ReadLines(const std::filesystem::path& path) { + std::ifstream input(path); + EXPECT_TRUE(input.is_open()); + std::vector lines; + std::string line; + while (std::getline(input, line)) { + if (!line.empty()) { + lines.push_back(line); + } + } + return lines; +} + +TEST(YpirEntryTest, SimplepirOnlineFlowWorksWithHexFiles) { + const auto params = CreateSmallTestParamsSimplePIR(); + const auto tmp_dir = + std::filesystem::temp_directory_path() / "ypir_entry_simplepir"; + std::filesystem::create_directories(tmp_dir); + + const auto db_path = tmp_dir / "db.hex"; + const auto query_path = tmp_dir / "query.txt"; + const auto output_path = tmp_dir / "result.hex"; + + std::vector db_lines; + db_lines.reserve(params.NumItems()); + for (uint64_t raw_idx = 0; raw_idx < params.NumItems(); ++raw_idx) { + const uint64_t row = raw_idx / params.db_cols; + const uint64_t col = raw_idx % params.db_cols; + db_lines.push_back( + HexUint16((row * 17 + col * 3) % params.spiral_params.PtModulus())); + } + WriteLines(db_path, db_lines); + WriteLines(query_path, {"0", "123456", "1048575"}); + + auto lctxs = yacl::link::test::SetupWorld(2); + YpirSenderOptions sender_options; + sender_options.mode = YpirMode::kSimplepir; + sender_options.db_rows = params.db_rows; + sender_options.db_cols = params.db_cols; + sender_options.item_size_bits = 16; + sender_options.db_file = db_path; + + YpirReceiverOptions receiver_options; + receiver_options.mode = YpirMode::kSimplepir; + receiver_options.db_rows = params.db_rows; + receiver_options.db_cols = params.db_cols; + receiver_options.item_size_bits = 16; + receiver_options.query_file = query_path; + receiver_options.output_file = output_path; + + auto sender = std::async(std::launch::async, [&] { + return SenderOnline(sender_options, lctxs[0]); + }); + auto receiver = std::async(std::launch::async, [&] { + return ReceiverOnline(receiver_options, lctxs[1]); + }); + + EXPECT_EQ(sender.get(), 0); + EXPECT_EQ(receiver.get(), 0); + + EXPECT_EQ(ReadLines(output_path), + (std::vector{ + HexUint16(0), + HexUint16((120ULL * 17 + 576ULL * 3) % + params.spiral_params.PtModulus()), + HexUint16((1023ULL * 17 + 1023ULL * 3) % + params.spiral_params.PtModulus())})); + + std::filesystem::remove_all(tmp_dir); +} + +TEST(YpirEntryTest, DoublepirOnlineFlowWorksWithHexFiles) { + const auto params = CreateSmallTestParamsDoublePIR(); + const auto tmp_dir = + std::filesystem::temp_directory_path() / "ypir_entry_doublepir"; + std::filesystem::create_directories(tmp_dir); + + const auto db_path = tmp_dir / "db.hex"; + const auto query_path = tmp_dir / "query.txt"; + const auto output_path = tmp_dir / "result.hex"; + + std::vector db_lines; + db_lines.reserve(params.NumItems()); + for (uint64_t raw_idx = 0; raw_idx < params.NumItems(); ++raw_idx) { + const uint64_t row = raw_idx / params.db_cols; + const uint64_t col = raw_idx % params.db_cols; + db_lines.push_back(HexByte((row + col) % 251)); + } + WriteLines(db_path, db_lines); + WriteLines(query_path, {"0", "113886", "1048575"}); + + auto lctxs = yacl::link::test::SetupWorld(2); + YpirSenderOptions sender_options; + sender_options.mode = YpirMode::kDoublepir; + sender_options.db_rows = params.db_rows; + sender_options.db_cols = params.db_cols; + sender_options.item_size_bits = 8; + sender_options.db_file = db_path; + + YpirReceiverOptions receiver_options; + receiver_options.mode = YpirMode::kDoublepir; + receiver_options.db_rows = params.db_rows; + receiver_options.db_cols = params.db_cols; + receiver_options.item_size_bits = 8; + receiver_options.query_file = query_path; + receiver_options.output_file = output_path; + + auto sender = std::async(std::launch::async, [&] { + return SenderOnline(sender_options, lctxs[0]); + }); + auto receiver = std::async(std::launch::async, [&] { + return ReceiverOnline(receiver_options, lctxs[1]); + }); + + EXPECT_EQ(sender.get(), 0); + EXPECT_EQ(receiver.get(), 0); + + EXPECT_EQ(ReadLines(output_path), + (std::vector{HexByte(0), HexByte((111ULL + 222ULL) % 251), + HexByte((1023ULL + 1023ULL) % 251)})); + + std::filesystem::remove_all(tmp_dir); +} + +} // namespace +} // namespace psi::ypir diff --git a/psi/algorithm/ypir/fast_dot_product_test.cc b/psi/algorithm/ypir/fast_dot_product_test.cc deleted file mode 100644 index eb002396..00000000 --- a/psi/algorithm/ypir/fast_dot_product_test.cc +++ /dev/null @@ -1,106 +0,0 @@ -// Test FastBatchedDotProduct to verify correctness -#include "gtest/gtest.h" -#include "spdlog/spdlog.h" - -#include "psi/algorithm/spiral/params.h" -#include "psi/algorithm/ypir/util.h" - -namespace psi::ypir { - -using namespace psi::spiral; - -TEST(FastDotProductTest, AllZerosInput) { - // Test with all-zeros database - size_t poly_len = 2048; - std::vector moduli = {268369921, 249561089}; - double noise_width = 6.4; - - PolyMatrixParams poly_matrix_params(2, 256, 21, 4, 8, 8, 1); - QueryParams query_params(1, 1, 1); - - Params params(poly_len, std::move(moduli), noise_width, - std::move(poly_matrix_params), std::move(query_params)); - - size_t db_rows = 1ULL << (params.DbDim1() + params.PolyLenLog2()); - size_t db_cols = params.Instances() * params.PolyLen(); - - // Create all-zeros database with uint8_t - std::vector db(db_rows * db_cols, 0); - - // Create query vector (all zeros except position 0) - std::vector query(db_rows, 0); - query[0] = 1; - - // Result vector - std::vector result(db_cols, 0); - - SPDLOG_INFO("Testing FastBatchedDotProduct with all-zeros database"); - SPDLOG_INFO("db_rows={}, db_cols={}", db_rows, db_cols); - - // Call FastBatchedDotProduct - // Signature: (params, c, a, a_elems, b_t, b_rows, b_cols) - FastBatchedDotProduct(params, result.data(), query.data(), db_rows, - db.data(), db_rows, db_cols); - - SPDLOG_INFO("Result size: {}", result.size()); - - // Check result - should be all zeros since database is all zeros - bool all_zero = true; - for (size_t i = 0; i < std::min(size_t(10), result.size()); ++i) { - SPDLOG_INFO(" result[{}] = {}", i, result[i]); - if (result[i] != 0) { - all_zero = false; - } - } - - EXPECT_TRUE(all_zero) - << "FastBatchedDotProduct with all-zeros should return all zeros"; -} - -TEST(FastDotProductTest, SimplePattern) { - // Test with pattern database - size_t poly_len = 2048; - std::vector moduli = {268369921, 249561089}; - double noise_width = 6.4; - - PolyMatrixParams poly_matrix_params(2, 256, 21, 4, 8, 8, 1); - QueryParams query_params(1, 1, 1); - - Params params(poly_len, std::move(moduli), noise_width, - std::move(poly_matrix_params), std::move(query_params)); - - size_t db_rows = 1ULL << (params.DbDim1() + params.PolyLenLog2()); - size_t db_cols = params.Instances() * params.PolyLen(); - - // Create database with pattern: db[i] = i % 256 - std::vector db(db_rows * db_cols); - for (size_t col = 0; col < db_cols; ++col) { - for (size_t row = 0; row < db_rows; ++row) { - // Column-major storage: db[col * db_rows + row] - db[col * db_rows + row] = - static_cast((col * db_rows + row) % 256); - } - } - - // Create query selecting first row - std::vector query(db_rows, 0); - query[0] = 1; // Select first row - - // Result vector - std::vector result(db_cols, 0); - - SPDLOG_INFO("Testing FastBatchedDotProduct with pattern database"); - SPDLOG_INFO("db_rows={}, db_cols={}", db_rows, db_cols); - - FastBatchedDotProduct(params, result.data(), query.data(), db_rows, - db.data(), db_rows, db_cols); - - SPDLOG_INFO("Result data (first 10):"); - for (size_t i = 0; i < std::min(size_t(10), result.size()); ++i) { - // Expected value is the first element of column i (row 0) - uint64_t expected = db[i * db_rows + 0]; - SPDLOG_INFO(" result[{}] = {} (expected {})", i, result[i], expected); - } -} - -} // namespace psi::ypir diff --git a/psi/algorithm/ypir/integration_test.cc b/psi/algorithm/ypir/integration_test.cc deleted file mode 100644 index bbbaead1..00000000 --- a/psi/algorithm/ypir/integration_test.cc +++ /dev/null @@ -1,758 +0,0 @@ -// Copyright 2025 The secretflow authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include -#include - -#include "gtest/gtest.h" -#include "spdlog/spdlog.h" - -#include "psi/algorithm/spiral/params.h" -#include "psi/algorithm/spiral/spiral_client.h" -#include "psi/algorithm/spiral/util.h" -#include "psi/algorithm/ypir/client.h" -#include "psi/algorithm/ypir/server.h" - -using namespace psi::ypir; -using namespace psi::spiral; - -class YPIRIntegrationTest : public ::testing::Test { - protected: - void SetUp() override { spdlog::set_level(spdlog::level::info); } -}; - -TEST_F(YPIRIntegrationTest, SimplePIR_1GB) { - // Setup parameters - 1GB database test - std::size_t poly_len{2048}; - std::vector moduli{268369921, 249561089}; - double noise_width{16.042421}; - - // 1GB SimplePIR: db_dim_1=5, instances=4 - // 2^(5+11)=65536 rows × 4*2048=8192 cols = 512M elements = 1GB (uint16_t) - PolyMatrixParams poly_matrix_params(2, 16384, 21, 4, 8, 8, 4); - QueryParams query_params(5, 1, 4); // db_dim_1=5, db_dim_2=1, instances=4 - - Params params(poly_len, std::move(moduli), noise_width, - std::move(poly_matrix_params), std::move(query_params)); - - size_t db_rows = 1ULL << (params.DbDim1() + params.PolyLenLog2()); - size_t db_cols = params.Instances() * params.PolyLen(); - size_t db_size = db_rows * db_cols; - - SPDLOG_INFO( - "SimplePIR Performance Test (1GB): db_rows={}, db_cols={}, db_size={} " - "(~{} MB), pt_modulus={}", - db_rows, db_cols, db_size, (db_size * sizeof(uint16_t)) / (1024 * 1024), - params.PtModulus()); - - // SimplePIR with pt_modulus=16384 requires uint16_t database - std::vector db(db_size); - std::random_device rd; - std::mt19937 gen(42); // Fixed seed for reproducibility - std::uniform_int_distribution<> dis(0, params.PtModulus() - 1); - for (auto& val : db) { - val = static_cast(dis(gen)); - } - - // Add some known values for verification at strategic positions - db[0] = 100; - db[1] = 101; - db[100] = 200; - db[1000] = 250; - db[100000] = 300; // Test larger index - - SPDLOG_INFO( - "Known test values: db[0]={}, db[1]={}, db[100]={}, db[1000]={}, " - "db[100000]={}", - db[0], db[1], db[100], db[1000], db[100000]); - - // Create server - auto server_start = std::chrono::high_resolution_clock::now(); - YServer server(params, db, true, false, true); - auto server_elapsed = std::chrono::duration_cast( - std::chrono::high_resolution_clock::now() - server_start); - SPDLOG_INFO("Server setup: {} ms", server_elapsed.count()); - - // Offline precomputation - OfflinePrecomputedValues offline_vals; - try { - absl::Span empty_span; - std::string_view empty_path; - - auto offline_start = std::chrono::high_resolution_clock::now(); - offline_vals = - server.PerformOfflinePrecomputationSimplepir(empty_span, empty_path); - - auto offline_elapsed = - std::chrono::duration_cast( - std::chrono::high_resolution_clock::now() - offline_start); - SPDLOG_INFO("Offline precomputation: {} ms", offline_elapsed.count()); - EXPECT_GT(offline_elapsed.count(), 0); - EXPECT_GT(offline_vals.hint_0.size(), 0); - EXPECT_GT(offline_vals.prepacked_lwe.size(), 0); - } catch (const std::exception& e) { - SPDLOG_ERROR("Exception in offline precomputation: {}", e.what()); - throw; - } - - // Test querying multiple indices to verify SimplePIR correctness - // Test known values at different positions - std::vector test_indices = {0, 1, 100, 1000, 100000}; - std::vector expected_values = {100, 101, 200, 250, 300}; - - for (size_t i = 0; i < test_indices.size(); ++i) { - size_t target_idx = test_indices[i]; - uint16_t expected_value = expected_values[i]; - size_t test_row_idx = target_idx / db_cols; - size_t test_col_idx = target_idx % db_cols; - - SPDLOG_INFO("\n=== Query {}/{}: index={} (row={}, col={}), expected={} ===", - i + 1, test_indices.size(), target_idx, test_row_idx, - test_col_idx, expected_value); - - // Client generates keys and query - auto client_start = std::chrono::high_resolution_clock::now(); - uint128_t fixed_seed = yacl::MakeUint128(0, 12345); - SpiralClient spiral_client(params, fixed_seed); - YClient y_client(spiral_client, params, fixed_seed); - - auto simple_query = y_client.GenerateFullQuerySimplepir(target_idx); - - auto client_elapsed = std::chrono::duration_cast( - std::chrono::high_resolution_clock::now() - client_start); - - // Calculate query size breakdown - size_t packed_query_size = - simple_query.packed_query_row.size() * sizeof(uint32_t); - size_t pack_params_size = - simple_query.pack_pub_params_row_1s_pm.size() * sizeof(uint64_t); - size_t total_query_size = packed_query_size + pack_params_size; - - SPDLOG_INFO("Client query generation: {} ms", client_elapsed.count()); - SPDLOG_INFO( - " Query breakdown: packed_query={} KB ({} elements), pack_params={} " - "KB ({} elements), total={} KB", - packed_query_size / 1024, simple_query.packed_query_row.size(), - pack_params_size / 1024, simple_query.pack_pub_params_row_1s_pm.size(), - total_query_size / 1024); - if (i == 0) { - SPDLOG_INFO( - " NOTE: pack_params is the same for all queries from same client " - "and can be reused"); - SPDLOG_INFO( - " In practice, send pack_params once, then only send " - "packed_query (64 KB) for subsequent queries"); - } - - // Server online computation - auto online_start = std::chrono::high_resolution_clock::now(); - - std::vector> pack_params_spans; - if (!simple_query.pack_pub_params_row_1s_pm.empty()) { - pack_params_spans.push_back( - absl::MakeConstSpan(simple_query.pack_pub_params_row_1s_pm)); - } - - auto response = server.PerformOnlineComputationSimplepir( - absl::MakeConstSpan(simple_query.packed_query_row), offline_vals, - absl::MakeConstSpan(pack_params_spans)); - - auto online_elapsed = std::chrono::duration_cast( - std::chrono::high_resolution_clock::now() - online_start); - - // Calculate response size - size_t response_size = response.size(); - - SPDLOG_INFO("Server online: {} ms, Response size: {} bytes (~{} KB)", - online_elapsed.count(), response_size, response_size / 1024); - - // Client decodes response - auto decode_start = std::chrono::high_resolution_clock::now(); - YPIRClient ypir_client(params); - auto decoded_values = - ypir_client.DecodeResponseSimplepirYClient(params, y_client, response); - auto decode_elapsed = std::chrono::duration_cast( - std::chrono::high_resolution_clock::now() - decode_start); - SPDLOG_INFO("Client decode: {} ms", decode_elapsed.count()); - - // Verify correctness - SimplePIR returns entire row - EXPECT_EQ(decoded_values.size(), db_cols); - - uint64_t decoded_value = decoded_values[test_col_idx]; - SPDLOG_INFO("Decoded: {}, Expected: {}", decoded_value, expected_value); - - EXPECT_EQ(decoded_value, expected_value) - << "Query " << i + 1 << " failed at index " << target_idx; - - if (decoded_value == expected_value) { - SPDLOG_INFO("✓ Query {} passed", i + 1); - } - } - - SPDLOG_INFO("\n✓✓✓ All SimplePIR 1GB queries passed! ✓✓✓"); -} - -// DoublePIR test based on Rust scheme.rs test_ypir_basic -// This tests the full DoublePIR flow with a smaller database for testing -TEST_F(YPIRIntegrationTest, DoublePIRBasicFlow) { - SPDLOG_INFO("=== DoublePIR Basic Flow Test (Rust-aligned) ==="); - - // Align with Rust test: params_for_scenario(1 << 25, 1) - // This creates 32MB database with db_dim_1=2, db_dim_2=1 - std::size_t poly_len = 2048; - std::vector moduli = {268369921, 249561089}; - double noise_width = 6.4; - - // Parameters aligned with Rust: - // - pt_modulus = 32768 (p = 32768 in Rust) - // - q2_bits = 28 - // - t_exp_left = 3 - // - db_dim_1 = 2, db_dim_2 = 1 - PolyMatrixParams poly_matrix_params(2, 32768, 21, 4, 8, 8, 1); - QueryParams query_params(2, 1, 1); // db_dim_1=2, db_dim_2=1, instances=1 - - Params params(poly_len, std::move(moduli), noise_width, - std::move(poly_matrix_params), std::move(query_params)); - - size_t db_rows = 1ULL << (params.DbDim1() + params.PolyLenLog2()); - size_t db_cols = 1ULL << (params.DbDim2() + params.PolyLenLog2()); - size_t db_size = db_rows * db_cols; - - SPDLOG_INFO( - "DoublePIR test: db_rows={}, db_cols={}, db_size={} (~{} KB), " - "pt_modulus={}", - db_rows, db_cols, db_size, db_size / 1024, params.PtModulus()); - - // Create database counter % 256 - std::vector db(db_size); - for (size_t i = 0; i < db_size; ++i) { - db[i] = static_cast(i % 256); - } - - SPDLOG_INFO( - "Database created with sequential values (Rust-aligned): db[i] = i % " - "256"); - SPDLOG_INFO(" db[0-9]: [{}, {}, {}, {}, {}, {}, {}, {}, {}, {}]", - static_cast(db[0]), static_cast(db[1]), - static_cast(db[2]), static_cast(db[3]), - static_cast(db[4]), static_cast(db[5]), - static_cast(db[6]), static_cast(db[7]), - static_cast(db[8]), static_cast(db[9])); - SPDLOG_INFO(" Column 1 first element: db[8192]={}", - static_cast(db[8192])); - - // Create server (DoublePIR uses uint8_t database) - auto server_start = std::chrono::high_resolution_clock::now(); - YPirServer server( - params, db, false, false, - true); // is_simplepir=false, inp_transposed=false, pad_rows=true - auto server_elapsed = std::chrono::duration_cast( - std::chrono::high_resolution_clock::now() - server_start); - SPDLOG_INFO("Server setup: {} ms", server_elapsed.count()); - - // Offline precomputation - OfflinePrecomputedValues offline_vals; - auto offline_start = std::chrono::high_resolution_clock::now(); - offline_vals = server.PerformOfflinePrecomputation(); - auto offline_elapsed = std::chrono::duration_cast( - std::chrono::high_resolution_clock::now() - offline_start); - SPDLOG_INFO("Offline precomputation: {} ms", offline_elapsed.count()); - EXPECT_GT(offline_elapsed.count(), 0); - EXPECT_GT(offline_vals.hint_0.size(), 0); - EXPECT_GT(offline_vals.hint_1.size(), 0); - EXPECT_NE(offline_vals.smaller_server, nullptr); - - // Test querying index 50 (expected value: 50) - row 0, col 50 - size_t target_idx = 50; - uint8_t expected_value = db[target_idx]; - size_t target_row = target_idx / db_cols; - size_t target_col = target_idx % db_cols; - SPDLOG_INFO("Querying index {} (row={}, col={}, expected value: {})", - target_idx, target_row, target_col, - static_cast(expected_value)); - SPDLOG_INFO( - " Row-major: db[0-3]=[{}, {}, {}, {}], db[8192-8195]=[{}, {}, {}, {}]", - static_cast(db[0]), static_cast(db[1]), static_cast(db[2]), - static_cast(db[3]), static_cast(db[8192]), - static_cast(db[8193]), static_cast(db[8194]), - static_cast(db[8195])); - - // Client generates keys and query - auto client_start = std::chrono::high_resolution_clock::now(); - uint128_t fixed_seed = yacl::MakeUint128(0, 12345); - SpiralClient spiral_client(params, fixed_seed); - YClient y_client(spiral_client, params, fixed_seed); - - // Create LWE client for server-side debugging (same seed as client) - LWEParams lwe_params = LWEParams::Default(); - LWEClient debug_lwe_client = LWEClient::FromSeed(lwe_params, fixed_seed); - SPDLOG_INFO( - "Created debug LWE client with same seed for server-side decryption"); - - auto full_query = y_client.GenerateFullQuery(target_idx); - - auto client_elapsed = std::chrono::duration_cast( - std::chrono::high_resolution_clock::now() - client_start); - SPDLOG_INFO("Client query generation: {} ms", client_elapsed.count()); - - // Server online computation - auto online_start = std::chrono::high_resolution_clock::now(); - - // Prepare queries for DoublePIR - std::vector first_dim_queries_packed = full_query.packed_query_row; - - SPDLOG_INFO("First dim query size: {}", first_dim_queries_packed.size()); - SPDLOG_INFO("Second dim query col size: {}", - full_query.packed_query_col.size()); - SPDLOG_INFO("Pack pub params size: {}", - full_query.pack_pub_params_row_1s_pm.size()); - - std::vector, std::vector>> - second_dim_queries; - second_dim_queries.push_back( - {full_query.packed_query_col, full_query.pack_pub_params_row_1s_pm}); - - // Pass debug LWE client to server for verification - server.SetDebugLweClient(&debug_lwe_client); - server.SetDebugOriginalDb(db, db_rows, db_cols); - - SPDLOG_INFO("Calling PerformOnlineComputation..."); - std::vector> responses; - try { - responses = server.PerformOnlineComputation( - offline_vals, first_dim_queries_packed, second_dim_queries); - } catch (const std::exception& e) { - SPDLOG_ERROR("Exception in PerformOnlineComputation: {}", e.what()); - throw; - } - - auto online_elapsed = std::chrono::duration_cast( - std::chrono::high_resolution_clock::now() - online_start); - SPDLOG_INFO("Server online computation: {} ms", online_elapsed.count()); - - ASSERT_EQ(responses.size(), 1) << "Expected 1 response"; - - // Client decodes response - auto decode_start = std::chrono::high_resolution_clock::now(); - YPIRClient ypir_client(params); - uint64_t decoded_value = - ypir_client.DecodeResponseNormalYClient(params, y_client, responses[0]); - auto decode_elapsed = std::chrono::duration_cast( - std::chrono::high_resolution_clock::now() - decode_start); - SPDLOG_INFO("Client decode: {} ms", decode_elapsed.count()); - - // Verify correctness - SPDLOG_INFO("Decoded value: {}, Expected: {}", decoded_value, - static_cast(expected_value)); - EXPECT_EQ(decoded_value, static_cast(expected_value)) - << "Decoded value mismatch"; - - SPDLOG_INFO("✓ DoublePIR correctness verified!"); -} - -// Test DoublePIR with multiple different indices to verify robustness -TEST_F(YPIRIntegrationTest, DoublePIRMultipleIndices) { - SPDLOG_INFO("=== DoublePIR Multiple Indices Test ==="); - - std::size_t poly_len = 2048; - std::vector moduli = {268369921, 249561089}; - double noise_width = 6.4; - PolyMatrixParams poly_matrix_params(2, 32768, 21, 4, 8, 8, 1); - QueryParams query_params(2, 1, 1); - Params params(poly_len, std::move(moduli), noise_width, - std::move(poly_matrix_params), std::move(query_params)); - - size_t db_rows = 1ULL << (params.DbDim1() + params.PolyLenLog2()); - size_t db_cols = 1ULL << (params.DbDim2() + params.PolyLenLog2()); - size_t db_size = db_rows * db_cols; - - SPDLOG_INFO("Database: rows={}, cols={}, size={}", db_rows, db_cols, db_size); - - // Create database with sequential values - std::vector db(db_size); - for (size_t i = 0; i < db_size; ++i) { - db[i] = static_cast(i % 256); - } - - YPirServer server(params, db, false, false, true); - auto offline_vals = server.PerformOfflinePrecomputation(); - - uint128_t fixed_seed = yacl::MakeUint128(0, 12345); - - // Test various indices across different rows and columns - std::vector test_indices = { - 0, // First element (row=0, col=0) - 50, // Same row, different col (row=0, col=50) - }; - - // Create client once with fixed seed to ensure deterministic queries - SpiralClient spiral_client(params, fixed_seed); - YClient y_client(spiral_client, params, fixed_seed); - - for (size_t i = 0; i < test_indices.size(); ++i) { - size_t target_idx = test_indices[i]; - uint8_t expected_value = db[target_idx]; - size_t target_row = target_idx / db_cols; - size_t target_col = target_idx % db_cols; - - SPDLOG_INFO("\n--- Query {}/{}: index={} (row={}, col={}), expected={} ---", - i + 1, test_indices.size(), target_idx, target_row, target_col, - static_cast(expected_value)); - - // Fresh offline values for each query - auto offline_vals_copy = server.PerformOfflinePrecomputation(); - - auto full_query = y_client.GenerateFullQuery(target_idx); - - std::vector, std::vector>> - second_dim_queries; - second_dim_queries.push_back( - {full_query.packed_query_col, full_query.pack_pub_params_row_1s_pm}); - - auto responses = server.PerformOnlineComputation( - offline_vals_copy, full_query.packed_query_row, second_dim_queries); - - ASSERT_EQ(responses.size(), 1); - - YPIRClient ypir_client(params); - uint64_t decoded_value = - ypir_client.DecodeResponseNormalYClient(params, y_client, responses[0]); - - SPDLOG_INFO("Decoded: {}, Expected: {}", decoded_value, - static_cast(expected_value)); - - EXPECT_EQ(decoded_value, static_cast(expected_value)) - << "Query " << i + 1 << " failed at index " << target_idx; - - if (decoded_value == static_cast(expected_value)) { - SPDLOG_INFO("✓ Query {} passed", i + 1); - } else { - SPDLOG_ERROR("✗ Query {} FAILED", i + 1); - } - } - - SPDLOG_INFO("\n✓✓✓ All {} DoublePIR queries passed! ✓✓✓", - test_indices.size()); -} -/* -// Test DoublePIR with random database values -TEST_F(YPIRIntegrationTest, DoublePIRRandomDatabase) { - SPDLOG_INFO("=== DoublePIR Random Database Test ==="); - - std::size_t poly_len = 2048; - std::vector moduli = {268369921, 249561089}; - double noise_width = 6.4; - PolyMatrixParams poly_matrix_params(2, 32768, 21, 4, 8, 8, 1); - QueryParams query_params(2, 1, 1); - Params params(poly_len, std::move(moduli), noise_width, - std::move(poly_matrix_params), std::move(query_params)); - - size_t db_rows = 1ULL << (params.DbDim1() + params.PolyLenLog2()); - size_t db_cols = 1ULL << (params.DbDim2() + params.PolyLenLog2()); - size_t db_size = db_rows * db_cols; - - // Create database with random values - std::vector db(db_size); - std::mt19937 gen(42); // Fixed seed for reproducibility - std::uniform_int_distribution<> dis(0, 255); - for (auto& val : db) { - val = static_cast(dis(gen)); - } - - SPDLOG_INFO("Random database created with seed=42"); - SPDLOG_INFO("Sample values: db[0]={}, db[50]={}, db[8192]={}, db[16384]={}", - static_cast(db[0]), static_cast(db[50]), - static_cast(db[8192]), static_cast(db[16384])); - - YPirServer server(params, db, false, false, true); - - uint128_t fixed_seed = yacl::MakeUint128(0, 12345); - - // Test random indices - std::vector test_indices = {0, 50, 1000, 8192, 10000, 20000, 30000}; - - for (size_t i = 0; i < test_indices.size(); ++i) { - size_t target_idx = test_indices[i]; - uint8_t expected_value = db[target_idx]; - size_t target_row = target_idx / db_cols; - size_t target_col = target_idx % db_cols; - - SPDLOG_INFO("\n--- Query {}/{}: index={} (row={}, col={}), expected={} ---", - i + 1, test_indices.size(), target_idx, target_row, target_col, - static_cast(expected_value)); - - auto offline_vals = server.PerformOfflinePrecomputation(); - - SpiralClient spiral_client(params, fixed_seed); - YClient y_client(spiral_client, params, fixed_seed); - auto full_query = y_client.GenerateFullQuery(target_idx); - - std::vector, std::vector>> - second_dim_queries; - second_dim_queries.push_back( - {full_query.packed_query_col, full_query.pack_pub_params_row_1s_pm}); - - auto responses = server.PerformOnlineComputation( - offline_vals, full_query.packed_query_row, second_dim_queries); - - ASSERT_EQ(responses.size(), 1); - - YPIRClient ypir_client(params); - uint64_t decoded_value = - ypir_client.DecodeResponseNormalYClient(params, y_client, responses[0]); - - EXPECT_EQ(decoded_value, static_cast(expected_value)) - << "Query failed at index " << target_idx; - - if (decoded_value == static_cast(expected_value)) { - SPDLOG_INFO("✓ Query {} passed (decoded={}, expected={})", i + 1, - decoded_value, static_cast(expected_value)); - } else { - SPDLOG_ERROR("✗ Query {} FAILED (decoded={}, expected={})", i + 1, - decoded_value, static_cast(expected_value)); - } - } - - SPDLOG_INFO("\n✓✓✓ All random database queries passed! ✓✓✓"); -} - -// Test DoublePIR with larger database (different dimensions) -TEST_F(YPIRIntegrationTest, DoublePIRLargerDatabase) { - SPDLOG_INFO("=== DoublePIR Larger Database Test ==="); - - std::size_t poly_len = 2048; - std::vector moduli = {268369921, 249561089}; - double noise_width = 6.4; - PolyMatrixParams poly_matrix_params(2, 32768, 21, 4, 8, 8, 1); - // Larger database: db_dim_1=3, db_dim_2=2 -> 16384 rows × 8192 cols - QueryParams query_params(3, 2, 1); - Params params(poly_len, std::move(moduli), noise_width, - std::move(poly_matrix_params), std::move(query_params)); - - size_t db_rows = 1ULL << (params.DbDim1() + params.PolyLenLog2()); - size_t db_cols = 1ULL << (params.DbDim2() + params.PolyLenLog2()); - size_t db_size = db_rows * db_cols; - - SPDLOG_INFO("Larger database: rows={}, cols={}, size={} (~{} MB)", db_rows, - db_cols, db_size, db_size / (1024 * 1024)); - - // Create database with sequential values - std::vector db(db_size); - for (size_t i = 0; i < db_size; ++i) { - db[i] = static_cast(i % 256); - } - - YPirServer server(params, db, false, false, true); - - SPDLOG_INFO("Starting offline precomputation for larger database..."); - auto offline_start = std::chrono::high_resolution_clock::now(); - auto offline_vals = server.PerformOfflinePrecomputation(); - auto offline_elapsed = std::chrono::duration_cast( - std::chrono::high_resolution_clock::now() - offline_start); - SPDLOG_INFO("Offline precomputation completed: {} ms", - offline_elapsed.count()); - - uint128_t fixed_seed = yacl::MakeUint128(0, 12345); - - // Test strategic indices in larger database - std::vector test_indices = { - 0, // First element - 100, // Row 0 - 8192, // First col of row 1 - 16384, // First col of row 2 - 100000, // Middle of database - db_size / 2, // Halfway point - db_size - 1 // Last element - }; - - for (size_t i = 0; i < test_indices.size(); ++i) { - size_t target_idx = test_indices[i]; - if (target_idx >= db_size) continue; - - uint8_t expected_value = db[target_idx]; - size_t target_row = target_idx / db_cols; - size_t target_col = target_idx % db_cols; - - SPDLOG_INFO("\n--- Query {}/{}: index={} (row={}, col={}), expected={} ---", - i + 1, test_indices.size(), target_idx, target_row, target_col, - static_cast(expected_value)); - - auto offline_vals_copy = server.PerformOfflinePrecomputation(); - - auto query_start = std::chrono::high_resolution_clock::now(); - SpiralClient spiral_client(params, fixed_seed); - YClient y_client(spiral_client, params, fixed_seed); - auto full_query = y_client.GenerateFullQuery(target_idx); - auto query_elapsed = std::chrono::duration_cast( - std::chrono::high_resolution_clock::now() - query_start); - - auto online_start = std::chrono::high_resolution_clock::now(); - std::vector, std::vector>> - second_dim_queries; - second_dim_queries.push_back( - {full_query.packed_query_col, full_query.pack_pub_params_row_1s_pm}); - - auto responses = server.PerformOnlineComputation( - offline_vals_copy, full_query.packed_query_row, second_dim_queries); - auto online_elapsed = std::chrono::duration_cast( - std::chrono::high_resolution_clock::now() - online_start); - - ASSERT_EQ(responses.size(), 1); - - auto decode_start = std::chrono::high_resolution_clock::now(); - YPIRClient ypir_client(params); - uint64_t decoded_value = - ypir_client.DecodeResponseNormalYClient(params, y_client, responses[0]); - auto decode_elapsed = std::chrono::duration_cast( - std::chrono::high_resolution_clock::now() - decode_start); - - SPDLOG_INFO("Timings: query={} ms, online={} ms, decode={} ms", - query_elapsed.count(), online_elapsed.count(), - decode_elapsed.count()); - - EXPECT_EQ(decoded_value, static_cast(expected_value)) - << "Query failed at index " << target_idx; - - if (decoded_value == static_cast(expected_value)) { - SPDLOG_INFO("✓ Query {} passed", i + 1); - } else { - SPDLOG_ERROR("✗ Query {} FAILED", i + 1); - } - } - - SPDLOG_INFO("\n✓✓✓ All larger database queries passed! ✓✓✓"); -} -*/ - -/* -// Test DoublePIR with multiple queries in one test - query same index 3 times -TEST_F(YPIRIntegrationTest, DoublePIRMultipleQueries) { - SPDLOG_INFO("=== DoublePIR Multiple Queries Test ==="); - - std::size_t poly_len = 2048; - std::vector moduli = {268369921, 249561089}; - double noise_width = 6.4; - PolyMatrixParams poly_matrix_params(2, 32768, 21, 4, 8, 8, 1); - QueryParams query_params(1, 2, 1); - Params params(poly_len, std::move(moduli), noise_width, - std::move(poly_matrix_params), std::move(query_params)); - - size_t db_rows = 1ULL << (params.DbDim1() + params.PolyLenLog2()); - size_t db_cols = 1ULL << (params.DbDim2() + params.PolyLenLog2()); - size_t db_size = db_rows * db_cols; - - std::vector db(db_size); - std::mt19937 gen(42); - std::uniform_int_distribution<> dis(0, 255); - for (auto& val : db) { - val = static_cast(dis(gen)); - } - // Add known test values BEFORE creating server - if (db_size > 1000) { - db[0] = 42; - db[1] = 43; - db[100] = 142; - db[1000] = 200; - } - - // Set test values for multiple queries - // - index 0 (row=0, col=0): same row, first col - // - index 8192 (row=1, col=0): different row, first col - // - index 8193 (row=1, col=1): different row, second col - db[8192] = 99; // row=1, col=0 - db[8193] = 88; // row=1, col=1 - - // Create server once - YPirServer server(params, db, false, false, true); - - // Debug: Print database layout - SPDLOG_INFO("Database layout: db_rows={}, db_cols={}", db_rows, db_cols); - SPDLOG_INFO("Verify expected values: db[0]={}, db[8192]={}, db[8193]={}", - static_cast(db[0]), static_cast(db[8192]), - static_cast(db[8193])); - - // Test 3 different queries - // Need to perform offline precomputation for EACH query because - // PerformOnlineComputation modifies offline_vals.hint_1 - - std::vector test_indices = {0, 8192, 8193}; - std::vector expected_values = {42, 99, 88}; - uint128_t fixed_seed = yacl::MakeUint128(0, 12345); - - for (size_t i = 0; i < test_indices.size(); ++i) { - size_t target_idx = test_indices[i]; - uint8_t expected_value = expected_values[i]; - - size_t target_row = target_idx / db_cols; - size_t target_col = target_idx % db_cols; - - // Perform offline precomputation for each query - OfflinePrecomputedValues offline_vals = -server.PerformOfflinePrecomputation(); - - SPDLOG_INFO("Query {}/3: index={} (row={}, col={}), expected={}", - i + 1, target_idx, target_row, target_col, - static_cast(expected_value)); - - // Create new client for each query with same seed - SpiralClient spiral_client(params, fixed_seed); - YClient y_client(spiral_client, params, fixed_seed); - auto full_query = y_client.GenerateFullQuery(target_idx); - - // Debug: check if queries are actually different - SPDLOG_INFO(" Query row first 5 values: [{}, {}, {}, {}, {}]", - full_query.packed_query_row[0], -full_query.packed_query_row[1], full_query.packed_query_row[2], -full_query.packed_query_row[3], full_query.packed_query_row[4]); - SPDLOG_INFO(" Query col first 5 values: [{}, {}, {}, {}, {}]", - full_query.packed_query_col[0], -full_query.packed_query_col[1], full_query.packed_query_col[2], -full_query.packed_query_col[3], full_query.packed_query_col[4]); - - std::vector first_dim_queries_packed = - full_query.packed_query_row; - std::vector, std::vector>> - second_dim_queries; - second_dim_queries.push_back( - {full_query.packed_query_col, -full_query.pack_pub_params_row_1s_pm}); - - auto responses = server.PerformOnlineComputation( - offline_vals, first_dim_queries_packed, second_dim_queries); - ASSERT_EQ(responses.size(), 1); - - YPIRClient ypir_client(params); - uint64_t decoded_value = - ypir_client.DecodeResponseNormalYClient(params, y_client, -responses[0]); - - SPDLOG_INFO(" Decoded: {}, Expected: {}", decoded_value, - static_cast(expected_value)); - - EXPECT_EQ(decoded_value, static_cast(expected_value)) - << "Query " << i + 1 << " (index=" << target_idx << ") failed: -decoded " - << decoded_value << ", expected " << -static_cast(expected_value); - - if (decoded_value == static_cast(expected_value)) { - SPDLOG_INFO(" ✓ Query {} passed", i + 1); - } else { - SPDLOG_ERROR(" ✗ Query {} FAILED", i + 1); - } - } - - SPDLOG_INFO("✓ All 3 different queries tested!"); -} -*/ \ No newline at end of file diff --git a/psi/algorithm/ypir/aes_prng.cc b/psi/algorithm/ypir/legacy/aes_prng.cc similarity index 95% rename from psi/algorithm/ypir/aes_prng.cc rename to psi/algorithm/ypir/legacy/aes_prng.cc index df287ecc..43cfef8b 100644 --- a/psi/algorithm/ypir/aes_prng.cc +++ b/psi/algorithm/ypir/legacy/aes_prng.cc @@ -12,9 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "psi/algorithm/ypir/aes_prng.h" +#include "psi/algorithm/ypir/legacy/aes_prng.h" -namespace psi::ypir::byhe { +namespace psi::ypir::ypir_internal { AESCTR_PRNG::AESCTR_PRNG() { const uint8_t key[16] = {}; @@ -95,4 +95,4 @@ void AESCTR_PRNG::fill_bytes(uint8_t* dst, size_t len) { } } -} // namespace psi::ypir::byhe +} // namespace psi::ypir::ypir_internal diff --git a/psi/algorithm/ypir/aes_prng.h b/psi/algorithm/ypir/legacy/aes_prng.h similarity index 95% rename from psi/algorithm/ypir/aes_prng.h rename to psi/algorithm/ypir/legacy/aes_prng.h index 0355b295..f210306f 100644 --- a/psi/algorithm/ypir/aes_prng.h +++ b/psi/algorithm/ypir/legacy/aes_prng.h @@ -20,7 +20,7 @@ #include -namespace psi::ypir::byhe { +namespace psi::ypir::ypir_internal { #define AES_128_ASSIST(t1, t2, rc) \ t2 = _mm_aeskeygenassist_si128(t1, rc); \ @@ -48,4 +48,4 @@ class AESCTR_PRNG { uint64_t ctr_hi_ = 0; }; -} // namespace psi::ypir::byhe +} // namespace psi::ypir::ypir_internal diff --git a/psi/algorithm/ypir/legacy/client.cc b/psi/algorithm/ypir/legacy/client.cc new file mode 100644 index 00000000..0b1a1a51 --- /dev/null +++ b/psi/algorithm/ypir/legacy/client.cc @@ -0,0 +1,279 @@ +#include "psi/algorithm/ypir/legacy/client.h" + +#include +#include +#include +#include + +namespace psi::ypir::ypir_internal { +namespace { + +uint64_t MakeSeedMaterial() { + const uint64_t time_seed = static_cast( + std::chrono::high_resolution_clock::now().time_since_epoch().count()); + std::random_device rd; + return time_seed ^ (static_cast(rd()) << 32) ^ rd(); +} + +std::mt19937_64& GlobalPrng() { + thread_local std::mt19937_64 rng(MakeSeedMaterial()); + return rng; +} + +uint64_t GetBase(uint64_t b, uint64_t z, uint64_t ti) { + return 1ULL << (b + ti * z); +} + +void LweEncrypt(Secret& sk, const std::vector& a, uint64_t message, + uint64_t& b, uint64_t pmod, double sig) { + const uint64_t lwe_dimension = sk.get_len(); + const uint64_t cmod = sk.get_mod(); + const long double delta = + static_cast(cmod) / static_cast(pmod); + + const uint64_t e = SampleGauss(sig, cmod, GlobalPrng()); + + std::vector tmp(lwe_dimension, 0); + EltwiseMultMod(tmp.data(), a.data(), sk.data.data(), lwe_dimension, cmod); + b = 0; + for (uint64_t i = 0; i < lwe_dimension; ++i) { + b = (b + tmp[i]) % cmod; + } + b = (b + e) % cmod; + b = (b + static_cast(message * delta)) % cmod; +} + +void LweDecrypt(Secret& sk, std::vector& a, uint64_t& message, + uint64_t& b, uint64_t pmod) { + const uint64_t lwe_dimension = sk.get_len(); + const uint64_t cmod = sk.get_mod(); + const long double delta = + static_cast(cmod) / static_cast(pmod); + + std::vector tmp(lwe_dimension, 0); + EltwiseMultMod(tmp.data(), a.data(), sk.data.data(), lwe_dimension, cmod); + for (uint64_t i = 0; i < lwe_dimension; ++i) { + b = (cmod + b - tmp[i]) % cmod; + } + + if (b > (cmod >> 1)) { + b = static_cast(std::llround((static_cast(b) - + static_cast(cmod)) / + delta)) % + pmod; + } else { + b = static_cast( + std::llround(static_cast(b) / delta)) % + pmod; + } + message = b; +} + +void PowerOfBase(const uint64_t* vec, uint64_t& num, uint64_t b, uint64_t z, + uint64_t t) { + num = 0; + for (uint64_t i = 0; i < t; ++i) { + num = (num << z) | vec[t - 1 - i]; + } + num <<= b; +} + +void RlweEncode(Secret& sk, const std::vector& a, + std::vector& message, std::vector& b, + const FheParams& fparm) { + const uint64_t poly_degree = fparm.get_poly_degree(); + const uint64_t rlwe_cmod = fparm.get_rlwe_cmod(); + const double sig = fparm.get_sig_ring(); + + YpirHexlNtt& ntt = fparm.get_ntt(); + if (!sk.get_ntt_form()) { + ntt.Forward(sk.data.data(), poly_degree); + sk.switch_ntt_format(); + } + + std::vector err(poly_degree, 0); + SampleGauss(err, sig, rlwe_cmod, GlobalPrng()); + EltwiseFMAMod(err.data(), message.data(), 1, err.data(), poly_degree, + rlwe_cmod); + ntt.Forward(err.data(), poly_degree); + + EltwiseMultMod(b.data(), sk.data.data(), a.data(), poly_degree, rlwe_cmod); + EltwiseAddMod(b.data(), err.data(), b.data(), poly_degree, rlwe_cmod); +} + +void RlweDecrypt(Secret& sk, std::vector& a, + std::vector& message, std::vector& b, + const FheParams& fparm) { + const uint64_t poly_degree = fparm.get_poly_degree(); + const uint64_t rlwe_cmod = fparm.get_rlwe_cmod(); + const uint64_t rlwe_pmod = fparm.get_rlwe_pmod(); + const uint64_t delta = rlwe_cmod / rlwe_pmod; + + YpirHexlNtt& ntt = fparm.get_ntt(); + if (!sk.get_ntt_form()) { + ntt.Forward(sk.data.data(), poly_degree); + sk.switch_ntt_format(); + } + + std::vector tmp(poly_degree, 0); + EltwiseMultMod(tmp.data(), sk.data.data(), a.data(), poly_degree, rlwe_cmod); + EltwiseSubMod(b.data(), b.data(), tmp.data(), poly_degree, rlwe_cmod); + ntt.Inverse(b.data(), poly_degree); + + message.assign(poly_degree, 0); + for (uint64_t i = 0; i < poly_degree; ++i) { + if (b[i] > (rlwe_cmod >> 1)) { + message[i] = static_cast( + std::llround((static_cast(b[i]) - + static_cast(rlwe_cmod)) / + static_cast(delta))) % + rlwe_pmod; + } else { + message[i] = static_cast( + std::llround(static_cast(b[i]) / + static_cast(delta))) % + rlwe_pmod; + } + } +} + +void MatrixReconstruct(const std::vector& vec, + std::vector>& mat, uint64_t row, + uint64_t col) { + mat.assign(row, std::vector(col, 0)); + uint64_t ptr = 0; + for (uint64_t i = 0; i < row; ++i) { + for (uint64_t j = 0; j < col; ++j, ++ptr) { + mat[i][j] = vec[ptr]; + } + } +} + +void GadgetEncrypt(Secret& sk, const std::vector>& a, + std::vector& message, + std::vector>& b, + const FheParams& fparm) { + const uint64_t b_auto = fparm.get_b_auto(); + const uint64_t z_auto = fparm.get_z_auto(); + const uint64_t t_auto = fparm.get_t_auto(); + const uint64_t poly_degree = fparm.get_poly_degree(); + const uint64_t rlwe_cmod = fparm.get_rlwe_cmod(); + + std::vector message_tmp(poly_degree, 0); + for (uint64_t i = 0; i < t_auto; ++i) { + const uint64_t base = GetBase(b_auto, z_auto, i) % rlwe_cmod; + EltwiseFMAMod(message_tmp.data(), message.data(), base, nullptr, + poly_degree, rlwe_cmod); + RlweEncode(sk, a[i], message_tmp, b[i], fparm); + } +} + +void GenerateAutokey(Secret& sk, + const std::vector>>& ksk_a, + std::vector>>& ksk_b, + const FheParams& fparm) { + const uint64_t degree = fparm.get_poly_degree(); + const uint64_t cmod = fparm.get_rlwe_cmod(); + const uint64_t expo = GetLog2(degree); + + YpirHexlNtt& ntt = fparm.get_ntt(); + if (sk.get_ntt_form()) { + ntt.Inverse(sk.data.data(), degree); + sk.switch_ntt_format(); + } + + std::vector newkey(degree, 0); + const std::vector copykey = sk.data; + for (uint64_t i = 0; i < expo; ++i) { + const uint64_t idx = (1ULL << (expo - i)) + 1; + ApplyAutoCoefForm(newkey, copykey, static_cast(idx), cmod); + GadgetEncrypt(sk, ksk_a[i], newkey, ksk_b[i], fparm); + } +} + +} // namespace + +void YpirRecover(Secret& simple_sk, Secret& double_sk, + std::vector>& res, uint64_t& message, + const FheParams& fparm, const PirParams&) { + const uint64_t degree = fparm.get_poly_degree(); + const uint64_t lwe_pmod = fparm.get_lwe_pmod(); + const uint64_t lwe_dimension = fparm.get_lwe_dimension(); + const uint64_t b = fparm.get_b_decomp(); + const uint64_t z = fparm.get_z_decomp(); + const uint64_t t = fparm.get_t_decomp(); + + std::vector pack_a_message(degree, 0); + std::vector pack_b_message(degree, 0); + RlweDecrypt(double_sk, res[0], pack_a_message, res[1], fparm); + RlweDecrypt(double_sk, res[2], pack_b_message, res[3], fparm); + + std::vector> matrix_pack_a_message; + MatrixReconstruct(pack_a_message, matrix_pack_a_message, lwe_dimension, t); + + std::vector a(lwe_dimension, 0); + for (uint64_t i = 0; i < lwe_dimension; ++i) { + PowerOfBase(matrix_pack_a_message[i].data(), a[i], b, z, t); + } + + uint64_t b_value = 0; + PowerOfBase(pack_b_message.data(), b_value, b, z, t); + LweDecrypt(simple_sk, a, message, b_value, lwe_pmod); +} + +YpirQuery Generate_query_ypir(uint64_t c_idx, uint64_t r_idx, Secret& lwe_sk, + Secret& rlwe_sk, AESCTR_PRNG& prng, + const FheParams& fparm, + const PirParams& pparm) { + YpirQuery out; + + const uint64_t cols = pparm.get_col(); + std::vector query_vec_col(cols, 0); + query_vec_col[c_idx] = 1; + + out.qu0.resize(cols); + const double sig = fparm.get_sig(); + const uint64_t lwe_pmod = fparm.get_lwe_pmod(); + const auto& matrix0 = fparm.get_persudo_matrix_simplepir(); + for (uint64_t i = 0; i < cols; ++i) { + LweEncrypt(lwe_sk, matrix0[i], query_vec_col[i], out.qu0[i], lwe_pmod, + sig); + } + + const uint64_t rows = pparm.get_row(); + const uint64_t degree = fparm.get_poly_degree(); + std::vector query_vec_row(rows, 0); + query_vec_row[r_idx] = 1; + + out.qu1.resize(rows); + const double sig_ring = fparm.get_sig_ring(); + const uint64_t rlwe_pmod = fparm.get_rlwe_pmod(); + std::vector> matrix1(rows, + std::vector(degree, 0)); + prng.refresh(kSecondDimensionSeed); + PseudorandomMatrixGenerate(matrix1, fparm.get_rlwe_cmod(), prng); + for (uint64_t i = 0; i < rows; ++i) { + LweEncrypt(rlwe_sk, matrix1[i], query_vec_row[i], out.qu1[i], rlwe_pmod, + sig_ring); + } + + const uint64_t t_auto = fparm.get_t_auto(); + const uint64_t expo = GetLog2(degree); + out.ksk_b.assign( + expo, std::vector>(t_auto, + std::vector(degree, 0))); + + std::vector>> ksk_a( + expo, + std::vector>(t_auto, + std::vector(degree, 0))); + prng.refresh(kThirdDimensionSeed); + for (uint64_t i = 0; i < expo; ++i) { + PseudorandomMatrixGenerate(ksk_a[i], fparm.get_rlwe_cmod(), prng); + } + GenerateAutokey(rlwe_sk, ksk_a, out.ksk_b, fparm); + + return out; +} + +} // namespace psi::ypir::ypir_internal diff --git a/psi/algorithm/ypir/legacy/client.h b/psi/algorithm/ypir/legacy/client.h new file mode 100644 index 00000000..07d792d9 --- /dev/null +++ b/psi/algorithm/ypir/legacy/client.h @@ -0,0 +1,25 @@ +#pragma once + +#include +#include + +#include "psi/algorithm/ypir/legacy/ypir_params.h" + +namespace psi::ypir::ypir_internal { + +struct YpirQuery { + std::vector qu0; + std::vector qu1; + std::vector>> ksk_b; +}; + +void YpirRecover(Secret& simple_sk, Secret& double_sk, + std::vector>& res, uint64_t& message, + const FheParams& fparm, const PirParams& pparm); + +YpirQuery Generate_query_ypir(uint64_t c_idx, uint64_t r_idx, Secret& lwe_sk, + Secret& rlwe_sk, AESCTR_PRNG& prng, + const FheParams& fparm, + const PirParams& pparm); + +} // namespace psi::ypir::ypir_internal diff --git a/psi/algorithm/ypir/hexl.cc b/psi/algorithm/ypir/legacy/hexl.cc similarity index 86% rename from psi/algorithm/ypir/hexl.cc rename to psi/algorithm/ypir/legacy/hexl.cc index 8f2dcd13..dcf5c4e8 100644 --- a/psi/algorithm/ypir/hexl.cc +++ b/psi/algorithm/ypir/legacy/hexl.cc @@ -12,13 +12,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "psi/algorithm/ypir/hexl.h" +#include "psi/algorithm/ypir/legacy/hexl.h" #include "yacl/base/exception.h" -namespace psi::ypir::byhe { +namespace psi::ypir::ypir_internal { -ByheHexlNtt::ByheHexlNtt(uint64_t degree, uint64_t modulus, +YpirHexlNtt::YpirHexlNtt(uint64_t degree, uint64_t modulus, uint64_t root_of_unity) : ntt_(degree, modulus, root_of_unity), degree_(degree), @@ -27,13 +27,13 @@ ByheHexlNtt::ByheHexlNtt(uint64_t degree, uint64_t modulus, YACL_ENFORCE(modulus_ > 0); } -void ByheHexlNtt::Forward(uint64_t* data, size_t len) { +void YpirHexlNtt::Forward(uint64_t* data, size_t len) { YACL_ENFORCE(len == degree_, "NTT Forward expects len == degree ({} != {})", len, degree_); ntt_.ComputeForward(data, data, 1, 1); } -void ByheHexlNtt::Inverse(uint64_t* data, size_t len) { +void YpirHexlNtt::Inverse(uint64_t* data, size_t len) { YACL_ENFORCE(len == degree_, "NTT Inverse expects len == degree ({} != {})", len, degree_); ntt_.ComputeInverse(data, data, 1, 1); @@ -59,4 +59,4 @@ void EltwiseFMAMod(uint64_t* out, const uint64_t* a, uint64_t scalar, intel::hexl::EltwiseFMAMod(out, a, scalar, add, len, modulus, 1); } -} // namespace psi::ypir::byhe +} // namespace psi::ypir::ypir_internal diff --git a/psi/algorithm/ypir/hexl.h b/psi/algorithm/ypir/legacy/hexl.h similarity index 90% rename from psi/algorithm/ypir/hexl.h rename to psi/algorithm/ypir/legacy/hexl.h index db9d11a8..cd0edfe3 100644 --- a/psi/algorithm/ypir/hexl.h +++ b/psi/algorithm/ypir/legacy/hexl.h @@ -19,16 +19,16 @@ #include "hexl/hexl.hpp" -namespace psi::ypir::byhe { +namespace psi::ypir::ypir_internal { constexpr uint64_t kCrtQ1 = 268369921ULL; constexpr uint64_t kCrtQ2 = 249561089ULL; constexpr uint64_t kCrtMod = kCrtQ1 * kCrtQ2; constexpr uint64_t kRootOfUnityCrt = 38878761190133527ULL; -class ByheHexlNtt { +class YpirHexlNtt { public: - ByheHexlNtt(uint64_t degree, uint64_t modulus, uint64_t root_of_unity); + YpirHexlNtt(uint64_t degree, uint64_t modulus, uint64_t root_of_unity); void Forward(uint64_t* data, size_t len); void Inverse(uint64_t* data, size_t len); @@ -50,4 +50,4 @@ void EltwiseSubMod(uint64_t* out, const uint64_t* a, const uint64_t* b, void EltwiseFMAMod(uint64_t* out, const uint64_t* a, uint64_t scalar, const uint64_t* add, size_t len, uint64_t modulus); -} // namespace psi::ypir::byhe +} // namespace psi::ypir::ypir_internal diff --git a/psi/algorithm/ypir/matmul.cpp b/psi/algorithm/ypir/legacy/matmul.cpp similarity index 100% rename from psi/algorithm/ypir/matmul.cpp rename to psi/algorithm/ypir/legacy/matmul.cpp diff --git a/psi/algorithm/ypir/legacy/server.cc b/psi/algorithm/ypir/legacy/server.cc new file mode 100644 index 00000000..24c51229 --- /dev/null +++ b/psi/algorithm/ypir/legacy/server.cc @@ -0,0 +1,160 @@ +#include "psi/algorithm/ypir/legacy/server.h" + +#include + +namespace psi::ypir::ypir_internal { +namespace { + +void DoublepirAnswer(const uint8_t* db, uint32_t* qu0, + std::vector& qu1, + const std::vector>& server_hint, + std::vector& h2, + std::vector>& h3, + std::vector& h4, const FheParams& fparm, + const PirParams& pparm) { + const uint64_t row = pparm.get_row(); + const uint64_t col = pparm.get_col(); + const uint64_t rlwe_cmod = fparm.get_rlwe_cmod(); + const uint64_t b = fparm.get_b_decomp(); + const uint64_t z = fparm.get_z_decomp(); + const uint64_t t = fparm.get_t_decomp(); + + std::vector simple_res(row, 0); + MatVecU8U32Mod2p32(db, qu0, simple_res.data(), row, col); + + std::vector> trans_simple_res_decomp; + VectorColDecompose(simple_res, trans_simple_res_decomp, b, z, t); + + const uint64_t* matrix_d2_flat = fparm.get_persudo_matrix_doublepir_flat(); + const uint64_t poly_degree = fparm.get_poly_degree(); + + MatrixVectorFirstDimension(h2, server_hint, qu1, rlwe_cmod); + + MatrixMultiplicationFlatU16(h3, trans_simple_res_decomp, matrix_d2_flat, + poly_degree, rlwe_cmod); + + MatrixVectorMultiplicationU16(h4, trans_simple_res_decomp, qu1, rlwe_cmod); +} + +} // namespace + +void YpirHintGenerate(std::vector>& db, + std::vector& h0, + std::vector>& double_server_hint, + std::vector>>& decomp_buf, + AESCTR_PRNG& prng, + const FheParams& fparm, const PirParams& pparm) { + const uint64_t lwe_dimension = fparm.get_lwe_dimension(); + const uint64_t poly_degree = fparm.get_poly_degree(); + const uint64_t rlwe_cmod = fparm.get_rlwe_cmod(); + const uint64_t t_auto = fparm.get_t_auto(); + const uint64_t t_decomp = fparm.get_t_decomp(); + const uint64_t expo = GetLog2(poly_degree); + const uint64_t pack_num = lwe_dimension * t_decomp; + + std::vector> double_client_hint( + lwe_dimension * t_decomp, std::vector(poly_degree, 0)); + + const uint64_t* matrix_flat = fparm.get_persudo_matrix_simplepir_flat(); + std::vector> simple_hint( + pparm.get_row(), std::vector(lwe_dimension, 0)); + MatrixMultiplicationFlat(simple_hint, db, matrix_flat, lwe_dimension, + fparm.get_lwe_cmod()); + + std::vector> matrix_decomp; + MatrixRowDecompose(simple_hint, matrix_decomp, fparm.get_b_decomp(), + fparm.get_z_decomp(), fparm.get_t_decomp()); + MatrixTranspose(matrix_decomp, double_server_hint); + + const uint64_t* matrix_d2_flat = fparm.get_persudo_matrix_doublepir_flat(); + MatrixMultiplicationFlat(double_client_hint, double_server_hint, + matrix_d2_flat, poly_degree, rlwe_cmod); + + std::vector>> ksk_a( + expo, + std::vector>(t_auto, + std::vector(poly_degree))); + prng.refresh(kThirdDimensionSeed); + for (uint64_t i = 0; i < expo; ++i) { + PseudorandomMatrixGenerate(ksk_a[i], rlwe_cmod, prng); + } + + const uint64_t mod_inv = ModInverse(static_cast(pack_num), + static_cast(rlwe_cmod)); + YpirHexlNtt& ntt = fparm.get_ntt(); + for (uint64_t i = 0; i < pack_num; ++i) { + Cdks21Lwe2RlweInplace(double_client_hint[i].data(), poly_degree, rlwe_cmod, + ntt); + EltwiseFMAMod(double_client_hint[i].data(), double_client_hint[i].data(), + mod_inv, nullptr, poly_degree, rlwe_cmod); + } + + h0 = PackrlwePreprocess(double_client_hint, GetLog2(pack_num), + GetLog2(poly_degree) - GetLog2(pack_num), ksk_a, + decomp_buf, fparm); +} + +void YpirAnswer(const uint8_t* db, uint32_t* qu0, std::vector& qu1, + const std::vector>>& ksk_b, + std::vector>>& decomp_buf, + const std::vector>& server_hint, + std::vector>& res, + const FheParams& fparm, const PirParams& pparm) { + const uint64_t lwe_dimension = fparm.get_lwe_dimension(); + const uint64_t poly_degree = fparm.get_poly_degree(); + const uint64_t rlwe_cmod = fparm.get_rlwe_cmod(); + const uint64_t t_decomp = fparm.get_t_decomp(); + const uint64_t pack_num = lwe_dimension * t_decomp; + const uint64_t mod_inv = ModInverse(static_cast(pack_num), + static_cast(rlwe_cmod)); + const uint64_t pack_num_log2 = GetLog2(pack_num); + const uint64_t t_decomp_log2 = GetLog2(t_decomp); + const uint64_t poly_degree_log2 = GetLog2(poly_degree); + + res.reserve(res.size() + 3); + + std::vector> h3(t_decomp, + std::vector(poly_degree, 0)); + std::vector h2(lwe_dimension * t_decomp, 0); + std::vector h4(t_decomp, 0); + + DoublepirAnswer(db, qu0, qu1, server_hint, h2, h3, h4, fparm, pparm); + + for (uint64_t i = 0; i < pack_num; ++i) { + h2[i] = + (static_cast(h2[i]) * mod_inv) % rlwe_cmod; + } + + uint64_t ptr = 0; + res.push_back(PackrlweOnlineConstantRows( + h2, pack_num_log2, poly_degree_log2 - pack_num_log2, ksk_b, decomp_buf, + ptr, fparm)); + + std::vector> h4_matrix( + t_decomp, std::vector(poly_degree, 0)); + const uint64_t mod_inv_2 = ModInverse(static_cast(t_decomp), + static_cast(rlwe_cmod)); + YpirHexlNtt& ntt = fparm.get_ntt(); + + for (uint64_t i = 0; i < t_decomp; ++i) { + Cdks21Lwe2RlweInplace(h3[i].data(), poly_degree, rlwe_cmod, ntt); + h4_matrix[i][0] = h4[i]; + ntt.Forward(h4_matrix[i].data(), poly_degree); + EltwiseFMAMod(h3[i].data(), h3[i].data(), mod_inv_2, nullptr, poly_degree, + rlwe_cmod); + EltwiseFMAMod(h4_matrix[i].data(), h4_matrix[i].data(), mod_inv_2, nullptr, + poly_degree, rlwe_cmod); + } + + const auto& ksk_a = fparm.get_persudo_hcube_ypir(); + std::vector>> decomp_b_buf; + ptr = 0; + res.push_back(PackrlwePreprocess(h3, t_decomp_log2, + poly_degree_log2 - t_decomp_log2, ksk_a, + decomp_b_buf, fparm)); + res.push_back(PackrlweOnline(h4_matrix, t_decomp_log2, + poly_degree_log2 - t_decomp_log2, ksk_b, + decomp_b_buf, ptr, fparm)); +} + +} // namespace psi::ypir::ypir_internal diff --git a/psi/algorithm/ypir/legacy/server.h b/psi/algorithm/ypir/legacy/server.h new file mode 100644 index 00000000..50a2256e --- /dev/null +++ b/psi/algorithm/ypir/legacy/server.h @@ -0,0 +1,24 @@ +#pragma once + +#include +#include + +#include "psi/algorithm/ypir/legacy/ypir_params.h" + +namespace psi::ypir::ypir_internal { + +void YpirAnswer(const uint8_t* db, uint32_t* qu0, std::vector& qu1, + const std::vector>>& ksk_b, + std::vector>>& decomp_buf, + const std::vector>& server_hint, + std::vector>& res, + const FheParams& fparm, const PirParams& pparm); + +void YpirHintGenerate(std::vector>& db, + std::vector& h0, + std::vector>& double_server_hint, + std::vector>>& decomp_buf, + AESCTR_PRNG& prng, + const FheParams& fparm, const PirParams& pparm); + +} // namespace psi::ypir::ypir_internal diff --git a/psi/algorithm/ypir/legacy/types.h b/psi/algorithm/ypir/legacy/types.h new file mode 100644 index 00000000..2f94aaad --- /dev/null +++ b/psi/algorithm/ypir/legacy/types.h @@ -0,0 +1,57 @@ +// Copyright 2024 Ant Group Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#pragma once + +#include +#include +#include +#include +#include + +#include "psi/algorithm/spiral/poly_matrix.h" + +namespace psi::ypir { + +using namespace psi::spiral; + +// Precomputation tuple type for packing operations +using Precomp = + std::vector, + std::vector>>>; + +// Forward declaration for YPirServer template class +template +class YPirServer; + +// Convenience alias for the most common type +using YServer = YPirServer; + +// Offline precomputation values for SimplePIR and DoublePIR +struct OfflinePrecomputedValues { + // SimplePIR fields + std::vector hint_0; // First hint + // DoublePIR fields + std::vector hint_1; // Second dimension hint + std::vector + pseudorandom_query_1; // Pseudorandom query for second dimension + std::pair, std::vector> y_constants; + std::shared_ptr smaller_server; + // Packing-related fields + std::vector> prepacked_lwe; + std::vector fake_pack_pub_params; + Precomp precomp; +}; + +} // namespace psi::ypir diff --git a/psi/algorithm/ypir/legacy/util.cc b/psi/algorithm/ypir/legacy/util.cc new file mode 100644 index 00000000..332b0015 --- /dev/null +++ b/psi/algorithm/ypir/legacy/util.cc @@ -0,0 +1,1130 @@ +#include "psi/algorithm/ypir/legacy/util.h" + +#include +#include +#include + +#include "psi/algorithm/spiral/arith/arith_params.h" +#include "psi/algorithm/spiral/arith/ntt.h" +#include "psi/algorithm/spiral/discrete_gaussian.h" +#include "psi/algorithm/spiral/gadget.h" +#include "psi/algorithm/spiral/poly_matrix_utils.h" +#include "yacl/base/int128.h" + +#include "psi/algorithm/spiral/params.h" +#include "psi/algorithm/spiral/poly_matrix.h" +#include "psi/algorithm/spiral/util.h" + +namespace psi::ypir { + +using namespace psi::spiral; + +std::vector ConcatHorizontal( + const std::vector>& v_a, size_t a_rows, + size_t a_cols) { + if (v_a.empty()) { + return {}; + } + + size_t num_vecs = v_a.size(); + + std::vector out(a_rows * a_cols * num_vecs); + size_t out_stride = num_vecs * a_cols; + + for (size_t i = 0; i < a_rows; ++i) { + for (size_t k = 0; k < num_vecs; ++k) { + auto src_begin = v_a[k].begin() + (i * a_cols); + auto src_end = src_begin + a_cols; + size_t dest_offset = (i * out_stride) + (k * a_cols); + + std::copy(src_begin, src_end, out.begin() + dest_offset); + } + } + + return out; +} + +extern "C" { +void matMulVecPacked(uint32_t* out, const uint32_t* a, const uint32_t* b, + size_t aRows, size_t aCols); + +void matMulVecPacked2(uint32_t* out, const uint32_t* a, const uint32_t* b_full, + size_t aRows, size_t aCols); + +void matMulVecPacked4(uint32_t* out, const uint32_t* a, const uint32_t* b_full, + size_t aRows, size_t aCols); + +void matMulVecPacked8(uint32_t* out, const uint32_t* a, const uint32_t* b_full, + size_t aRows, size_t aCols); +} + +// Wrapper function that matches the Rust signature +void MatMulVecPacked(uint32_t* out, const uint32_t* a, const uint32_t* b, + size_t a_rows, size_t a_cols, size_t b_rows, + size_t b_cols) { + // Debug output (equivalent to Rust's debug! macro) + + // Assertions + assert(a_rows * a_cols == a_rows * a_cols); // a.len() == a_rows * a_cols + assert(b_rows * b_cols == b_rows * b_cols); // b.len() == b_rows * b_cols + assert(a_cols * 4 == b_rows); + // Note: out.len() >= a_rows + 8 should be checked by caller + + // Dispatch based on b_cols + if (b_cols == 1) { + matMulVecPacked(out, a, b, a_rows, a_cols); + } else if (b_cols == 2) { + matMulVecPacked2(out, a, b, a_rows, a_cols); + } else if (b_cols == 4) { + matMulVecPacked4(out, a, b, a_rows, a_cols); + } else if (b_cols == 8) { + matMulVecPacked8(out, a, b, a_rows, a_cols); + } else { + fprintf(stderr, "Error: b_cols must be 1, 2, 4, or 8, got %zu\n", b_cols); + assert(false && "b_cols must be 1, 2, 4, or 8"); + } +} + +PolyMatrixNtt HomomorphicAutomorph(const Params& params, size_t t, size_t t_exp, + const PolyMatrixNtt& ct, + const PolyMatrixNtt& pub_param) { + YACL_ENFORCE(ct.Rows() == static_cast(2)); + YACL_ENFORCE(ct.Cols() == static_cast(1)); + + auto ct_raw = PolyMatrixRaw::Zero(params.PolyLen(), 2, 1); + FromNtt(params, ct_raw, ct); + auto ct_auto = Automorphism(params, ct_raw, t); + + auto ginv_ct = PolyMatrixRaw::Zero(params.PolyLen(), t_exp, 1); + psi::spiral::util::GadgetInvertRdim(params, ginv_ct, ct_auto, 1); + + auto ginv_ct_ntt = + PolyMatrixNtt::Zero(params.CrtCount(), params.PolyLen(), t_exp, 1); + for (size_t i = 1; i < t_exp; ++i) { + auto pol_src = ginv_ct.Poly(i, 0); + auto pol_dst = ginv_ct_ntt.Poly(i, 0); + ReduceCopy(params, pol_dst, pol_src); + arith::NttForward(params, pol_dst); + } + + auto w_times_ginv_ct = Multiply(params, pub_param, ginv_ct_ntt); + + auto ct_auto_1 = PolyMatrixRaw::Zero(params.PolyLen(), 1, 1); + + std::memcpy(ct_auto_1.Data().data(), + ct_auto.Data().data() + ct_auto.PolyStartIndex(1, 0), + sizeof(uint64_t) * ct_auto.NumWords()); + auto ct_auto_1_ntt = ToNtt(params, ct_auto_1); + + auto res = Add(params, ct_auto_1_ntt.PadTop(1), w_times_ginv_ct); + return res; +} + +PolyMatrixNtt RingPackLwesInner( + const Params& params, size_t ell, size_t start_idx, + const std::vector& rlwe_cts, + const std::vector& pub_params, + const std::pair, std::vector>& + y_constants) { + YACL_ENFORCE_EQ(pub_params.size(), params.PolyLenLog2()); + + if (ell == 0) { + return rlwe_cts[start_idx]; + } + + size_t step = 1ULL << (params.PolyLenLog2() - ell); + size_t even = start_idx; + size_t odd = start_idx + step; + + auto ct_even = RingPackLwesInner(params, ell - 1, even, rlwe_cts, pub_params, + y_constants); + auto ct_odd = RingPackLwesInner(params, ell - 1, odd, rlwe_cts, pub_params, + y_constants); + + const auto& y = y_constants.first[ell - 1]; + const auto& neg_y = y_constants.second[ell - 1]; + + auto y_times_ct_odd = ScalarMultiply(params, y, ct_odd); + auto neg_y_times_ct_odd = ScalarMultiply(params, neg_y, ct_odd); + + auto ct_sum_1 = ct_even; + AddInto(params, ct_sum_1, neg_y_times_ct_odd); + AddInto(params, ct_even, y_times_ct_odd); + + size_t t = (1ULL << ell) + 1; + const auto& pub_param = pub_params[params.PolyLenLog2() - 1 - (ell - 1)]; + auto ct_sum_1_automorphed = + HomomorphicAutomorph(params, t, params.TExpLeft(), ct_sum_1, pub_param); + + return Add(params, ct_even, ct_sum_1_automorphed); +} + +std::pair, std::vector> GenYConstants( + const Params& params) { + std::vector y_constants; + std::vector neg_y_constants; + + for (size_t num_cts_log2 = 1; num_cts_log2 <= params.PolyLenLog2(); + ++num_cts_log2) { + size_t num_cts = 1ULL << num_cts_log2; + + auto y_raw = PolyMatrixRaw::Zero(params.PolyLen(), 1, 1); + size_t idx = params.PolyLen() / num_cts; + y_raw.Data()[idx] = 1ULL; + auto y = ToNtt(params, y_raw); + + auto neg_y_raw = PolyMatrixRaw::Zero(params.PolyLen(), 1, 1); + neg_y_raw.Data()[idx] = params.Modulus() - 1; + auto neg_y = ToNtt(params, neg_y_raw); + + y_constants.push_back(y); + neg_y_constants.push_back(neg_y); + } + + return std::make_pair(y_constants, neg_y_constants); +} + +PolyMatrixNtt RingPackLwes( + const Params& params, const std::vector& b_values, + const std::vector& rlwe_cts, size_t num_cts, + const std::vector& pub_params, + const std::pair, std::vector>& + y_constants) { + YACL_ENFORCE_EQ(b_values.size(), num_cts); + YACL_ENFORCE_EQ(rlwe_cts.size(), num_cts); + + size_t ell = params.PolyLenLog2(); + auto out = + RingPackLwesInner(params, ell, 0, rlwe_cts, pub_params, y_constants); + + auto out_raw = FromNtt(params, out); + for (size_t z = 0; z < params.PolyLen(); ++z) { + uint128_t b_val_u128 = static_cast(b_values[z]); + uint128_t poly_len_u128 = static_cast(params.PolyLen()); + uint128_t prod = b_val_u128 * poly_len_u128; + uint64_t val = arith::BarrettReductionU128(params, prod); + + size_t idx = out_raw.PolyStartIndex(1, 0) + z; + uint64_t sum = out_raw.Data()[idx] + val; + out_raw.Data()[idx] = arith::BarrettU64(params, sum); + } + + return ToNtt(params, out_raw); +} + +std::vector NegacyclicPerm(absl::Span a, size_t shift, + uint64_t modulus) { + size_t n = a.size(); + std::vector out(n); + + for (size_t i = 0; i <= shift; ++i) { + out[i] = a[shift - i]; + } + + for (size_t i = shift + 1; i < n; ++i) { + size_t src_idx = n - (i - shift); + uint64_t val = a[src_idx] % modulus; + if (val == 0) { + out[i] = 0; + } else { + out[i] = modulus - val; + } + } + + return out; +} + +std::vector NegacyclicMatrix(absl::Span a, + uint64_t modulus) { + size_t n = a.size(); + std::vector out(n * n, 0); + + for (size_t i = 0; i < n; ++i) { + std::vector perm = NegacyclicPerm(a, i, modulus); + for (size_t j = 0; j < n; ++j) { + out[j * n + i] = perm[j]; + } + } + + return out; +} + +PolyMatrixNtt CondenseMatrix(const Params& params, const PolyMatrixNtt& a) { + PolyMatrixNtt res = PolyMatrixNtt::Zero(params.CrtCount(), params.PolyLen(), + a.Rows(), a.Cols()); + for (size_t i = 0; i < a.Rows(); ++i) { + for (size_t j = 0; j < a.Cols(); ++j) { + auto res_poly = res.Poly(i, j); + const auto a_poly = a.Poly(i, j); + if (a_poly.size() < 2 * params.PolyLen()) { + continue; + } + for (size_t z = 0; z < params.PolyLen(); ++z) { + res_poly[z] = a_poly[z] | (a_poly[z + params.PolyLen()] << 32); + } + } + } + + return res; +} + +// from ypir/packing.rs +PolyMatrixNtt RotationPoly(const Params& params, size_t amount) { + PolyMatrixRaw res = PolyMatrixRaw::Zero(params.PolyLen(), 1, 1); + + if (amount < res.Data().size()) { + res.Data()[amount] = 1; + } else { + YACL_THROW("Rotation amount exceeds polynomial length"); + } + + return ToNtt(params, res); +} +PolyMatrixNtt PackSingleLwe(const Params& params, + const std::vector& pub_params, + const PolyMatrixNtt& lwe_ct) { + PolyMatrixNtt cur_r = lwe_ct; + + size_t log_n = params.PolyLenLog2(); + + for (size_t i = 0; i < log_n; ++i) { + size_t t = (params.PolyLen() / (1ULL << i)) + 1; + + const auto& pub_param = pub_params[i]; + + auto tau_of_r = + HomomorphicAutomorph(params, t, params.TExpLeft(), cur_r, pub_param); + AddInto(params, cur_r, tau_of_r); + } + + return cur_r; +} + +PolyMatrixNtt PackUsingSingleWithOffset( + const Params& params, const std::vector& pub_params, + const std::vector& cts, size_t offset) { + PolyMatrixNtt res = + PolyMatrixNtt::Zero(params.CrtCount(), params.PolyLen(), 2, 1); + + SPDLOG_INFO( + "PackUsingSingleWithOffset: offset={}, cts.size()={}, poly_len={}", + offset, cts.size(), params.PolyLen()); + + for (size_t i = 0; i < cts.size(); ++i) { + PolyMatrixNtt packed_single = PackSingleLwe(params, pub_params, cts[i]); + + size_t rotation_amount = offset + i; + if (rotation_amount >= params.PolyLen()) { + SPDLOG_ERROR("ERROR: rotation_amount {} >= poly_len {} (offset={}, i={})", + rotation_amount, params.PolyLen(), offset, i); + YACL_THROW( + "Rotation amount exceeds polynomial length in " + "PackUsingSingleWithOffset"); + } + + PolyMatrixNtt rotation = RotationPoly(params, rotation_amount); + PolyMatrixNtt rotated = ScalarMultiply(params, rotation, packed_single); + + AddInto(params, res, rotated); + } + + return res; +} + +std::vector PrepPackLwes(const Params& params, + absl::Span lwe_cts, + size_t cols_to_do) { + size_t poly_len = params.PolyLen(); + size_t expected_size = poly_len * (poly_len + 1); + + if (lwe_cts.size() != expected_size) { + throw std::runtime_error("PrepPackLwes: lwe_cts size mismatch"); + } + if (cols_to_do != poly_len) { + throw std::runtime_error("PrepPackLwes: cols_to_do must equal poly_len"); + } + + std::vector rlwe_cts; + rlwe_cts.reserve(cols_to_do); + + for (size_t i = 0; i < cols_to_do; ++i) { + auto rlwe_ct = PolyMatrixRaw::Zero(params.PolyLen(), 2, 1); + std::vector poly; + poly.reserve(poly_len); + for (size_t j = 0; j < poly_len; ++j) { + poly.push_back(lwe_cts[j * poly_len + i]); + } + + auto nega = NegacyclicPerm(poly, 0, params.Modulus()); + + // Use Poly(0, 0) to get the first polynomial + auto first_poly = rlwe_ct.Poly(0, 0); + for (size_t j = 0; j < poly_len; ++j) { + first_poly[j] = nega[j]; + } + + rlwe_cts.push_back(ToNtt(params, rlwe_ct)); + } + + return rlwe_cts; +} + +std::vector> PrepPackManyLwes( + const Params& params, absl::Span lwe_cts, + size_t num_rlwe_outputs) { + size_t poly_len = params.PolyLen(); + + size_t expected_total_size = (poly_len + 1) * (num_rlwe_outputs * poly_len); + + if (lwe_cts.size() != expected_total_size) { + throw std::runtime_error("PrepPackManyLwes: Total size mismatch"); + } + + std::vector> vecs; + vecs.reserve(num_rlwe_outputs); + + for (size_t i = 0; i < num_rlwe_outputs; ++i) { + std::vector v; + // 每个 chunk 的大小应该是 poly_len * (poly_len + 1) + v.reserve(poly_len * (poly_len + 1)); + for (size_t j = 0; j < poly_len + 1; ++j) { + size_t start_idx = j * (num_rlwe_outputs * poly_len) + i * poly_len; + for (size_t k = 0; k < poly_len; ++k) { + v.push_back(lwe_cts[start_idx + k]); + } + } + vecs.push_back(std::move(v)); + } + std::vector> res; + res.reserve(num_rlwe_outputs); + + for (size_t i = 0; i < num_rlwe_outputs; ++i) { + res.push_back(PrepPackLwes(params, vecs[i], poly_len)); + } + + return res; +} + +std::vector> GenerateAutomorphTablesBruteForce( + const Params& params) { + std::vector> tables; + + tables.reserve(params.PolyLenLog2()); + + for (size_t i = params.PolyLenLog2(); i >= 1; --i) { + size_t poly_len = params.PolyLen(); + std::vector table_candidate(poly_len); + while (true) { + uint64_t t = (1ULL << i) + 1; + PolyMatrixRaw poly = PolyMatrixRaw::Random(params, 1, 1); + PolyMatrixNtt poly_ntt = ToNtt(params, poly); + PolyMatrixRaw poly_auto(params.PolyLen(), 1, 1); + Automorphism(params, poly_auto, poly, t); + PolyMatrixNtt poly_auto_ntt = ToNtt(params, poly_auto); + auto pol_orig = poly_ntt.Poly(0, 0); + auto pol_auto = poly_auto_ntt.Poly(0, 0); + bool must_redo = false; + for (size_t src_idx = 0; src_idx < poly_len; ++src_idx) { + uint64_t target_val = pol_orig[src_idx]; + int found_count = 0; + size_t found_pos = 0; + for (size_t dest_idx = 0; dest_idx < poly_len; ++dest_idx) { + if (pol_auto[dest_idx] == target_val) { + found_count++; + found_pos = dest_idx; + } + } + if (found_count != 1) { + must_redo = true; + break; + } + table_candidate[found_pos] = src_idx; + } + + if (!must_redo) { + break; + } + } + tables.push_back(std::move(table_candidate)); + } + + return tables; +} + +std::tuple, + std::vector>> +PrecomputePack(const Params& params, size_t poly_len_log2, + const std::vector& prepacked, + const std::vector& pub_params, + const std::pair, + std::vector>& y_constants) { + YACL_ENFORCE_EQ(pub_params.size(), params.PolyLenLog2(), + "pub_params size must match poly_len_log2"); + YACL_ENFORCE_EQ(params.CrtCount(), 2UL, "CRT count must be 2"); + + std::vector working_set = prepacked; + PolyMatrixNtt y_times_ct_odd = + PolyMatrixNtt::Zero(params.CrtCount(), params.PolyLen(), 2, 1); + + PolyMatrixNtt neg_y_times_ct_odd = + PolyMatrixNtt::Zero(params.CrtCount(), params.PolyLen(), 2, 1); + PolyMatrixNtt ct_sum_1 = + PolyMatrixNtt::Zero(params.CrtCount(), params.PolyLen(), 2, 1); + + PolyMatrixRaw ct_raw = PolyMatrixRaw::Zero(params.PolyLen(), 1, 1); + PolyMatrixRaw ct_auto = PolyMatrixRaw::Zero(params.PolyLen(), 1, 1); + + size_t t_exp = params.TExpLeft(); + PolyMatrixRaw ginv_ct = + PolyMatrixRaw::Zero(params.PolyLen(), t_exp, 1); // Fixed: poly_len first + PolyMatrixNtt ginv_ct_ntt = + PolyMatrixNtt::Zero(params.CrtCount(), params.PolyLen(), t_exp, 1); + + PolyMatrixNtt ct_auto_1_ntt = + PolyMatrixNtt::Zero(params.CrtCount(), params.PolyLen(), 1, 1); + PolyMatrixNtt w_times_ginv_ct = + PolyMatrixNtt::Zero(params.CrtCount(), params.PolyLen(), 2, 1); + PolyMatrixNtt scratch = + PolyMatrixNtt::Zero(params.CrtCount(), params.PolyLen(), 2, 1); + std::vector v_trgsw; + v_trgsw.reserve(poly_len_log2); + + for (size_t cur_ell = 1; cur_ell <= poly_len_log2; ++cur_ell) { + size_t num_in = 1ULL << (poly_len_log2 - cur_ell + 1); + size_t num_out = num_in >> 1; + + const auto& y = y_constants.first[cur_ell - 1]; + const auto& neg_y = y_constants.second[cur_ell - 1]; + + for (size_t i = 0; i < num_out; ++i) { + auto& ct_even = working_set[i]; + const auto& ct_odd = working_set[i + num_out]; + + // y_times_ct_odd = y * ct_odd + ScalarMultiply(params, y_times_ct_odd, y, ct_odd); + // neg_y_times_ct_odd = -y * ct_odd + ScalarMultiply(params, neg_y_times_ct_odd, neg_y, ct_odd); + + // ct_sum_1 = ct_even + neg_y * ct_odd + ct_sum_1.CopyInto(ct_even, 0, 0); + AddInto(params, ct_sum_1, neg_y_times_ct_odd); + + AddInto(params, ct_even, y_times_ct_odd); + + uint64_t t = (1ULL << cur_ell) + 1; + FromNttScratch(params, ct_raw, scratch.Data(), ct_sum_1); + + Automorphism(params, ct_auto, ct_raw, t); + util::GadgetInvertRdim(params, ginv_ct, ct_auto, 1); + ToNtt(params, ginv_ct_ntt, ginv_ct); + + auto scratch_poly = scratch.Poly(0, 0); // Get the stored 2nd row data + AutomorphismPolyUncrtd(params, ct_auto_1_ntt.Data(), scratch_poly, t); + arith::NttForward(params, ct_auto_1_ntt.Data()); + + v_trgsw.push_back(CondenseMatrix(params, ginv_ct_ntt)); + + size_t param_idx = poly_len_log2 - cur_ell; + const auto& pub_param = pub_params[param_idx]; + + // W * Ginv + std::fill(w_times_ginv_ct.Data().begin(), w_times_ginv_ct.Data().end(), + 0); + MultiplyNoReduce(w_times_ginv_ct, pub_param, ginv_ct_ntt, 0); + + AddIntoAt(params, ct_even, ct_auto_1_ntt, 1, 0); + + AddInto(params, ct_even, w_times_ginv_ct); + } + } + + auto combined_hints = GenerateAutomorphTablesBruteForce(params); + return std::make_tuple(working_set[0], v_trgsw, combined_hints); +} + +inline uint64_t FastBarrettRawU64(uint64_t input, uint64_t const_ratio_1, + uint64_t modulus) { + uint128_t mul = static_cast(input) * const_ratio_1; + uint64_t tmp = static_cast(mul >> 64); + uint64_t res = input - tmp * modulus; + return res; +} + +void FastAddInto(const Params& params, PolyMatrixNtt& res, + const PolyMatrixNtt& a) { + if (res.Rows() != a.Rows() || res.Cols() != a.Cols()) { + throw std::runtime_error("FastAddInto: Dimension mismatch"); + } + + size_t poly_len = params.PolyLen(); + size_t crt_count = params.CrtCount(); + + uint64_t* res_ptr = const_cast(res.Data().data()); + const uint64_t* a_ptr = a.Data().data(); + size_t num_polys = res.Rows() * res.Cols(); + + for (size_t p = 0; p < num_polys; ++p) { + for (size_t c = 0; c < crt_count; ++c) { + size_t poly_offset = p * (crt_count * poly_len); + size_t crt_offset = poly_offset + c * poly_len; + + for (size_t i = 0; i < poly_len; ++i) { + size_t idx = crt_offset + i; + uint64_t val = res_ptr[idx] + a_ptr[idx]; + res_ptr[idx] = + FastBarrettRawU64(val, params.BarrettCr1(c), params.Moduli(c)); + } + } + } +} + +void FastAddIntoNoReduce(PolyMatrixNtt& res, const PolyMatrixNtt& a) { + if (res.Rows() != a.Rows() || res.Cols() != a.Cols()) { + throw std::runtime_error("FastAddIntoNoReduce: Dimension mismatch"); + } + size_t len = res.Data().size(); + for (size_t i = 0; i < len; ++i) { + res.Data()[i] += a.Data()[i]; + } +} + +void MultiplyPolyAvx(uint64_t* res, const uint64_t* a, const uint64_t* b, + size_t len) { + for (size_t i = 0; i < len; ++i) { + uint64_t x = static_cast(static_cast(a[i])); + uint64_t y = static_cast(static_cast(b[i])); + res[i] = x * y; + } +} + +void ScalarMultiplyAvx(const Params& params, PolyMatrixNtt& res, + const PolyMatrixNtt& a, const PolyMatrixNtt& b) { + if (a.Rows() != 1 || a.Cols() != 1) { + throw std::runtime_error( + "ScalarMultiplyAvx: 'a' must be a 1x1 matrix (scalar)"); + } + + if (res.Rows() != b.Rows() || res.Cols() != b.Cols()) { + throw std::runtime_error( + "ScalarMultiplyAvx: 'res' and 'b' dimension mismatch"); + } + + // poly_size = poly_len * crt_count + size_t poly_size = params.PolyLen() * params.CrtCount(); + + const uint64_t* pol2_ptr = a.Data().data(); + + const uint64_t* b_ptr = b.Data().data(); + + uint64_t* res_ptr = const_cast(res.Data().data()); + + size_t total_polys = b.Rows() * b.Cols(); + + for (size_t i = 0; i < total_polys; ++i) { + size_t offset = i * poly_size; + + const uint64_t* pol1_ptr = b_ptr + offset; + + uint64_t* res_poly_ptr = res_ptr + offset; + + MultiplyPolyAvx(res_poly_ptr, pol1_ptr, pol2_ptr, poly_size); + } +} + +void FastMultiplyNoReduce(const Params& params, PolyMatrixNtt& res, + const PolyMatrixNtt& a, const PolyMatrixNtt& b, + size_t /*start_inner_dim*/) { + if (res.Rows() != 1 || res.Cols() != 1) { + throw std::runtime_error("FastMultiplyNoReduce: Result must be 1x1"); + } + if (res.Rows() != a.Rows() || res.Cols() != b.Cols()) { + throw std::runtime_error( + "FastMultiplyNoReduce: Dimension mismatch (Result)"); + } + if (a.Cols() != b.Rows()) { + throw std::runtime_error( + "FastMultiplyNoReduce: Dimension mismatch (Inner)"); + } + + if (params.CrtCount() != 2) { + throw std::runtime_error("FastMultiplyNoReduce: Requires CRT count = 2"); + } + + uint64_t* res_ptr = const_cast(res.Data().data()); + const uint64_t* a_ptr = a.Data().data(); + const uint64_t* b_ptr = b.Data().data(); + + size_t pol_sz = params.PolyLen(); + size_t k_dim = a.Cols(); + + for (size_t idx = 0; idx < pol_sz; ++idx) { + uint64_t sum_lo = 0; + uint64_t sum_hi = 0; + + for (size_t k = 0; k < k_dim; ++k) { + size_t offset = k * 2 * pol_sz + idx; + + uint64_t x = a_ptr[offset]; + uint64_t y = b_ptr[offset]; + + uint64_t x_lo = x & 0xFFFFFFFF; + uint64_t x_hi = x >> 32; + + uint64_t y_lo = y & 0xFFFFFFFF; + uint64_t y_hi = y >> 32; + + sum_lo += x_lo * y_lo; + sum_hi += x_hi * y_hi; + } + + res_ptr[idx] = sum_lo; + res_ptr[pol_sz + idx] = sum_hi; + } +} + +void ApplyAutomorphNttRaw(const Params& params, const uint64_t* poly, + uint64_t* out, size_t t, + const std::vector>& tables) { + size_t poly_len = params.PolyLen(); + if (t <= 1) throw std::runtime_error("ApplyAutomorphNttRaw: t must be > 1"); + + size_t val = poly_len / (t - 1); + // C++20 + // size_t table_idx = std::countr_zero(val); + size_t table_idx = __builtin_ctzll(val); + + if (table_idx >= tables.size()) { + throw std::runtime_error("ApplyAutomorphNttRaw: Table index out of bounds"); + } + + const std::vector& table = tables[table_idx]; + + for (size_t i = 0; i < poly_len; ++i) { + out[i] += poly[table[i]]; + } +} + +void ApplyAutomorphNtt(const Params& params, + const std::vector>& tables, + const PolyMatrixNtt& mat, PolyMatrixNtt& res, size_t t) { + if (mat.Rows() != res.Rows() || mat.Cols() != res.Cols()) { + throw std::runtime_error("ApplyAutomorphNtt: Dimension mismatch"); + } + + const uint64_t* mat_ptr = mat.Data().data(); + + uint64_t* res_ptr = const_cast(res.Data().data()); + + size_t poly_len = params.PolyLen(); + size_t total_elements = mat.Data().size(); + + for (size_t offset = 0; offset < total_elements; offset += poly_len) { + ApplyAutomorphNttRaw(params, mat_ptr + offset, res_ptr + offset, t, tables); + } +} + +void FastReduce(const Params& params, PolyMatrixNtt& res) { + size_t crt_count = params.CrtCount(); + size_t poly_len = params.PolyLen(); + + for (size_t m = 0; m < crt_count; ++m) { + for (size_t i = 0; i < poly_len; ++i) { + size_t idx = m * poly_len + i; + res.Data()[idx] = arith::BarrettCoeffU64(params, res.Data()[idx], m); + } + } +} + +PolyMatrixNtt PackUsingPrecompVals( + const Params& params, size_t ell, + absl::Span pub_params, + absl::Span b_values, const PolyMatrixNtt& precomp_res, + absl::Span precomp_vals, + const std::vector>& precomp_tables, + const std::pair, std::vector>& + y_constants) { + size_t initial_capacity = 1ULL << (ell - 1); + std::vector working_set; + working_set.reserve(initial_capacity); + + for (size_t i = 0; i < initial_capacity; ++i) { + working_set.push_back( + PolyMatrixNtt::Zero(params.CrtCount(), params.PolyLen(), 1, 1)); + } + + auto y_times_ct_odd = + PolyMatrixNtt::Zero(params.CrtCount(), params.PolyLen(), 1, 1); + auto neg_y_times_ct_odd = + PolyMatrixNtt::Zero(params.CrtCount(), params.PolyLen(), 1, 1); + auto ct_sum_1 = + PolyMatrixNtt::Zero(params.CrtCount(), params.PolyLen(), 1, 1); + auto w_times_ginv_ct = + PolyMatrixNtt::Zero(params.CrtCount(), params.PolyLen(), 1, 1); + + size_t idx_precomp = 0; + + for (size_t cur_ell = 1; cur_ell <= ell; ++cur_ell) { + size_t num_in = 1ULL << (ell - cur_ell + 1); + size_t num_out = num_in >> 1; + + if (num_in == params.PolyLen()) { + num_in = num_out; + } + + for (size_t i = 0; i < num_out; ++i) { + PolyMatrixNtt& ct_even = working_set[i]; + + const auto& y = y_constants.first[cur_ell - 1]; + const auto& neg_y = y_constants.second[cur_ell - 1]; + + if (cur_ell > 1) { + PolyMatrixNtt& ct_odd = working_set[num_out + i]; + ScalarMultiplyAvx(params, y_times_ct_odd, y, ct_odd); + ScalarMultiplyAvx(params, neg_y_times_ct_odd, neg_y, ct_odd); + } + + if (cur_ell > 1) { + std::copy(ct_even.Data().begin(), ct_even.Data().end(), + const_cast(ct_sum_1.Data().data())); + + FastAddIntoNoReduce(ct_sum_1, neg_y_times_ct_odd); + FastAddIntoNoReduce(ct_even, y_times_ct_odd); + } + + const PolyMatrixNtt* ct_ptr = &ct_sum_1; + size_t t = (1ULL << cur_ell) + 1; + + const auto& cur_ginv_ct_ntt = precomp_vals[idx_precomp]; + idx_precomp++; + + size_t w_idx = params.PolyLenLog2() - cur_ell; + const auto& w = pub_params[w_idx]; + + FastMultiplyNoReduce(params, w_times_ginv_ct, w, cur_ginv_ct_ntt, 0); + + if (cur_ell > 1) { + ApplyAutomorphNtt(params, precomp_tables, *ct_ptr, ct_even, t); + + if (i < num_out / 2 && ((cur_ell - 1) % 5 != 0)) { + FastAddIntoNoReduce(ct_even, w_times_ginv_ct); + } else { + FastAddInto(params, ct_even, w_times_ginv_ct); + } + } else { + if (i < num_out / 2) { + FastAddIntoNoReduce(ct_even, w_times_ginv_ct); + } else { + FastAddInto(params, ct_even, w_times_ginv_ct); + } + } + } + } + + if (idx_precomp != precomp_vals.size()) { + throw std::runtime_error("PackUsingPrecompVals: idx_precomp mismatch"); + } + + PolyMatrixNtt resulting_row_1 = working_set[0]; + FastReduce(params, resulting_row_1); + + PolyMatrixNtt res = precomp_res; + + size_t poly_len = params.PolyLen(); + size_t crt_count = params.CrtCount(); + size_t row_1_offset_ntt = crt_count * poly_len; + + uint64_t* res_data = const_cast(res.Data().data()); + const uint64_t* row_1_src = resulting_row_1.Data().data(); + + std::copy(row_1_src, row_1_src + (crt_count * poly_len), + res_data + row_1_offset_ntt); + + PolyMatrixRaw out_raw = FromNtt(params, res); + uint64_t modulus = params.Modulus(); + + for (size_t z = 0; z < poly_len; ++z) { + uint128_t val_u128 = static_cast(b_values[z]) * poly_len; + uint64_t val = arith::BarrettReductionU128(params, val_u128); + + size_t idx = poly_len + z; + + out_raw.Data()[idx] += val; + if (out_raw.Data()[idx] >= modulus) { + out_raw.Data()[idx] -= modulus; + } + } + + return ToNtt(params, out_raw); +} + +std::vector PackManyLwes( + const Params& params, + const std::vector>& prep_rlwe_cts, + const Precomp& precomp, absl::Span b_values, + size_t num_rlwe_outputs, + const std::vector& pack_pub_params_row_1s, + const std::pair, std::vector>& + y_constants) { + if (prep_rlwe_cts.size() != num_rlwe_outputs) { + throw std::runtime_error("PackManyLwes: prep_rlwe_cts size mismatch"); + } + + if (!prep_rlwe_cts.empty() && prep_rlwe_cts[0].size() != params.PolyLen()) { + throw std::runtime_error("PackManyLwes: prep_rlwe_cts inner size mismatch"); + } + + if (b_values.size() != num_rlwe_outputs * params.PolyLen()) { + throw std::runtime_error("PackManyLwes: b_values size mismatch"); + } + + if (precomp.size() != num_rlwe_outputs) { + throw std::runtime_error("PackManyLwes: precomp size mismatch"); + } + + std::vector res; + res.reserve(num_rlwe_outputs); + + size_t poly_len = params.PolyLen(); + size_t poly_len_log2 = params.PolyLenLog2(); + + for (size_t i = 0; i < num_rlwe_outputs; ++i) { + const auto& [precomp_res, precomp_vals, precomp_tables] = precomp[i]; + + auto b_values_slice = b_values.subspan(i * poly_len, poly_len); + + PolyMatrixNtt packed = PackUsingPrecompVals( + params, poly_len_log2, + absl::MakeConstSpan(pack_pub_params_row_1s), // Vector -> Span + b_values_slice, precomp_res, + absl::MakeConstSpan(precomp_vals), // Vector -> Span + precomp_tables, y_constants); + + res.push_back(std::move(packed)); + } + + return res; +} + +PolyMatrixNtt GetRegevSample(const Params& params, const PolyMatrixRaw& sk_reg, + yacl::crypto::Prg& rng, + yacl::crypto::Prg& rng_pub) { + auto a = PolyMatrixRaw::RandomPrg(params, 1, 1, rng_pub); + auto a_ntt = ToNtt(params, a); + auto a_inv = ToNtt(params, Negate(params, a)); + DiscreteGaussian dg(params.NoiseWidth()); + auto e = Noise(params, 1, 1, dg, rng); + + auto e_ntt = ToNtt(params, e); + auto sk_reg_ntt = ToNtt(params, sk_reg); + auto b_p = Multiply(params, sk_reg_ntt, a_ntt); + auto b = Add(params, e_ntt, b_p); + auto p = PolyMatrixNtt::Zero(params.CrtCount(), params.PolyLen(), 2, 1); + p.CopyInto(a_inv, 0, 0); + p.CopyInto(b, 1, 0); + + return p; +} + +PolyMatrixNtt GetFreshRegevPublicKey(const Params& params, + const PolyMatrixRaw& sk_reg, size_t m, + yacl::crypto::Prg& rng, + yacl::crypto::Prg& rng_pub) { + auto p = PolyMatrixNtt::Zero(params.CrtCount(), params.PolyLen(), 2, m); + for (size_t i = 0; i < m; ++i) { + p.CopyInto(GetRegevSample(params, sk_reg, rng, rng_pub), 0, i); + } + return p; +} + +std::vector RawGenerateExpansionParams( + const Params& params, const PolyMatrixRaw& sk_reg, size_t num_exp, + size_t m_exp, yacl::crypto::Prg& rng, + yacl::crypto::Prg& rng_pub) { + auto g_exp = util::BuildGadget(params, 1, m_exp); + auto g_exp_ntt = ToNtt(params, g_exp); + + std::vector res; + res.reserve(num_exp); + + for (size_t i = 0; i < num_exp; ++i) { + size_t t = (params.PolyLen() / (1ULL << i)) + 1; + auto tau_sk_reg = Automorphism(params, sk_reg, t); + auto tau_sk_reg_ntt = ToNtt(params, tau_sk_reg); + auto prod = Multiply(params, tau_sk_reg_ntt, g_exp_ntt); + auto sample = GetFreshRegevPublicKey(params, sk_reg, m_exp, rng, rng_pub); + + PolyMatrixNtt padded_prod = prod.PadTop(1); + auto w_exp_i = Add(params, sample, padded_prod); + res.push_back(std::move(w_exp_i)); + } + return res; +} + +// from kernal.rs + +template +void FastBatchedDotProduct(const Params& params, uint64_t* c, const uint64_t* a, + size_t a_elems, const T* b_t, size_t b_rows, + size_t b_cols) { + if (a_elems != b_rows) { + throw std::runtime_error("FastBatchedDotProduct: Dimension mismatch"); + } + + const size_t chunk_size = std::min(65536, a_elems); + const size_t num_chunks = a_elems / chunk_size; + + for (size_t k_outer = 0; k_outer < num_chunks; ++k_outer) { + const uint64_t* a_chunk_ptr = a + (k_outer * chunk_size); + for (size_t j = 0; j < b_cols; ++j) { + const T* b_ptr = b_t + (j * b_rows) + (k_outer * chunk_size); + uint64_t total_sum_lo = 0; + uint64_t total_sum_hi = 0; + for (size_t k_inner = 0; k_inner < chunk_size; ++k_inner) { + uint64_t a_val = a_chunk_ptr[k_inner]; + uint64_t b_val = static_cast(b_ptr[k_inner]); + uint64_t a_lo = a_val & 0xFFFFFFFF; + uint64_t a_hi = a_val >> 32; + total_sum_lo += a_lo * b_val; + total_sum_hi += a_hi * b_val; + } + + uint64_t lo = arith::BarrettCoeffU64(params, total_sum_lo, 0); + uint64_t hi = arith::BarrettCoeffU64(params, total_sum_hi, 1); + + uint64_t res = params.CrtCompose2(lo, hi); + + uint64_t sum = c[j] + res; + c[j] = arith::BarrettU64(params, sum); + } + } +} + +// from serialize.rs +std::vector UnpackVecPm(const Params& params, size_t rows, + size_t cols, + absl::Span data) { + if (params.CrtCount() != 2) { + throw std::runtime_error("UnpackVecPm: Params CRT count must be 2"); + } + + size_t poly_len = params.PolyLen(); + size_t chunk_size = rows * cols * poly_len; + + if (chunk_size == 0) { + return {}; + } + + if (data.size() % chunk_size != 0) { + throw std::runtime_error( + "UnpackVecPm: Data size not aligned with matrix dimensions"); + } + + size_t num_matrices = data.size() / chunk_size; + std::vector v_cts; + v_cts.reserve(num_matrices); + + for (size_t i = 0; i < num_matrices; ++i) { + const uint64_t* in_data_ptr = data.data() + (i * chunk_size); + + auto ct = + PolyMatrixNtt::Zero(params.CrtCount(), params.PolyLen(), rows, cols); + + uint64_t* out_data_ptr = const_cast(ct.Data().data()); + + for (size_t row = 0; row < rows; ++row) { + for (size_t col = 0; col < cols; ++col) { + size_t in_offs = (row * cols + col) * poly_len; + + size_t out_offs = (row * cols + col) * 2 * poly_len; + + for (size_t z = 0; z < poly_len; ++z) { + out_data_ptr[out_offs + z] = in_data_ptr[in_offs + z]; + } + } + } + v_cts.push_back(std::move(ct)); + } + + return v_cts; +} +PolyMatrixNtt UncondenseMatrix(const Params& params, const PolyMatrixNtt& a) { + size_t rows = a.Rows(); + size_t cols = a.Cols(); + size_t poly_len = params.PolyLen(); + + PolyMatrixNtt res = + PolyMatrixNtt::Zero(params.CrtCount(), params.PolyLen(), rows, cols); + + for (size_t i = 0; i < rows; ++i) { + for (size_t j = 0; j < cols; ++j) { + auto res_poly = res.Poly(i, j); + const auto a_poly = a.Poly(i, j); + + for (size_t z = 0; z < poly_len; ++z) { + uint64_t val = a_poly[z]; + res_poly[z] = val & 0xFFFFFFFFULL; + res_poly[z + poly_len] = val >> 32; + } + } + } + + return res; +} +// from modulus switch.rs +std::vector ModulusSwitch(const Params& params, + const PolyMatrixRaw& poly_matrix, + uint64_t q_prime_1, uint64_t q_prime_2) { + if (poly_matrix.Rows() != 2 || poly_matrix.Cols() != 1) { + throw std::runtime_error("ModulusSwitch: Matrix must be 2x1"); + } + size_t poly_len = params.PolyLen(); + uint64_t current_modulus = params.Modulus(); + + size_t bits_for_row0 = static_cast(std::ceil(std::log2(q_prime_2))); + size_t bits_for_row1 = static_cast(std::ceil(std::log2(q_prime_1))); + + size_t total_sz_bits = (bits_for_row0 + bits_for_row1) * poly_len; + size_t total_sz_bytes = (total_sz_bits + 7) / 8; + + std::vector res(total_sz_bytes, 0); + + size_t bit_offs = 0; + + const uint64_t* row_0_ptr = poly_matrix.Data().data(); + + for (size_t z = 0; z < poly_len; ++z) { + uint64_t val = row_0_ptr[z]; + uint64_t val_rescaled = arith::Rescale(val, current_modulus, q_prime_2); + + util::WriteArbitraryBits(res, val_rescaled, bit_offs, bits_for_row0); + bit_offs += bits_for_row0; + } + + const uint64_t* row_1_ptr = poly_matrix.Data().data() + poly_len; + + for (size_t z = 0; z < poly_len; ++z) { + uint64_t val = row_1_ptr[z]; + uint64_t val_rescaled = arith::Rescale(val, current_modulus, q_prime_1); + + util::WriteArbitraryBits(res, val_rescaled, bit_offs, bits_for_row1); + bit_offs += bits_for_row1; + } + + return res; +} + +// Explicit instantiation of template functions +template void FastBatchedDotProduct(const Params& params, uint64_t* c, + const uint64_t* a, size_t a_elems, + const uint8_t* b_t, size_t b_rows, + size_t b_cols); +template void FastBatchedDotProduct(const Params& params, uint64_t* c, + const uint64_t* a, size_t a_elems, + const uint16_t* b_t, + size_t b_rows, size_t b_cols); +template void FastBatchedDotProduct(const Params& params, uint64_t* c, + const uint64_t* a, size_t a_elems, + const uint32_t* b_t, + size_t b_rows, size_t b_cols); + +} // namespace psi::ypir diff --git a/psi/algorithm/ypir/legacy/util.h b/psi/algorithm/ypir/legacy/util.h new file mode 100644 index 00000000..97d657bf --- /dev/null +++ b/psi/algorithm/ypir/legacy/util.h @@ -0,0 +1,130 @@ +#pragma once + +#include + +#include "absl/types/span.h" + +#include "psi/algorithm/spiral/params.h" +#include "psi/algorithm/spiral/poly_matrix.h" + +#include "psi/algorithm/ypir/legacy/types.h" +namespace psi::ypir { + +using namespace psi::spiral; +std::vector ConcatHorizontal( + const std::vector>& v_a, size_t a_rows, + size_t a_cols); + +void MatMulVecPacked(uint32_t* out, const uint32_t* a, const uint32_t* b, + size_t a_rows, size_t a_cols, size_t b_rows, + size_t b_cols); + +PolyMatrixNtt HomomorphicAutomorph(const Params& params, size_t t, size_t t_exp, + const PolyMatrixNtt& ct, + const PolyMatrixNtt& pub_param); + +PolyMatrixNtt RingPackLwesInner( + const Params& params, size_t ell, size_t start_idx, + const std::vector& rlwe_cts, + const std::vector& pub_params, + const std::pair, std::vector>& + y_constants); + +std::pair, std::vector> GenYConstants( + const Params& params); + +PolyMatrixNtt RingPackLwes( + const Params& params, const std::vector& b_values, + const std::vector& rlwe_cts, size_t num_cts, + const std::vector& pub_params, + const std::pair, std::vector>& + y_constants); + +std::vector NegacyclicPerm(absl::Span a, size_t shift, + uint64_t modulus); +std::vector NegacyclicMatrix(absl::Span a, + uint64_t modulus); +PolyMatrixNtt CondenseMatrix(const Params& params, const PolyMatrixNtt& a); +PolyMatrixNtt UncondenseMatrix(const Params& params, const PolyMatrixNtt& a); +PolyMatrixNtt PackUsingSingleWithOffset( + const Params& params, const std::vector& pub_params, + const std::vector& cts, size_t offset); + +std::vector PrepPackLwes(const Params& params, + absl::Span lwe_cts, + size_t cols_to_do); + +std::vector> PrepPackManyLwes( + const Params& params, absl::Span lwe_cts, + size_t num_rlwe_outputs); + +std::vector> GenerateAutomorphTablesBruteForce( + const Params& params); + +std::tuple, + std::vector>> +PrecomputePack(const Params& params, size_t poly_len_log2, + const std::vector& prepacked, + const std::vector& pub_params, + const std::pair, + std::vector>& y_constants); +void FastAddIntoNoReduce(PolyMatrixNtt& res, const PolyMatrixNtt& a); +void MultiplyPolyAvx(uint64_t* res, const uint64_t* a, const uint64_t* b, + size_t len); +void ScalarMultiplyAvx(const Params& params, PolyMatrixNtt& res, + const PolyMatrixNtt& a, const PolyMatrixNtt& b); + +void FastMultiplyNoReduce(const Params& params, PolyMatrixNtt& res, + const PolyMatrixNtt& a, const PolyMatrixNtt& b, + size_t start_inner_dim = 0); +void ApplyAutomorphNttRaw(const Params& params, const uint64_t* poly, + uint64_t* out, size_t t, + const std::vector>& tables); +void ApplyAutomorphNtt(const Params& params, + const std::vector>& tables, + const PolyMatrixNtt& mat, PolyMatrixNtt& res, size_t t); +void FastReduce(const Params& params, PolyMatrixNtt& res); +PolyMatrixNtt PackUsingPrecompVals( + const Params& params, + size_t ell, // params.poly_len_log2 + absl::Span pub_params, + absl::Span b_values, const PolyMatrixNtt& precomp_res, + absl::Span precomp_vals, + const std::vector>& precomp_tables, + const std::pair, std::vector>& + y_constants); + +std::vector PackManyLwes( + const Params& params, + const std::vector>& prep_rlwe_cts, + const Precomp& precomp, absl::Span b_values, + size_t num_rlwe_outputs, + const std::vector& pack_pub_params_row_1s, + const std::pair, std::vector>& + y_constants); + +PolyMatrixNtt GetRegevSample(const Params& params, const PolyMatrixRaw& sk_reg, + yacl::crypto::Prg& rng, + yacl::crypto::Prg& rng_pub); +PolyMatrixNtt GetFreshRegevPublicKey(const Params& params, + const PolyMatrixRaw& sk_reg, size_t m, + yacl::crypto::Prg& rng, + yacl::crypto::Prg& rng_pub); +std::vector RawGenerateExpansionParams( + const Params& params, const PolyMatrixRaw& sk_reg, size_t num_exp, + size_t m_exp, yacl::crypto::Prg& rng, + yacl::crypto::Prg& rng_pub); + +template +void FastBatchedDotProduct(const Params& params, uint64_t* c, const uint64_t* a, + size_t a_elems, const T* b_t, size_t b_rows, + size_t b_cols); + +std::vector UnpackVecPm(const Params& params, size_t rows, + size_t cols, + absl::Span data); + +std::vector ModulusSwitch(const Params& params, + const PolyMatrixRaw& poly_matrix, + uint64_t q_prime_1, uint64_t q_prime_2); +} // namespace psi::ypir \ No newline at end of file diff --git a/psi/algorithm/ypir/ypir_params.cc b/psi/algorithm/ypir/legacy/ypir_params.cc similarity index 97% rename from psi/algorithm/ypir/ypir_params.cc rename to psi/algorithm/ypir/legacy/ypir_params.cc index f1ab1166..8f9fa0c7 100644 --- a/psi/algorithm/ypir/ypir_params.cc +++ b/psi/algorithm/ypir/legacy/ypir_params.cc @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "psi/algorithm/ypir/ypir_params.h" +#include "psi/algorithm/ypir/legacy/ypir_params.h" #include #include @@ -20,7 +20,7 @@ #include #include "yacl/base/exception.h" -namespace psi::ypir::byhe { +namespace psi::ypir::ypir_internal { namespace { uint64_t Log2Exact(uint64_t n) { @@ -100,8 +100,7 @@ FheParams::FheParams(uint64_t rlwe_degree, uint64_t rlwe_ct_modulus, YACL_ENFORCE(lwe_ct_modulus_ > 0); YACL_ENFORCE(rlwe_pt_modulus_ > 0); YACL_ENFORCE(lwe_pt_modulus_ > 0); - YACL_ENFORCE(byhe::IsPowerOfTwo(rlwe_degree_), - "rlwe_degree must be power of two"); + YACL_ENFORCE(IsPowerOfTwo(rlwe_degree_), "rlwe_degree must be power of two"); rlwe_degree_log2_ = Log2Exact(rlwe_degree_); } @@ -139,7 +138,7 @@ PirParams::PirParams(uint64_t rows, uint64_t cols) } // ====================================================================== -// Byhe utilities that depend on FheParams (moved from byhe_util.cc) +// YPIR utilities that depend on FheParams. // ====================================================================== void ApplyAutoNttForm(const std::vector& vec, @@ -178,7 +177,7 @@ void KeyswitchPreprocess( const uint64_t length = fparm.get_poly_degree(); const uint64_t modulus = fparm.get_rlwe_cmod(); - ByheHexlNtt& ntt = fparm.get_ntt(); + YpirHexlNtt& ntt = fparm.get_ntt(); std::vector> decomp_a(t, std::vector(length, 0)); ntt.Inverse(a_in.data(), length); @@ -431,7 +430,7 @@ std::vector PackrlweOnlineConstantRows( } void Cdks21Lwe2RlweInplace(uint64_t* lwe_a, uint64_t degree, uint64_t cmod, - ByheHexlNtt& ntt) { + YpirHexlNtt& ntt) { uint64_t a0 = lwe_a[0]; for (uint64_t i = 1; i < (degree + 1) / 2; ++i) { @@ -451,4 +450,4 @@ void Cdks21Lwe2RlweInplace(uint64_t* lwe_a, uint64_t degree, uint64_t cmod, ntt.Forward(lwe_a, degree); } -} // namespace psi::ypir::byhe +} // namespace psi::ypir::ypir_internal diff --git a/psi/algorithm/ypir/ypir_params.h b/psi/algorithm/ypir/legacy/ypir_params.h similarity index 95% rename from psi/algorithm/ypir/ypir_params.h rename to psi/algorithm/ypir/legacy/ypir_params.h index d37c9f5f..15ec7a87 100644 --- a/psi/algorithm/ypir/ypir_params.h +++ b/psi/algorithm/ypir/legacy/ypir_params.h @@ -17,9 +17,9 @@ #include #include -#include "psi/algorithm/ypir/ypir_util.h" +#include "psi/algorithm/ypir/legacy/ypir_util.h" -namespace psi::ypir::byhe { +namespace psi::ypir::ypir_internal { class Secret { public: @@ -61,7 +61,7 @@ class FheParams { double sigma_ring, AutoParams auto_params, DecompParams decomp_params); - // byhe-style getters + // ypir-internal getters uint64_t get_poly_degree() const { return rlwe_degree_; } uint64_t get_rlwe_cmod() const { return rlwe_ct_modulus_; } uint64_t get_rlwe_pmod() const { return rlwe_pt_modulus_; } @@ -76,7 +76,7 @@ class FheParams { uint64_t get_t_decomp() const { return decomp_params_.t; } double get_sig() const { return sigma_; } double get_sig_ring() const { return sigma_ring_; } - ByheHexlNtt& get_ntt() const noexcept { return ntt_; } + YpirHexlNtt& get_ntt() const noexcept { return ntt_; } const std::vector>& get_persudo_matrix_simplepir() const noexcept { @@ -127,7 +127,7 @@ class FheParams { DecompParams decomp_params_; uint64_t rlwe_degree_log2_ = 0; - mutable ByheHexlNtt ntt_; + mutable YpirHexlNtt ntt_; std::vector> persudo_matrix_simplepir_; std::vector> persudo_matrix_doublepir_; @@ -152,4 +152,4 @@ class PirParams { uint64_t cols_ = 0; }; -} // namespace psi::ypir::byhe +} // namespace psi::ypir::ypir_internal diff --git a/psi/algorithm/ypir/ypir_util.cc b/psi/algorithm/ypir/legacy/ypir_util.cc similarity index 99% rename from psi/algorithm/ypir/ypir_util.cc rename to psi/algorithm/ypir/legacy/ypir_util.cc index d165ec76..babea32a 100644 --- a/psi/algorithm/ypir/ypir_util.cc +++ b/psi/algorithm/ypir/legacy/ypir_util.cc @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "psi/algorithm/ypir/ypir_util.h" +#include "psi/algorithm/ypir/legacy/ypir_util.h" #include #include @@ -24,7 +24,7 @@ #endif -namespace psi::ypir::byhe { +namespace psi::ypir::ypir_internal { namespace { int64_t ExGcd(int64_t a, int64_t b, int64_t& x, int64_t& y) { @@ -516,4 +516,4 @@ void MatVecU8U32Mod2p32(const uint8_t* A, const uint32_t* x, uint32_t* y, MatVecU8U32Mod2p32Scalar(A, x, y, rows, cols); } -} // namespace psi::ypir::byhe +} // namespace psi::ypir::ypir_internal diff --git a/psi/algorithm/ypir/ypir_util.h b/psi/algorithm/ypir/legacy/ypir_util.h similarity index 94% rename from psi/algorithm/ypir/ypir_util.h rename to psi/algorithm/ypir/legacy/ypir_util.h index 86bd4fa7..7076ddc7 100644 --- a/psi/algorithm/ypir/ypir_util.h +++ b/psi/algorithm/ypir/legacy/ypir_util.h @@ -19,10 +19,10 @@ #include #include -#include "psi/algorithm/ypir/aes_prng.h" -#include "psi/algorithm/ypir/hexl.h" +#include "psi/algorithm/ypir/legacy/aes_prng.h" +#include "psi/algorithm/ypir/legacy/hexl.h" -namespace psi::ypir::byhe { +namespace psi::ypir::ypir_internal { class FheParams; @@ -54,7 +54,7 @@ void PrecomputeAutomap(uint32_t length, uint32_t idx, void PseudorandomMatrixGenerate(std::vector>& matrix, uint64_t modulus, AESCTR_PRNG& prng); -// Helpers for byhe-style precomputation buffers. +// Helpers for ypir-internal precomputation buffers. void SetPseudorandomMatrixSimplepir(std::vector>& matrix, std::vector& matrix_flat, uint64_t rows, uint64_t cols, @@ -79,7 +79,7 @@ void SetPrecomputedPt(std::vector>& precomputed_pt, uint64_t poly_degree, uint64_t max_lh, NttForwardFn ntt_forward); -// byhe server-side helpers +// ypir server-side helpers void VectorColDecompose(const std::vector& vec, std::vector>& decomp_matrix, uint64_t b, uint64_t z, uint64_t t); @@ -129,6 +129,6 @@ std::vector PackrlweOnlineConstantRows( const FheParams& fparm); void Cdks21Lwe2RlweInplace(uint64_t* lwe_a, uint64_t degree, uint64_t cmod, - ByheHexlNtt& ntt); + YpirHexlNtt& ntt); -} // namespace psi::ypir::byhe +} // namespace psi::ypir::ypir_internal diff --git a/psi/algorithm/ypir/params.cc b/psi/algorithm/ypir/params.cc index b756571c..2c0354c1 100644 --- a/psi/algorithm/ypir/params.cc +++ b/psi/algorithm/ypir/params.cc @@ -1,37 +1,134 @@ -// Copyright 2025 The secretflow authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - #include "psi/algorithm/ypir/params.h" -#include "psi/algorithm/spiral/params.h" -#include "psi/algorithm/spiral/util.h" +#include +#include +#include +#include + +#include "yacl/base/exception.h" namespace psi::ypir { +namespace { + +size_t Log2Exact(uint64_t v) { + YACL_ENFORCE_GT(v, 0U); + YACL_ENFORCE_EQ(v & (v - 1), 0U, "value must be a power of two"); + size_t out = 0; + while (v > 1) { + v >>= 1; + ++out; + } + return out; +} + +struct MatrixShape { + uint64_t rows = 0; + uint64_t cols = 0; +}; + +MatrixShape ChooseShape(uint64_t num_items, uint64_t base) { + YACL_ENFORCE_GT(base, 0U); + uint64_t rows = base; + uint64_t cols = base; + while (rows * cols < num_items) { + if (rows <= cols) { + rows <<= 1; + } else { + cols <<= 1; + } + } + return {rows, cols}; +} + +YpirParameters BuildSimplepirParamsForShape(uint64_t db_rows, uint64_t db_cols, + uint64_t item_size_bits) { + const uint64_t poly_len = 1024; + const uint64_t pt_modulus = item_size_bits <= 8 ? (1ULL << 8) : (1ULL << 14); + YACL_ENFORCE_GE(db_rows, poly_len); + YACL_ENFORCE_EQ(db_cols % poly_len, 0U, + "simplepir db_cols must be a multiple of {}", poly_len); + const size_t db_dim_1 = Log2Exact(db_rows) - Log2Exact(poly_len); + const size_t instances = db_cols / poly_len; + + std::vector moduli = {268369921ULL, 249561089ULL}; + double noise_width = 16.042421; + psi::spiral::PolyMatrixParams poly_matrix_params(2, pt_modulus, 21, 4, 8, 8, + instances); + psi::spiral::QueryParams query_params(db_dim_1, 0, instances); + psi::spiral::Params spiral_params(poly_len, std::move(moduli), noise_width, + std::move(poly_matrix_params), + std::move(query_params)); + + YpirParameters out; + out.mode = YpirMode::kSimplepir; + out.spiral_params = std::move(spiral_params); + out.db_rows = + 1ULL << (out.spiral_params.DbDim1() + out.spiral_params.PolyLenLog2()); + out.db_cols = out.spiral_params.Instances() * out.spiral_params.PolyLen(); + out.value_bytes = std::max(1, (item_size_bits + 7) / 8); + return out; +} + +YpirParameters BuildDoublepirParamsForShape(uint64_t db_rows, uint64_t db_cols, + uint64_t item_size_bits) { + const uint64_t poly_len = 1024; + YACL_ENFORCE_GE(db_rows, poly_len); + YACL_ENFORCE_GE(db_cols, poly_len); + const size_t db_dim_1 = Log2Exact(db_rows) - Log2Exact(poly_len); + const size_t db_dim_2 = Log2Exact(db_cols) - Log2Exact(poly_len); + + std::vector moduli = {268369921ULL, 249561089ULL}; + double noise_width = 6.4; + psi::spiral::PolyMatrixParams poly_matrix_params(2, 1ULL << 15, 21, 4, 8, 8, + 1); + psi::spiral::QueryParams query_params(db_dim_1, db_dim_2, 1); + psi::spiral::Params spiral_params(poly_len, std::move(moduli), noise_width, + std::move(poly_matrix_params), + std::move(query_params)); + + YpirParameters out; + out.mode = YpirMode::kDoublepir; + out.spiral_params = std::move(spiral_params); + out.db_rows = + 1ULL << (out.spiral_params.DbDim1() + out.spiral_params.PolyLenLog2()); + out.db_cols = + 1ULL << (out.spiral_params.DbDim2() + out.spiral_params.PolyLenLog2()); + out.value_bytes = std::max(1, (item_size_bits + 7) / 8); + return out; +} + +} // namespace + +YpirParameters CreateParamsForScenarioSimplePIR(uint64_t num_items, + uint64_t item_size_bits) { + const auto shape = ChooseShape(num_items, 1024); + return BuildSimplepirParamsForShape(shape.rows, shape.cols, item_size_bits); +} + +YpirParameters CreateParamsForScenarioDoublePIR(uint64_t num_items, + uint64_t item_size_bits) { + const auto shape = ChooseShape(num_items, 1024); + return BuildDoublepirParamsForShape(shape.rows, shape.cols, item_size_bits); +} + +YpirParameters CreateParamsForShapeSimplePIR(uint64_t db_rows, + uint64_t db_cols, + uint64_t item_size_bits) { + return BuildSimplepirParamsForShape(db_rows, db_cols, item_size_bits); +} + +YpirParameters CreateParamsForShapeDoublePIR(uint64_t db_rows, + uint64_t db_cols, + uint64_t item_size_bits) { + return BuildDoublepirParamsForShape(db_rows, db_cols, item_size_bits); +} -psi::spiral::Params CreateParamsForScenarioSimplePIR( - uint64_t /*num_items*/, uint64_t /*item_size_bits*/) { - // For now, use the fast expansion testing params as a reasonable default - // In production, you would calculate optimal parameters based on num_items - // and item_size_bits - return psi::spiral::util::GetFastExpansionTestingParam(); +YpirParameters CreateSmallTestParamsSimplePIR() { + return BuildSimplepirParamsForShape(1ULL << 10, 1ULL << 10, 16); } -psi::spiral::Params CreateParamsForScenario(uint64_t /*num_items*/, - uint64_t /*item_size_bits*/) { - // For now, use the fast expansion testing params for DoublePIR too - // In production, you would use different parameters optimized for DoublePIR - return psi::spiral::util::GetFastExpansionTestingParam(); +YpirParameters CreateSmallTestParamsDoublePIR() { + return BuildDoublepirParamsForShape(1ULL << 10, 1ULL << 10, 8); } } // namespace psi::ypir diff --git a/psi/algorithm/ypir/params.h b/psi/algorithm/ypir/params.h index 0f08cada..a3b01e73 100644 --- a/psi/algorithm/ypir/params.h +++ b/psi/algorithm/ypir/params.h @@ -1,53 +1,34 @@ -// Copyright 2025 The secretflow authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - #pragma once #include #include -#include "psi/algorithm/spiral/common.h" #include "psi/algorithm/spiral/params.h" +#include "psi/algorithm/ypir/types.h" namespace psi::ypir { -struct LWEParams { - size_t n = 1024; - uint64_t modulus = 1ULL << 32; - uint64_t pt_modulus = 1ULL << 8; - size_t q2_bits = 28; - double noise_width = 27.57291103; +struct YpirParameters { + YpirMode mode = YpirMode::kSimplepir; + psi::spiral::Params spiral_params; + uint64_t db_rows = 0; + uint64_t db_cols = 0; + size_t value_bytes = 0; - uint64_t ScaleK() const { return modulus / pt_modulus; } - static LWEParams Default() { return LWEParams(); } - uint64_t GetQPrime2() const { - const size_t modulus_bits = - static_cast(std::ceil(std::log2(static_cast(modulus)))); - if (q2_bits == modulus_bits) { - return modulus; - } else { - return psi::spiral::kQ2Values[q2_bits]; - } - } + [[nodiscard]] uint64_t NumItems() const { return db_rows * db_cols; } }; -// Create parameters for SimplePIR scenario -psi::spiral::Params CreateParamsForScenarioSimplePIR(uint64_t num_items, - uint64_t item_size_bits); - -// Create parameters for DoublePIR scenario -psi::spiral::Params CreateParamsForScenario(uint64_t num_items, - uint64_t item_size_bits); +YpirParameters CreateParamsForScenarioSimplePIR(uint64_t num_items, + uint64_t item_size_bits); +YpirParameters CreateParamsForScenarioDoublePIR(uint64_t num_items, + uint64_t item_size_bits); +YpirParameters CreateParamsForShapeSimplePIR(uint64_t db_rows, + uint64_t db_cols, + uint64_t item_size_bits); +YpirParameters CreateParamsForShapeDoublePIR(uint64_t db_rows, + uint64_t db_cols, + uint64_t item_size_bits); +YpirParameters CreateSmallTestParamsSimplePIR(); +YpirParameters CreateSmallTestParamsDoublePIR(); } // namespace psi::ypir diff --git a/psi/algorithm/ypir/params_test.cc b/psi/algorithm/ypir/params_test.cc new file mode 100644 index 00000000..c1b4e67f --- /dev/null +++ b/psi/algorithm/ypir/params_test.cc @@ -0,0 +1,51 @@ +#include "psi/algorithm/ypir/params.h" + +#include "gtest/gtest.h" + +namespace psi::ypir { +namespace { + +TEST(YpirParamsTest, SmallSimplepirParamsMatchFastRegressionShape) { + const auto params = CreateSmallTestParamsSimplePIR(); + EXPECT_EQ(params.mode, YpirMode::kSimplepir); + EXPECT_EQ(params.db_rows, 1ULL << 10); + EXPECT_EQ(params.db_cols, 1ULL << 10); + EXPECT_EQ(params.value_bytes, 2U); +} + +TEST(YpirParamsTest, SmallDoublepirParamsMatchFastRegressionShape) { + const auto params = CreateSmallTestParamsDoublePIR(); + EXPECT_EQ(params.mode, YpirMode::kDoublepir); + EXPECT_EQ(params.db_rows, 1ULL << 10); + EXPECT_EQ(params.db_cols, 1ULL << 10); + EXPECT_EQ(params.value_bytes, 1U); +} + +TEST(YpirParamsTest, ScenarioHelpersRespectRequestedValueSize) { + const auto simple_params = + CreateParamsForScenarioSimplePIR((1ULL << 18) + 7, 8); + const auto double_params = + CreateParamsForScenarioDoublePIR((1ULL << 19) + 9, 24); + + EXPECT_GE(simple_params.NumItems(), (1ULL << 18) + 7); + EXPECT_EQ(simple_params.value_bytes, 1U); + EXPECT_GE(double_params.NumItems(), (1ULL << 19) + 9); + EXPECT_EQ(double_params.value_bytes, 3U); +} + +TEST(YpirParamsTest, ShapeHelpersPreserveRequestedShape) { + const auto simple_params = CreateParamsForShapeSimplePIR(1ULL << 11, + 3ULL << 10, 16); + const auto double_params = CreateParamsForShapeDoublePIR(1ULL << 11, + 1ULL << 12, 8); + + EXPECT_EQ(simple_params.db_rows, 1ULL << 11); + EXPECT_EQ(simple_params.db_cols, 3ULL << 10); + EXPECT_EQ(simple_params.value_bytes, 2U); + EXPECT_EQ(double_params.db_rows, 1ULL << 11); + EXPECT_EQ(double_params.db_cols, 1ULL << 12); + EXPECT_EQ(double_params.value_bytes, 1U); +} + +} // namespace +} // namespace psi::ypir diff --git a/psi/algorithm/ypir/pir_interface_test.cc b/psi/algorithm/ypir/pir_interface_test.cc new file mode 100644 index 00000000..c72b3cf2 --- /dev/null +++ b/psi/algorithm/ypir/pir_interface_test.cc @@ -0,0 +1,95 @@ +#include "psi/algorithm/ypir/client.h" +#include "psi/algorithm/ypir/server.h" + +#include +#include +#include + +#include "gtest/gtest.h" + +namespace psi::ypir { +namespace { + +uint64_t BytesToU64(const std::vector& bytes) { + uint64_t value = 0; + for (size_t i = 0; i < bytes.size(); ++i) { + value |= static_cast(bytes[i]) << (8 * i); + } + return value; +} + +template +psi::pir::RawDatabase BuildItemDatabase(const YpirParameters& params, + Fn&& make_value) { + std::vector> rows( + params.NumItems(), std::vector(params.value_bytes, 0)); + for (uint64_t raw_idx = 0; raw_idx < params.NumItems(); ++raw_idx) { + const T value = make_value(raw_idx); + std::memcpy(rows[raw_idx].data(), &value, params.value_bytes); + } + return psi::pir::RawDatabase(std::move(rows)); +} + +TEST(YpirPirInterfaceTest, SimplepirImplementsIndexPirInterfaces) { + auto params = CreateSmallTestParamsSimplePIR(); + YpirClient concrete_client(params); + YpirServer concrete_server(params); + + psi::pir::IndexPirClient& client = concrete_client; + psi::pir::IndexPirDataBase& server = concrete_server; + + const auto raw_db = BuildItemDatabase( + params, [&](uint64_t raw_idx) { + const uint64_t row = raw_idx / params.db_cols; + const uint64_t col = raw_idx % params.db_cols; + return static_cast( + (row * 17 + col * 3) % params.spiral_params.PtModulus()); + }); + server.GenerateFromRawData(raw_db); + + const uint64_t raw_idx = 123ULL * params.db_cols + 456ULL; + const auto pks = client.GeneratePksBuffer(); + const auto query = client.GenerateIndexQuery(raw_idx); + const auto response = server.Response(query, pks); + const auto decoded = client.DecodeIndexResponse(response, raw_idx); + + EXPECT_EQ(client.GetPirType(), psi::pir::PirType::YPIR_PIR); + EXPECT_EQ(server.GetPirType(), psi::pir::PirType::YPIR_PIR); + EXPECT_EQ(server.MaxElementsOfOnePt(), 1U); + EXPECT_TRUE(server.DbSeted()); + EXPECT_EQ(BytesToU64(decoded), + (123ULL * 17 + 456ULL * 3) % params.spiral_params.PtModulus()); +} + +TEST(YpirPirInterfaceTest, DoublepirImplementsIndexPirInterfaces) { + auto params = CreateSmallTestParamsDoublePIR(); + YpirClient concrete_client(params); + YpirServer concrete_server(params); + + psi::pir::IndexPirClient& client = concrete_client; + psi::pir::IndexPirDataBase& server = concrete_server; + + const auto raw_db = BuildItemDatabase( + params, [&](uint64_t raw_idx) { + const uint64_t row = raw_idx / params.db_cols; + const uint64_t col = raw_idx % params.db_cols; + return static_cast((row + col) % 251); + }); + server.GenerateFromRawData(raw_db); + + const uint64_t raw_idx = 111ULL * params.db_cols + 222ULL; + const auto pks = client.GeneratePksBuffer(); + const auto query = client.GenerateIndexQuery(raw_idx); + const auto response = server.Response(query, pks); + const auto decoded = client.DecodeIndexResponse(response, raw_idx); + + EXPECT_EQ(client.GetPirType(), psi::pir::PirType::YPIR_PIR); + EXPECT_EQ(server.GetPirType(), psi::pir::PirType::YPIR_PIR); + EXPECT_EQ(server.MaxElementsOfOnePt(), 1U); + EXPECT_TRUE(server.DbSeted()); + ASSERT_EQ(decoded.size(), 1U); + EXPECT_EQ(decoded[0], static_cast((111 + 222) % 251)); +} + +} // namespace +} // namespace psi::ypir diff --git a/psi/algorithm/ypir/rescale_test.cc b/psi/algorithm/ypir/rescale_test.cc deleted file mode 100644 index 51fa11cd..00000000 --- a/psi/algorithm/ypir/rescale_test.cc +++ /dev/null @@ -1,58 +0,0 @@ -#include "gtest/gtest.h" - -#include "psi/algorithm/spiral/arith/arith.h" -#include "psi/algorithm/spiral/params.h" - -namespace psi::ypir { - -using namespace psi::spiral; - -TEST(RescaleTest, SimplePIRRescale) { - // SimplePIR parameters - uint64_t q = 66974689739603969ULL; // modulus - uint64_t pt_modulus = 256; - uint64_t scale_k = q / pt_modulus; // 261619881795328 - - // Test: encode db value 100, then decode - uint8_t db_value = 100; - - // When query encrypts scale_k at position i, and we compute dot product - // with db, we get approximately: scale_k * db_value (plus noise) - uint64_t encoded = scale_k * db_value; - - // After decryption, rescale should recover the original value - uint64_t decoded = arith::Rescale(encoded, q, pt_modulus); - - EXPECT_EQ(decoded, db_value) - << "Rescale failed: expected " << (int)db_value << ", got " << decoded; - - // Test multiple values - for (uint8_t val : {0, 1, 100, 101, 200, 250, 255}) { - uint64_t enc = scale_k * val; - uint64_t dec = arith::Rescale(enc, q, pt_modulus); - EXPECT_EQ(dec, val) << "Failed for value " << (int)val; - } -} - -TEST(RescaleTest, WithNoise) { - uint64_t q = 66974689739603969ULL; - uint64_t pt_modulus = 256; - uint64_t scale_k = q / pt_modulus; - - uint8_t db_value = 100; - uint64_t encoded = scale_k * db_value; - - // Add small noise (simulating LWE noise) - // Noise should be << q / (2 * pt_modulus) to decode correctly - for (int64_t noise = -1000; noise <= 1000; noise += 100) { - uint64_t noisy = - static_cast(static_cast(encoded) + noise); - uint64_t decoded = arith::Rescale(noisy, q, pt_modulus); - - EXPECT_EQ(decoded, db_value) - << "Failed with noise=" << noise << ", encoded=" << encoded - << ", noisy=" << noisy << ", decoded=" << decoded; - } -} - -} // namespace psi::ypir diff --git a/psi/algorithm/ypir/scale_k_test.cc b/psi/algorithm/ypir/scale_k_test.cc deleted file mode 100644 index c80c9e78..00000000 --- a/psi/algorithm/ypir/scale_k_test.cc +++ /dev/null @@ -1,38 +0,0 @@ -#include "gtest/gtest.h" - -#include "psi/algorithm/ypir/client.h" -#include "psi/algorithm/ypir/params.h" -#include "psi/algorithm/ypir/server.h" - -namespace psi::ypir { - -TEST(ScaleKTest, VerifyScaleK) { - // SimplePIR parameters - size_t poly_len = 2048; - std::vector moduli{268369921, 249561089}; - double noise_width = 16.042421; - PolyMatrixParams poly_matrix_params(2, 16384, 21, 4, 8, 8, 1); - QueryParams query_params(1, 1, 1); - - Params params(poly_len, std::move(moduli), noise_width, - std::move(poly_matrix_params), std::move(query_params)); - - uint64_t modulus = params.Modulus(); - uint64_t pt_modulus = params.PtModulus(); - uint64_t scale_k = params.ScaleK(); - - // Verify scale_k ≈ modulus / pt_modulus - uint64_t expected_scale_k = modulus / pt_modulus; - EXPECT_EQ(scale_k, expected_scale_k); - - // Test rescale - uint64_t test_value = 100; - uint64_t scaled = scale_k * test_value; - - // Rescale back - uint64_t rescaled = arith::Rescale(scaled, modulus, pt_modulus); - - EXPECT_EQ(rescaled, test_value); -} - -} // namespace psi::ypir diff --git a/psi/algorithm/ypir/serialize.cc b/psi/algorithm/ypir/serialize.cc new file mode 100644 index 00000000..ef9b441f --- /dev/null +++ b/psi/algorithm/ypir/serialize.cc @@ -0,0 +1,140 @@ +#include "psi/algorithm/ypir/serialize.h" + +#include +#include +#include +#include +#include + +#include "yacl/base/exception.h" + +namespace psi::ypir { +namespace { + +template +void AppendPod(std::string& out, const T& value) { + out.append(reinterpret_cast(&value), sizeof(T)); +} + +template +T ReadPod(const char*& ptr, const char* end) { + YACL_ENFORCE_GE(end - ptr, static_cast(sizeof(T))); + T value; + std::memcpy(&value, ptr, sizeof(T)); + ptr += sizeof(T); + return value; +} + +template +void AppendVector(std::string& out, const std::vector& values) { + AppendPod(out, values.size()); + if (!values.empty()) { + out.append(reinterpret_cast(values.data()), + values.size() * sizeof(T)); + } +} + +template +std::vector ReadVector(const char*& ptr, const char* end) { + const auto size = ReadPod(ptr, end); + YACL_ENFORCE_GE(end - ptr, static_cast(size * sizeof(T))); + std::vector out(size); + if (size > 0) { + std::memcpy(out.data(), ptr, size * sizeof(T)); + ptr += size * sizeof(T); + } + return out; +} + +template +void AppendVector2D(std::string& out, + const std::vector>& values) { + AppendPod(out, values.size()); + for (const auto& inner : values) { + AppendVector(out, inner); + } +} + +template +std::vector> ReadVector2D(const char*& ptr, const char* end) { + const auto outer = ReadPod(ptr, end); + std::vector> out; + out.reserve(outer); + for (uint64_t i = 0; i < outer; ++i) { + out.push_back(ReadVector(ptr, end)); + } + return out; +} + +template +void AppendVector3D(std::string& out, + const std::vector>>& values) { + AppendPod(out, values.size()); + for (const auto& inner : values) { + AppendVector2D(out, inner); + } +} + +template +std::vector>> ReadVector3D(const char*& ptr, + const char* end) { + const auto outer = ReadPod(ptr, end); + std::vector>> out; + out.reserve(outer); + for (uint64_t i = 0; i < outer; ++i) { + out.push_back(ReadVector2D(ptr, end)); + } + return out; +} + +yacl::Buffer ToBuffer(const std::string& bytes) { + return yacl::Buffer(bytes.data(), bytes.size()); +} + +} // namespace + +yacl::Buffer SerializeQuery(const YpirQuery& query) { + std::string bytes; + AppendPod(bytes, static_cast(query.mode)); + AppendVector(bytes, query.packed_query_row); + AppendVector(bytes, query.qu0); + AppendVector(bytes, query.qu1); + AppendVector3D(bytes, query.ksk_b); + return ToBuffer(bytes); +} + +YpirQuery DeserializeQuery(const yacl::ByteContainerView& buffer) { + const char* ptr = reinterpret_cast(buffer.data()); + const char* end = ptr + buffer.size(); + + YpirQuery query; + query.mode = static_cast(ReadPod(ptr, end)); + query.packed_query_row = ReadVector(ptr, end); + query.qu0 = ReadVector(ptr, end); + query.qu1 = ReadVector(ptr, end); + query.ksk_b = ReadVector3D(ptr, end); + YACL_ENFORCE(ptr == end, "unexpected trailing bytes in YpirQuery"); + return query; +} + +yacl::Buffer SerializeResponse(const YpirResponse& response) { + std::string bytes; + AppendPod(bytes, static_cast(response.mode)); + AppendVector(bytes, response.simplepir_response); + AppendVector2D(bytes, response.doublepir_response); + return ToBuffer(bytes); +} + +YpirResponse DeserializeResponse(const yacl::ByteContainerView& buffer) { + const char* ptr = reinterpret_cast(buffer.data()); + const char* end = ptr + buffer.size(); + + YpirResponse response; + response.mode = static_cast(ReadPod(ptr, end)); + response.simplepir_response = ReadVector(ptr, end); + response.doublepir_response = ReadVector2D(ptr, end); + YACL_ENFORCE(ptr == end, "unexpected trailing bytes in YpirResponse"); + return response; +} + +} // namespace psi::ypir diff --git a/psi/algorithm/ypir/serialize.h b/psi/algorithm/ypir/serialize.h new file mode 100644 index 00000000..60198dab --- /dev/null +++ b/psi/algorithm/ypir/serialize.h @@ -0,0 +1,16 @@ +#pragma once + +#include "yacl/base/buffer.h" +#include "yacl/base/byte_container_view.h" + +#include "psi/algorithm/ypir/types.h" + +namespace psi::ypir { + +yacl::Buffer SerializeQuery(const YpirQuery& query); +YpirQuery DeserializeQuery(const yacl::ByteContainerView& buffer); + +yacl::Buffer SerializeResponse(const YpirResponse& response); +YpirResponse DeserializeResponse(const yacl::ByteContainerView& buffer); + +} // namespace psi::ypir diff --git a/psi/algorithm/ypir/serialize_test.cc b/psi/algorithm/ypir/serialize_test.cc new file mode 100644 index 00000000..2a61c212 --- /dev/null +++ b/psi/algorithm/ypir/serialize_test.cc @@ -0,0 +1,43 @@ +#include "psi/algorithm/ypir/serialize.h" + +#include + +#include "gtest/gtest.h" + +namespace psi::ypir { +namespace { + +TEST(YpirSerializeTest, QueryRoundTrip) { + YpirQuery query; + query.mode = YpirMode::kDoublepir; + query.packed_query_row = {1, 2, 3}; + query.qu0 = {4, 5}; + query.qu1 = {6, 7, 8}; + query.ksk_b = {{{9, 10}, {11}}, {{12, 13, 14}}}; + + const auto buffer = SerializeQuery(query); + const auto decoded = DeserializeQuery(buffer); + + EXPECT_EQ(decoded.mode, query.mode); + EXPECT_EQ(decoded.packed_query_row, query.packed_query_row); + EXPECT_EQ(decoded.qu0, query.qu0); + EXPECT_EQ(decoded.qu1, query.qu1); + EXPECT_EQ(decoded.ksk_b, query.ksk_b); +} + +TEST(YpirSerializeTest, ResponseRoundTrip) { + YpirResponse response; + response.mode = YpirMode::kDoublepir; + response.simplepir_response = {15, 16, 17}; + response.doublepir_response = {{18, 19}, {20}}; + + const auto buffer = SerializeResponse(response); + const auto decoded = DeserializeResponse(buffer); + + EXPECT_EQ(decoded.mode, response.mode); + EXPECT_EQ(decoded.simplepir_response, response.simplepir_response); + EXPECT_EQ(decoded.doublepir_response, response.doublepir_response); +} + +} // namespace +} // namespace psi::ypir diff --git a/psi/algorithm/ypir/server.cc b/psi/algorithm/ypir/server.cc index 85a93c30..082e35b4 100644 --- a/psi/algorithm/ypir/server.cc +++ b/psi/algorithm/ypir/server.cc @@ -1,160 +1,186 @@ #include "psi/algorithm/ypir/server.h" +#include +#include +#include +#include +#include #include -namespace psi::ypir::byhe { +#include "yacl/base/exception.h" + +#include "psi/algorithm/ypir/legacy/util.h" +#include "psi/algorithm/ypir/serialize.h" + +namespace psi::ypir { namespace { -void DoublepirAnswer(const uint8_t* db, uint32_t* qu0, - std::vector& qu1, - std::vector>& server_hint, - std::vector& h2, - std::vector>& h3, - std::vector& h4, const FheParams& fparm, - const PirParams& pparm) { - const uint64_t row = pparm.get_row(); - const uint64_t col = pparm.get_col(); - const uint64_t rlwe_cmod = fparm.get_rlwe_cmod(); - const uint64_t b = fparm.get_b_decomp(); - const uint64_t z = fparm.get_z_decomp(); - const uint64_t t = fparm.get_t_decomp(); +template +std::vector RowBytesToValues(const std::vector& bytes) { + YACL_ENFORCE_EQ(bytes.size() % sizeof(T), 0U); + std::vector out(bytes.size() / sizeof(T)); + std::memcpy(out.data(), bytes.data(), bytes.size()); + return out; +} - std::vector simple_res(row, 0); - MatVecU8U32Mod2p32(db, qu0, simple_res.data(), row, col); +template +T ReadScalarValue(const std::vector& bytes) { + YACL_ENFORCE_EQ(bytes.size(), sizeof(T)); + T out = 0; + std::memcpy(&out, bytes.data(), sizeof(T)); + return out; +} - std::vector> trans_simple_res_decomp; - VectorColDecompose(simple_res, trans_simple_res_decomp, b, z, t); +} // namespace - const uint64_t* matrix_d2_flat = fparm.get_persudo_matrix_doublepir_flat(); - const uint64_t poly_degree = fparm.get_poly_degree(); +template +YpirServer::YpirServer(YpirParameters params) + : psi::pir::IndexPirDataBase(psi::pir::PirType::YPIR_PIR), + params_(std::move(params)) { + if (params_.mode == YpirMode::kDoublepir) { + ypir_context_ = std::make_unique( + internal::ypir::CreateContext(params_)); + } +} - MatrixVectorFirstDimension(h2, server_hint, qu1, rlwe_cmod); +template +void YpirServer::GenerateFromRawData(const psi::pir::RawDatabase& raw_database) { + static_assert(std::is_same_v || std::is_same_v, + "YpirServer only supports uint8_t and uint16_t values"); + + const bool item_layout = + raw_database.Rows() <= params_.NumItems() && + raw_database.RowByteLen() == params_.value_bytes; + const bool matrix_layout = + raw_database.Rows() == params_.db_rows && + raw_database.RowByteLen() == params_.db_cols * sizeof(T); + YACL_ENFORCE(item_layout || matrix_layout, + "raw database shape does not match YPIR parameters"); + + if (params_.mode == YpirMode::kSimplepir) { + simplepir_db_column_major_.assign(params_.db_rows * params_.db_cols, 0); + if (item_layout) { + YACL_ENFORCE_EQ(params_.value_bytes, sizeof(T)); + for (uint64_t raw_idx = 0; raw_idx < raw_database.Rows(); ++raw_idx) { + const uint64_t row = raw_idx / params_.db_cols; + const uint64_t col = raw_idx % params_.db_cols; + simplepir_db_column_major_[col * params_.db_rows + row] = + ReadScalarValue(raw_database.At(raw_idx)); + } + } else { + for (uint64_t row = 0; row < params_.db_rows; ++row) { + auto row_values = RowBytesToValues(raw_database.At(row)); + for (uint64_t col = 0; col < params_.db_cols; ++col) { + simplepir_db_column_major_[col * params_.db_rows + row] = + row_values[col]; + } + } + } + } else { + YACL_ENFORCE(sizeof(T) == 1, "DoublePIR currently expects uint8_t rows"); + doublepir_db_row_major_.assign(params_.db_rows * params_.db_cols, 0); + if (item_layout) { + YACL_ENFORCE_EQ(params_.value_bytes, sizeof(uint8_t)); + for (uint64_t raw_idx = 0; raw_idx < raw_database.Rows(); ++raw_idx) { + doublepir_db_row_major_[raw_idx] = + ReadScalarValue(raw_database.At(raw_idx)); + } + } else { + for (uint64_t row = 0; row < params_.db_rows; ++row) { + const auto& row_bytes = raw_database.At(row); + std::memcpy(doublepir_db_row_major_.data() + row * params_.db_cols, + row_bytes.data(), row_bytes.size()); + } + } + } - MatrixMultiplicationFlatU16(h3, trans_simple_res_decomp, matrix_d2_flat, - poly_degree, rlwe_cmod); + db_set_ = true; +} - MatrixVectorMultiplicationU16(h4, trans_simple_res_decomp, qu1, rlwe_cmod); +template +void YpirServer::GenerateFromSimpleHashTable( + const psi::pir::RawDatabase& raw_database) { + GenerateFromRawData(raw_database); } -} // namespace +template +void YpirServer::Dump(std::ostream& out_stream) const { + out_stream << "YpirServer{mode=" + << (params_.mode == YpirMode::kSimplepir ? "simplepir" + : "doublepir") + << ", db_rows=" << params_.db_rows << ", db_cols=" + << params_.db_cols << ", value_bytes=" << params_.value_bytes + << ", db_set=" << db_set_ << "}"; +} -void YpirHintGenerate(std::vector>& db, - std::vector& h0, - std::vector>& double_server_hint, - std::vector>>& decomp_buf, - AESCTR_PRNG& prng, - const FheParams& fparm, const PirParams& pparm) { - const uint64_t lwe_dimension = fparm.get_lwe_dimension(); - const uint64_t poly_degree = fparm.get_poly_degree(); - const uint64_t rlwe_cmod = fparm.get_rlwe_cmod(); - const uint64_t t_auto = fparm.get_t_auto(); - const uint64_t t_decomp = fparm.get_t_decomp(); - const uint64_t expo = GetLog2(poly_degree); - const uint64_t pack_num = lwe_dimension * t_decomp; - - std::vector> double_client_hint( - lwe_dimension * t_decomp, std::vector(poly_degree, 0)); - - const uint64_t* matrix_flat = fparm.get_persudo_matrix_simplepir_flat(); - std::vector> simple_hint( - pparm.get_row(), std::vector(lwe_dimension, 0)); - MatrixMultiplicationFlat(simple_hint, db, matrix_flat, lwe_dimension, - fparm.get_lwe_cmod()); - - std::vector> matrix_decomp; - MatrixRowDecompose(simple_hint, matrix_decomp, fparm.get_b_decomp(), - fparm.get_z_decomp(), fparm.get_t_decomp()); - MatrixTranspose(matrix_decomp, double_server_hint); - - const uint64_t* matrix_d2_flat = fparm.get_persudo_matrix_doublepir_flat(); - MatrixMultiplicationFlat(double_client_hint, double_server_hint, - matrix_d2_flat, poly_degree, rlwe_cmod); - - std::vector>> ksk_a( - expo, - std::vector>(t_auto, - std::vector(poly_degree))); - prng.refresh(kThirdDimensionSeed); - for (uint64_t i = 0; i < expo; ++i) { - PseudorandomMatrixGenerate(ksk_a[i], rlwe_cmod, prng); - } +template +YpirPrecomputedState YpirServer::PerformOfflinePrecomputation() const { + YACL_ENFORCE(db_set_, "database must be loaded before precomputation"); - const uint64_t mod_inv = ModInverse(static_cast(pack_num), - static_cast(rlwe_cmod)); - ByheHexlNtt& ntt = fparm.get_ntt(); - for (uint64_t i = 0; i < pack_num; ++i) { - Cdks21Lwe2RlweInplace(double_client_hint[i].data(), poly_degree, rlwe_cmod, - ntt); - EltwiseFMAMod(double_client_hint[i].data(), double_client_hint[i].data(), - mod_inv, nullptr, poly_degree, rlwe_cmod); + if (params_.mode == YpirMode::kSimplepir) { + YpirPrecomputedState state; + state.mode = YpirMode::kSimplepir; + return state; } - h0 = PackrlwePreprocess(double_client_hint, GetLog2(pack_num), - GetLog2(poly_degree) - GetLog2(pack_num), ksk_a, - decomp_buf, fparm); + YACL_ENFORCE(ypir_context_ != nullptr); + return internal::ypir::PrepareOfflineState(doublepir_db_row_major_, params_, + *ypir_context_); } -void YpirAnswer(const uint8_t* db, uint32_t* qu0, std::vector& qu1, - const std::vector>>& ksk_b, - std::vector>>& decomp_buf, - std::vector>& server_hint, - std::vector>& res, - const FheParams& fparm, const PirParams& pparm) { - const uint64_t lwe_dimension = fparm.get_lwe_dimension(); - const uint64_t poly_degree = fparm.get_poly_degree(); - const uint64_t rlwe_cmod = fparm.get_rlwe_cmod(); - const uint64_t t_decomp = fparm.get_t_decomp(); - const uint64_t pack_num = lwe_dimension * t_decomp; - const uint64_t mod_inv = ModInverse(static_cast(pack_num), - static_cast(rlwe_cmod)); - const uint64_t pack_num_log2 = GetLog2(pack_num); - const uint64_t t_decomp_log2 = GetLog2(t_decomp); - const uint64_t poly_degree_log2 = GetLog2(poly_degree); - - res.reserve(res.size() + 3); - - std::vector> h3(t_decomp, - std::vector(poly_degree, 0)); - std::vector h2(lwe_dimension * t_decomp, 0); - std::vector h4(t_decomp, 0); - - DoublepirAnswer(db, qu0, qu1, server_hint, h2, h3, h4, fparm, pparm); - - for (uint64_t i = 0; i < pack_num; ++i) { - h2[i] = - (static_cast(h2[i]) * mod_inv) % rlwe_cmod; - } +template +YpirResponse YpirServer::ProcessQuery(const YpirQuery& query) const { + return ProcessQuery(query, PerformOfflinePrecomputation()); +} - uint64_t ptr = 0; - res.push_back(PackrlweOnlineConstantRows( - h2, pack_num_log2, poly_degree_log2 - pack_num_log2, ksk_b, decomp_buf, - ptr, fparm)); - - std::vector> h4_matrix( - t_decomp, std::vector(poly_degree, 0)); - const uint64_t mod_inv_2 = ModInverse(static_cast(t_decomp), - static_cast(rlwe_cmod)); - ByheHexlNtt& ntt = fparm.get_ntt(); - - for (uint64_t i = 0; i < t_decomp; ++i) { - Cdks21Lwe2RlweInplace(h3[i].data(), poly_degree, rlwe_cmod, ntt); - h4_matrix[i][0] = h4[i]; - ntt.Forward(h4_matrix[i].data(), poly_degree); - EltwiseFMAMod(h3[i].data(), h3[i].data(), mod_inv_2, nullptr, poly_degree, - rlwe_cmod); - EltwiseFMAMod(h4_matrix[i].data(), h4_matrix[i].data(), mod_inv_2, nullptr, - poly_degree, rlwe_cmod); +template +YpirResponse YpirServer::ProcessQuery(const YpirQuery& query, + const YpirPrecomputedState& state) const { + YACL_ENFORCE(db_set_, "database must be loaded before query processing"); + YACL_ENFORCE(query.mode == params_.mode); + + if (params_.mode == YpirMode::kSimplepir) { + YACL_ENFORCE_EQ(query.packed_query_row.size(), params_.db_rows); + + std::vector result(params_.db_cols, 0); + psi::ypir::FastBatchedDotProduct( + params_.spiral_params, result.data(), query.packed_query_row.data(), + params_.db_rows, simplepir_db_column_major_.data(), params_.db_rows, + params_.db_cols); + + YpirResponse response; + response.mode = YpirMode::kSimplepir; + response.simplepir_response = std::move(result); + return response; } - const auto& ksk_a = fparm.get_persudo_hcube_ypir(); - std::vector>> decomp_b_buf; - ptr = 0; - res.push_back(PackrlwePreprocess(h3, t_decomp_log2, - poly_degree_log2 - t_decomp_log2, ksk_a, - decomp_b_buf, fparm)); - res.push_back(PackrlweOnline(h4_matrix, t_decomp_log2, - poly_degree_log2 - t_decomp_log2, ksk_b, - decomp_b_buf, ptr, fparm)); + YACL_ENFORCE(ypir_context_ != nullptr); + return internal::ypir::ProcessQuery(doublepir_db_row_major_, query, state, + params_, *ypir_context_); +} + +template +yacl::Buffer YpirServer::Response( + const yacl::ByteContainerView& query_buffer) const { + return SerializeResponse(ProcessQuery(DeserializeQuery(query_buffer))); } -} // namespace psi::ypir::byhe +template +yacl::Buffer YpirServer::Response( + const yacl::ByteContainerView& query_buffer, + const yacl::Buffer& /*pks_buffer*/) const { + return Response(query_buffer); +} + +template +std::string YpirServer::Response( + const yacl::ByteContainerView& query_buffer, + const std::string& /*pks_buffer*/) const { + auto buffer = Response(query_buffer); + return std::string(static_cast(buffer)); +} + +template class YpirServer; +template class YpirServer; + +} // namespace psi::ypir diff --git a/psi/algorithm/ypir/server.h b/psi/algorithm/ypir/server.h index fa3b4fdd..76499d3c 100644 --- a/psi/algorithm/ypir/server.h +++ b/psi/algorithm/ypir/server.h @@ -1,24 +1,55 @@ #pragma once #include +#include +#include +#include #include -#include "psi/algorithm/ypir/ypir_params.h" +#include "yacl/base/buffer.h" +#include "yacl/base/byte_container_view.h" -namespace psi::ypir::byhe { +#include "psi/algorithm/pir_interface/pir_db.h" +#include "psi/algorithm/ypir/ypir_internal_server.h" +#include "psi/algorithm/ypir/params.h" +#include "psi/algorithm/ypir/types.h" -void YpirAnswer(const uint8_t* db, uint32_t* qu0, std::vector& qu1, - const std::vector>>& ksk_b, - std::vector>>& decomp_buf, - std::vector>& server_hint, - std::vector>& res, - const FheParams& fparm, const PirParams& pparm); +namespace psi::ypir { -void YpirHintGenerate(std::vector>& db, - std::vector& H0, - std::vector>& double_server_hint, - std::vector>>& decomp_buf, - AESCTR_PRNG& prng, - const FheParams& fparm, const PirParams& pparm); +template +class YpirServer : public psi::pir::IndexPirDataBase { + public: + explicit YpirServer(YpirParameters params); -} // namespace psi::ypir::byhe + void GenerateFromRawData(const psi::pir::RawDatabase& raw_database) override; + void GenerateFromSimpleHashTable( + const psi::pir::RawDatabase& raw_database) override; + void Dump(std::ostream& out_stream) const override; + std::size_t MaxElementsOfOnePt() const override { return 1; } + bool DbSeted() const override { return db_set_; } + + [[nodiscard]] bool DbSet() const { return db_set_; } + [[nodiscard]] const YpirParameters& GetParameters() const { return params_; } + + YpirPrecomputedState PerformOfflinePrecomputation() const; + YpirResponse ProcessQuery(const YpirQuery& query) const; + YpirResponse ProcessQuery(const YpirQuery& query, + const YpirPrecomputedState& state) const; + yacl::Buffer Response(const yacl::ByteContainerView& query_buffer) const; + yacl::Buffer Response(const yacl::ByteContainerView& query_buffer, + const yacl::Buffer& pks_buffer) const override; + std::string Response(const yacl::ByteContainerView& query_buffer, + const std::string& pks_buffer) const override; + + private: + YpirParameters params_; + bool db_set_ = false; + std::vector simplepir_db_column_major_; + std::vector doublepir_db_row_major_; + std::unique_ptr ypir_context_; +}; + +extern template class YpirServer; +extern template class YpirServer; + +} // namespace psi::ypir diff --git a/psi/algorithm/ypir/server.rs b/psi/algorithm/ypir/server.rs deleted file mode 100644 index 6a0bfc15..00000000 --- a/psi/algorithm/ypir/server.rs +++ /dev/null @@ -1,1377 +0,0 @@ -#[cfg(target_feature = "avx2")] -use std::arch::x86_64::*; -use std::{marker::PhantomData, ops::Range, time::Instant}; - -use log::debug; -use log::info; -use rand::{Rng, SeedableRng}; -use rand_chacha::ChaCha20Rng; - -use spiral_rs::aligned_memory::AlignedMemory64; -use spiral_rs::{arith::*, client::*, params::*, poly::*}; - -use crate::measurement::Measurement; -use crate::serialize::*; - -use super::{ - bits::*, - client::*, - constants::*, - convolution::{negacyclic_perm_u32, Convolution}, - kernel::*, - lwe::*, - matmul::matmul_vec_packed, - modulus_switch::ModulusSwitch, - packing::*, - params::*, - transpose::*, - util::*, -}; - -pub fn generate_y_constants<'a>( - params: &'a Params, -) -> (Vec>, Vec>) { - let mut y_constants = Vec::new(); - let mut neg_y_constants = Vec::new(); - for num_cts_log2 in 1..params.poly_len_log2 + 1 { - let num_cts = 1 << num_cts_log2; - - // Y = X^(poly_len / num_cts) - let mut y_raw = PolyMatrixRaw::zero(params, 1, 1); - y_raw.data[params.poly_len / num_cts] = 1; - let y = y_raw.ntt(); - - let mut neg_y_raw = PolyMatrixRaw::zero(params, 1, 1); - neg_y_raw.data[params.poly_len / num_cts] = params.modulus - 1; - let neg_y = neg_y_raw.ntt(); - - y_constants.push(y); - neg_y_constants.push(neg_y); - } - - (y_constants, neg_y_constants) -} - -/// Takes a matrix of u64s and returns a matrix of T's. -/// -/// Input is row x cols u64's. -/// Output is out_rows x cols T's. -pub fn split_alloc( - buf: &[u64], - special_bit_offs: usize, - rows: usize, - cols: usize, - out_rows: usize, - inp_mod_bits: usize, - pt_bits: usize, -) -> Vec { - let mut out = vec![0u16; out_rows * cols]; - - assert!(out_rows >= rows); - assert!(inp_mod_bits >= pt_bits); - - for j in 0..cols { - let mut bytes_tmp = vec![0u8; out_rows * inp_mod_bits / 8]; - - // read this column - let mut bit_offs = 0; - for i in 0..rows { - let inp = buf[i * cols + j]; - // if j < 10 { - // debug!("({},{}) inp: {}", i, j, inp); - // } - - if i == rows - 1 { - bit_offs = special_bit_offs; - } - - // if j == 4095 { - // debug!("write: {}/{} {}/{}", j, cols, i, rows); - // } - write_bits(&mut bytes_tmp, inp, bit_offs, inp_mod_bits); - bit_offs += inp_mod_bits; - } - - // debug!("stretch: {}", j); - - // now, 'stretch' the column vertically - let mut bit_offs = 0; - for i in 0..out_rows { - // if j == 4095 { - // debug!("stretch: {}/{}", i, out_rows); - // debug!("reading at offs: {}, {} bits", bit_offs, pt_bits); - // debug!("into byte buffer of len: {}", bytes_tmp.len()); - // debug!("writing at {} in out of len {}", i * cols + j, out.len()); - // } - let out_val = read_bits(&bytes_tmp, bit_offs, pt_bits); - out[i * cols + j] = out_val as u16; - // if j == 4095 { - // debug!("wrote at {} in out of len {}", i * cols + j, out.len()); - // } - bit_offs += pt_bits; - if bit_offs >= out_rows * inp_mod_bits { - break; - } - } - - // debug!("here {}", j); - // debug!( - // "out {}", - // out[(special_bit_offs / pt_bits) * cols + j].to_u64() - // ); - // debug!("buf {}", buf[(rows - 1) * cols + j] & ((1 << pt_bits) - 1)); - - assert_eq!( - out[(special_bit_offs / pt_bits) * cols + j] as u64, - buf[(rows - 1) * cols + j] & ((1 << pt_bits) - 1) - ); - } - - out -} - -pub fn generate_fake_pack_pub_params<'a>(params: &'a Params) -> Vec> { - let pack_pub_params = raw_generate_expansion_params( - ¶ms, - &PolyMatrixRaw::zero(¶ms, 1, 1), - params.poly_len_log2, - params.t_exp_left, - &mut ChaCha20Rng::from_entropy(), - &mut ChaCha20Rng::from_seed(STATIC_SEED_2), - ); - pack_pub_params -} - -#[derive(Clone)] -pub struct YServer<'a, T> { - params: &'a Params, - smaller_params: Params, - db_buf_aligned: AlignedMemory64, // db_buf: Vec, // stored transposed - phantom: PhantomData, - pad_rows: bool, - ypir_params: YPIRParams, -} - -impl<'a, T> YServer<'a, T> -where - T: Sized + Copy + ToU64 + Default, - *const T: ToM512 + ToU64, -{ - pub fn new<'b, I>( - params: &'a Params, - mut db: I, - is_simplepir: bool, - inp_transposed: bool, - pad_rows: bool, - ) -> Self - where - I: Iterator, - { - // TODO: hack - // let lwe_params = LWEParams::default(); - let mut ypir_params = YPIRParams::default(); - ypir_params.is_simplepir = is_simplepir; - let bytes_per_pt_el = std::mem::size_of::(); //1; //((lwe_params.pt_modulus as f64).log2() / 8.).ceil() as usize; - - let db_rows = 1 << (params.db_dim_1 + params.poly_len_log2); - let db_rows_padded = if pad_rows { - params.db_rows_padded() - } else { - db_rows - }; - let db_cols = if is_simplepir { - params.instances * params.poly_len - } else { - 1 << (params.db_dim_2 + params.poly_len_log2) - }; - - let sz_bytes = db_rows_padded * db_cols * bytes_per_pt_el; - - let mut db_buf_aligned = AlignedMemory64::new(sz_bytes / 8); - let db_buf_mut = as_bytes_mut(&mut db_buf_aligned); - let db_buf_ptr = db_buf_mut.as_mut_ptr() as *mut T; - - for i in 0..db_rows { - for j in 0..db_cols { - let idx = if inp_transposed { - i * db_cols + j - } else { - j * db_rows_padded + i - }; - - unsafe { - *db_buf_ptr.add(idx) = db.next().unwrap(); - // *db_buf_ptr.add(idx) = if i < db_rows { - // db.next().unwrap() - // } else { - // T::default() - // }; - } - } - } - - // Parameters for the second round (the "DoublePIR" round) - let smaller_params = if is_simplepir { - params.clone() - } else { - let lwe_params = LWEParams::default(); - let pt_bits = (params.pt_modulus as f64).log2().floor() as usize; - let blowup_factor = lwe_params.q2_bits as f64 / pt_bits as f64; - let mut smaller_params = params.clone(); - smaller_params.db_dim_1 = params.db_dim_2; - smaller_params.db_dim_2 = ((blowup_factor * (lwe_params.n + 1) as f64) - / params.poly_len as f64) - .log2() - .ceil() as usize; - - let out_rows = 1 << (smaller_params.db_dim_2 + params.poly_len_log2); - assert_eq!(smaller_params.db_dim_1, params.db_dim_2); - assert!(out_rows as f64 >= (blowup_factor * (lwe_params.n + 1) as f64)); - smaller_params - }; - - Self { - params, - smaller_params, - db_buf_aligned, - phantom: PhantomData, - pad_rows, - ypir_params, - } - } - - pub fn db_rows(&self) -> usize { - 1 << (self.params.db_dim_1 + self.params.poly_len_log2) - } - - pub fn db_rows_padded(&self) -> usize { - if self.pad_rows { - self.params.db_rows_padded() - } else { - 1 << (self.params.db_dim_1 + self.params.poly_len_log2) - } - } - - pub fn db_cols(&self) -> usize { - if self.ypir_params.is_simplepir { - self.params.instances * self.params.poly_len - } else { - 1 << (self.params.db_dim_2 + self.params.poly_len_log2) - } - } - - pub fn multiply_batched_with_db_packed( - &self, - aligned_query_packed: &[u64], - query_rows: usize, - ) -> AlignedMemory64 { - // let db_rows = 1 << (self.params.db_dim_1 + self.params.poly_len_log2); - let db_rows_padded = self.db_rows_padded(); - let db_cols = self.db_cols(); - assert_eq!(aligned_query_packed.len(), K * query_rows * db_rows_padded); - assert_eq!(query_rows, 1); - - let now = Instant::now(); - let mut result = AlignedMemory64::new(K * db_cols); - fast_batched_dot_product::( - self.params, - result.as_mut_slice(), - aligned_query_packed, - db_rows_padded, - &self.db(), - db_rows_padded, - db_cols, - ); - debug!("Fast dot product in {} us", now.elapsed().as_micros()); - - result - } - - pub fn lwe_multiply_batched_with_db_packed( - &self, - aligned_query_packed: &[u32], - ) -> Vec { - let _db_rows = 1 << (self.params.db_dim_1 + self.params.poly_len_log2); - let db_cols = self.db_cols(); - let db_rows_padded = self.db_rows_padded(); - assert_eq!(aligned_query_packed.len(), K * db_rows_padded); - // assert_eq!(aligned_query_packed[db_rows + 1], 0); - - let mut result = vec![0u32; (db_cols + 8) * K]; - let now = Instant::now(); - // let mut result = AlignedMemory64::new(K * db_cols + 8); - // lwe_fast_batched_dot_product::( - // self.params, - // result.as_mut_slice(), - // aligned_query_packed, - // db_rows, - // &self.db(), - // db_rows, - // db_cols, - // ); - let a_rows = db_cols; - let a_true_cols = db_rows_padded; - let a_cols = a_true_cols / 4; // order is inverted on purpose, because db is transposed - let b_rows = a_true_cols; - let b_cols = K; - matmul_vec_packed( - result.as_mut_slice(), - self.db_u32(), - aligned_query_packed, - a_rows, - a_cols, - b_rows, - b_cols, - ); - let t = Instant::now(); - let result = transpose_generic(&result, db_cols, K); - debug!("Transpose in {} us", t.elapsed().as_micros()); - debug!("Fast dot product in {} us", now.elapsed().as_micros()); - - result - } - - pub fn multiply_with_db_ring( - &self, - preprocessed_query: &[PolyMatrixNTT], - col_range: Range, - seed_idx: u8, - ) -> Vec { - let db_rows_poly = 1 << (self.params.db_dim_1); - let db_rows = 1 << (self.params.db_dim_1 + self.params.poly_len_log2); - assert_eq!(preprocessed_query.len(), db_rows_poly); - - // assert_eq!(db_rows_poly, 1); // temporary restriction - - // let mut preprocessed_query = Vec::new(); - // for query_el in query { - // let query_raw = query_el.raw(); - // let query_raw_transformed = - // negacyclic_perm(query_raw.get_poly(0, 0), 0, self.params.modulus); - // let mut query_transformed_pol = PolyMatrixRaw::zero(self.params, 1, 1); - // query_transformed_pol - // .as_mut_slice() - // .copy_from_slice(&query_raw_transformed); - // preprocessed_query.push(query_transformed_pol.ntt()); - // } - - let mut result = Vec::new(); - let db = self.db(); - - let mut prod = PolyMatrixNTT::zero(self.params, 1, 1); - let mut db_elem_poly = PolyMatrixRaw::zero(self.params, 1, 1); - let mut db_elem_ntt = PolyMatrixNTT::zero(self.params, 1, 1); - - for col in col_range.clone() { - let mut sum = PolyMatrixNTT::zero(self.params, 1, 1); - - for row in 0..db_rows_poly { - for z in 0..self.params.poly_len { - db_elem_poly.data[z] = - db[col * db_rows + row * self.params.poly_len + z].to_u64(); - } - to_ntt(&mut db_elem_ntt, &db_elem_poly); - - multiply(&mut prod, &preprocessed_query[row], &db_elem_ntt); - - if row == db_rows_poly - 1 { - add_into(&mut sum, &prod); - } else { - add_into_no_reduce(&mut sum, &prod); - } - } - - let sum_raw = sum.raw(); - - // do negacyclic permutation (for first mul only) - if seed_idx == SEED_0 && !self.ypir_params.is_simplepir { - let sum_raw_transformed = - negacyclic_perm(sum_raw.get_poly(0, 0), 0, self.params.modulus); - result.extend(&sum_raw_transformed); - } else { - result.extend(sum_raw.as_slice()); - } - } - - // result - let now = Instant::now(); - let res = transpose_generic(&result, col_range.len(), self.params.poly_len); - debug!("transpose in {} us", now.elapsed().as_micros()); - res - } - - pub fn generate_pseudorandom_query(&self, public_seed_idx: u8) -> Vec> { - let mut client = Client::init(&self.params); - client.generate_secret_keys(); - let y_client = YClient::new(&mut client, &self.params); - let query = y_client.generate_query_impl(public_seed_idx, self.params.db_dim_1, true, 0); - let query_mapped = query - .iter() - .map(|x| x.submatrix(0, 0, 1, 1)) - .collect::>(); - - let mut preprocessed_query = Vec::new(); - for query_raw in query_mapped { - // let query_raw_transformed = - // negacyclic_perm(query_raw.get_poly(0, 0), 0, self.params.modulus); - // let query_raw_transformed = query_raw.get_poly(0, 0); - let query_raw_transformed = if public_seed_idx == SEED_0 { - negacyclic_perm(query_raw.get_poly(0, 0), 0, self.params.modulus) - // query_raw.get_poly(0, 0).to_owned() - } else { - negacyclic_perm(query_raw.get_poly(0, 0), 0, self.params.modulus) - }; - let mut query_transformed_pol = PolyMatrixRaw::zero(self.params, 1, 1); - query_transformed_pol - .as_mut_slice() - .copy_from_slice(&query_raw_transformed); - preprocessed_query.push(query_transformed_pol.ntt()); - } - - preprocessed_query - } - - pub fn answer_hint_ring(&self, public_seed_idx: u8, cols: usize) -> Vec { - let preprocessed_query = self.generate_pseudorandom_query(public_seed_idx); - - let res = self.multiply_with_db_ring(&preprocessed_query, 0..cols, public_seed_idx); - - res - } - - pub fn generate_hint_0(&self) -> Vec { - let _db_rows = 1 << (self.params.db_dim_1 + self.params.poly_len_log2); - let db_cols = self.db_cols(); - - let mut rng_pub = ChaCha20Rng::from_seed(get_seed(SEED_0)); - let lwe_params = LWEParams::default(); - - // pseudorandom LWE query is n x db_rows - let psuedorandom_query = - generate_matrix_ring(&mut rng_pub, lwe_params.n, lwe_params.n, db_cols); - - // db is db_cols x db_rows (!!!) - // hint_0 is n x db_cols - let hint_0 = naive_multiply_matrices( - &psuedorandom_query, - lwe_params.n, - db_cols, - &self.db(), - self.db_rows_padded(), // TODO: doesn't quite work - db_cols, - true, - ); - hint_0.iter().map(|&x| x as u64).collect::>() - } - - pub fn generate_hint_0_ring(&self) -> Vec { - let db_rows = 1 << (self.params.db_dim_1 + self.params.poly_len_log2); - let db_cols = self.db_cols(); - - let lwe_params = LWEParams::default(); - let n = lwe_params.n; - let conv = Convolution::new(n); - - let mut hint_0 = vec![0u64; n * db_cols]; - - let convd_len = conv.params().crt_count * conv.params().poly_len; - - let mut rng_pub = ChaCha20Rng::from_seed(get_seed(SEED_0)); - - let mut v_nega_perm_a = Vec::new(); - for _ in 0..db_rows / n { - let mut a = vec![0u32; n]; - for idx in 0..n { - a[idx] = rng_pub.sample::(rand::distributions::Standard); - } - let nega_perm_a = negacyclic_perm_u32(&a); - let nega_perm_a_ntt = conv.ntt(&nega_perm_a); - v_nega_perm_a.push(nega_perm_a_ntt); - } - - // limit on the number of times we can add results modulo M before we wrap - let log2_conv_output = - log2(lwe_params.modulus) + log2(lwe_params.n as u64) + log2(lwe_params.pt_modulus); - let log2_modulus = log2(conv.params().modulus); - let log2_max_adds = log2_modulus - log2_conv_output - 1; - assert!(log2_max_adds > 0); - let max_adds = 1 << log2_max_adds; - - for col in 0..db_cols { - let mut tmp_col = vec![0u64; convd_len]; - for outer_row in 0..db_rows / n { - let start_idx = col * self.db_rows_padded() + outer_row * n; - let pt_col = &self.db()[start_idx..start_idx + n]; - let pt_col_u32 = pt_col - .iter() - .map(|&x| x.to_u64() as u32) - .collect::>(); - assert_eq!(pt_col_u32.len(), n); - let pt_ntt = conv.ntt(&pt_col_u32); - - let convolved_ntt = conv.pointwise_mul(&v_nega_perm_a[outer_row], &pt_ntt); - - for r in 0..convd_len { - tmp_col[r] += convolved_ntt[r] as u64; - } - - if outer_row % max_adds == max_adds - 1 || outer_row == db_rows / n - 1 { - let mut col_poly_u32 = vec![0u32; convd_len]; - for i in 0..conv.params().crt_count { - for j in 0..conv.params().poly_len { - let val = barrett_coeff_u64( - conv.params(), - tmp_col[i * conv.params().poly_len + j], - i, - ); - col_poly_u32[i * conv.params().poly_len + j] = val as u32; - } - } - let col_poly_raw = conv.raw(&col_poly_u32); - for i in 0..n { - hint_0[i * db_cols + col] += col_poly_raw[i] as u64; - hint_0[i * db_cols + col] %= 1u64 << 32; - } - tmp_col.fill(0); - } - } - } - - hint_0 - } - - pub fn answer_query(&self, aligned_query_packed: &[u64]) -> AlignedMemory64 { - self.multiply_batched_with_db_packed::<1>(aligned_query_packed, 1) - } - - pub fn answer_batched_queries( - &self, - aligned_queries_packed: &[u64], - ) -> AlignedMemory64 { - self.multiply_batched_with_db_packed::(aligned_queries_packed, 1) - } - - pub fn perform_offline_precomputation_simplepir( - &self, - measurement: Option<&mut Measurement>, - hint_0_load: Option<&Vec>, - hint_0_store: Option<&String>, - ) -> OfflinePrecomputedValues<'a> { - // Set up some parameters - - let params = self.params; - assert!(self.ypir_params.is_simplepir); - - let db_cols = params.instances * params.poly_len; - let num_rlwe_outputs = db_cols / params.poly_len; - - // Begin offline precomputation - - let now = Instant::now(); - let hint_0 = if let Some(hint_0_load) = hint_0_load { - hint_0_load.to_vec() - } else { - let hint_0_res = self.answer_hint_ring(SEED_0, db_cols); - if let Some(hint_0_store) = hint_0_store { - write_vec_u64_to_file(hint_0_store, &hint_0_res); - } - hint_0_res - }; - // hint_0 is poly_len x db_cols - let simplepir_prep_time_ms = now.elapsed().as_millis(); - if let Some(measurement) = measurement { - measurement.offline.simplepir_prep_time_ms = simplepir_prep_time_ms as usize; - } - - let now = Instant::now(); - let y_constants = generate_y_constants(¶ms); - - let combined = [&hint_0[..], &vec![0u64; db_cols]].concat(); - assert_eq!(combined.len(), db_cols * (params.poly_len + 1)); - let prepacked_lwe = prep_pack_many_lwes(¶ms, &combined, num_rlwe_outputs); - - let fake_pack_pub_params = generate_fake_pack_pub_params(¶ms); - - let mut precomp: Precomp = Vec::new(); - for i in 0..prepacked_lwe.len() { - let tup = precompute_pack( - params, - params.poly_len_log2, - &prepacked_lwe[i], - &fake_pack_pub_params, - &y_constants, - ); - precomp.push(tup); - } - debug!("Precomp in {} us", now.elapsed().as_micros()); - - OfflinePrecomputedValues { - hint_0, - hint_1: vec![], - pseudorandom_query_1: vec![], - y_constants, - smaller_server: None, - prepacked_lwe, - fake_pack_pub_params, - precomp, - } - } - - pub fn perform_offline_precomputation( - &self, - measurement: Option<&mut Measurement>, - ) -> OfflinePrecomputedValues { - // Set up some parameters - - let params = self.params; - let lwe_params = LWEParams::default(); - assert!(!self.ypir_params.is_simplepir); - - let db_cols = 1 << (params.db_dim_2 + params.poly_len_log2); - - // LWE reduced moduli - let lwe_q_prime_bits = lwe_params.q2_bits as usize; - let lwe_q_prime = lwe_params.get_q_prime_2(); - - // The number of bits represented by a plaintext RLWE coefficient - let pt_bits = (params.pt_modulus as f64).log2().floor() as usize; - // assert_eq!(pt_bits, 16); - - // The factor by which ciphertext values are bigger than plaintext values - let blowup_factor = lwe_q_prime_bits as f64 / pt_bits as f64; - debug!("blowup_factor: {}", blowup_factor); - // assert!(blowup_factor.ceil() - blowup_factor >= 0.05); - - // The starting index of the final value (the '1' in lwe_params.n + 1) - // This is rounded to start on a pt_bits boundary - let special_offs = - ((lwe_params.n * lwe_q_prime_bits) as f64 / pt_bits as f64).ceil() as usize; - let special_bit_offs = special_offs * pt_bits; - - // Parameters for the second round (the "DoublePIR" round) - let mut smaller_params = params.clone(); - smaller_params.db_dim_1 = params.db_dim_2; - smaller_params.db_dim_2 = ((blowup_factor * (lwe_params.n + 1) as f64) - / params.poly_len as f64) - .log2() - .ceil() as usize; - - let out_rows = 1 << (smaller_params.db_dim_2 + params.poly_len_log2); - let rho = 1 << smaller_params.db_dim_2; - assert_eq!(smaller_params.db_dim_1, params.db_dim_2); - assert!(out_rows as f64 >= (blowup_factor * (lwe_params.n + 1) as f64)); - - debug!( - "the first {} LWE output ciphertexts of the DoublePIR round (out of {} total) are query-indepednent", - special_offs, out_rows - ); - debug!( - "the next {} LWE output ciphertexts are query-dependent", - blowup_factor.ceil() as usize - ); - debug!("the rest are zero"); - - // Begin offline precomputation - - let now = Instant::now(); - let hint_0: Vec = self.generate_hint_0_ring(); - // hint_0 is n x db_cols - let simplepir_prep_time_ms = now.elapsed().as_millis(); - if let Some(measurement) = measurement { - measurement.offline.simplepir_prep_time_ms = simplepir_prep_time_ms as usize; - } - debug!("Answered hint (ring) in {} us", now.elapsed().as_micros()); - - // compute (most of) the secondary hint - let intermediate_cts = [&hint_0[..], &vec![0u64; db_cols]].concat(); - let intermediate_cts_rescaled = intermediate_cts - .iter() - .map(|x| rescale(*x, lwe_params.modulus, lwe_q_prime)) - .collect::>(); - - // split and do a second PIR over intermediate_cts - // split into blowup_factor=q/p instances (so that all values are now mod p) - // the second PIR is over a database of db_cols x (blowup_factor * (lwe_params.n + 1)) values mod p - - // inp: (lwe_params.n + 1, db_cols) - // out: (out_rows >= (lwe_params.n + 1) * blowup_factor, db_cols) - // we are 'stretching' the columns (and padding) - - debug!("Splitting intermediate cts..."); - - let smaller_db = split_alloc( - &intermediate_cts_rescaled, - special_bit_offs, - lwe_params.n + 1, - db_cols, - out_rows, - lwe_q_prime_bits, - pt_bits, - ); - assert_eq!(smaller_db.len(), db_cols * out_rows); - - debug!("Done splitting intermediate cts."); - - // This is the 'intermediate' db after the first pass of PIR and expansion - let smaller_server: YServer = YServer::::new( - &self.smaller_params, - smaller_db.into_iter(), - false, - true, - false, - ); - debug!("gen'd smaller server."); - - let hint_1 = smaller_server.answer_hint_ring( - SEED_1, - 1 << (smaller_server.params.db_dim_2 + smaller_server.params.poly_len_log2), - ); - assert_eq!(hint_1.len(), params.poly_len * out_rows); - assert_eq!(hint_1[special_offs], 0); - assert_eq!(hint_1[special_offs + 1], 0); - - let pseudorandom_query_1 = smaller_server.generate_pseudorandom_query(SEED_1); - let y_constants = generate_y_constants(¶ms); - - let combined = [&hint_1[..], &vec![0u64; out_rows]].concat(); - assert_eq!(combined.len(), out_rows * (params.poly_len + 1)); - let prepacked_lwe = prep_pack_many_lwes(¶ms, &combined, rho); - - let now = Instant::now(); - let fake_pack_pub_params = generate_fake_pack_pub_params(¶ms); - - let mut precomp: Precomp = Vec::new(); - for i in 0..prepacked_lwe.len() { - let tup = precompute_pack( - params, - params.poly_len_log2, - &prepacked_lwe[i], - &fake_pack_pub_params, - &y_constants, - ); - precomp.push(tup); - } - debug!("Precomp in {} us", now.elapsed().as_micros()); - - OfflinePrecomputedValues { - hint_0, - hint_1, - pseudorandom_query_1, - y_constants, - smaller_server: Some(smaller_server), - prepacked_lwe, - fake_pack_pub_params, - precomp, - } - } - - /// Perform SimplePIR-style YPIR - pub fn perform_online_computation_simplepir( - &self, - first_dim_queries_packed: &[u64], - offline_vals: &OfflinePrecomputedValues<'a>, - pack_pub_params_row_1s: &[&[u64]], - mut measurement: Option<&mut Measurement>, - ) -> Vec { - assert!(self.ypir_params.is_simplepir); - - // Set up some parameters - - let params = self.params; - - let y_constants = &offline_vals.y_constants; - let prepacked_lwe = &offline_vals.prepacked_lwe; - let precomp = &offline_vals.precomp; - - // RLWE reduced moduli - let rlwe_q_prime_1 = params.get_q_prime_1(); - let rlwe_q_prime_2 = params.get_q_prime_2(); - - let db_rows = 1 << (params.db_dim_1 + params.poly_len_log2); - let db_cols = params.instances * params.poly_len; - - assert_eq!(first_dim_queries_packed.len(), params.db_rows_padded()); - - // Begin online computation - - let first_pass = Instant::now(); - // debug!("Performing mul..."); - let mut intermediate = AlignedMemory64::new(db_cols); - fast_batched_dot_product::<1, T>( - ¶ms, - intermediate.as_mut_slice(), - first_dim_queries_packed, - db_rows, - self.db(), - db_rows, - db_cols, - ); - // debug!("Done w mul..."); - let first_pass_time_ms = first_pass.elapsed().as_millis(); - if let Some(ref mut m) = measurement { - m.online.first_pass_time_ms = first_pass_time_ms as usize; - } - - let ring_packing = Instant::now(); - let num_rlwe_outputs = db_cols / params.poly_len; - let pack_pub_params_row_1s_pms = - unpack_vec_pm(¶ms, 1, params.t_exp_left, pack_pub_params_row_1s[0]); - let packed = pack_many_lwes( - ¶ms, - &prepacked_lwe, - &precomp, - intermediate.as_slice(), - num_rlwe_outputs, - &pack_pub_params_row_1s_pms, - &y_constants, - ); - // debug!("Packed..."); - if let Some(m) = measurement { - m.online.ring_packing_time_ms = ring_packing.elapsed().as_millis() as usize; - } - - let mut packed_mod_switched = Vec::with_capacity(packed.len()); - for ct in packed.iter() { - let res = ct.raw(); - let res_switched = res.switch(rlwe_q_prime_1, rlwe_q_prime_2); - packed_mod_switched.push(res_switched); - } - - assert_eq!(packed_mod_switched.len(), num_rlwe_outputs); - - let concated = packed_mod_switched - .iter() - .map(|x| x.as_slice()) - .flatten() - .copied() - .collect::>(); - - concated - } - - pub fn perform_online_computation( - &self, - offline_vals: &mut OfflinePrecomputedValues<'a>, - first_dim_queries_packed: &[u32], - second_dim_queries: &[(&[u64], &[u64])], - mut measurement: Option<&mut Measurement>, - ) -> Vec> { - // Set up some parameters - - let params = self.params; - let lwe_params = LWEParams::default(); - - let db_cols = self.db_cols(); - - // RLWE reduced moduli - let rlwe_q_prime_1 = params.get_q_prime_1(); - let rlwe_q_prime_2 = params.get_q_prime_2(); - - // LWE reduced moduli - let lwe_q_prime_bits = lwe_params.q2_bits as usize; - let lwe_q_prime = lwe_params.get_q_prime_2(); - - // The number of bits represented by a plaintext RLWE coefficient - let pt_bits = (params.pt_modulus as f64).log2().floor() as usize; - // assert_eq!(pt_bits, 16); - - // The factor by which ciphertext values are bigger than plaintext values - let blowup_factor = lwe_q_prime_bits as f64 / pt_bits as f64; - debug!("blowup_factor: {}", blowup_factor); - // assert!(blowup_factor.ceil() - blowup_factor >= 0.05); - - // The starting index of the final value (the '1' in lwe_params.n + 1) - // This is rounded to start on a pt_bits boundary - let special_offs = - ((lwe_params.n * lwe_q_prime_bits) as f64 / pt_bits as f64).ceil() as usize; - - // Parameters for the second round (the "DoublePIR" round) - let mut smaller_params = params.clone(); - smaller_params.db_dim_1 = params.db_dim_2; - smaller_params.db_dim_2 = ((blowup_factor * (lwe_params.n + 1) as f64) - / params.poly_len as f64) - .log2() - .ceil() as usize; - - let out_rows = 1 << (smaller_params.db_dim_2 + params.poly_len_log2); - let rho = 1 << smaller_params.db_dim_2; - assert_eq!(smaller_params.db_dim_1, params.db_dim_2); - assert!(out_rows as f64 >= (blowup_factor * (lwe_params.n + 1) as f64)); - - // Load offline precomputed values - let hint_1_combined = &mut offline_vals.hint_1; - let pseudorandom_query_1 = &offline_vals.pseudorandom_query_1; - let y_constants = &offline_vals.y_constants; - let smaller_server = offline_vals.smaller_server.as_mut().unwrap(); - let prepacked_lwe = &offline_vals.prepacked_lwe; - let fake_pack_pub_params = &offline_vals.fake_pack_pub_params; - let precomp = &offline_vals.precomp; - - // Begin online computation - - let online_phase = Instant::now(); - let first_pass = Instant::now(); - let intermediate = self.lwe_multiply_batched_with_db_packed::(first_dim_queries_packed); - let simplepir_resp_bytes = intermediate.len() / K * (lwe_q_prime_bits as usize) / 8; - debug!("simplepir_resp_bytes {} bytes", simplepir_resp_bytes); - let first_pass_time_ms = first_pass.elapsed().as_millis(); - debug!("First pass took {} us", first_pass.elapsed().as_micros()); - - if let Some(ref mut m) = measurement { - m.online.first_pass_time_ms = first_pass_time_ms as usize; - m.online.simplepir_resp_bytes = simplepir_resp_bytes; - } - - debug!("intermediate.len(): {}", intermediate.len()); - let mut second_pass_time_ms = 0; - let mut ring_packing_time_ms = 0; - let mut responses = Vec::new(); - for (intermediate_chunk, (packed_query_col, pack_pub_params_row_1s)) in intermediate - .as_slice() - .chunks(db_cols) - .zip(second_dim_queries.iter()) - { - let second_pass = Instant::now(); - let intermediate_cts_rescaled = intermediate_chunk - .iter() - .map(|x| rescale(*x as u64, lwe_params.modulus, lwe_q_prime)) - .collect::>(); - assert_eq!(intermediate_cts_rescaled.len(), db_cols); - debug!( - "intermediate_cts_rescaled[0] = {}", - intermediate_cts_rescaled[0] - ); - - let now = Instant::now(); - // modify the smaller_server db to include the intermediate values - // let mut smaller_server_clone = smaller_server.clone(); - { - // remember, this is stored in 'transposed' form - // so it is out_cols x db_cols - let smaller_db_mut: &mut [u16] = smaller_server.db_mut(); - for j in 0..db_cols { - // new value to write into the db - let val = intermediate_cts_rescaled[j]; - - for m in 0..blowup_factor.ceil() as usize { - // index in the transposed db - let out_idx = (special_offs + m) * db_cols + j; - - // part of the value to write into the db - let val_part = ((val >> (m * pt_bits)) & ((1 << pt_bits) - 1)) as u16; - - // assert_eq!(smaller_db_mut[out_idx], DoubleType::default()); - smaller_db_mut[out_idx] = val_part; - } - } - } - debug!("load secondary hint {} us", now.elapsed().as_micros()); - - let now = Instant::now(); - { - let blowup_factor_ceil = blowup_factor.ceil() as usize; - - let phase = Instant::now(); - let secondary_hint = smaller_server.multiply_with_db_ring( - &pseudorandom_query_1, - special_offs..special_offs + blowup_factor_ceil, - SEED_1, - ); - debug!( - "multiply_with_db_ring took: {} us", - phase.elapsed().as_micros() - ); - // let phase = Instant::now(); - // let secondary_hint = - // smaller_server_clone.answer_hint(SEED_1, special_offs..special_offs + blowup_factor_ceil); - // debug!( - // "traditional answer_hint took: {} us", - // phase.elapsed().as_micros() - // ); - - assert_eq!(secondary_hint.len(), params.poly_len * blowup_factor_ceil); - - for i in 0..params.poly_len { - for j in 0..blowup_factor_ceil { - let inp_idx = i * blowup_factor_ceil + j; - let out_idx = i * out_rows + special_offs + j; - - // assert_eq!(hint_1_combined[out_idx], 0); // we no longer clone for each query, just overwrite - hint_1_combined[out_idx] = secondary_hint[inp_idx]; - } - } - } - debug!("compute secondary hint in {} us", now.elapsed().as_micros()); - - assert_eq!(hint_1_combined.len(), params.poly_len * out_rows); - - let response: AlignedMemory64 = smaller_server.answer_query(packed_query_col); - - second_pass_time_ms += second_pass.elapsed().as_millis(); - let ring_packing = Instant::now(); - let now = Instant::now(); - assert_eq!(response.len(), 1 * out_rows); - - // combined is now (poly_len + 1) * (out_rows) - // let combined = [&hint_1_combined[..], response.as_slice()].concat(); - let mut excess_cts = Vec::with_capacity(blowup_factor.ceil() as usize); - for j in special_offs..special_offs + blowup_factor.ceil() as usize { - let mut rlwe_ct = PolyMatrixRaw::zero(¶ms, 2, 1); - - // 'a' vector - // put this in negacyclic order - let mut poly = Vec::new(); - for k in 0..params.poly_len { - poly.push(hint_1_combined[k * out_rows + j]); - } - let nega = negacyclic_perm(&poly, 0, params.modulus); - - rlwe_ct.get_poly_mut(0, 0).copy_from_slice(&nega); - - // for k in 0..params.poly_len { - // rlwe_ct.get_poly_mut(0, 0)[k] = nega[k]; - // } - - // let j_within_last = j % params.poly_len; - // prepacked_lwe_mut.last_mut().unwrap()[j_within_last] = rlwe_ct.ntt(); - excess_cts.push(rlwe_ct.ntt()); - } - debug!("in between: {} us", now.elapsed().as_micros()); - - // assert_eq!(pack_pub_params_row_1s[0].rows, 1); - - let pack_pub_params_row_1s_pms = - unpack_vec_pm(¶ms, 1, params.t_exp_left, pack_pub_params_row_1s); - let mut packed = pack_many_lwes( - ¶ms, - &prepacked_lwe, - &precomp, - response.as_slice(), - rho, - &pack_pub_params_row_1s_pms, - &y_constants, - ); - - let now = Instant::now(); - let mut pack_pub_params = fake_pack_pub_params.clone(); - for i in 0..pack_pub_params.len() { - let uncondensed = uncondense_matrix(params, &pack_pub_params_row_1s_pms[i]); - pack_pub_params[i].copy_into(&uncondensed, 1, 0); - } - debug!("uncondense pub params: {} us", now.elapsed().as_micros()); - let now = Instant::now(); - let other_packed = - pack_using_single_with_offset(¶ms, &pack_pub_params, &excess_cts, special_offs); - add_into(&mut packed[0], &other_packed); - debug!( - "pack_using_single_with_offset: {} us", - now.elapsed().as_micros() - ); - - let now = Instant::now(); - let mut packed_mod_switched = Vec::with_capacity(packed.len()); - for ct in packed.iter() { - let res = ct.raw(); - let res_switched = res.switch(rlwe_q_prime_1, rlwe_q_prime_2); - packed_mod_switched.push(res_switched); - } - debug!("switching: {} us", now.elapsed().as_micros()); - // debug!("Preprocessing pack in {} us", now.elapsed().as_micros()); - // debug!(""); - ring_packing_time_ms += ring_packing.elapsed().as_millis(); - - // packed is blowup_factor ring ct's - // these encode, contiguously [poly_len + 1, blowup_factor] - // (and some padding) - assert_eq!(packed.len(), rho); - - let concated = packed_mod_switched - .into_iter() - .flat_map(|x| x.into_iter()) - .collect::>(); - - responses.push(concated); - } - debug!( - "Total online time: {} us", - online_phase.elapsed().as_micros() - ); - debug!(""); - - if let Some(ref mut m) = measurement { - m.online.second_pass_time_ms = second_pass_time_ms as usize; - m.online.ring_packing_time_ms = ring_packing_time_ms as usize; - } - - assert_eq!(responses.len(), K); - - responses - } - - pub fn perform_full_online_computation( - &self, - offline_vals: &mut OfflinePrecomputedValues<'a>, - query: &[u8], - ) -> Vec { - let first_dim_bytes_sz = self.params.db_rows_padded() * std::mem::size_of::(); - let second_dim_bytes_sz = self.db_cols() * std::mem::size_of::(); - let pub_param_bytes_sz = self.params.poly_len_log2 - * self.params.t_exp_left - * self.params.poly_len - * std::mem::size_of::(); - assert_eq!( - query.len(), - first_dim_bytes_sz + second_dim_bytes_sz + pub_param_bytes_sz - ); - - let first_dim_bytes = &query[..first_dim_bytes_sz]; - let second_dim_bytes = &query[first_dim_bytes_sz..first_dim_bytes_sz + second_dim_bytes_sz]; - let pub_param_bytes = &query[first_dim_bytes_sz + second_dim_bytes_sz..]; - - let first_dim = Vec::::from_bytes(first_dim_bytes); - let second_dim = AlignedMemory64::from_bytes(second_dim_bytes); - let pub_params = AlignedMemory64::from_bytes(pub_param_bytes); - - self.perform_online_computation::<1>( - offline_vals, - &first_dim, - &[(second_dim.as_slice(), pub_params.as_slice())], - None, - ) - .remove(0) - } - - pub fn perform_full_online_computation_simplepir( - &self, - offline_vals: &OfflinePrecomputedValues<'a>, - query: &[u8], - ) -> Vec { - let first_dim_bytes_sz = self.params.db_rows() * std::mem::size_of::(); - let pub_param_bytes_sz = self.params.poly_len_log2 - * self.params.t_exp_left - * self.params.poly_len - * std::mem::size_of::(); - assert_eq!(query.len(), first_dim_bytes_sz + pub_param_bytes_sz); - - let first_dim_bytes = &query[..first_dim_bytes_sz]; - let pub_param_bytes = &query[first_dim_bytes_sz..]; - - let first_dim = AlignedMemory64::from_bytes(first_dim_bytes); - let pub_params = AlignedMemory64::from_bytes(pub_param_bytes); - - self.perform_online_computation_simplepir( - first_dim.as_slice(), - offline_vals, - &[pub_params.as_slice()], - None, - ) - } - - // generic function that returns a u8 or u16: - pub fn db(&self) -> &[T] { - unsafe { - std::slice::from_raw_parts( - self.db_buf_aligned.as_ptr() as *const T, - self.db_buf_aligned.len() * 8 / std::mem::size_of::(), - ) - } - } - - pub fn db_mut(&mut self) -> &mut [T] { - unsafe { - std::slice::from_raw_parts_mut( - self.db_buf_aligned.as_ptr() as *mut T, - self.db_buf_aligned.len() * 8 / std::mem::size_of::(), - ) - } - } - - pub fn db_u16(&self) -> &[u16] { - unsafe { - std::slice::from_raw_parts( - self.db_buf_aligned.as_ptr() as *const u16, - self.db_buf_aligned.len() * 8 / std::mem::size_of::(), - ) - } - } - - pub fn db_u32(&self) -> &[u32] { - unsafe { - std::slice::from_raw_parts( - self.db_buf_aligned.as_ptr() as *const u32, - self.db_buf_aligned.len() * 8 / std::mem::size_of::(), - ) - } - } - - pub fn get_elem(&self, target_idx: usize) -> T { - let db_cols = self.db_cols(); - let (target_row, target_col) = (target_idx / db_cols, target_idx % db_cols); - self.get_elem_row_col(target_row, target_col) - } - - pub fn get_elem_row_col(&self, row: usize, col: usize) -> T { - self.db()[col * self.db_rows_padded() + row] // stored transposed - } - - pub fn get_row(&self, row: usize) -> Vec { - let db_cols = self.db_cols(); - let mut res = Vec::with_capacity(db_cols); - for col in 0..db_cols { - res.push(self.get_elem_row_col(row, col)); - } - res - // // convert to u8 contiguously - // let mut res_u8 = Vec::with_capacity(db_cols * std::mem::size_of::()); - // for &x in res.iter() { - // res_u8.extend_from_slice(&x.to_u64().to_le_bytes()[..std::mem::size_of::()]); - // } - // res_u8 - } -} - -#[cfg(not(target_feature = "avx2"))] -#[allow(non_camel_case_types)] -type __m512i = u64; - -pub trait ToM512 { - fn to_m512(self) -> __m512i; -} - -#[cfg(feature = "explicit_avx512")] -mod m512_impl { - use super::*; - - impl ToM512 for *const u8 { - #[inline(always)] - fn to_m512(self) -> __m512i { - unsafe { _mm512_cvtepu8_epi64(_mm_loadl_epi64(self as *const _)) } - } - } - - impl ToM512 for *const u16 { - #[inline(always)] - fn to_m512(self) -> __m512i { - unsafe { _mm512_cvtepu16_epi64(_mm_load_si128(self as *const _)) } - } - } - - impl ToM512 for *const u32 { - #[inline(always)] - fn to_m512(self) -> __m512i { - unsafe { _mm512_cvtepu32_epi64(_mm256_load_si256(self as *const _)) } - } - } -} - -#[cfg(not(feature = "explicit_avx512"))] -mod m512_impl { - use super::*; - - impl ToM512 for *const u8 { - #[inline(always)] - fn to_m512(self) -> __m512i { - panic!("AVX512 implementation not being used") - } - } - - impl ToM512 for *const u16 { - #[inline(always)] - fn to_m512(self) -> __m512i { - panic!("AVX512 implementation not being used") - } - } - - impl ToM512 for *const u32 { - #[inline(always)] - fn to_m512(self) -> __m512i { - panic!("AVX512 implementation not being used") - } - } -} - -pub trait ToU64 { - fn to_u64(self) -> u64; -} - -impl ToU64 for u8 { - fn to_u64(self) -> u64 { - self as u64 - } -} - -impl ToU64 for u16 { - fn to_u64(self) -> u64 { - self as u64 - } -} - -impl ToU64 for u32 { - fn to_u64(self) -> u64 { - self as u64 - } -} - -impl ToU64 for u64 { - fn to_u64(self) -> u64 { - self - } -} - -impl ToU64 for *const u8 { - fn to_u64(self) -> u64 { - (unsafe { *self }) as u64 - } -} - -impl ToU64 for *const u16 { - fn to_u64(self) -> u64 { - (unsafe { *self }) as u64 - } -} - -impl ToU64 for *const u64 { - fn to_u64(self) -> u64 { - unsafe { *self } - } -} - -pub fn naive_multiply_matrices( - a: &[u32], - a_rows: usize, - a_cols: usize, - b_t: &[T], // transposed - b_rows: usize, - b_cols: usize, - is_b_transposd: bool, -) -> Vec { - // performs wrapping arithmetic - - assert_eq!(a_cols, b_rows); - - // debug!("Multiplying {}x{} by {}x{}", a_rows, a_cols, b_rows, b_cols); - - let mut result = vec![0u32; a_rows * b_cols]; - for i in 0..a_rows { - for j in 0..b_cols { - for k in 0..a_cols { - let a_idx = i * a_cols + k; - let b_idx = if is_b_transposd { - j * b_rows + k // on purpose, since transposed - } else { - k * b_cols + j - }; - let res_idx = i * b_cols + j; - - unsafe { - let a_val = *a.get_unchecked(a_idx); - let b_val = (b_t.get_unchecked(b_idx)).to_u64() as u32; - - result[res_idx] = result[res_idx].wrapping_add(a_val.wrapping_mul(b_val)); - } - } - } - } - - result -} diff --git a/psi/algorithm/ypir/server_test.cc b/psi/algorithm/ypir/server_test.cc new file mode 100644 index 00000000..506cd55d --- /dev/null +++ b/psi/algorithm/ypir/server_test.cc @@ -0,0 +1,52 @@ +#include "psi/algorithm/ypir/server.h" + +#include +#include +#include + +#include "gtest/gtest.h" + +namespace psi::ypir { +namespace { + +template +psi::pir::RawDatabase BuildDatabase(const YpirParameters& params) { + std::vector> rows(params.db_rows, + std::vector(params.db_cols * sizeof(T), 0)); + for (uint64_t row = 0; row < params.db_rows; ++row) { + for (uint64_t col = 0; col < params.db_cols; ++col) { + const T value = static_cast((row * 17 + col * 3) % 251); + std::memcpy(rows[row].data() + col * sizeof(T), &value, sizeof(T)); + } + } + return psi::pir::RawDatabase(std::move(rows)); +} + +TEST(YpirServerTest, SimplepirOfflineStateIsEmpty) { + auto params = CreateSmallTestParamsSimplePIR(); + YpirServer server(params); + server.GenerateFromRawData(BuildDatabase(params)); + + const auto state = server.PerformOfflinePrecomputation(); + EXPECT_EQ(state.mode, YpirMode::kSimplepir); + EXPECT_TRUE(state.hint_0.empty()); + EXPECT_TRUE(state.server_hint.empty()); + EXPECT_TRUE(state.decomp_buf.empty()); +} + +TEST(YpirServerTest, DoublepirOfflineStateCanBeReused) { + auto params = CreateSmallTestParamsDoublePIR(); + YpirServer server(params); + server.GenerateFromRawData(BuildDatabase(params)); + + const auto state1 = server.PerformOfflinePrecomputation(); + const auto state2 = server.PerformOfflinePrecomputation(); + + EXPECT_EQ(state1.mode, YpirMode::kDoublepir); + EXPECT_EQ(state2.mode, YpirMode::kDoublepir); + EXPECT_EQ(state1.hint_0, state2.hint_0); + EXPECT_EQ(state1.server_hint, state2.server_hint); +} + +} // namespace +} // namespace psi::ypir diff --git a/psi/algorithm/ypir/simplepir_basic_flow_test.cc b/psi/algorithm/ypir/simplepir_basic_flow_test.cc deleted file mode 100644 index 134eaf5a..00000000 --- a/psi/algorithm/ypir/simplepir_basic_flow_test.cc +++ /dev/null @@ -1,135 +0,0 @@ -// Basic flow test - test individual components -#include "gtest/gtest.h" -#include "spdlog/spdlog.h" - -#include "psi/algorithm/spiral/params.h" -#include "psi/algorithm/ypir/util.h" - -namespace psi::ypir { - -using namespace psi::spiral; - -TEST(SimplePIRBasicFlowTest, TestQueryDatabaseMatrixMultiplication) { - // Test the basic matrix multiplication: query * database - size_t poly_len = 2048; - std::vector moduli = {268369921, 249561089}; - double noise_width = 16.042421; - - PolyMatrixParams poly_matrix_params(2, 16384, 21, 4, 8, 8, 1); - QueryParams query_params(1, 1, 1); - - Params params(poly_len, std::move(moduli), noise_width, - std::move(poly_matrix_params), std::move(query_params)); - - size_t db_rows = 1ULL << (params.DbDim1() + params.PolyLenLog2()); - size_t db_cols = params.Instances() * params.PolyLen(); - - SPDLOG_INFO("=== Basic Flow Test ==="); - SPDLOG_INFO("db_rows={}, db_cols={}", db_rows, db_cols); - - // Create all-zeros database - std::vector db(db_rows * db_cols, 0); - - // Create simple query - select first row - std::vector query(db_rows, 0); - query[0] = params.ScaleK(); // scale_k at position 0 - - SPDLOG_INFO("Query[0] = {} (scale_k)", query[0]); - - // Pack query for FastBatchedDotProduct - std::vector query_packed(db_rows); - const uint64_t m0 = params.Moduli(0); - const uint64_t m1 = params.Moduli(1); - - for (size_t i = 0; i < db_rows; ++i) { - query_packed[i] = (query[i] % m0) | ((query[i] % m1) << 32); - } - - SPDLOG_INFO("Packed query[0] = 0x{:016x}", query_packed[0]); - - // Result - std::vector result(db_cols, 0); - - // Call FastBatchedDotProduct - FastBatchedDotProduct(params, result.data(), query_packed.data(), - db_rows, db.data(), db_rows, db_cols); - - SPDLOG_INFO("Result after dot product (first 10):"); - bool all_zero = true; - for (size_t i = 0; i < std::min(size_t(10), result.size()); ++i) { - SPDLOG_INFO(" result[{}] = {}", i, result[i]); - if (result[i] != 0) { - all_zero = false; - } - } - - if (all_zero) { - SPDLOG_INFO("✓ All results are zero as expected"); - } else { - SPDLOG_ERROR("✗ Got non-zero results for zero database!"); - } - - EXPECT_TRUE(all_zero) << "Result should be all zeros for zero database"; -} - -TEST(SimplePIRBasicFlowTest, TestQueryDatabaseWithData) { - // Test with non-zero database - size_t poly_len = 2048; - std::vector moduli = {268369921, 249561089}; - double noise_width = 16.042421; - - PolyMatrixParams poly_matrix_params(2, 16384, 21, 4, 8, 8, 1); - QueryParams query_params(1, 1, 1); - - Params params(poly_len, std::move(moduli), noise_width, - std::move(poly_matrix_params), std::move(query_params)); - - size_t db_rows = 1ULL << (params.DbDim1() + params.PolyLenLog2()); - size_t db_cols = params.Instances() * params.PolyLen(); - - SPDLOG_INFO("=== Basic Flow Test with Data ==="); - - // Create database with pattern - std::vector db(db_rows * db_cols); - for (size_t col = 0; col < db_cols; ++col) { - for (size_t row = 0; row < db_rows; ++row) { - // Column-major: db[col * db_rows + row] - db[col * db_rows + row] = static_cast((row + col) % 100); - } - } - - SPDLOG_INFO("DB[0,0] = {}, DB[0,1] = {}, DB[1,0] = {}", db[0], db[1], - db[db_rows]); - - // Query for row 0 - std::vector query(db_rows, 0); - query[0] = params.ScaleK(); - - // Pack query - std::vector query_packed(db_rows); - const uint64_t m0 = params.Moduli(0); - const uint64_t m1 = params.Moduli(1); - - for (size_t i = 0; i < db_rows; ++i) { - query_packed[i] = (query[i] % m0) | ((query[i] % m1) << 32); - } - - // Result - std::vector result(db_cols, 0); - - FastBatchedDotProduct(params, result.data(), query_packed.data(), - db_rows, db.data(), db_rows, db_cols); - - SPDLOG_INFO("Result after dot product (first 10):"); - for (size_t i = 0; i < std::min(size_t(10), result.size()); ++i) { - // Rescale result back to plaintext space - uint64_t rescaled = - arith::Rescale(result[i], params.Modulus(), params.PtModulus()); - uint16_t expected = db[i * db_rows + 0]; // First row, column i - SPDLOG_INFO(" result[{}] = {} (rescaled: {}), expected: {}", i, result[i], - rescaled, expected); - } - std::cout << "test" << std::endl; -} - -} // namespace psi::ypir diff --git a/psi/algorithm/ypir/simplepir_flow_test.cc b/psi/algorithm/ypir/simplepir_flow_test.cc new file mode 100644 index 00000000..59c99328 --- /dev/null +++ b/psi/algorithm/ypir/simplepir_flow_test.cc @@ -0,0 +1,52 @@ +#include "psi/algorithm/ypir/client.h" +#include "psi/algorithm/ypir/server.h" + +#include +#include +#include + +#include "gtest/gtest.h" + +namespace psi::ypir { +namespace { + +uint64_t BytesToU64(const std::vector& bytes) { + uint64_t value = 0; + for (size_t i = 0; i < bytes.size(); ++i) { + value |= static_cast(bytes[i]) << (8 * i); + } + return value; +} + +psi::pir::RawDatabase BuildSimplepirDatabase(const YpirParameters& params) { + std::vector> rows(params.db_rows, + std::vector(params.db_cols * sizeof(uint16_t), 0)); + for (uint64_t row = 0; row < params.db_rows; ++row) { + for (uint64_t col = 0; col < params.db_cols; ++col) { + const uint16_t value = static_cast((row * 17 + col * 3) % params.spiral_params.PtModulus()); + std::memcpy(rows[row].data() + col * sizeof(uint16_t), &value, sizeof(value)); + } + } + return psi::pir::RawDatabase(std::move(rows)); +} + +TEST(YpirSimplepirFlowTest, EndToEndSmallDatabase) { + auto params = CreateSmallTestParamsSimplePIR(); + YpirClient client(params); + YpirServer server(params); + server.GenerateFromRawData(BuildSimplepirDatabase(params)); + + const uint64_t row = 123; + const uint64_t col = 456; + const uint64_t raw_idx = row * params.db_cols + col; + + const auto query_buffer = client.GenerateQueryBuffer(raw_idx); + const auto response_buffer = server.Response(query_buffer); + const auto decoded = client.DecodeResponseBuffer(response_buffer, raw_idx); + + const uint64_t expected = (row * 17 + col * 3) % params.spiral_params.PtModulus(); + EXPECT_EQ(BytesToU64(decoded), expected); +} + +} // namespace +} // namespace psi::ypir diff --git a/psi/algorithm/ypir/smoke_test.cc b/psi/algorithm/ypir/smoke_test.cc new file mode 100644 index 00000000..25aec4a4 --- /dev/null +++ b/psi/algorithm/ypir/smoke_test.cc @@ -0,0 +1,25 @@ +#include "psi/algorithm/ypir/client.h" +#include "psi/algorithm/ypir/server.h" + +#include "gtest/gtest.h" + +namespace psi::ypir { +namespace { + +TEST(YpirSmokeTest, ConstructPublicObjects) { + auto simple_params = CreateSmallTestParamsSimplePIR(); + auto double_params = CreateSmallTestParamsDoublePIR(); + + YpirClient simple_client(simple_params); + YpirClient double_client(double_params); + YpirServer simple_server(simple_params); + YpirServer double_server(double_params); + + EXPECT_EQ(simple_client.GetParameters().mode, YpirMode::kSimplepir); + EXPECT_EQ(double_client.GetParameters().mode, YpirMode::kDoublepir); + EXPECT_FALSE(simple_server.DbSet()); + EXPECT_FALSE(double_server.DbSet()); +} + +} // namespace +} // namespace psi::ypir diff --git a/psi/algorithm/ypir/types.h b/psi/algorithm/ypir/types.h index f565aced..24d301c2 100644 --- a/psi/algorithm/ypir/types.h +++ b/psi/algorithm/ypir/types.h @@ -1,55 +1,34 @@ -// Copyright 2024 Ant Group Co., Ltd. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - #pragma once #include -#include #include -#include "psi/algorithm/spiral/poly_matrix.h" - namespace psi::ypir { -using namespace psi::spiral; - -// Precomputation tuple type for packing operations -using Precomp = - std::vector, - std::vector>>>; +enum class YpirMode : uint8_t { + kSimplepir = 0, + kDoublepir = 1, +}; -// Forward declaration for YPirServer template class -template -class YPirServer; +struct YpirPrecomputedState { + YpirMode mode = YpirMode::kSimplepir; + std::vector hint_0; + std::vector> server_hint; + std::vector>> decomp_buf; +}; -// Convenience alias for the most common type -using YServer = YPirServer; +struct YpirQuery { + YpirMode mode = YpirMode::kSimplepir; + std::vector packed_query_row; + std::vector qu0; + std::vector qu1; + std::vector>> ksk_b; +}; -// Offline precomputation values for SimplePIR and DoublePIR -struct OfflinePrecomputedValues { - // SimplePIR fields - std::vector hint_0; // First hint - // DoublePIR fields - std::vector hint_1; // Second dimension hint - std::vector - pseudorandom_query_1; // Pseudorandom query for second dimension - std::pair, std::vector> y_constants; - std::shared_ptr smaller_server; - // Packing-related fields - std::vector> prepacked_lwe; - std::vector fake_pack_pub_params; - Precomp precomp; +struct YpirResponse { + YpirMode mode = YpirMode::kSimplepir; + std::vector simplepir_response; + std::vector> doublepir_response; }; } // namespace psi::ypir diff --git a/psi/algorithm/ypir/util.cc b/psi/algorithm/ypir/util.cc index 6e073202..aa622971 100644 --- a/psi/algorithm/ypir/util.cc +++ b/psi/algorithm/ypir/util.cc @@ -1,1130 +1,44 @@ #include "psi/algorithm/ypir/util.h" -#include -#include +#include +#include #include -#include "../spiral/arith/arith_params.h" -#include "../spiral/arith/ntt.h" -#include "../spiral/discrete_gaussian.h" -#include "../spiral/gadget.h" -#include "../spiral/poly_matrix_utils.h" -#include "yacl/base/int128.h" +#include "yacl/base/exception.h" -#include "psi/algorithm/spiral/params.h" -#include "psi/algorithm/spiral/poly_matrix.h" -#include "psi/algorithm/spiral/util.h" +#include "psi/algorithm/spiral/arith/arith.h" namespace psi::ypir { -using namespace psi::spiral; +std::vector BuildPackedSimplepirQuery(const YpirParameters& params, + uint64_t raw_idx) { + YACL_ENFORCE(params.mode == YpirMode::kSimplepir); + YACL_ENFORCE_LT(raw_idx, params.NumItems()); -std::vector ConcatHorizontal( - const std::vector>& v_a, size_t a_rows, - size_t a_cols) { - if (v_a.empty()) { - return {}; - } - - size_t num_vecs = v_a.size(); - - std::vector out(a_rows * a_cols * num_vecs); - size_t out_stride = num_vecs * a_cols; - - for (size_t i = 0; i < a_rows; ++i) { - for (size_t k = 0; k < num_vecs; ++k) { - auto src_begin = v_a[k].begin() + (i * a_cols); - auto src_end = src_begin + a_cols; - size_t dest_offset = (i * out_stride) + (k * a_cols); - - std::copy(src_begin, src_end, out.begin() + dest_offset); - } - } - - return out; -} - -extern "C" { -void matMulVecPacked(uint32_t* out, const uint32_t* a, const uint32_t* b, - size_t aRows, size_t aCols); - -void matMulVecPacked2(uint32_t* out, const uint32_t* a, const uint32_t* b_full, - size_t aRows, size_t aCols); - -void matMulVecPacked4(uint32_t* out, const uint32_t* a, const uint32_t* b_full, - size_t aRows, size_t aCols); - -void matMulVecPacked8(uint32_t* out, const uint32_t* a, const uint32_t* b_full, - size_t aRows, size_t aCols); -} - -// Wrapper function that matches the Rust signature -void MatMulVecPacked(uint32_t* out, const uint32_t* a, const uint32_t* b, - size_t a_rows, size_t a_cols, size_t b_rows, - size_t b_cols) { - // Debug output (equivalent to Rust's debug! macro) - - // Assertions - assert(a_rows * a_cols == a_rows * a_cols); // a.len() == a_rows * a_cols - assert(b_rows * b_cols == b_rows * b_cols); // b.len() == b_rows * b_cols - assert(a_cols * 4 == b_rows); - // Note: out.len() >= a_rows + 8 should be checked by caller - - // Dispatch based on b_cols - if (b_cols == 1) { - matMulVecPacked(out, a, b, a_rows, a_cols); - } else if (b_cols == 2) { - matMulVecPacked2(out, a, b, a_rows, a_cols); - } else if (b_cols == 4) { - matMulVecPacked4(out, a, b, a_rows, a_cols); - } else if (b_cols == 8) { - matMulVecPacked8(out, a, b, a_rows, a_cols); - } else { - fprintf(stderr, "Error: b_cols must be 1, 2, 4, or 8, got %zu\n", b_cols); - assert(false && "b_cols must be 1, 2, 4, or 8"); - } -} - -PolyMatrixNtt HomomorphicAutomorph(const Params& params, size_t t, size_t t_exp, - const PolyMatrixNtt& ct, - const PolyMatrixNtt& pub_param) { - YACL_ENFORCE(ct.Rows() == static_cast(2)); - YACL_ENFORCE(ct.Cols() == static_cast(1)); - - auto ct_raw = PolyMatrixRaw::Zero(params.PolyLen(), 2, 1); - FromNtt(params, ct_raw, ct); - auto ct_auto = Automorphism(params, ct_raw, t); - - auto ginv_ct = PolyMatrixRaw::Zero(params.PolyLen(), t_exp, 1); - psi::spiral::util::GadgetInvertRdim(params, ginv_ct, ct_auto, 1); - - auto ginv_ct_ntt = - PolyMatrixNtt::Zero(params.CrtCount(), params.PolyLen(), t_exp, 1); - for (size_t i = 1; i < t_exp; ++i) { - auto pol_src = ginv_ct.Poly(i, 0); - auto pol_dst = ginv_ct_ntt.Poly(i, 0); - ReduceCopy(params, pol_dst, pol_src); - arith::NttForward(params, pol_dst); - } - - auto w_times_ginv_ct = Multiply(params, pub_param, ginv_ct_ntt); - - auto ct_auto_1 = PolyMatrixRaw::Zero(params.PolyLen(), 1, 1); - - std::memcpy(ct_auto_1.Data().data(), - ct_auto.Data().data() + ct_auto.PolyStartIndex(1, 0), - sizeof(uint64_t) * ct_auto.NumWords()); - auto ct_auto_1_ntt = ToNtt(params, ct_auto_1); - - auto res = Add(params, ct_auto_1_ntt.PadTop(1), w_times_ginv_ct); - return res; -} - -PolyMatrixNtt RingPackLwesInner( - const Params& params, size_t ell, size_t start_idx, - const std::vector& rlwe_cts, - const std::vector& pub_params, - const std::pair, std::vector>& - y_constants) { - YACL_ENFORCE_EQ(pub_params.size(), params.PolyLenLog2()); - - if (ell == 0) { - return rlwe_cts[start_idx]; - } - - size_t step = 1ULL << (params.PolyLenLog2() - ell); - size_t even = start_idx; - size_t odd = start_idx + step; - - auto ct_even = RingPackLwesInner(params, ell - 1, even, rlwe_cts, pub_params, - y_constants); - auto ct_odd = RingPackLwesInner(params, ell - 1, odd, rlwe_cts, pub_params, - y_constants); - - const auto& y = y_constants.first[ell - 1]; - const auto& neg_y = y_constants.second[ell - 1]; - - auto y_times_ct_odd = ScalarMultiply(params, y, ct_odd); - auto neg_y_times_ct_odd = ScalarMultiply(params, neg_y, ct_odd); - - auto ct_sum_1 = ct_even; - AddInto(params, ct_sum_1, neg_y_times_ct_odd); - AddInto(params, ct_even, y_times_ct_odd); - - size_t t = (1ULL << ell) + 1; - const auto& pub_param = pub_params[params.PolyLenLog2() - 1 - (ell - 1)]; - auto ct_sum_1_automorphed = - HomomorphicAutomorph(params, t, params.TExpLeft(), ct_sum_1, pub_param); - - return Add(params, ct_even, ct_sum_1_automorphed); -} + const uint64_t row_idx = raw_idx / params.db_cols; + std::vector query(params.db_rows, 0); + query[row_idx] = params.spiral_params.ScaleK(); -std::pair, std::vector> GenYConstants( - const Params& params) { - std::vector y_constants; - std::vector neg_y_constants; - - for (size_t num_cts_log2 = 1; num_cts_log2 <= params.PolyLenLog2(); - ++num_cts_log2) { - size_t num_cts = 1ULL << num_cts_log2; - - auto y_raw = PolyMatrixRaw::Zero(params.PolyLen(), 1, 1); - size_t idx = params.PolyLen() / num_cts; - y_raw.Data()[idx] = 1ULL; - auto y = ToNtt(params, y_raw); - - auto neg_y_raw = PolyMatrixRaw::Zero(params.PolyLen(), 1, 1); - neg_y_raw.Data()[idx] = params.Modulus() - 1; - auto neg_y = ToNtt(params, neg_y_raw); - - y_constants.push_back(y); - neg_y_constants.push_back(neg_y); - } - - return std::make_pair(y_constants, neg_y_constants); -} - -PolyMatrixNtt RingPackLwes( - const Params& params, const std::vector& b_values, - const std::vector& rlwe_cts, size_t num_cts, - const std::vector& pub_params, - const std::pair, std::vector>& - y_constants) { - YACL_ENFORCE_EQ(b_values.size(), num_cts); - YACL_ENFORCE_EQ(rlwe_cts.size(), num_cts); - - size_t ell = params.PolyLenLog2(); - auto out = - RingPackLwesInner(params, ell, 0, rlwe_cts, pub_params, y_constants); - - auto out_raw = FromNtt(params, out); - for (size_t z = 0; z < params.PolyLen(); ++z) { - uint128_t b_val_u128 = static_cast(b_values[z]); - uint128_t poly_len_u128 = static_cast(params.PolyLen()); - uint128_t prod = b_val_u128 * poly_len_u128; - uint64_t val = arith::BarrettReductionU128(params, prod); - - size_t idx = out_raw.PolyStartIndex(1, 0) + z; - uint64_t sum = out_raw.Data()[idx] + val; - out_raw.Data()[idx] = arith::BarrettU64(params, sum); - } - - return ToNtt(params, out_raw); -} - -std::vector NegacyclicPerm(absl::Span a, size_t shift, - uint64_t modulus) { - size_t n = a.size(); - std::vector out(n); - - for (size_t i = 0; i <= shift; ++i) { - out[i] = a[shift - i]; - } - - for (size_t i = shift + 1; i < n; ++i) { - size_t src_idx = n - (i - shift); - uint64_t val = a[src_idx] % modulus; - if (val == 0) { - out[i] = 0; - } else { - out[i] = modulus - val; - } + const uint64_t m0 = params.spiral_params.Moduli(0); + const uint64_t m1 = params.spiral_params.Moduli(1); + std::vector packed(params.db_rows, 0); + for (size_t i = 0; i < packed.size(); ++i) { + packed[i] = (query[i] % m0) | ((query[i] % m1) << 32); } - - return out; + return packed; } -std::vector NegacyclicMatrix(absl::Span a, - uint64_t modulus) { - size_t n = a.size(); - std::vector out(n * n, 0); - - for (size_t i = 0; i < n; ++i) { - std::vector perm = NegacyclicPerm(a, i, modulus); - for (size_t j = 0; j < n; ++j) { - out[j * n + i] = perm[j]; - } +std::vector EncodeIntegerValue(uint64_t value, size_t value_bytes) { + std::vector out(value_bytes, 0); + for (size_t i = 0; i < value_bytes; ++i) { + out[i] = static_cast((value >> (8 * i)) & 0xff); } - return out; } -PolyMatrixNtt CondenseMatrix(const Params& params, const PolyMatrixNtt& a) { - PolyMatrixNtt res = PolyMatrixNtt::Zero(params.CrtCount(), params.PolyLen(), - a.Rows(), a.Cols()); - for (size_t i = 0; i < a.Rows(); ++i) { - for (size_t j = 0; j < a.Cols(); ++j) { - auto res_poly = res.Poly(i, j); - const auto a_poly = a.Poly(i, j); - if (a_poly.size() < 2 * params.PolyLen()) { - continue; - } - for (size_t z = 0; z < params.PolyLen(); ++z) { - res_poly[z] = a_poly[z] | (a_poly[z + params.PolyLen()] << 32); - } - } - } - - return res; -} - -// from ypir/packing.rs -PolyMatrixNtt RotationPoly(const Params& params, size_t amount) { - PolyMatrixRaw res = PolyMatrixRaw::Zero(params.PolyLen(), 1, 1); - - if (amount < res.Data().size()) { - res.Data()[amount] = 1; - } else { - YACL_THROW("Rotation amount exceeds polynomial length"); - } - - return ToNtt(params, res); -} -PolyMatrixNtt PackSingleLwe(const Params& params, - const std::vector& pub_params, - const PolyMatrixNtt& lwe_ct) { - PolyMatrixNtt cur_r = lwe_ct; - - size_t log_n = params.PolyLenLog2(); - - for (size_t i = 0; i < log_n; ++i) { - size_t t = (params.PolyLen() / (1ULL << i)) + 1; - - const auto& pub_param = pub_params[i]; - - auto tau_of_r = - HomomorphicAutomorph(params, t, params.TExpLeft(), cur_r, pub_param); - AddInto(params, cur_r, tau_of_r); - } - - return cur_r; -} - -PolyMatrixNtt PackUsingSingleWithOffset( - const Params& params, const std::vector& pub_params, - const std::vector& cts, size_t offset) { - PolyMatrixNtt res = - PolyMatrixNtt::Zero(params.CrtCount(), params.PolyLen(), 2, 1); - - SPDLOG_INFO( - "PackUsingSingleWithOffset: offset={}, cts.size()={}, poly_len={}", - offset, cts.size(), params.PolyLen()); - - for (size_t i = 0; i < cts.size(); ++i) { - PolyMatrixNtt packed_single = PackSingleLwe(params, pub_params, cts[i]); - - size_t rotation_amount = offset + i; - if (rotation_amount >= params.PolyLen()) { - SPDLOG_ERROR("ERROR: rotation_amount {} >= poly_len {} (offset={}, i={})", - rotation_amount, params.PolyLen(), offset, i); - YACL_THROW( - "Rotation amount exceeds polynomial length in " - "PackUsingSingleWithOffset"); - } - - PolyMatrixNtt rotation = RotationPoly(params, rotation_amount); - PolyMatrixNtt rotated = ScalarMultiply(params, rotation, packed_single); - - AddInto(params, res, rotated); - } - - return res; -} - -std::vector PrepPackLwes(const Params& params, - absl::Span lwe_cts, - size_t cols_to_do) { - size_t poly_len = params.PolyLen(); - size_t expected_size = poly_len * (poly_len + 1); - - if (lwe_cts.size() != expected_size) { - throw std::runtime_error("PrepPackLwes: lwe_cts size mismatch"); - } - if (cols_to_do != poly_len) { - throw std::runtime_error("PrepPackLwes: cols_to_do must equal poly_len"); - } - - std::vector rlwe_cts; - rlwe_cts.reserve(cols_to_do); - - for (size_t i = 0; i < cols_to_do; ++i) { - auto rlwe_ct = PolyMatrixRaw::Zero(params.PolyLen(), 2, 1); - std::vector poly; - poly.reserve(poly_len); - for (size_t j = 0; j < poly_len; ++j) { - poly.push_back(lwe_cts[j * poly_len + i]); - } - - auto nega = NegacyclicPerm(poly, 0, params.Modulus()); - - // Use Poly(0, 0) to get the first polynomial - auto first_poly = rlwe_ct.Poly(0, 0); - for (size_t j = 0; j < poly_len; ++j) { - first_poly[j] = nega[j]; - } - - rlwe_cts.push_back(ToNtt(params, rlwe_ct)); - } - - return rlwe_cts; -} - -std::vector> PrepPackManyLwes( - const Params& params, absl::Span lwe_cts, - size_t num_rlwe_outputs) { - size_t poly_len = params.PolyLen(); - - size_t expected_total_size = (poly_len + 1) * (num_rlwe_outputs * poly_len); - - if (lwe_cts.size() != expected_total_size) { - throw std::runtime_error("PrepPackManyLwes: Total size mismatch"); - } - - std::vector> vecs; - vecs.reserve(num_rlwe_outputs); - - for (size_t i = 0; i < num_rlwe_outputs; ++i) { - std::vector v; - // 每个 chunk 的大小应该是 poly_len * (poly_len + 1) - v.reserve(poly_len * (poly_len + 1)); - for (size_t j = 0; j < poly_len + 1; ++j) { - size_t start_idx = j * (num_rlwe_outputs * poly_len) + i * poly_len; - for (size_t k = 0; k < poly_len; ++k) { - v.push_back(lwe_cts[start_idx + k]); - } - } - vecs.push_back(std::move(v)); - } - std::vector> res; - res.reserve(num_rlwe_outputs); - - for (size_t i = 0; i < num_rlwe_outputs; ++i) { - res.push_back(PrepPackLwes(params, vecs[i], poly_len)); - } - - return res; -} - -std::vector> GenerateAutomorphTablesBruteForce( - const Params& params) { - std::vector> tables; - - tables.reserve(params.PolyLenLog2()); - - for (size_t i = params.PolyLenLog2(); i >= 1; --i) { - size_t poly_len = params.PolyLen(); - std::vector table_candidate(poly_len); - while (true) { - uint64_t t = (1ULL << i) + 1; - PolyMatrixRaw poly = PolyMatrixRaw::Random(params, 1, 1); - PolyMatrixNtt poly_ntt = ToNtt(params, poly); - PolyMatrixRaw poly_auto(params.PolyLen(), 1, 1); - Automorphism(params, poly_auto, poly, t); - PolyMatrixNtt poly_auto_ntt = ToNtt(params, poly_auto); - auto pol_orig = poly_ntt.Poly(0, 0); - auto pol_auto = poly_auto_ntt.Poly(0, 0); - bool must_redo = false; - for (size_t src_idx = 0; src_idx < poly_len; ++src_idx) { - uint64_t target_val = pol_orig[src_idx]; - int found_count = 0; - size_t found_pos = 0; - for (size_t dest_idx = 0; dest_idx < poly_len; ++dest_idx) { - if (pol_auto[dest_idx] == target_val) { - found_count++; - found_pos = dest_idx; - } - } - if (found_count != 1) { - must_redo = true; - break; - } - table_candidate[found_pos] = src_idx; - } - - if (!must_redo) { - break; - } - } - tables.push_back(std::move(table_candidate)); - } - - return tables; -} - -std::tuple, - std::vector>> -PrecomputePack(const Params& params, size_t poly_len_log2, - const std::vector& prepacked, - const std::vector& pub_params, - const std::pair, - std::vector>& y_constants) { - YACL_ENFORCE_EQ(pub_params.size(), params.PolyLenLog2(), - "pub_params size must match poly_len_log2"); - YACL_ENFORCE_EQ(params.CrtCount(), 2UL, "CRT count must be 2"); - - std::vector working_set = prepacked; - PolyMatrixNtt y_times_ct_odd = - PolyMatrixNtt::Zero(params.CrtCount(), params.PolyLen(), 2, 1); - - PolyMatrixNtt neg_y_times_ct_odd = - PolyMatrixNtt::Zero(params.CrtCount(), params.PolyLen(), 2, 1); - PolyMatrixNtt ct_sum_1 = - PolyMatrixNtt::Zero(params.CrtCount(), params.PolyLen(), 2, 1); - - PolyMatrixRaw ct_raw = PolyMatrixRaw::Zero(params.PolyLen(), 1, 1); - PolyMatrixRaw ct_auto = PolyMatrixRaw::Zero(params.PolyLen(), 1, 1); - - size_t t_exp = params.TExpLeft(); - PolyMatrixRaw ginv_ct = - PolyMatrixRaw::Zero(params.PolyLen(), t_exp, 1); // Fixed: poly_len first - PolyMatrixNtt ginv_ct_ntt = - PolyMatrixNtt::Zero(params.CrtCount(), params.PolyLen(), t_exp, 1); - - PolyMatrixNtt ct_auto_1_ntt = - PolyMatrixNtt::Zero(params.CrtCount(), params.PolyLen(), 1, 1); - PolyMatrixNtt w_times_ginv_ct = - PolyMatrixNtt::Zero(params.CrtCount(), params.PolyLen(), 2, 1); - PolyMatrixNtt scratch = - PolyMatrixNtt::Zero(params.CrtCount(), params.PolyLen(), 2, 1); - std::vector v_trgsw; - v_trgsw.reserve(poly_len_log2); - - for (size_t cur_ell = 1; cur_ell <= poly_len_log2; ++cur_ell) { - size_t num_in = 1ULL << (poly_len_log2 - cur_ell + 1); - size_t num_out = num_in >> 1; - - const auto& y = y_constants.first[cur_ell - 1]; - const auto& neg_y = y_constants.second[cur_ell - 1]; - - for (size_t i = 0; i < num_out; ++i) { - auto& ct_even = working_set[i]; - const auto& ct_odd = working_set[i + num_out]; - - // y_times_ct_odd = y * ct_odd - ScalarMultiply(params, y_times_ct_odd, y, ct_odd); - // neg_y_times_ct_odd = -y * ct_odd - ScalarMultiply(params, neg_y_times_ct_odd, neg_y, ct_odd); - - // ct_sum_1 = ct_even + neg_y * ct_odd - ct_sum_1.CopyInto(ct_even, 0, 0); - AddInto(params, ct_sum_1, neg_y_times_ct_odd); - - AddInto(params, ct_even, y_times_ct_odd); - - uint64_t t = (1ULL << cur_ell) + 1; - FromNttScratch(params, ct_raw, scratch.Data(), ct_sum_1); - - Automorphism(params, ct_auto, ct_raw, t); - util::GadgetInvertRdim(params, ginv_ct, ct_auto, 1); - ToNtt(params, ginv_ct_ntt, ginv_ct); - - auto scratch_poly = scratch.Poly(0, 0); // Get the stored 2nd row data - AutomorphismPolyUncrtd(params, ct_auto_1_ntt.Data(), scratch_poly, t); - arith::NttForward(params, ct_auto_1_ntt.Data()); - - v_trgsw.push_back(CondenseMatrix(params, ginv_ct_ntt)); - - size_t param_idx = poly_len_log2 - cur_ell; - const auto& pub_param = pub_params[param_idx]; - - // W * Ginv - std::fill(w_times_ginv_ct.Data().begin(), w_times_ginv_ct.Data().end(), - 0); - MultiplyNoReduce(w_times_ginv_ct, pub_param, ginv_ct_ntt, 0); - - AddIntoAt(params, ct_even, ct_auto_1_ntt, 1, 0); - - AddInto(params, ct_even, w_times_ginv_ct); - } - } - - auto combined_hints = GenerateAutomorphTablesBruteForce(params); - return std::make_tuple(working_set[0], v_trgsw, combined_hints); -} - -inline uint64_t FastBarrettRawU64(uint64_t input, uint64_t const_ratio_1, - uint64_t modulus) { - uint128_t mul = static_cast(input) * const_ratio_1; - uint64_t tmp = static_cast(mul >> 64); - uint64_t res = input - tmp * modulus; - return res; +uint64_t DecodeSimplepirValue(const YpirParameters& params, uint64_t value) { + return psi::spiral::arith::Rescale(value, params.spiral_params.Modulus(), + params.spiral_params.PtModulus()); } -void FastAddInto(const Params& params, PolyMatrixNtt& res, - const PolyMatrixNtt& a) { - if (res.Rows() != a.Rows() || res.Cols() != a.Cols()) { - throw std::runtime_error("FastAddInto: Dimension mismatch"); - } - - size_t poly_len = params.PolyLen(); - size_t crt_count = params.CrtCount(); - - uint64_t* res_ptr = const_cast(res.Data().data()); - const uint64_t* a_ptr = a.Data().data(); - size_t num_polys = res.Rows() * res.Cols(); - - for (size_t p = 0; p < num_polys; ++p) { - for (size_t c = 0; c < crt_count; ++c) { - size_t poly_offset = p * (crt_count * poly_len); - size_t crt_offset = poly_offset + c * poly_len; - - for (size_t i = 0; i < poly_len; ++i) { - size_t idx = crt_offset + i; - uint64_t val = res_ptr[idx] + a_ptr[idx]; - res_ptr[idx] = - FastBarrettRawU64(val, params.BarrettCr1(c), params.Moduli(c)); - } - } - } -} - -void FastAddIntoNoReduce(PolyMatrixNtt& res, const PolyMatrixNtt& a) { - if (res.Rows() != a.Rows() || res.Cols() != a.Cols()) { - throw std::runtime_error("FastAddIntoNoReduce: Dimension mismatch"); - } - size_t len = res.Data().size(); - for (size_t i = 0; i < len; ++i) { - res.Data()[i] += a.Data()[i]; - } -} - -void MultiplyPolyAvx(uint64_t* res, const uint64_t* a, const uint64_t* b, - size_t len) { - for (size_t i = 0; i < len; ++i) { - uint64_t x = static_cast(static_cast(a[i])); - uint64_t y = static_cast(static_cast(b[i])); - res[i] = x * y; - } -} - -void ScalarMultiplyAvx(const Params& params, PolyMatrixNtt& res, - const PolyMatrixNtt& a, const PolyMatrixNtt& b) { - if (a.Rows() != 1 || a.Cols() != 1) { - throw std::runtime_error( - "ScalarMultiplyAvx: 'a' must be a 1x1 matrix (scalar)"); - } - - if (res.Rows() != b.Rows() || res.Cols() != b.Cols()) { - throw std::runtime_error( - "ScalarMultiplyAvx: 'res' and 'b' dimension mismatch"); - } - - // poly_size = poly_len * crt_count - size_t poly_size = params.PolyLen() * params.CrtCount(); - - const uint64_t* pol2_ptr = a.Data().data(); - - const uint64_t* b_ptr = b.Data().data(); - - uint64_t* res_ptr = const_cast(res.Data().data()); - - size_t total_polys = b.Rows() * b.Cols(); - - for (size_t i = 0; i < total_polys; ++i) { - size_t offset = i * poly_size; - - const uint64_t* pol1_ptr = b_ptr + offset; - - uint64_t* res_poly_ptr = res_ptr + offset; - - MultiplyPolyAvx(res_poly_ptr, pol1_ptr, pol2_ptr, poly_size); - } -} - -void FastMultiplyNoReduce(const Params& params, PolyMatrixNtt& res, - const PolyMatrixNtt& a, const PolyMatrixNtt& b, - size_t /*start_inner_dim*/) { - if (res.Rows() != 1 || res.Cols() != 1) { - throw std::runtime_error("FastMultiplyNoReduce: Result must be 1x1"); - } - if (res.Rows() != a.Rows() || res.Cols() != b.Cols()) { - throw std::runtime_error( - "FastMultiplyNoReduce: Dimension mismatch (Result)"); - } - if (a.Cols() != b.Rows()) { - throw std::runtime_error( - "FastMultiplyNoReduce: Dimension mismatch (Inner)"); - } - - if (params.CrtCount() != 2) { - throw std::runtime_error("FastMultiplyNoReduce: Requires CRT count = 2"); - } - - uint64_t* res_ptr = const_cast(res.Data().data()); - const uint64_t* a_ptr = a.Data().data(); - const uint64_t* b_ptr = b.Data().data(); - - size_t pol_sz = params.PolyLen(); - size_t k_dim = a.Cols(); - - for (size_t idx = 0; idx < pol_sz; ++idx) { - uint64_t sum_lo = 0; - uint64_t sum_hi = 0; - - for (size_t k = 0; k < k_dim; ++k) { - size_t offset = k * 2 * pol_sz + idx; - - uint64_t x = a_ptr[offset]; - uint64_t y = b_ptr[offset]; - - uint64_t x_lo = x & 0xFFFFFFFF; - uint64_t x_hi = x >> 32; - - uint64_t y_lo = y & 0xFFFFFFFF; - uint64_t y_hi = y >> 32; - - sum_lo += x_lo * y_lo; - sum_hi += x_hi * y_hi; - } - - res_ptr[idx] = sum_lo; - res_ptr[pol_sz + idx] = sum_hi; - } -} - -void ApplyAutomorphNttRaw(const Params& params, const uint64_t* poly, - uint64_t* out, size_t t, - const std::vector>& tables) { - size_t poly_len = params.PolyLen(); - if (t <= 1) throw std::runtime_error("ApplyAutomorphNttRaw: t must be > 1"); - - size_t val = poly_len / (t - 1); - // C++20 - // size_t table_idx = std::countr_zero(val); - size_t table_idx = __builtin_ctzll(val); - - if (table_idx >= tables.size()) { - throw std::runtime_error("ApplyAutomorphNttRaw: Table index out of bounds"); - } - - const std::vector& table = tables[table_idx]; - - for (size_t i = 0; i < poly_len; ++i) { - out[i] += poly[table[i]]; - } -} - -void ApplyAutomorphNtt(const Params& params, - const std::vector>& tables, - const PolyMatrixNtt& mat, PolyMatrixNtt& res, size_t t) { - if (mat.Rows() != res.Rows() || mat.Cols() != res.Cols()) { - throw std::runtime_error("ApplyAutomorphNtt: Dimension mismatch"); - } - - const uint64_t* mat_ptr = mat.Data().data(); - - uint64_t* res_ptr = const_cast(res.Data().data()); - - size_t poly_len = params.PolyLen(); - size_t total_elements = mat.Data().size(); - - for (size_t offset = 0; offset < total_elements; offset += poly_len) { - ApplyAutomorphNttRaw(params, mat_ptr + offset, res_ptr + offset, t, tables); - } -} - -void FastReduce(const Params& params, PolyMatrixNtt& res) { - size_t crt_count = params.CrtCount(); - size_t poly_len = params.PolyLen(); - - for (size_t m = 0; m < crt_count; ++m) { - for (size_t i = 0; i < poly_len; ++i) { - size_t idx = m * poly_len + i; - res.Data()[idx] = arith::BarrettCoeffU64(params, res.Data()[idx], m); - } - } -} - -PolyMatrixNtt PackUsingPrecompVals( - const Params& params, size_t ell, - absl::Span pub_params, - absl::Span b_values, const PolyMatrixNtt& precomp_res, - absl::Span precomp_vals, - const std::vector>& precomp_tables, - const std::pair, std::vector>& - y_constants) { - size_t initial_capacity = 1ULL << (ell - 1); - std::vector working_set; - working_set.reserve(initial_capacity); - - for (size_t i = 0; i < initial_capacity; ++i) { - working_set.push_back( - PolyMatrixNtt::Zero(params.CrtCount(), params.PolyLen(), 1, 1)); - } - - auto y_times_ct_odd = - PolyMatrixNtt::Zero(params.CrtCount(), params.PolyLen(), 1, 1); - auto neg_y_times_ct_odd = - PolyMatrixNtt::Zero(params.CrtCount(), params.PolyLen(), 1, 1); - auto ct_sum_1 = - PolyMatrixNtt::Zero(params.CrtCount(), params.PolyLen(), 1, 1); - auto w_times_ginv_ct = - PolyMatrixNtt::Zero(params.CrtCount(), params.PolyLen(), 1, 1); - - size_t idx_precomp = 0; - - for (size_t cur_ell = 1; cur_ell <= ell; ++cur_ell) { - size_t num_in = 1ULL << (ell - cur_ell + 1); - size_t num_out = num_in >> 1; - - if (num_in == params.PolyLen()) { - num_in = num_out; - } - - for (size_t i = 0; i < num_out; ++i) { - PolyMatrixNtt& ct_even = working_set[i]; - - const auto& y = y_constants.first[cur_ell - 1]; - const auto& neg_y = y_constants.second[cur_ell - 1]; - - if (cur_ell > 1) { - PolyMatrixNtt& ct_odd = working_set[num_out + i]; - ScalarMultiplyAvx(params, y_times_ct_odd, y, ct_odd); - ScalarMultiplyAvx(params, neg_y_times_ct_odd, neg_y, ct_odd); - } - - if (cur_ell > 1) { - std::copy(ct_even.Data().begin(), ct_even.Data().end(), - const_cast(ct_sum_1.Data().data())); - - FastAddIntoNoReduce(ct_sum_1, neg_y_times_ct_odd); - FastAddIntoNoReduce(ct_even, y_times_ct_odd); - } - - const PolyMatrixNtt* ct_ptr = &ct_sum_1; - size_t t = (1ULL << cur_ell) + 1; - - const auto& cur_ginv_ct_ntt = precomp_vals[idx_precomp]; - idx_precomp++; - - size_t w_idx = params.PolyLenLog2() - cur_ell; - const auto& w = pub_params[w_idx]; - - FastMultiplyNoReduce(params, w_times_ginv_ct, w, cur_ginv_ct_ntt, 0); - - if (cur_ell > 1) { - ApplyAutomorphNtt(params, precomp_tables, *ct_ptr, ct_even, t); - - if (i < num_out / 2 && ((cur_ell - 1) % 5 != 0)) { - FastAddIntoNoReduce(ct_even, w_times_ginv_ct); - } else { - FastAddInto(params, ct_even, w_times_ginv_ct); - } - } else { - if (i < num_out / 2) { - FastAddIntoNoReduce(ct_even, w_times_ginv_ct); - } else { - FastAddInto(params, ct_even, w_times_ginv_ct); - } - } - } - } - - if (idx_precomp != precomp_vals.size()) { - throw std::runtime_error("PackUsingPrecompVals: idx_precomp mismatch"); - } - - PolyMatrixNtt resulting_row_1 = working_set[0]; - FastReduce(params, resulting_row_1); - - PolyMatrixNtt res = precomp_res; - - size_t poly_len = params.PolyLen(); - size_t crt_count = params.CrtCount(); - size_t row_1_offset_ntt = crt_count * poly_len; - - uint64_t* res_data = const_cast(res.Data().data()); - const uint64_t* row_1_src = resulting_row_1.Data().data(); - - std::copy(row_1_src, row_1_src + (crt_count * poly_len), - res_data + row_1_offset_ntt); - - PolyMatrixRaw out_raw = FromNtt(params, res); - uint64_t modulus = params.Modulus(); - - for (size_t z = 0; z < poly_len; ++z) { - uint128_t val_u128 = static_cast(b_values[z]) * poly_len; - uint64_t val = arith::BarrettReductionU128(params, val_u128); - - size_t idx = poly_len + z; - - out_raw.Data()[idx] += val; - if (out_raw.Data()[idx] >= modulus) { - out_raw.Data()[idx] -= modulus; - } - } - - return ToNtt(params, out_raw); -} - -std::vector PackManyLwes( - const Params& params, - const std::vector>& prep_rlwe_cts, - const Precomp& precomp, absl::Span b_values, - size_t num_rlwe_outputs, - const std::vector& pack_pub_params_row_1s, - const std::pair, std::vector>& - y_constants) { - if (prep_rlwe_cts.size() != num_rlwe_outputs) { - throw std::runtime_error("PackManyLwes: prep_rlwe_cts size mismatch"); - } - - if (!prep_rlwe_cts.empty() && prep_rlwe_cts[0].size() != params.PolyLen()) { - throw std::runtime_error("PackManyLwes: prep_rlwe_cts inner size mismatch"); - } - - if (b_values.size() != num_rlwe_outputs * params.PolyLen()) { - throw std::runtime_error("PackManyLwes: b_values size mismatch"); - } - - if (precomp.size() != num_rlwe_outputs) { - throw std::runtime_error("PackManyLwes: precomp size mismatch"); - } - - std::vector res; - res.reserve(num_rlwe_outputs); - - size_t poly_len = params.PolyLen(); - size_t poly_len_log2 = params.PolyLenLog2(); - - for (size_t i = 0; i < num_rlwe_outputs; ++i) { - const auto& [precomp_res, precomp_vals, precomp_tables] = precomp[i]; - - auto b_values_slice = b_values.subspan(i * poly_len, poly_len); - - PolyMatrixNtt packed = PackUsingPrecompVals( - params, poly_len_log2, - absl::MakeConstSpan(pack_pub_params_row_1s), // Vector -> Span - b_values_slice, precomp_res, - absl::MakeConstSpan(precomp_vals), // Vector -> Span - precomp_tables, y_constants); - - res.push_back(std::move(packed)); - } - - return res; -} - -PolyMatrixNtt GetRegevSample(const Params& params, const PolyMatrixRaw& sk_reg, - yacl::crypto::Prg& rng, - yacl::crypto::Prg& rng_pub) { - auto a = PolyMatrixRaw::RandomPrg(params, 1, 1, rng_pub); - auto a_ntt = ToNtt(params, a); - auto a_inv = ToNtt(params, Negate(params, a)); - DiscreteGaussian dg(params.NoiseWidth()); - auto e = Noise(params, 1, 1, dg, rng); - - auto e_ntt = ToNtt(params, e); - auto sk_reg_ntt = ToNtt(params, sk_reg); - auto b_p = Multiply(params, sk_reg_ntt, a_ntt); - auto b = Add(params, e_ntt, b_p); - auto p = PolyMatrixNtt::Zero(params.CrtCount(), params.PolyLen(), 2, 1); - p.CopyInto(a_inv, 0, 0); - p.CopyInto(b, 1, 0); - - return p; -} - -PolyMatrixNtt GetFreshRegevPublicKey(const Params& params, - const PolyMatrixRaw& sk_reg, size_t m, - yacl::crypto::Prg& rng, - yacl::crypto::Prg& rng_pub) { - auto p = PolyMatrixNtt::Zero(params.CrtCount(), params.PolyLen(), 2, m); - for (size_t i = 0; i < m; ++i) { - p.CopyInto(GetRegevSample(params, sk_reg, rng, rng_pub), 0, i); - } - return p; -} - -std::vector RawGenerateExpansionParams( - const Params& params, const PolyMatrixRaw& sk_reg, size_t num_exp, - size_t m_exp, yacl::crypto::Prg& rng, - yacl::crypto::Prg& rng_pub) { - auto g_exp = util::BuildGadget(params, 1, m_exp); - auto g_exp_ntt = ToNtt(params, g_exp); - - std::vector res; - res.reserve(num_exp); - - for (size_t i = 0; i < num_exp; ++i) { - size_t t = (params.PolyLen() / (1ULL << i)) + 1; - auto tau_sk_reg = Automorphism(params, sk_reg, t); - auto tau_sk_reg_ntt = ToNtt(params, tau_sk_reg); - auto prod = Multiply(params, tau_sk_reg_ntt, g_exp_ntt); - auto sample = GetFreshRegevPublicKey(params, sk_reg, m_exp, rng, rng_pub); - - PolyMatrixNtt padded_prod = prod.PadTop(1); - auto w_exp_i = Add(params, sample, padded_prod); - res.push_back(std::move(w_exp_i)); - } - return res; -} - -// from kernal.rs - -template -void FastBatchedDotProduct(const Params& params, uint64_t* c, const uint64_t* a, - size_t a_elems, const T* b_t, size_t b_rows, - size_t b_cols) { - if (a_elems != b_rows) { - throw std::runtime_error("FastBatchedDotProduct: Dimension mismatch"); - } - - const size_t chunk_size = std::min(65536, a_elems); - const size_t num_chunks = a_elems / chunk_size; - - for (size_t k_outer = 0; k_outer < num_chunks; ++k_outer) { - const uint64_t* a_chunk_ptr = a + (k_outer * chunk_size); - for (size_t j = 0; j < b_cols; ++j) { - const T* b_ptr = b_t + (j * b_rows) + (k_outer * chunk_size); - uint64_t total_sum_lo = 0; - uint64_t total_sum_hi = 0; - for (size_t k_inner = 0; k_inner < chunk_size; ++k_inner) { - uint64_t a_val = a_chunk_ptr[k_inner]; - uint64_t b_val = static_cast(b_ptr[k_inner]); - uint64_t a_lo = a_val & 0xFFFFFFFF; - uint64_t a_hi = a_val >> 32; - total_sum_lo += a_lo * b_val; - total_sum_hi += a_hi * b_val; - } - - uint64_t lo = arith::BarrettCoeffU64(params, total_sum_lo, 0); - uint64_t hi = arith::BarrettCoeffU64(params, total_sum_hi, 1); - - uint64_t res = params.CrtCompose2(lo, hi); - - uint64_t sum = c[j] + res; - c[j] = arith::BarrettU64(params, sum); - } - } -} - -// from serialize.rs -std::vector UnpackVecPm(const Params& params, size_t rows, - size_t cols, - absl::Span data) { - if (params.CrtCount() != 2) { - throw std::runtime_error("UnpackVecPm: Params CRT count must be 2"); - } - - size_t poly_len = params.PolyLen(); - size_t chunk_size = rows * cols * poly_len; - - if (chunk_size == 0) { - return {}; - } - - if (data.size() % chunk_size != 0) { - throw std::runtime_error( - "UnpackVecPm: Data size not aligned with matrix dimensions"); - } - - size_t num_matrices = data.size() / chunk_size; - std::vector v_cts; - v_cts.reserve(num_matrices); - - for (size_t i = 0; i < num_matrices; ++i) { - const uint64_t* in_data_ptr = data.data() + (i * chunk_size); - - auto ct = - PolyMatrixNtt::Zero(params.CrtCount(), params.PolyLen(), rows, cols); - - uint64_t* out_data_ptr = const_cast(ct.Data().data()); - - for (size_t row = 0; row < rows; ++row) { - for (size_t col = 0; col < cols; ++col) { - size_t in_offs = (row * cols + col) * poly_len; - - size_t out_offs = (row * cols + col) * 2 * poly_len; - - for (size_t z = 0; z < poly_len; ++z) { - out_data_ptr[out_offs + z] = in_data_ptr[in_offs + z]; - } - } - } - v_cts.push_back(std::move(ct)); - } - - return v_cts; -} -PolyMatrixNtt UncondenseMatrix(const Params& params, const PolyMatrixNtt& a) { - size_t rows = a.Rows(); - size_t cols = a.Cols(); - size_t poly_len = params.PolyLen(); - - PolyMatrixNtt res = - PolyMatrixNtt::Zero(params.CrtCount(), params.PolyLen(), rows, cols); - - for (size_t i = 0; i < rows; ++i) { - for (size_t j = 0; j < cols; ++j) { - auto res_poly = res.Poly(i, j); - const auto a_poly = a.Poly(i, j); - - for (size_t z = 0; z < poly_len; ++z) { - uint64_t val = a_poly[z]; - res_poly[z] = val & 0xFFFFFFFFULL; - res_poly[z + poly_len] = val >> 32; - } - } - } - - return res; -} -// from modulus switch.rs -std::vector ModulusSwitch(const Params& params, - const PolyMatrixRaw& poly_matrix, - uint64_t q_prime_1, uint64_t q_prime_2) { - if (poly_matrix.Rows() != 2 || poly_matrix.Cols() != 1) { - throw std::runtime_error("ModulusSwitch: Matrix must be 2x1"); - } - size_t poly_len = params.PolyLen(); - uint64_t current_modulus = params.Modulus(); - - size_t bits_for_row0 = static_cast(std::ceil(std::log2(q_prime_2))); - size_t bits_for_row1 = static_cast(std::ceil(std::log2(q_prime_1))); - - size_t total_sz_bits = (bits_for_row0 + bits_for_row1) * poly_len; - size_t total_sz_bytes = (total_sz_bits + 7) / 8; - - std::vector res(total_sz_bytes, 0); - - size_t bit_offs = 0; - - const uint64_t* row_0_ptr = poly_matrix.Data().data(); - - for (size_t z = 0; z < poly_len; ++z) { - uint64_t val = row_0_ptr[z]; - uint64_t val_rescaled = arith::Rescale(val, current_modulus, q_prime_2); - - util::WriteArbitraryBits(res, val_rescaled, bit_offs, bits_for_row0); - bit_offs += bits_for_row0; - } - - const uint64_t* row_1_ptr = poly_matrix.Data().data() + poly_len; - - for (size_t z = 0; z < poly_len; ++z) { - uint64_t val = row_1_ptr[z]; - uint64_t val_rescaled = arith::Rescale(val, current_modulus, q_prime_1); - - util::WriteArbitraryBits(res, val_rescaled, bit_offs, bits_for_row1); - bit_offs += bits_for_row1; - } - - return res; -} - -// Explicit instantiation of template functions -template void FastBatchedDotProduct(const Params& params, uint64_t* c, - const uint64_t* a, size_t a_elems, - const uint8_t* b_t, size_t b_rows, - size_t b_cols); -template void FastBatchedDotProduct(const Params& params, uint64_t* c, - const uint64_t* a, size_t a_elems, - const uint16_t* b_t, - size_t b_rows, size_t b_cols); -template void FastBatchedDotProduct(const Params& params, uint64_t* c, - const uint64_t* a, size_t a_elems, - const uint32_t* b_t, - size_t b_rows, size_t b_cols); - } // namespace psi::ypir diff --git a/psi/algorithm/ypir/util.h b/psi/algorithm/ypir/util.h index 544d294c..905b4ccc 100644 --- a/psi/algorithm/ypir/util.h +++ b/psi/algorithm/ypir/util.h @@ -1,128 +1,16 @@ #pragma once #include +#include +#include -#include "../spiral/params.h" -#include "../spiral/poly_matrix.h" +#include "psi/algorithm/ypir/params.h" -#include "psi/algorithm/ypir/types.h" namespace psi::ypir { -using namespace psi::spiral; -std::vector ConcatHorizontal( - const std::vector>& v_a, size_t a_rows, - size_t a_cols); +std::vector BuildPackedSimplepirQuery(const YpirParameters& params, + uint64_t raw_idx); +std::vector EncodeIntegerValue(uint64_t value, size_t value_bytes); +uint64_t DecodeSimplepirValue(const YpirParameters& params, uint64_t value); -void MatMulVecPacked(uint32_t* out, const uint32_t* a, const uint32_t* b, - size_t a_rows, size_t a_cols, size_t b_rows, - size_t b_cols); - -PolyMatrixNtt HomomorphicAutomorph(const Params& params, size_t t, size_t t_exp, - const PolyMatrixNtt& ct, - const PolyMatrixNtt& pub_param); - -PolyMatrixNtt RingPackLwesInner( - const Params& params, size_t ell, size_t start_idx, - const std::vector& rlwe_cts, - const std::vector& pub_params, - const std::pair, std::vector>& - y_constants); - -std::pair, std::vector> GenYConstants( - const Params& params); - -PolyMatrixNtt RingPackLwes( - const Params& params, const std::vector& b_values, - const std::vector& rlwe_cts, size_t num_cts, - const std::vector& pub_params, - const std::pair, std::vector>& - y_constants); - -std::vector NegacyclicPerm(absl::Span a, size_t shift, - uint64_t modulus); -std::vector NegacyclicMatrix(absl::Span a, - uint64_t modulus); -PolyMatrixNtt CondenseMatrix(const Params& params, const PolyMatrixNtt& a); -PolyMatrixNtt UncondenseMatrix(const Params& params, const PolyMatrixNtt& a); -PolyMatrixNtt PackUsingSingleWithOffset( - const Params& params, const std::vector& pub_params, - const std::vector& cts, size_t offset); - -std::vector PrepPackLwes(const Params& params, - absl::Span lwe_cts, - size_t cols_to_do); - -std::vector> PrepPackManyLwes( - const Params& params, absl::Span lwe_cts, - size_t num_rlwe_outputs); - -std::vector> GenerateAutomorphTablesBruteForce( - const Params& params); - -std::tuple, - std::vector>> -PrecomputePack(const Params& params, size_t poly_len_log2, - const std::vector& prepacked, - const std::vector& pub_params, - const std::pair, - std::vector>& y_constants); -void FastAddIntoNoReduce(PolyMatrixNtt& res, const PolyMatrixNtt& a); -void MultiplyPolyAvx(uint64_t* res, const uint64_t* a, const uint64_t* b, - size_t len); -void ScalarMultiplyAvx(const Params& params, PolyMatrixNtt& res, - const PolyMatrixNtt& a, const PolyMatrixNtt& b); - -void FastMultiplyNoReduce(const Params& params, PolyMatrixNtt& res, - const PolyMatrixNtt& a, const PolyMatrixNtt& b, - size_t start_inner_dim = 0); -void ApplyAutomorphNttRaw(const Params& params, const uint64_t* poly, - uint64_t* out, size_t t, - const std::vector>& tables); -void ApplyAutomorphNtt(const Params& params, - const std::vector>& tables, - const PolyMatrixNtt& mat, PolyMatrixNtt& res, size_t t); -void FastReduce(const Params& params, PolyMatrixNtt& res); -PolyMatrixNtt PackUsingPrecompVals( - const Params& params, - size_t ell, // params.poly_len_log2 - absl::Span pub_params, - absl::Span b_values, const PolyMatrixNtt& precomp_res, - absl::Span precomp_vals, - const std::vector>& precomp_tables, - const std::pair, std::vector>& - y_constants); - -std::vector PackManyLwes( - const Params& params, - const std::vector>& prep_rlwe_cts, - const Precomp& precomp, absl::Span b_values, - size_t num_rlwe_outputs, - const std::vector& pack_pub_params_row_1s, - const std::pair, std::vector>& - y_constants); - -PolyMatrixNtt GetRegevSample(const Params& params, const PolyMatrixRaw& sk_reg, - yacl::crypto::Prg& rng, - yacl::crypto::Prg& rng_pub); -PolyMatrixNtt GetFreshRegevPublicKey(const Params& params, - const PolyMatrixRaw& sk_reg, size_t m, - yacl::crypto::Prg& rng, - yacl::crypto::Prg& rng_pub); -std::vector RawGenerateExpansionParams( - const Params& params, const PolyMatrixRaw& sk_reg, size_t num_exp, - size_t m_exp, yacl::crypto::Prg& rng, - yacl::crypto::Prg& rng_pub); - -template -void FastBatchedDotProduct(const Params& params, uint64_t* c, const uint64_t* a, - size_t a_elems, const T* b_t, size_t b_rows, - size_t b_cols); - -std::vector UnpackVecPm(const Params& params, size_t rows, - size_t cols, - absl::Span data); - -std::vector ModulusSwitch(const Params& params, - const PolyMatrixRaw& poly_matrix, - uint64_t q_prime_1, uint64_t q_prime_2); -} // namespace psi::ypir \ No newline at end of file +} // namespace psi::ypir diff --git a/psi/algorithm/ypir/util_test.cc b/psi/algorithm/ypir/util_test.cc deleted file mode 100644 index fa1e3d83..00000000 --- a/psi/algorithm/ypir/util_test.cc +++ /dev/null @@ -1,201 +0,0 @@ -#include "../spiral/util.h" - -#include "../spiral/arith/arith.h" -#include "../spiral/arith/number_theory.h" -#include "../spiral/gadget.h" -#include "../spiral/poly_matrix.h" -#include "../spiral/poly_matrix_utils.h" -#include "../spiral/public_keys.h" -#include "../spiral/spiral_client.h" -#include "gtest/gtest.h" -#include "yacl/crypto/rand/rand.h" -#include "yacl/crypto/tools/prg.h" - -#include "psi/algorithm/ypir/util.h" - -namespace psi::ypir { -TEST(RLWETest, EncDecTest) { - auto params = spiral::util::GetFastExpansionTestingParam(); - - uint64_t p = params.PtModulus(); - uint64_t q = params.Modulus(); - uint64_t scale_k = params.ScaleK(); - auto sigma_raw = spiral::PolyMatrixRaw::Zero(params.PolyLen(), 1, 1); - auto pt_seed = yacl::crypto::SecureRandU128(); - yacl::crypto::Prg pt_rng(pt_seed); - std::vector m_enc(params.PolyLen()); - for (size_t i = 0; i < params.PolyLen(); ++i) { - m_enc[i] = pt_rng() % p; - sigma_raw.Data()[i] = (m_enc[i] * scale_k) % q; - } - auto sigma_ntt = spiral::ToNtt(params, sigma_raw); - - class ClientDerive : public spiral::SpiralClient { - public: - using spiral::SpiralClient::DecryptMatrixRegev; - using spiral::SpiralClient::EncryptMatrixRegev; - using spiral::SpiralClient::SpiralClient; - }; - ClientDerive client(params); - - auto seed = yacl::crypto::SecureRandU128(); - yacl::crypto::Prg rng(seed); - auto pub_seed = yacl::crypto::SecureRandU128(); - yacl::crypto::Prg rng_pub(pub_seed); - - auto ct = client.EncryptMatrixRegev(sigma_ntt, rng, rng_pub); - auto dec_ntt = client.DecryptMatrixRegev(ct); - auto dec_raw = spiral::FromNtt(params, dec_ntt); - - ASSERT_EQ(dec_raw.Data().size(), sigma_raw.Data().size()); - for (size_t i = 0; i < sigma_raw.Data().size(); ++i) { - uint64_t v_rescaled = spiral::arith::Rescale( - dec_raw.Data()[i], params.Modulus(), params.PtModulus()); - uint64_t v_exp = m_enc[i]; - ASSERT_EQ(v_rescaled, v_exp) << "mismatch at coeff " << i; - } -} - -TEST(RLWETest, AutomorphismTest) { - auto params = spiral::util::GetFastExpansionTestingParam(); - - uint64_t p = params.PtModulus(); - uint64_t q = params.Modulus(); - uint64_t scale_k = params.ScaleK(); - auto sigma_raw = spiral::PolyMatrixRaw::Zero(params.PolyLen(), 1, 1); - auto pt_seed = yacl::crypto::SecureRandU128(); - yacl::crypto::Prg pt_rng(pt_seed); - std::vector m_enc(params.PolyLen()); - for (size_t i = 0; i < params.PolyLen(); ++i) { - m_enc[i] = pt_rng() % p; - sigma_raw.Data()[i] = (m_enc[i] * scale_k) % q; - } - auto sigma_ntt = spiral::ToNtt(params, sigma_raw); - - class ClientDerive : public spiral::SpiralClient { - public: - using spiral::SpiralClient::DecryptMatrixRegev; - using spiral::SpiralClient::EncryptMatrixRegev; - using spiral::SpiralClient::GenPublicKeys; - using spiral::SpiralClient::SpiralClient; - }; - ClientDerive client(params); - auto pp = client.GenPublicKeys(); - - auto seed = yacl::crypto::SecureRandU128(); - yacl::crypto::Prg rng(seed); - auto pub_seed = yacl::crypto::SecureRandU128(); - yacl::crypto::Prg rng_pub(pub_seed); - - auto ct = client.EncryptMatrixRegev(sigma_ntt, rng, rng_pub); - - for (size_t i = 0; i < pp.v_expansion_right_.size(); ++i) { - size_t t = (params.PolyLen() / (1 << i)) + 1; - size_t t_exp = params.TExpRight(); - - const auto& pub_param = pp.v_expansion_right_[i]; - - auto ct_auto_ntt = HomomorphicAutomorph(params, t, t_exp, ct, pub_param); - - auto dec_auto_ntt = client.DecryptMatrixRegev(ct_auto_ntt); - auto dec_auto_raw = spiral::FromNtt(params, dec_auto_ntt); - - auto sigma_auto_raw = spiral::Automorphism(params, sigma_raw, t); - - auto sigma_auto_ntt = spiral::ToNtt(params, sigma_auto_raw); - - ASSERT_EQ(dec_auto_raw.Data().size(), sigma_auto_raw.Data().size()); - for (size_t j = 0; j < sigma_auto_raw.Data().size(); ++j) { - uint64_t v_rescaled = spiral::arith::Rescale( - dec_auto_raw.Data()[j], params.Modulus(), params.PtModulus()); - uint64_t v_exp_scaled = sigma_auto_raw.Data()[j]; - uint64_t v_exp = spiral::arith::Rescale(v_exp_scaled, params.Modulus(), - params.PtModulus()); - ASSERT_EQ(v_rescaled, v_exp) - << "mismatch at coeff " << j << " for expansion level " << i; - } - } -} - -TEST(RLWETest, PackingTest) { - auto params = spiral::util::GetFastExpansionTestingParam(); - - class ClientDerive : public spiral::SpiralClient { - public: - using spiral::SpiralClient::DecryptMatrixRegev; - using spiral::SpiralClient::EncryptMatrixRegev; - using spiral::SpiralClient::GenPublicKeys; - using spiral::SpiralClient::GetSkRegev; - using spiral::SpiralClient::SpiralClient; - }; - ClientDerive client(params); - auto pp = client.GenPublicKeys(); - - auto y_constants = GenYConstants(params); - - auto pack_seed = yacl::crypto::SecureRandU128(); - yacl::crypto::Prg pack_rng(yacl::crypto::SecureRandU128()); - yacl::crypto::Prg pack_rng_pub(pack_seed); - auto pack_pub_params = RawGenerateExpansionParams( - params, client.GetSkRegev(), params.PolyLenLog2(), params.TExpLeft(), - pack_rng, pack_rng_pub); - - auto cts_seed = yacl::crypto::SecureRandU128(); - yacl::crypto::Prg ct_rng(cts_seed); - auto ct_pub_seed = yacl::crypto::SecureRandU128(); - yacl::crypto::Prg ct_rng_pub(ct_pub_seed); - - std::vector v_ct; - std::vector b_values; - v_ct.reserve(params.PolyLen()); - b_values.reserve(params.PolyLen()); - - uint64_t p = params.PtModulus(); - uint64_t scale_k = params.ScaleK(); - uint64_t mod_inv = spiral::arith::InvertUintMod( - static_cast(params.PolyLen()), params.Modulus()); - - for (size_t i = 0; i < params.PolyLen(); ++i) { - auto pt = spiral::PolyMatrixRaw::Zero(params.PolyLen(), 1, 1); - uint64_t val = i % p; - uint64_t val_to_enc = spiral::arith::MultiplyUintMod(val * scale_k, mod_inv, - params.Modulus()); - pt.Data()[0] = val_to_enc; - - auto pt_ntt = spiral::ToNtt(params, pt); - auto ct = client.EncryptMatrixRegev(pt_ntt, ct_rng, ct_rng_pub); - auto ct_raw = spiral::FromNtt(params, ct); - - b_values.push_back(ct_raw.Data()[ct_raw.PolyStartIndex(1, 0)]); - - std::fill( - ct_raw.Data().begin() + ct_raw.PolyStartIndex(1, 0), - ct_raw.Data().begin() + ct_raw.PolyStartIndex(1, 0) + params.PolyLen(), - 0ULL); - v_ct.push_back(spiral::ToNtt(params, ct_raw)); - } - - auto packed = RingPackLwes(params, b_values, v_ct, params.PolyLen(), - pack_pub_params, y_constants); - - auto dec = client.DecryptMatrixRegev(packed); - auto dec_raw = spiral::FromNtt(params, dec); - - auto rescaled = spiral::PolyMatrixRaw::Zero(params.PolyLen(), 1, 1); - for (size_t i = 0; i < params.PolyLen(); ++i) { - rescaled.Data()[i] = spiral::arith::Rescale( - dec_raw.Data()[i], params.Modulus(), params.PtModulus()); - } - - auto gold = spiral::PolyMatrixRaw::Zero(params.PolyLen(), 1, 1); - for (size_t i = 0; i < params.PolyLen(); ++i) { - gold.Data()[i] = i % p; - } - - ASSERT_EQ(rescaled.Data().size(), gold.Data().size()); - for (size_t i = 0; i < gold.Data().size(); ++i) { - ASSERT_EQ(rescaled.Data()[i], gold.Data()[i]) << "mismatch at coeff " << i; - } -} - -} // namespace psi::ypir \ No newline at end of file diff --git a/psi/algorithm/ypir/ypir_basic_flow_test.cc b/psi/algorithm/ypir/ypir_basic_flow_test.cc deleted file mode 100644 index 7ab5b1a7..00000000 --- a/psi/algorithm/ypir/ypir_basic_flow_test.cc +++ /dev/null @@ -1,138 +0,0 @@ -#include "gtest/gtest.h" - -#include -#include -#include - -#include "psi/algorithm/ypir/client.h" -#include "psi/algorithm/ypir/hexl.h" -#include "psi/algorithm/ypir/ypir_params.h" -#include "psi/algorithm/ypir/server.h" - -namespace psi::ypir { - -namespace { - -static psi::ypir::byhe::ByheHexlNtt* g_ntt = nullptr; - -void NttForwardWrapper(uint64_t* data, size_t len) { - g_ntt->Forward(data, len); -} - -template -double MeasureElapsedMs(Fn&& fn) { - const auto start = std::chrono::steady_clock::now(); - fn(); - const auto end = std::chrono::steady_clock::now(); - return std::chrono::duration(end - start).count(); -} - -} // namespace - -TEST(YPIRBasicFlowTest, ByheYpirFlowSmoke) { - using namespace psi::ypir::byhe; - srand(1235); - std::cout << std::fixed << std::setprecision(3); - - const uint64_t lwe_dimension = 1024; - const uint64_t lwe_pmod = (1 << 8); - const uint64_t lwe_cmod = (1ULL << 32); - const uint64_t rlwe_degree = 2048; - const uint64_t rlwe_pmod = (1 << 16); - const uint64_t rlwe_cmod = kCrtMod; - const double sigma = 3.19; - const double sigma_ring = 3.19; - const AutoParams auto_params{20, 18, 2}; - const DecompParams decomp_params{16, 16, 1}; - - FheParams fparm(rlwe_degree, rlwe_cmod, rlwe_pmod, lwe_dimension, lwe_cmod, - lwe_pmod, sigma, sigma_ring, auto_params, decomp_params); - - const uint64_t db_row = 1 << 12; - const uint64_t db_col = 1 << 12; - PirParams pparm(db_row, db_col); - - g_ntt = &fparm.get_ntt(); - fparm.SetNttForward(&NttForwardWrapper); - - fparm.set_persudo_matrix_simplepir(pparm.get_col()); - fparm.set_persudo_matrix_doublepir(pparm.get_row()); - fparm.set_persudo_hcube_ypir(); - - const uint64_t expo = GetLog2(rlwe_degree); - std::vector auto_idx; - for (uint64_t i = 1; i <= expo; ++i) { - auto_idx.push_back((1ULL << i) + 1); - } - fparm.set_automap(auto_idx); - fparm.set_precomputed_pt(expo); - - // Build a small database and flatten to bytes. - std::vector> db( - pparm.get_row(), std::vector(pparm.get_col(), 0)); - for (uint64_t i = 0; i < pparm.get_row(); ++i) { - for (uint64_t j = 0; j < pparm.get_col(); ++j) { - db[i][j] = static_cast((i + j) % lwe_pmod); - } - } - - std::vector db8(pparm.get_row() * pparm.get_col(), 0); - for (uint64_t i = 0; i < pparm.get_row(); ++i) { - for (uint64_t j = 0; j < pparm.get_col(); ++j) { - db8[i * pparm.get_col() + j] = static_cast(db[i][j]); - } - } - - std::vector H0(rlwe_degree, 0); - std::vector> double_server_hint; - std::vector>> decomp_buf; - AESCTR_PRNG prng; - const double hint_generate_ms = MeasureElapsedMs([&] { - psi::ypir::byhe::YpirHintGenerate(db, H0, double_server_hint, decomp_buf, - prng, fparm, pparm); - }); - std::cout << "YpirHintGenerate took " << hint_generate_ms << " ms" - << std::endl; - - std::vector> mat_tmp; - MatrixTranspose(double_server_hint, mat_tmp); - - const uint64_t r_idx = rand() % db_row; - const uint64_t c_idx = rand() % db_col; - Secret simple_sk(lwe_dimension, lwe_cmod); - Secret double_sk(rlwe_degree, rlwe_cmod); - - YpirQuery query; - const double query_generate_ms = MeasureElapsedMs([&] { - query = psi::ypir::byhe::Generate_query_ypir(c_idx, r_idx, simple_sk, - double_sk, prng, fparm, - pparm); - }); - std::cout << "Generate_query_ypir took " << query_generate_ms << " ms" - << std::endl; - - std::vector qu0_32(query.qu0.size(), 0); - for (size_t i = 0; i < query.qu0.size(); ++i) { - qu0_32[i] = static_cast(query.qu0[i]); - } - - std::vector> res; - res.push_back(H0); - const double answer_ms = MeasureElapsedMs([&] { - psi::ypir::byhe::YpirAnswer(db8.data(), qu0_32.data(), query.qu1, - query.ksk_b, decomp_buf, mat_tmp, res, fparm, - pparm); - }); - std::cout << "YpirAnswer took " << answer_ms << " ms" << std::endl; - - uint64_t message = 0; - const double recover_ms = MeasureElapsedMs([&] { - psi::ypir::byhe::YpirRecover(simple_sk, double_sk, res, message, fparm, - pparm); - }); - std::cout << "YpirRecover took " << recover_ms << " ms" << std::endl; - std::cout << message << " " << db[r_idx][c_idx] << std::endl; - EXPECT_EQ(message, db[r_idx][c_idx]); -} - -} // namespace psi::ypir diff --git a/psi/algorithm/ypir/ypir_flow_test.cc b/psi/algorithm/ypir/ypir_flow_test.cc new file mode 100644 index 00000000..5c9e9196 --- /dev/null +++ b/psi/algorithm/ypir/ypir_flow_test.cc @@ -0,0 +1,44 @@ +#include "psi/algorithm/ypir/client.h" +#include "psi/algorithm/ypir/serialize.h" +#include "psi/algorithm/ypir/server.h" + +#include +#include + +#include "gtest/gtest.h" + +namespace psi::ypir { +namespace { + +psi::pir::RawDatabase BuildDoublepirDatabase(const YpirParameters& params) { + std::vector> rows(params.db_rows, + std::vector(params.db_cols, 0)); + for (uint64_t row = 0; row < params.db_rows; ++row) { + for (uint64_t col = 0; col < params.db_cols; ++col) { + rows[row][col] = static_cast((row + col) % 251); + } + } + return psi::pir::RawDatabase(std::move(rows)); +} + +TEST(YpirDoublepirFlowTest, EndToEndSmallDatabase) { + auto params = CreateSmallTestParamsDoublePIR(); + YpirClient client(params); + YpirServer server(params); + server.GenerateFromRawData(BuildDoublepirDatabase(params)); + + const auto state = server.PerformOfflinePrecomputation(); + const uint64_t row = 111; + const uint64_t col = 222; + const uint64_t raw_idx = row * params.db_cols + col; + + const auto query_buffer = client.GenerateQueryBuffer(raw_idx); + const auto response = server.ProcessQuery(DeserializeQuery(query_buffer), state); + const auto decoded = client.DecodeResponse(response, raw_idx); + + ASSERT_EQ(decoded.size(), 1U); + EXPECT_EQ(decoded[0], static_cast((row + col) % 251)); +} + +} // namespace +} // namespace psi::ypir diff --git a/psi/algorithm/ypir/ypir_internal_client.cc b/psi/algorithm/ypir/ypir_internal_client.cc new file mode 100644 index 00000000..6a38622a --- /dev/null +++ b/psi/algorithm/ypir/ypir_internal_client.cc @@ -0,0 +1,53 @@ +#include "psi/algorithm/ypir/ypir_internal_client.h" + +#include "yacl/base/exception.h" + +#include "psi/algorithm/ypir/util.h" + +namespace psi::ypir::internal::ypir { + +YpirQuery GenerateQuery(uint64_t raw_idx, const YpirParameters& params, + ClientSecrets& secrets, const Context& context) { + YACL_ENFORCE(params.mode == YpirMode::kDoublepir); + YACL_ENFORCE_LT(raw_idx, params.NumItems()); + + const uint64_t row_idx = raw_idx / params.db_cols; + const uint64_t col_idx = raw_idx % params.db_cols; + + secrets.simple_secret = psi::ypir::ypir_internal::Secret( + context.fhe_params->get_lwe_dimension(), context.fhe_params->get_lwe_cmod()); + secrets.double_secret = psi::ypir::ypir_internal::Secret( + context.fhe_params->get_poly_degree(), context.fhe_params->get_rlwe_cmod()); + secrets.initialized = true; + + auto legacy_query = psi::ypir::ypir_internal::Generate_query_ypir( + col_idx, row_idx, secrets.simple_secret, secrets.double_secret, + *context.prng, *context.fhe_params, *context.pir_params); + + YpirQuery query; + query.mode = YpirMode::kDoublepir; + query.qu0 = std::move(legacy_query.qu0); + query.qu1 = std::move(legacy_query.qu1); + query.ksk_b = std::move(legacy_query.ksk_b); + return query; +} + +std::vector RecoverResponse(const YpirResponse& response, + const YpirParameters& params, + const ClientSecrets& secrets, + const Context& context) { + YACL_ENFORCE(params.mode == YpirMode::kDoublepir); + YACL_ENFORCE(secrets.initialized, "GenerateQuery must be called before decode"); + YACL_ENFORCE(response.mode == YpirMode::kDoublepir); + + auto simple_secret = secrets.simple_secret; + auto double_secret = secrets.double_secret; + auto result = response.doublepir_response; + uint64_t message = 0; + + psi::ypir::ypir_internal::YpirRecover(simple_secret, double_secret, result, message, + *context.fhe_params, *context.pir_params); + return EncodeIntegerValue(message, params.value_bytes); +} + +} // namespace psi::ypir::internal::ypir diff --git a/psi/algorithm/ypir/ypir_internal_client.h b/psi/algorithm/ypir/ypir_internal_client.h new file mode 100644 index 00000000..fab1a09a --- /dev/null +++ b/psi/algorithm/ypir/ypir_internal_client.h @@ -0,0 +1,25 @@ +#pragma once + +#include + +#include "psi/algorithm/ypir/legacy/client.h" +#include "psi/algorithm/ypir/ypir_internal_params.h" +#include "psi/algorithm/ypir/types.h" + +namespace psi::ypir::internal::ypir { + +struct ClientSecrets { + psi::ypir::ypir_internal::Secret simple_secret; + psi::ypir::ypir_internal::Secret double_secret; + bool initialized = false; +}; + +YpirQuery GenerateQuery(uint64_t raw_idx, const YpirParameters& params, + ClientSecrets& secrets, const Context& context); + +std::vector RecoverResponse(const YpirResponse& response, + const YpirParameters& params, + const ClientSecrets& secrets, + const Context& context); + +} // namespace psi::ypir::internal::ypir diff --git a/psi/algorithm/ypir/ypir_internal_params.cc b/psi/algorithm/ypir/ypir_internal_params.cc new file mode 100644 index 00000000..90f4e919 --- /dev/null +++ b/psi/algorithm/ypir/ypir_internal_params.cc @@ -0,0 +1,58 @@ +#include "psi/algorithm/ypir/ypir_internal_params.h" + +#include + +#include "yacl/base/exception.h" + +namespace psi::ypir::internal::ypir { +namespace { + +thread_local psi::ypir::ypir_internal::YpirHexlNtt* g_ntt = nullptr; + +void NttForwardWrapper(uint64_t* data, size_t len) { g_ntt->Forward(data, len); } + +Context BuildContext(uint64_t rows, uint64_t cols) { + using namespace psi::ypir::ypir_internal; + + const uint64_t lwe_dimension = 1024; + const uint64_t lwe_pmod = (1 << 8); + const uint64_t lwe_cmod = (1ULL << 32); + const uint64_t rlwe_degree = 2048; + const uint64_t rlwe_pmod = (1 << 16); + const uint64_t rlwe_cmod = kCrtMod; + const double sigma = 3.19; + const double sigma_ring = 3.19; + const AutoParams auto_params{20, 18, 2}; + const DecompParams decomp_params{16, 16, 1}; + + auto fhe_params = std::make_shared( + rlwe_degree, rlwe_cmod, rlwe_pmod, lwe_dimension, lwe_cmod, lwe_pmod, + sigma, sigma_ring, auto_params, decomp_params); + auto pir_params = std::make_shared(rows, cols); + auto prng = std::make_shared(); + + g_ntt = &fhe_params->get_ntt(); + fhe_params->SetNttForward(&NttForwardWrapper); + fhe_params->set_persudo_matrix_simplepir(pir_params->get_col()); + fhe_params->set_persudo_matrix_doublepir(pir_params->get_row()); + fhe_params->set_persudo_hcube_ypir(); + + const uint64_t expo = GetLog2(rlwe_degree); + std::vector auto_idx; + for (uint64_t i = 1; i <= expo; ++i) { + auto_idx.push_back((1ULL << i) + 1); + } + fhe_params->set_automap(auto_idx); + fhe_params->set_precomputed_pt(expo); + + return {std::move(fhe_params), std::move(pir_params), std::move(prng)}; +} + +} // namespace + +Context CreateContext(const YpirParameters& params) { + YACL_ENFORCE(params.mode == YpirMode::kDoublepir); + return BuildContext(params.db_rows, params.db_cols); +} + +} // namespace psi::ypir::internal::ypir diff --git a/psi/algorithm/ypir/ypir_internal_params.h b/psi/algorithm/ypir/ypir_internal_params.h new file mode 100644 index 00000000..4e665a26 --- /dev/null +++ b/psi/algorithm/ypir/ypir_internal_params.h @@ -0,0 +1,18 @@ +#pragma once + +#include + +#include "psi/algorithm/ypir/legacy/ypir_params.h" +#include "psi/algorithm/ypir/params.h" + +namespace psi::ypir::internal::ypir { + +struct Context { + std::shared_ptr fhe_params; + std::shared_ptr pir_params; + std::shared_ptr prng; +}; + +Context CreateContext(const YpirParameters& params); + +} // namespace psi::ypir::internal::ypir diff --git a/psi/algorithm/ypir/ypir_internal_server.cc b/psi/algorithm/ypir/ypir_internal_server.cc new file mode 100644 index 00000000..07199210 --- /dev/null +++ b/psi/algorithm/ypir/ypir_internal_server.cc @@ -0,0 +1,71 @@ +#include "psi/algorithm/ypir/ypir_internal_server.h" + +#include "yacl/base/exception.h" + +#include "psi/algorithm/ypir/legacy/server.h" + +namespace psi::ypir::internal::ypir { +namespace { + +std::vector> ExpandDatabase(const std::vector& db, + uint64_t rows, + uint64_t cols) { + YACL_ENFORCE_EQ(db.size(), rows * cols); + std::vector> out(rows, std::vector(cols, 0)); + for (uint64_t row = 0; row < rows; ++row) { + for (uint64_t col = 0; col < cols; ++col) { + out[row][col] = db[row * cols + col]; + } + } + return out; +} + +} // namespace + +YpirPrecomputedState PrepareOfflineState(const std::vector& db, + const YpirParameters& params, + const Context& context) { + YACL_ENFORCE(params.mode == YpirMode::kDoublepir); + auto db_matrix = ExpandDatabase(db, params.db_rows, params.db_cols); + + YpirPrecomputedState state; + state.mode = YpirMode::kDoublepir; + std::vector> server_hint; + psi::ypir::ypir_internal::YpirHintGenerate(db_matrix, state.hint_0, server_hint, + state.decomp_buf, *context.prng, + *context.fhe_params, *context.pir_params); + psi::ypir::ypir_internal::MatrixTranspose(server_hint, state.server_hint); + return state; +} + +YpirResponse ProcessQuery(const std::vector& db, + const YpirQuery& query, + const YpirPrecomputedState& state, + const YpirParameters& params, + const Context& context) { + YACL_ENFORCE(params.mode == YpirMode::kDoublepir); + YACL_ENFORCE(query.mode == YpirMode::kDoublepir); + YACL_ENFORCE(state.mode == YpirMode::kDoublepir); + + std::vector qu0(query.qu0.size(), 0); + for (size_t i = 0; i < query.qu0.size(); ++i) { + qu0[i] = static_cast(query.qu0[i]); + } + + auto qu1 = query.qu1; + auto decomp_buf = state.decomp_buf; + const auto& server_hint = state.server_hint; + + std::vector> result; + result.push_back(state.hint_0); + psi::ypir::ypir_internal::YpirAnswer(db.data(), qu0.data(), qu1, query.ksk_b, + decomp_buf, server_hint, result, + *context.fhe_params, *context.pir_params); + + YpirResponse response; + response.mode = YpirMode::kDoublepir; + response.doublepir_response = std::move(result); + return response; +} + +} // namespace psi::ypir::internal::ypir diff --git a/psi/algorithm/ypir/ypir_internal_server.h b/psi/algorithm/ypir/ypir_internal_server.h new file mode 100644 index 00000000..a8a06f72 --- /dev/null +++ b/psi/algorithm/ypir/ypir_internal_server.h @@ -0,0 +1,21 @@ +#pragma once + +#include +#include + +#include "psi/algorithm/ypir/ypir_internal_params.h" +#include "psi/algorithm/ypir/types.h" + +namespace psi::ypir::internal::ypir { + +YpirPrecomputedState PrepareOfflineState(const std::vector& db, + const YpirParameters& params, + const Context& context); + +YpirResponse ProcessQuery(const std::vector& db, + const YpirQuery& query, + const YpirPrecomputedState& state, + const YpirParameters& params, + const Context& context); + +} // namespace psi::ypir::internal::ypir diff --git a/psi/apps/psi_launcher/BUILD.bazel b/psi/apps/psi_launcher/BUILD.bazel index 7723ed47..250dac05 100644 --- a/psi/apps/psi_launcher/BUILD.bazel +++ b/psi/apps/psi_launcher/BUILD.bazel @@ -42,12 +42,25 @@ psi_cc_library( hdrs = ["report.h"], ) +psi_cc_library( + name = "launch_ypir", + srcs = ["ypir_launch.cc"], + hdrs = ["ypir_launch.h"], + deps = [ + "//psi/algorithm/ypir:entry", + "//psi/proto:pir_cc_proto", + "@yacl//yacl/base:exception", + "@yacl//yacl/link:context", + ], +) + psi_cc_library( name = "launch", srcs = ["launch.cc"], hdrs = ["launch.h"], deps = [ ":factory", + ":launch_ypir", ":report", "//psi:trace_categories", "//psi/algorithm/dkpir:entry", @@ -72,6 +85,16 @@ psi_cc_test( ], ) +psi_cc_test( + name = "ypir_test", + srcs = ["ypir_test.cc"], + deps = [ + ":launch_ypir", + "@abseil-cpp//absl/strings", + "@yacl//yacl/link:test_util", + ], +) + psi_cc_library( name = "kuscia_adapter", srcs = [ diff --git a/psi/apps/psi_launcher/launch.h b/psi/apps/psi_launcher/launch.h index 080f550a..0b5dad32 100644 --- a/psi/apps/psi_launcher/launch.h +++ b/psi/apps/psi_launcher/launch.h @@ -47,6 +47,12 @@ PirResultReport RunPir(const ApsiReceiverConfig& apsi_receiver_config, PirResultReport RunPir(const ApsiSenderConfig& apsi_sender_config, const std::shared_ptr& lctx); +PirResultReport RunPir(const YpirReceiverConfig& ypir_receiver_config, + const std::shared_ptr& lctx); + +PirResultReport RunPir(const YpirSenderConfig& ypir_sender_config, + const std::shared_ptr& lctx); + PirResultReport RunDkPir(const DkPirReceiverConfig& dk_pir_receiver_config, const std::shared_ptr& lctx); diff --git a/psi/apps/psi_launcher/main.cc b/psi/apps/psi_launcher/main.cc index 39650064..1d65811e 100644 --- a/psi/apps/psi_launcher/main.cc +++ b/psi/apps/psi_launcher/main.cc @@ -121,6 +121,18 @@ int main(int argc, char* argv[]) { YACL_ENFORCE(google::protobuf::util::MessageToJsonString( report, &report_json, json_print_options) .ok()); + } else if (launch_config.has_ypir_sender_config()) { + psi::PirResultReport report = + psi::RunPir(launch_config.ypir_sender_config(), lctx); + YACL_ENFORCE(google::protobuf::util::MessageToJsonString( + report, &report_json, json_print_options) + .ok()); + } else if (launch_config.has_ypir_receiver_config()) { + psi::PirResultReport report = + psi::RunPir(launch_config.ypir_receiver_config(), lctx); + YACL_ENFORCE(google::protobuf::util::MessageToJsonString( + report, &report_json, json_print_options) + .ok()); } else if (launch_config.has_dk_pir_sender_config()) { psi::PirResultReport report = psi::RunDkPir(launch_config.dk_pir_sender_config(), lctx); diff --git a/psi/apps/psi_launcher/ypir_launch.cc b/psi/apps/psi_launcher/ypir_launch.cc new file mode 100644 index 00000000..289d98e6 --- /dev/null +++ b/psi/apps/psi_launcher/ypir_launch.cc @@ -0,0 +1,49 @@ +#include "psi/apps/psi_launcher/ypir_launch.h" + +#include "psi/algorithm/ypir/entry.h" +#include "yacl/base/exception.h" + +namespace psi { +namespace { + +psi::ypir::YpirMode ToYpirMode(YpirProtocolMode mode) { + switch (mode) { + case YPIR_PROTOCOL_MODE_SIMPLEPIR: + return psi::ypir::YpirMode::kSimplepir; + case YPIR_PROTOCOL_MODE_DOUBLEPIR: + return psi::ypir::YpirMode::kDoublepir; + default: + YACL_THROW("unsupported YPIR mode"); + } +} + +} // namespace + +PirResultReport RunPir(const YpirReceiverConfig& ypir_receiver_config, + const std::shared_ptr& lctx) { + psi::ypir::YpirReceiverOptions options; + options.mode = ToYpirMode(ypir_receiver_config.mode()); + options.db_rows = ypir_receiver_config.db_rows(); + options.db_cols = ypir_receiver_config.db_cols(); + options.item_size_bits = ypir_receiver_config.item_size_bits(); + options.query_file = ypir_receiver_config.query_file(); + options.output_file = ypir_receiver_config.output_file(); + + YACL_ENFORCE_EQ(psi::ypir::ReceiverOnline(options, lctx), 0); + return PirResultReport(); +} + +PirResultReport RunPir(const YpirSenderConfig& ypir_sender_config, + const std::shared_ptr& lctx) { + psi::ypir::YpirSenderOptions options; + options.mode = ToYpirMode(ypir_sender_config.mode()); + options.db_rows = ypir_sender_config.db_rows(); + options.db_cols = ypir_sender_config.db_cols(); + options.item_size_bits = ypir_sender_config.item_size_bits(); + options.db_file = ypir_sender_config.db_file(); + + YACL_ENFORCE_EQ(psi::ypir::SenderOnline(options, lctx), 0); + return PirResultReport(); +} + +} // namespace psi diff --git a/psi/apps/psi_launcher/ypir_launch.h b/psi/apps/psi_launcher/ypir_launch.h new file mode 100644 index 00000000..86151c06 --- /dev/null +++ b/psi/apps/psi_launcher/ypir_launch.h @@ -0,0 +1,17 @@ +#pragma once + +#include + +#include "yacl/link/context.h" + +#include "psi/proto/pir.pb.h" + +namespace psi { + +PirResultReport RunPir(const YpirReceiverConfig& ypir_receiver_config, + const std::shared_ptr& lctx); + +PirResultReport RunPir(const YpirSenderConfig& ypir_sender_config, + const std::shared_ptr& lctx); + +} // namespace psi diff --git a/psi/apps/psi_launcher/ypir_test.cc b/psi/apps/psi_launcher/ypir_test.cc new file mode 100644 index 00000000..4b510b6d --- /dev/null +++ b/psi/apps/psi_launcher/ypir_test.cc @@ -0,0 +1,150 @@ +#include "psi/apps/psi_launcher/ypir_launch.h" + +#include +#include +#include +#include +#include + +#include "absl/strings/escaping.h" +#include "gtest/gtest.h" +#include "yacl/link/test_util.h" + +namespace psi { +namespace { + +std::string HexByte(uint64_t value) { + std::vector bytes = {static_cast(value)}; + return absl::BytesToHexString(absl::string_view( + reinterpret_cast(bytes.data()), bytes.size())); +} + +std::string HexUint16(uint64_t value) { + const uint16_t narrowed = static_cast(value); + return absl::BytesToHexString(absl::string_view( + reinterpret_cast(&narrowed), sizeof(narrowed))); +} + +void WriteLines(const std::filesystem::path& path, + const std::vector& lines) { + std::ofstream output(path, std::ios::out | std::ios::trunc); + ASSERT_TRUE(output.is_open()); + for (const auto& line : lines) { + output << line << '\n'; + } +} + +std::vector ReadLines(const std::filesystem::path& path) { + std::ifstream input(path); + EXPECT_TRUE(input.is_open()); + std::vector lines; + std::string line; + while (std::getline(input, line)) { + if (!line.empty()) { + lines.push_back(line); + } + } + return lines; +} + +TEST(YpirLauncherTest, RunPirSimplepirUsesLauncherEntry) { + const auto tmp_dir = + std::filesystem::temp_directory_path() / "ypir_launcher_simplepir"; + std::filesystem::create_directories(tmp_dir); + const auto db_path = tmp_dir / "db.hex"; + const auto query_path = tmp_dir / "query.txt"; + const auto output_path = tmp_dir / "result.hex"; + + std::vector db_lines; + db_lines.reserve(1ULL << 20); + for (uint64_t raw_idx = 0; raw_idx < (1ULL << 20); ++raw_idx) { + const uint64_t row = raw_idx / (1ULL << 10); + const uint64_t col = raw_idx % (1ULL << 10); + db_lines.push_back(HexUint16((row * 17 + col * 3) % (1ULL << 14))); + } + WriteLines(db_path, db_lines); + WriteLines(query_path, {"0", "123456", "1048575"}); + + YpirSenderConfig sender_config; + sender_config.set_mode(YPIR_PROTOCOL_MODE_SIMPLEPIR); + sender_config.set_db_rows(1ULL << 10); + sender_config.set_db_cols(1ULL << 10); + sender_config.set_item_size_bits(16); + sender_config.set_db_file(db_path); + + YpirReceiverConfig receiver_config; + receiver_config.set_mode(YPIR_PROTOCOL_MODE_SIMPLEPIR); + receiver_config.set_db_rows(1ULL << 10); + receiver_config.set_db_cols(1ULL << 10); + receiver_config.set_item_size_bits(16); + receiver_config.set_query_file(query_path); + receiver_config.set_output_file(output_path); + + auto lctxs = yacl::link::test::SetupWorld(2); + auto sender = std::async(std::launch::async, [&] { + return RunPir(sender_config, lctxs[0]); + }); + auto receiver = std::async(std::launch::async, [&] { + return RunPir(receiver_config, lctxs[1]); + }); + + EXPECT_EQ(sender.get().match_cnt(), 0); + EXPECT_EQ(receiver.get().match_cnt(), 0); + EXPECT_EQ(ReadLines(output_path), + (std::vector{HexUint16(0), HexUint16(3768), + HexUint16(4076)})); + + std::filesystem::remove_all(tmp_dir); +} + +TEST(YpirLauncherTest, RunPirDoublepirUsesLauncherEntry) { + const auto tmp_dir = + std::filesystem::temp_directory_path() / "ypir_launcher_doublepir"; + std::filesystem::create_directories(tmp_dir); + const auto db_path = tmp_dir / "db.hex"; + const auto query_path = tmp_dir / "query.txt"; + const auto output_path = tmp_dir / "result.hex"; + + std::vector db_lines; + db_lines.reserve(1ULL << 20); + for (uint64_t raw_idx = 0; raw_idx < (1ULL << 20); ++raw_idx) { + const uint64_t row = raw_idx / (1ULL << 10); + const uint64_t col = raw_idx % (1ULL << 10); + db_lines.push_back(HexByte((row + col) % 251)); + } + WriteLines(db_path, db_lines); + WriteLines(query_path, {"0", "113886", "1048575"}); + + YpirSenderConfig sender_config; + sender_config.set_mode(YPIR_PROTOCOL_MODE_DOUBLEPIR); + sender_config.set_db_rows(1ULL << 10); + sender_config.set_db_cols(1ULL << 10); + sender_config.set_item_size_bits(8); + sender_config.set_db_file(db_path); + + YpirReceiverConfig receiver_config; + receiver_config.set_mode(YPIR_PROTOCOL_MODE_DOUBLEPIR); + receiver_config.set_db_rows(1ULL << 10); + receiver_config.set_db_cols(1ULL << 10); + receiver_config.set_item_size_bits(8); + receiver_config.set_query_file(query_path); + receiver_config.set_output_file(output_path); + + auto lctxs = yacl::link::test::SetupWorld(2); + auto sender = std::async(std::launch::async, [&] { + return RunPir(sender_config, lctxs[0]); + }); + auto receiver = std::async(std::launch::async, [&] { + return RunPir(receiver_config, lctxs[1]); + }); + + EXPECT_EQ(sender.get().match_cnt(), 0); + EXPECT_EQ(receiver.get().match_cnt(), 0); + EXPECT_EQ(ReadLines(output_path), + (std::vector{HexByte(0), HexByte(82), HexByte(38)})); + + std::filesystem::remove_all(tmp_dir); +} + +} // namespace +} // namespace psi diff --git a/psi/proto/entry.proto b/psi/proto/entry.proto index 265ebaa5..49c65bca 100644 --- a/psi/proto/entry.proto +++ b/psi/proto/entry.proto @@ -47,5 +47,9 @@ message LaunchConfig { DkPirSenderConfig dk_pir_sender_config = 8; DkPirReceiverConfig dk_pir_receiver_config = 9; + + YpirSenderConfig ypir_sender_config = 10; + + YpirReceiverConfig ypir_receiver_config = 11; } } diff --git a/psi/proto/pir.proto b/psi/proto/pir.proto index 094ecba8..87a426ed 100644 --- a/psi/proto/pir.proto +++ b/psi/proto/pir.proto @@ -225,7 +225,50 @@ message DkPirReceiverConfig { bool skip_count_check = 11; } +enum YpirProtocolMode { + YPIR_PROTOCOL_MODE_UNSPECIFIED = 0; + YPIR_PROTOCOL_MODE_SIMPLEPIR = 1; + YPIR_PROTOCOL_MODE_DOUBLEPIR = 2; +} + +message YpirSenderConfig { + // YPIR mode. SIMPLEPIR currently supports up to 16-bit values and DOUBLEPIR + // currently supports 8-bit values. + YpirProtocolMode mode = 1; + + // Logical database shape. + uint64 db_rows = 2; + uint64 db_cols = 3; + + // Plaintext bit width of each value. + uint64 item_size_bits = 4; + + // Path to a text file that contains exactly db_rows * db_cols hex-encoded + // values, one per line, without a header. + string db_file = 5; +} + +message YpirReceiverConfig { + // YPIR mode. Must match sender config. + YpirProtocolMode mode = 1; + + // Logical database shape. Must match sender config. + uint64 db_rows = 2; + uint64 db_cols = 3; + + // Plaintext bit width of each value. Must match sender config. + uint64 item_size_bits = 4; + + // Path to a text file containing raw indexes in decimal, one per line, + // without a header. + string query_file = 5; + + // Path to a text file where hex-encoded results will be written, one per + // line, without a header. + string output_file = 6; +} + // The report of pir task. message PirResultReport { int64 match_cnt = 1; -} \ No newline at end of file +} From e834bddbb8e6cd16fbb4322c356fdf38760682d7 Mon Sep 17 00:00:00 2001 From: sh1k4u Date: Thu, 26 Mar 2026 14:54:53 +0800 Subject: [PATCH 03/12] fix some issues --- .gitignore | 1 + .vscode/settings.json | 83 ---------------------- MODULE.bazel | 7 +- bazel/hexl_repo.bzl | 51 +++++++++++++ bazel/psi.bzl | 2 +- psi/algorithm/spiral/params.cc | 19 ----- psi/algorithm/spiral/params.h | 1 - psi/algorithm/spiral/poly_matrix.cc | 4 +- psi/algorithm/spiral/spiral_client.cc | 10 +-- psi/algorithm/spiral/spiral_server.cc | 2 +- psi/algorithm/spiral/spiral_server_test.cc | 2 +- 11 files changed, 65 insertions(+), 117 deletions(-) delete mode 100644 .vscode/settings.json create mode 100644 bazel/hexl_repo.bzl diff --git a/.gitignore b/.gitignore index 1bdfef08..96682349 100644 --- a/.gitignore +++ b/.gitignore @@ -48,3 +48,4 @@ ossutil_output/ psi/apps/pir/docker/linux/ psi/apps/pir/docker/version.txt +.vscode/ diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index e7081524..00000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,83 +0,0 @@ -{ - "files.associations": { - "*.inc": "cpp", - "random": "cpp", - "algorithm": "cpp", - "ratio": "cpp", - "cmath": "cpp", - "cstdint": "cpp", - "valarray": "cpp", - "optional": "cpp", - "system_error": "cpp", - "array": "cpp", - "functional": "cpp", - "regex": "cpp", - "tuple": "cpp", - "type_traits": "cpp", - "utility": "cpp", - "variant": "cpp", - "charconv": "cpp", - "chrono": "cpp", - "format": "cpp", - "istream": "cpp", - "ostream": "cpp", - "span": "cpp", - "cctype": "cpp", - "clocale": "cpp", - "cstdarg": "cpp", - "cstddef": "cpp", - "cstdio": "cpp", - "cstdlib": "cpp", - "cstring": "cpp", - "ctime": "cpp", - "cwchar": "cpp", - "cwctype": "cpp", - "atomic": "cpp", - "bit": "cpp", - "bitset": "cpp", - "cinttypes": "cpp", - "compare": "cpp", - "concepts": "cpp", - "condition_variable": "cpp", - "deque": "cpp", - "list": "cpp", - "map": "cpp", - "set": "cpp", - "string": "cpp", - "unordered_map": "cpp", - "unordered_set": "cpp", - "vector": "cpp", - "exception": "cpp", - "iterator": "cpp", - "memory": "cpp", - "memory_resource": "cpp", - "numeric": "cpp", - "string_view": "cpp", - "fstream": "cpp", - "initializer_list": "cpp", - "iomanip": "cpp", - "iosfwd": "cpp", - "iostream": "cpp", - "limits": "cpp", - "mutex": "cpp", - "new": "cpp", - "numbers": "cpp", - "sstream": "cpp", - "stdexcept": "cpp", - "stop_token": "cpp", - "streambuf": "cpp", - "thread": "cpp", - "typeinfo": "cpp", - "any": "cpp", - "hash_map": "cpp", - "hash_set": "cpp", - "codecvt": "cpp", - "complex": "cpp", - "forward_list": "cpp", - "future": "cpp", - "semaphore": "cpp", - "shared_mutex": "cpp", - "source_location": "cpp", - "typeindex": "cpp" - } -} \ No newline at end of file diff --git a/MODULE.bazel b/MODULE.bazel index c4b3ca43..a542ff92 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -57,6 +57,7 @@ use_repo( ) new_local_repository = use_repo_rule("@bazel_tools//tools/build_defs/repo:local.bzl", "new_local_repository") +hexl_repository = use_repo_rule("//bazel:hexl_repo.bzl", "hexl_repository") new_local_repository( name = "macos_omp_x64", @@ -70,11 +71,7 @@ new_local_repository( path = "/opt/homebrew/opt/libomp/", ) -new_local_repository( - name = "hexl", - build_file = "//bazel:hexl.BUILD", - path = "/usr/local", -) +hexl_repository(name = "hexl") bazel_dep(name = "kuscia", version = "0.14.0b0") bazel_dep(name = "perfetto", version = "41.0") diff --git a/bazel/hexl_repo.bzl b/bazel/hexl_repo.bzl new file mode 100644 index 00000000..626c5fdd --- /dev/null +++ b/bazel/hexl_repo.bzl @@ -0,0 +1,51 @@ +_HEXL_BUILD = """load("@rules_cc//cc:defs.bzl", "cc_import", "cc_library") + +package(default_visibility = ["//visibility:public"]) + +cc_import( + name = "hexl_lib", + static_library = "lib/libhexl.a", +) + +cc_library( + name = "hexl", + hdrs = glob(["include/hexl/**/*.h", "include/hexl/**/*.hpp"]), + includes = ["include"], + deps = [":hexl_lib"], +) +""" + +def _hexl_repository_impl(repository_ctx): + roots = [] + env_root = repository_ctx.os.environ.get("HEXL_ROOT", "") + if env_root: + roots.append(env_root) + + roots.extend([ + "/usr/local", + "/usr", + ]) + + for root in roots: + include_dir = repository_ctx.path(root + "/include") + header_dir = repository_ctx.path(root + "/include/hexl") + for lib_dir_name in ["lib", "lib64"]: + lib_dir = repository_ctx.path(root + "/" + lib_dir_name) + static_lib = repository_ctx.path(root + "/" + lib_dir_name + "/libhexl.a") + if header_dir.exists and static_lib.exists: + repository_ctx.symlink(include_dir, "include") + repository_ctx.symlink(lib_dir, "lib") + repository_ctx.file("BUILD.bazel", _HEXL_BUILD) + repository_ctx.file("WORKSPACE.bazel", "workspace(name = \"hexl\")\n") + return + + fail( + "HEXL was not found. Set HEXL_ROOT to the installation prefix, " + + "or install HEXL under /usr/local or /usr." + ) + +hexl_repository = repository_rule( + implementation = _hexl_repository_impl, + environ = ["HEXL_ROOT"], + local = True, +) diff --git a/bazel/psi.bzl b/bazel/psi.bzl index e7663364..adf7b1f8 100644 --- a/bazel/psi.bzl +++ b/bazel/psi.bzl @@ -26,7 +26,7 @@ WARNING_FLAGS = [ ] DEBUG_FLAGS = ["-O0", "-g", "-DSPDLOG_ACTIVE_LEVEL=1"] RELEASE_FLAGS = ["-O2"] -FAST_FLAGS = ["-O3", "-march=native"] +FAST_FLAGS = ["-O3"] def _psi_copts(): return select({ diff --git a/psi/algorithm/spiral/params.cc b/psi/algorithm/spiral/params.cc index 4dd986b0..dfd51810 100644 --- a/psi/algorithm/spiral/params.cc +++ b/psi/algorithm/spiral/params.cc @@ -193,23 +193,4 @@ std::uint64_t Params::CrtCompose(const std::vector& a, return ss.str(); } -size_t Params::Rho() const { - const size_t q2_bits = 28; - const size_t lwe_q_prime_bits = q2_bits; - - const size_t pt_bits = PtModulusBitLen(); - const double blowup_factor = - static_cast(lwe_q_prime_bits) / static_cast(pt_bits); - const double num_polys_needed = - (blowup_factor * static_cast(1024 + 1)) / - static_cast(PolyLen()); - - const size_t smaller_params_db_dim_2 = - static_cast(std::ceil(std::log2(num_polys_needed))); - - const size_t rho = 1ULL << smaller_params_db_dim_2; - - return rho; -} - } // namespace psi::spiral diff --git a/psi/algorithm/spiral/params.h b/psi/algorithm/spiral/params.h index c3cddda9..80ed4538 100644 --- a/psi/algorithm/spiral/params.h +++ b/psi/algorithm/spiral/params.h @@ -397,7 +397,6 @@ class Params { return 1 << (query_params_.db_dim1_ + poly_len_log2_); } - size_t Rho() const; void SetDbDim1(size_t v1) { query_params_.db_dim1_ = v1; } void SetDbDim2(size_t v2) { query_params_.db_dim2_ = v2; } diff --git a/psi/algorithm/spiral/poly_matrix.cc b/psi/algorithm/spiral/poly_matrix.cc index 1b0cfe1b..2b1bbf84 100644 --- a/psi/algorithm/spiral/poly_matrix.cc +++ b/psi/algorithm/spiral/poly_matrix.cc @@ -225,7 +225,7 @@ PolyMatrixRaw PolyMatrixRaw::SingleValue(size_t poly_len, uint64_t value) { PolyMatrixRaw PolyMatrixRaw::Random(const Params& params, size_t rows, size_t cols) { - yacl::crypto::Prg prg(yacl::MakeUint128(0, 20001)); + yacl::crypto::Prg prg(yacl::crypto::SecureRandU128()); return RandomPrg(params, rows, cols, prg); } @@ -330,7 +330,7 @@ absl::Span PolyMatrixNtt::Poly(size_t r, size_t c) const { PolyMatrixNtt PolyMatrixNtt::Random(const Params& params, size_t rows, size_t cols) { - yacl::crypto::Prg prg(yacl::MakeUint128(0, 20002)); + yacl::crypto::Prg prg(yacl::crypto::SecureRandU128()); return RandomPrg(params, rows, cols, prg); } diff --git a/psi/algorithm/spiral/spiral_client.cc b/psi/algorithm/spiral/spiral_client.cc index c4278cc2..d66761c9 100644 --- a/psi/algorithm/spiral/spiral_client.cc +++ b/psi/algorithm/spiral/spiral_client.cc @@ -265,9 +265,9 @@ PublicKeys SpiralClient::GenPublicKeys() const { auto sk_gsw_ntt = ToNtt(params_, sk_gsw_); PublicKeys pp; - uint128_t seed = yacl::MakeUint128(0, 10001); + uint128_t seed = yacl::crypto::SecureRandU128(); yacl::crypto::Prg rng(seed); - uint128_t pub_seed = yacl::MakeUint128(0, 10002); + uint128_t pub_seed = yacl::crypto::SecureRandU128(); yacl::crypto::Prg rng_pub(pub_seed); // params for packing @@ -334,10 +334,12 @@ SpiralQuery SpiralClient::GenQueryInternal(size_t pt_idx_target) const { uint64_t modulus_cr0 = params_.BarrettCr0Modulus(); uint64_t modulus_cr1 = params_.BarrettCr1Modulus(); - yacl::crypto::Prg rng(yacl::MakeUint128(0, 10003)); + yacl::crypto::Prg rng(yacl::crypto::SecureRandU128()); // a empty query SpiralQuery query; - uint128_t query_seed = yacl::MakeUint128(0, 10004); + uint128_t query_seed; + rng.Fill(absl::MakeSpan(reinterpret_cast(&query_seed), + sizeof(query_seed))); yacl::crypto::Prg rng_pub(query_seed); query.seed_ = query_seed; diff --git a/psi/algorithm/spiral/spiral_server.cc b/psi/algorithm/spiral/spiral_server.cc index cde15792..0dc5e1f4 100644 --- a/psi/algorithm/spiral/spiral_server.cc +++ b/psi/algorithm/spiral/spiral_server.cc @@ -970,7 +970,7 @@ std::vector GetVneg1(const Params& params) { std::pair> GenRandomDbAndGetItem( const Params& params, size_t item_idx) { - yacl::crypto::Prg rng(yacl::MakeUint128(0, 30001)); + yacl::crypto::Prg rng(yacl::crypto::SecureRandU128()); size_t instances = params.Instances(); size_t trials = params.N() * params.N(); size_t dim0 = 1 << params.DbDim1(); diff --git a/psi/algorithm/spiral/spiral_server_test.cc b/psi/algorithm/spiral/spiral_server_test.cc index 850ad90d..cfe876ba 100644 --- a/psi/algorithm/spiral/spiral_server_test.cc +++ b/psi/algorithm/spiral/spiral_server_test.cc @@ -382,7 +382,7 @@ TEST(SpiralServer, FoldCiphertexts) { auto ct_gsw_inv = PolyMatrixRaw::Zero(params.PolyLen(), 2, 2 * params.TGsw()); for (size_t i = 0; i < params.DbDim2(); ++i) { - Invert(params, ct_gsw_inv, FromNtt(params, v_folding[i])); + Negate(params, ct_gsw_inv, FromNtt(params, v_folding[i])); auto ct_gsw_neg = PolyMatrixNtt::Zero(params.CrtCount(), params.PolyLen(), 2, 2 * params.TGsw()); From 7f230438b736002669b118a6759b8a69ede1ddc4 Mon Sep 17 00:00:00 2001 From: sh1k4u Date: Thu, 26 Mar 2026 16:26:48 +0800 Subject: [PATCH 04/12] fix issues again --- .circleci/test.yml | 6 ++ CONTRIBUTING.md | 10 +++ MODULE.bazel | 1 + bazel/hexl_repo.bzl | 7 +- bazel/install_hexl.sh | 31 +++++++ psi/algorithm/ypir/BUILD.bazel | 14 ++-- psi/algorithm/ypir/client.h | 2 +- psi/algorithm/ypir/client_test.cc | 3 +- psi/algorithm/ypir/entry.cc | 24 +++--- psi/algorithm/ypir/entry_test.cc | 21 ++--- psi/algorithm/ypir/legacy/aes_prng.h | 4 +- psi/algorithm/ypir/legacy/client.cc | 38 ++++----- psi/algorithm/ypir/legacy/client.h | 3 +- psi/algorithm/ypir/legacy/hexl.cc | 12 ++- psi/algorithm/ypir/legacy/server.cc | 31 ++++--- psi/algorithm/ypir/legacy/server.h | 15 ++-- psi/algorithm/ypir/legacy/util.cc | 6 +- psi/algorithm/ypir/legacy/util.h | 1 - psi/algorithm/ypir/legacy/ypir_params.cc | 98 ++++++++++------------ psi/algorithm/ypir/legacy/ypir_util.cc | 86 +++++++++---------- psi/algorithm/ypir/legacy/ypir_util.h | 22 ++--- psi/algorithm/ypir/params.cc | 6 +- psi/algorithm/ypir/params.h | 6 +- psi/algorithm/ypir/params_test.cc | 8 +- psi/algorithm/ypir/pir_interface_test.cc | 25 +++--- psi/algorithm/ypir/server.cc | 22 ++--- psi/algorithm/ypir/server.h | 2 +- psi/algorithm/ypir/server_test.cc | 4 +- psi/algorithm/ypir/simplepir_flow_test.cc | 20 +++-- psi/algorithm/ypir/smoke_test.cc | 4 +- psi/algorithm/ypir/ypir_flow_test.cc | 15 ++-- psi/algorithm/ypir/ypir_internal_client.cc | 18 ++-- psi/algorithm/ypir/ypir_internal_client.h | 2 +- psi/algorithm/ypir/ypir_internal_params.cc | 4 +- psi/algorithm/ypir/ypir_internal_server.cc | 17 ++-- psi/algorithm/ypir/ypir_internal_server.h | 5 +- psi/apps/psi_launcher/ypir_launch.cc | 3 +- psi/apps/psi_launcher/ypir_test.cc | 24 +++--- 38 files changed, 323 insertions(+), 297 deletions(-) create mode 100755 bazel/install_hexl.sh diff --git a/.circleci/test.yml b/.circleci/test.yml index 6e963faa..33db7a34 100644 --- a/.circleci/test.yml +++ b/.circleci/test.yml @@ -37,6 +37,12 @@ commands: - run: name: Setup BuildBuddy Cache command: ../devtools/bazel_cache_setup.py + - run: + name: Install Intel HEXL + command: | + export HEXL_ROOT="${HOME}/.local/hexl" + ./bazel/install_hexl.sh "${HEXL_ROOT}" + echo "export HEXL_ROOT=${HEXL_ROOT}" >> "${BASH_ENV}" - run: name: "build" command: bazel build //... -c opt --ui_event_filters=-info,-debug,-warning --jobs 20 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 02d6def6..918b70cc 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -13,6 +13,8 @@ part of the project. In general, please use clang-format to format code, and follow clang-tidy tips. +For Bazel files (`MODULE.bazel`, `*.bzl`, `BUILD`, `BUILD.bazel`), please use `buildifier`. + Most of the code style is derived from the [Google C++ style guidelines](https://google.github.io/styleguide/cppguide.html), except: @@ -57,6 +59,10 @@ docker exec -it psi-dev-$(whoami) bash ```sh Install gcc>=11.2, cmake>=3.26, ninja, nasm>=2.15, python>=3.10, bazelisk, xxd, lld + +# Install Intel HEXL, or set HEXL_ROOT to an existing install prefix. +./bazel/install_hexl.sh "$HOME/.local/hexl" +export HEXL_ROOT="$HOME/.local/hexl" ``` #### macOS @@ -80,6 +86,10 @@ brew install bazelisk cmake ninja libomp wget # For Intel mac only brew install nasm + +# Install Intel HEXL, or set HEXL_ROOT to an existing install prefix. +./bazel/install_hexl.sh "$HOME/.local/hexl" +export HEXL_ROOT="$HOME/.local/hexl" ``` ### Build & UnitTest diff --git a/MODULE.bazel b/MODULE.bazel index a542ff92..84e97d5d 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -57,6 +57,7 @@ use_repo( ) new_local_repository = use_repo_rule("@bazel_tools//tools/build_defs/repo:local.bzl", "new_local_repository") + hexl_repository = use_repo_rule("//bazel:hexl_repo.bzl", "hexl_repository") new_local_repository( diff --git a/bazel/hexl_repo.bzl b/bazel/hexl_repo.bzl index 626c5fdd..76b60707 100644 --- a/bazel/hexl_repo.bzl +++ b/bazel/hexl_repo.bzl @@ -22,7 +22,10 @@ def _hexl_repository_impl(repository_ctx): roots.append(env_root) roots.extend([ + "/usr/local/opt/intel-hexl", "/usr/local", + "/opt/homebrew/opt/intel-hexl", + "/opt/homebrew", "/usr", ]) @@ -40,8 +43,8 @@ def _hexl_repository_impl(repository_ctx): return fail( - "HEXL was not found. Set HEXL_ROOT to the installation prefix, " - + "or install HEXL under /usr/local or /usr." + "HEXL was not found. Set HEXL_ROOT to the installation prefix, " + + "or install HEXL under /usr/local or /usr.", ) hexl_repository = repository_rule( diff --git a/bazel/install_hexl.sh b/bazel/install_hexl.sh new file mode 100755 index 00000000..e0cc64f9 --- /dev/null +++ b/bazel/install_hexl.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env bash + +set -euo pipefail + +hexl_version="${HEXL_VERSION:-v1.2.6}" +install_prefix="${1:-${HEXL_ROOT:-${HOME}/.local/hexl}}" + +if [[ -f "${install_prefix}/lib/libhexl.a" && -d "${install_prefix}/include/hexl" ]]; then + printf 'Intel HEXL already installed at %s\n' "${install_prefix}" + exit 0 +fi + +parallelism="$(getconf _NPROCESSORS_ONLN 2>/dev/null || echo 4)" +workdir="$(mktemp -d)" +repo_dir="${workdir}/hexl" +build_dir="${workdir}/build" + +cleanup() { + rm -rf "${workdir}" +} + +trap cleanup EXIT + +printf 'Installing Intel HEXL %s into %s\n' "${hexl_version}" "${install_prefix}" + +git clone --depth 1 --branch "${hexl_version}" https://github.com/IntelLabs/hexl.git "${repo_dir}" + +cmake -S "${repo_dir}" -B "${build_dir}" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="${install_prefix}" -DHEXL_BENCHMARK=OFF -DHEXL_COVERAGE=OFF -DHEXL_DOCS=OFF -DHEXL_SHARED_LIB=OFF -DHEXL_TESTING=OFF -DHEXL_TREAT_WARNING_AS_ERROR=OFF + +cmake --build "${build_dir}" --parallel "${parallelism}" +cmake --install "${build_dir}" diff --git a/psi/algorithm/ypir/BUILD.bazel b/psi/algorithm/ypir/BUILD.bazel index 6511efeb..e3503c1c 100644 --- a/psi/algorithm/ypir/BUILD.bazel +++ b/psi/algorithm/ypir/BUILD.bazel @@ -24,7 +24,7 @@ psi_cc_library( ], copts = ["-maes"], deps = [ - "@hexl//:hexl", + "@hexl", "@yacl//yacl/base:exception", ], ) @@ -109,10 +109,10 @@ psi_cc_library( srcs = ["ypir_internal_client.cc"], hdrs = ["ypir_internal_client.h"], deps = [ - ":ypir_internal_params", ":legacy_ypir_impl", ":types", ":util", + ":ypir_internal_params", "@yacl//yacl/base:exception", ], ) @@ -122,9 +122,9 @@ psi_cc_library( srcs = ["ypir_internal_server.cc"], hdrs = ["ypir_internal_server.h"], deps = [ - ":ypir_internal_params", ":legacy_ypir_impl", ":types", + ":ypir_internal_params", "@yacl//yacl/base:exception", ], ) @@ -134,12 +134,12 @@ psi_cc_library( srcs = ["client.cc"], hdrs = ["client.h"], deps = [ - "//psi/algorithm/pir_interface:index_pir", - "//psi/algorithm/pir_interface:pir_db", - ":ypir_internal_client", ":params", ":serialize", ":util", + ":ypir_internal_client", + "//psi/algorithm/pir_interface:index_pir", + "//psi/algorithm/pir_interface:pir_db", "@yacl//yacl/base:buffer", "@yacl//yacl/base:byte_container_view", "@yacl//yacl/base:exception", @@ -151,10 +151,10 @@ psi_cc_library( srcs = ["server.cc"], hdrs = ["server.h"], deps = [ - ":ypir_internal_server", ":legacy_simplepir", ":params", ":serialize", + ":ypir_internal_server", "//psi/algorithm/pir_interface:pir_db", "@yacl//yacl/base:buffer", "@yacl//yacl/base:byte_container_view", diff --git a/psi/algorithm/ypir/client.h b/psi/algorithm/ypir/client.h index 981e6fab..0be8ba3c 100644 --- a/psi/algorithm/ypir/client.h +++ b/psi/algorithm/ypir/client.h @@ -8,9 +8,9 @@ #include "yacl/base/byte_container_view.h" #include "psi/algorithm/pir_interface/index_pir.h" -#include "psi/algorithm/ypir/ypir_internal_client.h" #include "psi/algorithm/ypir/params.h" #include "psi/algorithm/ypir/types.h" +#include "psi/algorithm/ypir/ypir_internal_client.h" namespace psi::ypir { diff --git a/psi/algorithm/ypir/client_test.cc b/psi/algorithm/ypir/client_test.cc index 0064ff04..47ff5e0e 100644 --- a/psi/algorithm/ypir/client_test.cc +++ b/psi/algorithm/ypir/client_test.cc @@ -1,10 +1,11 @@ #include "psi/algorithm/ypir/client.h" -#include "psi/algorithm/ypir/serialize.h" #include #include "gtest/gtest.h" +#include "psi/algorithm/ypir/serialize.h" + namespace psi::ypir { namespace { diff --git a/psi/algorithm/ypir/entry.cc b/psi/algorithm/ypir/entry.cc index 58291773..916644e3 100644 --- a/psi/algorithm/ypir/entry.cc +++ b/psi/algorithm/ypir/entry.cc @@ -82,7 +82,8 @@ std::vector ReadLines(const std::string& path) { return lines; } -void WriteLines(const std::string& path, const std::vector& lines) { +void WriteLines(const std::string& path, + const std::vector& lines) { std::ofstream output(path, std::ios::out | std::ios::trunc); YACL_ENFORCE(output.is_open(), "failed to open output file: {}", path); for (const auto& line : lines) { @@ -111,8 +112,8 @@ std::string ResponseTag(uint64_t idx) { return fmt::format("ypir/response/{}", idx); } -YpirParameters BuildParameters(YpirMode mode, uint64_t db_rows, uint64_t db_cols, - uint64_t item_size_bits) { +YpirParameters BuildParameters(YpirMode mode, uint64_t db_rows, + uint64_t db_cols, uint64_t item_size_bits) { YACL_ENFORCE_GT(db_rows, 0U); YACL_ENFORCE_GT(db_cols, 0U); YACL_ENFORCE_GT(item_size_bits, 0U); @@ -156,9 +157,8 @@ std::vector EncodeOutputLines( std::vector out; out.reserve(values.size()); for (const auto& value : values) { - out.push_back( - absl::BytesToHexString(absl::string_view( - reinterpret_cast(value.data()), value.size()))); + out.push_back(absl::BytesToHexString(absl::string_view( + reinterpret_cast(value.data()), value.size()))); } return out; } @@ -168,8 +168,8 @@ int RunSenderWithServer(const YpirParameters& params, const YpirSenderOptions& options, std::shared_ptr lctx) { YpirServer server(params); - server.GenerateFromRawData(psi::pir::RawDatabase( - LoadDatabaseRows(options.db_file, params.value_bytes, params.NumItems()))); + server.GenerateFromRawData(psi::pir::RawDatabase(LoadDatabaseRows( + options.db_file, params.value_bytes, params.NumItems()))); lctx->ConnectToMesh(); const uint64_t query_count = @@ -195,8 +195,9 @@ int SenderOnline(const YpirSenderOptions& options, params.db_rows, params.db_cols); if (params.mode == YpirMode::kSimplepir) { - YACL_ENFORCE_LE(params.value_bytes, sizeof(uint16_t), - "SimplePIR launcher currently supports up to 16-bit values"); + YACL_ENFORCE_LE( + params.value_bytes, sizeof(uint16_t), + "SimplePIR launcher currently supports up to 16-bit values"); if (params.value_bytes == 1) { return RunSenderWithServer(params, options, std::move(lctx)); } @@ -213,7 +214,8 @@ int ReceiverOnline(const YpirReceiverOptions& options, YACL_ENFORCE(lctx != nullptr, "link context is required for YPIR receiver"); const auto params = BuildParameters(options.mode, options.db_rows, options.db_cols, options.item_size_bits); - const auto query_indices = LoadQueryIndices(options.query_file, params.NumItems()); + const auto query_indices = + LoadQueryIndices(options.query_file, params.NumItems()); SPDLOG_INFO("Starting YPIR receiver, mode={}, query_count={}", params.mode == YpirMode::kSimplepir ? "simplepir" : "doublepir", diff --git a/psi/algorithm/ypir/entry_test.cc b/psi/algorithm/ypir/entry_test.cc index 994d8b0c..d210e3c7 100644 --- a/psi/algorithm/ypir/entry_test.cc +++ b/psi/algorithm/ypir/entry_test.cc @@ -96,13 +96,13 @@ TEST(YpirEntryTest, SimplepirOnlineFlowWorksWithHexFiles) { EXPECT_EQ(sender.get(), 0); EXPECT_EQ(receiver.get(), 0); - EXPECT_EQ(ReadLines(output_path), - (std::vector{ - HexUint16(0), - HexUint16((120ULL * 17 + 576ULL * 3) % - params.spiral_params.PtModulus()), - HexUint16((1023ULL * 17 + 1023ULL * 3) % - params.spiral_params.PtModulus())})); + EXPECT_EQ( + ReadLines(output_path), + (std::vector{HexUint16(0), + HexUint16((120ULL * 17 + 576ULL * 3) % + params.spiral_params.PtModulus()), + HexUint16((1023ULL * 17 + 1023ULL * 3) % + params.spiral_params.PtModulus())})); std::filesystem::remove_all(tmp_dir); } @@ -153,9 +153,10 @@ TEST(YpirEntryTest, DoublepirOnlineFlowWorksWithHexFiles) { EXPECT_EQ(sender.get(), 0); EXPECT_EQ(receiver.get(), 0); - EXPECT_EQ(ReadLines(output_path), - (std::vector{HexByte(0), HexByte((111ULL + 222ULL) % 251), - HexByte((1023ULL + 1023ULL) % 251)})); + EXPECT_EQ( + ReadLines(output_path), + (std::vector{HexByte(0), HexByte((111ULL + 222ULL) % 251), + HexByte((1023ULL + 1023ULL) % 251)})); std::filesystem::remove_all(tmp_dir); } diff --git a/psi/algorithm/ypir/legacy/aes_prng.h b/psi/algorithm/ypir/legacy/aes_prng.h index f210306f..b7e7bc00 100644 --- a/psi/algorithm/ypir/legacy/aes_prng.h +++ b/psi/algorithm/ypir/legacy/aes_prng.h @@ -14,12 +14,12 @@ #pragma once +#include + #include #include #include -#include - namespace psi::ypir::ypir_internal { #define AES_128_ASSIST(t1, t2, rc) \ diff --git a/psi/algorithm/ypir/legacy/client.cc b/psi/algorithm/ypir/legacy/client.cc index 0b1a1a51..9beb4fe0 100644 --- a/psi/algorithm/ypir/legacy/client.cc +++ b/psi/algorithm/ypir/legacy/client.cc @@ -57,9 +57,9 @@ void LweDecrypt(Secret& sk, std::vector& a, uint64_t& message, } if (b > (cmod >> 1)) { - b = static_cast(std::llround((static_cast(b) - - static_cast(cmod)) / - delta)) % + b = static_cast(std::llround( + (static_cast(b) - static_cast(cmod)) / + delta)) % pmod; } else { b = static_cast( @@ -129,10 +129,10 @@ void RlweDecrypt(Secret& sk, std::vector& a, static_cast(delta))) % rlwe_pmod; } else { - message[i] = static_cast( - std::llround(static_cast(b[i]) / - static_cast(delta))) % - rlwe_pmod; + message[i] = + static_cast(std::llround(static_cast(b[i]) / + static_cast(delta))) % + rlwe_pmod; } } } @@ -168,10 +168,10 @@ void GadgetEncrypt(Secret& sk, const std::vector>& a, } } -void GenerateAutokey(Secret& sk, - const std::vector>>& ksk_a, - std::vector>>& ksk_b, - const FheParams& fparm) { +void GenerateAutokey( + Secret& sk, const std::vector>>& ksk_a, + std::vector>>& ksk_b, + const FheParams& fparm) { const uint64_t degree = fparm.get_poly_degree(); const uint64_t cmod = fparm.get_rlwe_cmod(); const uint64_t expo = GetLog2(degree); @@ -223,8 +223,7 @@ void YpirRecover(Secret& simple_sk, Secret& double_sk, YpirQuery Generate_query_ypir(uint64_t c_idx, uint64_t r_idx, Secret& lwe_sk, Secret& rlwe_sk, AESCTR_PRNG& prng, - const FheParams& fparm, - const PirParams& pparm) { + const FheParams& fparm, const PirParams& pparm) { YpirQuery out; const uint64_t cols = pparm.get_col(); @@ -236,8 +235,7 @@ YpirQuery Generate_query_ypir(uint64_t c_idx, uint64_t r_idx, Secret& lwe_sk, const uint64_t lwe_pmod = fparm.get_lwe_pmod(); const auto& matrix0 = fparm.get_persudo_matrix_simplepir(); for (uint64_t i = 0; i < cols; ++i) { - LweEncrypt(lwe_sk, matrix0[i], query_vec_col[i], out.qu0[i], lwe_pmod, - sig); + LweEncrypt(lwe_sk, matrix0[i], query_vec_col[i], out.qu0[i], lwe_pmod, sig); } const uint64_t rows = pparm.get_row(); @@ -259,14 +257,12 @@ YpirQuery Generate_query_ypir(uint64_t c_idx, uint64_t r_idx, Secret& lwe_sk, const uint64_t t_auto = fparm.get_t_auto(); const uint64_t expo = GetLog2(degree); - out.ksk_b.assign( - expo, std::vector>(t_auto, - std::vector(degree, 0))); + out.ksk_b.assign(expo, std::vector>( + t_auto, std::vector(degree, 0))); std::vector>> ksk_a( - expo, - std::vector>(t_auto, - std::vector(degree, 0))); + expo, std::vector>( + t_auto, std::vector(degree, 0))); prng.refresh(kThirdDimensionSeed); for (uint64_t i = 0; i < expo; ++i) { PseudorandomMatrixGenerate(ksk_a[i], fparm.get_rlwe_cmod(), prng); diff --git a/psi/algorithm/ypir/legacy/client.h b/psi/algorithm/ypir/legacy/client.h index 07d792d9..3fa963d2 100644 --- a/psi/algorithm/ypir/legacy/client.h +++ b/psi/algorithm/ypir/legacy/client.h @@ -19,7 +19,6 @@ void YpirRecover(Secret& simple_sk, Secret& double_sk, YpirQuery Generate_query_ypir(uint64_t c_idx, uint64_t r_idx, Secret& lwe_sk, Secret& rlwe_sk, AESCTR_PRNG& prng, - const FheParams& fparm, - const PirParams& pparm); + const FheParams& fparm, const PirParams& pparm); } // namespace psi::ypir::ypir_internal diff --git a/psi/algorithm/ypir/legacy/hexl.cc b/psi/algorithm/ypir/legacy/hexl.cc index dcf5c4e8..86d056cb 100644 --- a/psi/algorithm/ypir/legacy/hexl.cc +++ b/psi/algorithm/ypir/legacy/hexl.cc @@ -20,22 +20,20 @@ namespace psi::ypir::ypir_internal { YpirHexlNtt::YpirHexlNtt(uint64_t degree, uint64_t modulus, uint64_t root_of_unity) - : ntt_(degree, modulus, root_of_unity), - degree_(degree), - modulus_(modulus) { + : ntt_(degree, modulus, root_of_unity), degree_(degree), modulus_(modulus) { YACL_ENFORCE(degree_ > 0); YACL_ENFORCE(modulus_ > 0); } void YpirHexlNtt::Forward(uint64_t* data, size_t len) { - YACL_ENFORCE(len == degree_, - "NTT Forward expects len == degree ({} != {})", len, degree_); + YACL_ENFORCE(len == degree_, "NTT Forward expects len == degree ({} != {})", + len, degree_); ntt_.ComputeForward(data, data, 1, 1); } void YpirHexlNtt::Inverse(uint64_t* data, size_t len) { - YACL_ENFORCE(len == degree_, - "NTT Inverse expects len == degree ({} != {})", len, degree_); + YACL_ENFORCE(len == degree_, "NTT Inverse expects len == degree ({} != {})", + len, degree_); ntt_.ComputeInverse(data, data, 1, 1); } diff --git a/psi/algorithm/ypir/legacy/server.cc b/psi/algorithm/ypir/legacy/server.cc index 24c51229..ce6e4ef3 100644 --- a/psi/algorithm/ypir/legacy/server.cc +++ b/psi/algorithm/ypir/legacy/server.cc @@ -38,12 +38,11 @@ void DoublepirAnswer(const uint8_t* db, uint32_t* qu0, } // namespace -void YpirHintGenerate(std::vector>& db, - std::vector& h0, - std::vector>& double_server_hint, - std::vector>>& decomp_buf, - AESCTR_PRNG& prng, - const FheParams& fparm, const PirParams& pparm) { +void YpirHintGenerate( + std::vector>& db, std::vector& h0, + std::vector>& double_server_hint, + std::vector>>& decomp_buf, + AESCTR_PRNG& prng, const FheParams& fparm, const PirParams& pparm) { const uint64_t lwe_dimension = fparm.get_lwe_dimension(); const uint64_t poly_degree = fparm.get_poly_degree(); const uint64_t rlwe_cmod = fparm.get_rlwe_cmod(); @@ -71,9 +70,8 @@ void YpirHintGenerate(std::vector>& db, matrix_d2_flat, poly_degree, rlwe_cmod); std::vector>> ksk_a( - expo, - std::vector>(t_auto, - std::vector(poly_degree))); + expo, std::vector>( + t_auto, std::vector(poly_degree))); prng.refresh(kThirdDimensionSeed); for (uint64_t i = 0; i < expo; ++i) { PseudorandomMatrixGenerate(ksk_a[i], rlwe_cmod, prng); @@ -84,7 +82,7 @@ void YpirHintGenerate(std::vector>& db, YpirHexlNtt& ntt = fparm.get_ntt(); for (uint64_t i = 0; i < pack_num; ++i) { Cdks21Lwe2RlweInplace(double_client_hint[i].data(), poly_degree, rlwe_cmod, - ntt); + ntt); EltwiseFMAMod(double_client_hint[i].data(), double_client_hint[i].data(), mod_inv, nullptr, poly_degree, rlwe_cmod); } @@ -98,8 +96,8 @@ void YpirAnswer(const uint8_t* db, uint32_t* qu0, std::vector& qu1, const std::vector>>& ksk_b, std::vector>>& decomp_buf, const std::vector>& server_hint, - std::vector>& res, - const FheParams& fparm, const PirParams& pparm) { + std::vector>& res, const FheParams& fparm, + const PirParams& pparm) { const uint64_t lwe_dimension = fparm.get_lwe_dimension(); const uint64_t poly_degree = fparm.get_poly_degree(); const uint64_t rlwe_cmod = fparm.get_rlwe_cmod(); @@ -121,14 +119,13 @@ void YpirAnswer(const uint8_t* db, uint32_t* qu0, std::vector& qu1, DoublepirAnswer(db, qu0, qu1, server_hint, h2, h3, h4, fparm, pparm); for (uint64_t i = 0; i < pack_num; ++i) { - h2[i] = - (static_cast(h2[i]) * mod_inv) % rlwe_cmod; + h2[i] = (static_cast(h2[i]) * mod_inv) % rlwe_cmod; } uint64_t ptr = 0; - res.push_back(PackrlweOnlineConstantRows( - h2, pack_num_log2, poly_degree_log2 - pack_num_log2, ksk_b, decomp_buf, - ptr, fparm)); + res.push_back(PackrlweOnlineConstantRows(h2, pack_num_log2, + poly_degree_log2 - pack_num_log2, + ksk_b, decomp_buf, ptr, fparm)); std::vector> h4_matrix( t_decomp, std::vector(poly_degree, 0)); diff --git a/psi/algorithm/ypir/legacy/server.h b/psi/algorithm/ypir/legacy/server.h index 50a2256e..56e01fa2 100644 --- a/psi/algorithm/ypir/legacy/server.h +++ b/psi/algorithm/ypir/legacy/server.h @@ -11,14 +11,13 @@ void YpirAnswer(const uint8_t* db, uint32_t* qu0, std::vector& qu1, const std::vector>>& ksk_b, std::vector>>& decomp_buf, const std::vector>& server_hint, - std::vector>& res, - const FheParams& fparm, const PirParams& pparm); + std::vector>& res, const FheParams& fparm, + const PirParams& pparm); -void YpirHintGenerate(std::vector>& db, - std::vector& h0, - std::vector>& double_server_hint, - std::vector>>& decomp_buf, - AESCTR_PRNG& prng, - const FheParams& fparm, const PirParams& pparm); +void YpirHintGenerate( + std::vector>& db, std::vector& h0, + std::vector>& double_server_hint, + std::vector>>& decomp_buf, + AESCTR_PRNG& prng, const FheParams& fparm, const PirParams& pparm); } // namespace psi::ypir::ypir_internal diff --git a/psi/algorithm/ypir/legacy/util.cc b/psi/algorithm/ypir/legacy/util.cc index 332b0015..7844dd47 100644 --- a/psi/algorithm/ypir/legacy/util.cc +++ b/psi/algorithm/ypir/legacy/util.cc @@ -4,15 +4,15 @@ #include #include +#include "yacl/base/int128.h" + #include "psi/algorithm/spiral/arith/arith_params.h" #include "psi/algorithm/spiral/arith/ntt.h" #include "psi/algorithm/spiral/discrete_gaussian.h" #include "psi/algorithm/spiral/gadget.h" -#include "psi/algorithm/spiral/poly_matrix_utils.h" -#include "yacl/base/int128.h" - #include "psi/algorithm/spiral/params.h" #include "psi/algorithm/spiral/poly_matrix.h" +#include "psi/algorithm/spiral/poly_matrix_utils.h" #include "psi/algorithm/spiral/util.h" namespace psi::ypir { diff --git a/psi/algorithm/ypir/legacy/util.h b/psi/algorithm/ypir/legacy/util.h index 97d657bf..eff77dc9 100644 --- a/psi/algorithm/ypir/legacy/util.h +++ b/psi/algorithm/ypir/legacy/util.h @@ -6,7 +6,6 @@ #include "psi/algorithm/spiral/params.h" #include "psi/algorithm/spiral/poly_matrix.h" - #include "psi/algorithm/ypir/legacy/types.h" namespace psi::ypir { diff --git a/psi/algorithm/ypir/legacy/ypir_params.cc b/psi/algorithm/ypir/legacy/ypir_params.cc index 8f9fa0c7..5d5f1226 100644 --- a/psi/algorithm/ypir/legacy/ypir_params.cc +++ b/psi/algorithm/ypir/legacy/ypir_params.cc @@ -18,6 +18,7 @@ #include #include #include + #include "yacl/base/exception.h" namespace psi::ypir::ypir_internal { @@ -34,7 +35,8 @@ uint64_t Log2Exact(uint64_t n) { // Thread-local buffer pool for PackrlweOnline* recursive functions. // Each recursion depth gets 6 dedicated scratch vectors: -// 0=tmp, 1=tmp1, 2=tmp2, 3=result, 4=b_e (left child result), 5=b_o (right child result) +// 0=tmp, 1=tmp1, 2=tmp2, 3=result, 4=b_e (left child result), 5=b_o (right +// child result) // Slots 4/5 eliminate the ~1022 × 16 KB heap copies for b_e/b_o in // PackrlweOnlineConstantRowsImpl. struct PackrlwePool { @@ -47,8 +49,7 @@ struct PackrlwePool { if (len == length) return; len = length; for (auto& row : v) - for (auto& buf : row) - buf.resize(length); + for (auto& buf : row) buf.resize(length); } std::vector& Get(size_t depth, size_t slot) { @@ -61,10 +62,8 @@ thread_local PackrlwePool g_packrlwe_pool; } // namespace Secret::Secret(uint64_t length, uint64_t cmod) : len_(length), mod_(cmod) { - std::mt19937_64 rng( - static_cast(std::chrono::high_resolution_clock::now() - .time_since_epoch() - .count())); + std::mt19937_64 rng(static_cast( + std::chrono::high_resolution_clock::now().time_since_epoch().count())); std::uniform_int_distribution dist(-1, 1); data.reserve(length); for (uint64_t i = 0; i < length; ++i) { @@ -131,8 +130,7 @@ void FheParams::set_precomputed_pt(uint64_t max_lh) { SetPrecomputedPt(precomputed_pt_, rlwe_degree_, max_lh, ntt_forward_); } -PirParams::PirParams(uint64_t rows, uint64_t cols) - : rows_(rows), cols_(cols) { +PirParams::PirParams(uint64_t rows, uint64_t cols) : rows_(rows), cols_(cols) { YACL_ENFORCE(rows_ > 0); YACL_ENFORCE(cols_ > 0); } @@ -200,15 +198,13 @@ void KeyswitchPreprocess( std::vector tmp(length, 0); for (uint64_t i = 0; i < t; ++i) { EltwiseMultMod(tmp.data(), ksk_a[i].data(), decomp_buf.back()[i].data(), - length, - modulus); + length, modulus); EltwiseSubMod(a_out.data(), a_out.data(), tmp.data(), length, modulus); } } void KeyswitchOnline(const std::vector>& ksk_b, - std::vector& b_in, - std::vector& b_out, + std::vector& b_in, std::vector& b_out, std::vector>& decomp_buf, const FheParams& fparm) { const uint64_t t = fparm.get_t_auto(); @@ -230,18 +226,19 @@ void KeyswitchOnline(const std::vector>& ksk_b, } namespace { -void EvalAutoPreprocess(std::vector& a_in, std::vector& a_out, - const std::vector>& ksk_a, - uint64_t idx, - std::vector>>& decomp_buf, - const FheParams& fparm) { +void EvalAutoPreprocess( + std::vector& a_in, std::vector& a_out, + const std::vector>& ksk_a, uint64_t idx, + std::vector>>& decomp_buf, + const FheParams& fparm) { ApplyAutoNttForm(a_in, a_in, idx, fparm); KeyswitchPreprocess(ksk_a, a_in, a_out, decomp_buf, fparm); } void EvalAutoOnline(std::vector& b_in, std::vector& b_out, const std::vector>& ksk_b, - uint64_t idx, std::vector>& decomp_buf, + uint64_t idx, + std::vector>& decomp_buf, const FheParams& fparm) { // Permute b_in into b_out (out-of-place: no scratch copy needed). // Then key-switch b_out in place, avoiding the extra copy in KeyswitchOnline. @@ -263,12 +260,10 @@ std::vector PackrlwePreprocessImpl( const uint64_t modulus = fparm.get_rlwe_cmod(); const uint64_t expo = GetLog2(length); - std::vector a_e = - PackrlwePreprocessImpl(a, start, stride << 1, l - 1, h, ksk_a, - decomp_buf, fparm); - std::vector a_o = - PackrlwePreprocessImpl(a, start + stride, stride << 1, l - 1, h, ksk_a, - decomp_buf, fparm); + std::vector a_e = PackrlwePreprocessImpl( + a, start, stride << 1, l - 1, h, ksk_a, decomp_buf, fparm); + std::vector a_o = PackrlwePreprocessImpl( + a, start + stride, stride << 1, l - 1, h, ksk_a, decomp_buf, fparm); const std::vector& pt = fparm.get_precomputed_pt(l + h); std::vector tmp(length, 0); @@ -280,10 +275,9 @@ std::vector PackrlwePreprocessImpl( EltwiseAddMod(result.data(), a_e.data(), tmp.data(), length, modulus); EltwiseSubMod(tmp1.data(), a_e.data(), tmp.data(), length, modulus); - EvalAutoPreprocess( - tmp1, tmp2, - ksk_a[GetAutokeyIdx((1ULL << (l + h)) + 1, expo)], - (1ULL << (l + h)) + 1, decomp_buf, fparm); + EvalAutoPreprocess(tmp1, tmp2, + ksk_a[GetAutokeyIdx((1ULL << (l + h)) + 1, expo)], + (1ULL << (l + h)) + 1, decomp_buf, fparm); EltwiseAddMod(result.data(), result.data(), tmp2.data(), length, modulus); return result; } @@ -312,19 +306,17 @@ std::vector PackrlweOnlineImpl( const std::vector& pt = fparm.get_precomputed_pt(l + h); g_packrlwe_pool.Init(length); - auto& tmp = g_packrlwe_pool.Get(depth, 0); - auto& tmp1 = g_packrlwe_pool.Get(depth, 1); - auto& tmp2 = g_packrlwe_pool.Get(depth, 2); + auto& tmp = g_packrlwe_pool.Get(depth, 0); + auto& tmp1 = g_packrlwe_pool.Get(depth, 1); + auto& tmp2 = g_packrlwe_pool.Get(depth, 2); auto& result = g_packrlwe_pool.Get(depth, 3); EltwiseMultMod(tmp.data(), pt.data(), b_o.data(), length, modulus); EltwiseAddMod(result.data(), b_e.data(), tmp.data(), length, modulus); EltwiseSubMod(tmp1.data(), b_e.data(), tmp.data(), length, modulus); - EvalAutoOnline( - tmp1, tmp2, - ksk_b[GetAutokeyIdx((1ULL << (l + h)) + 1, expo)], - (1ULL << (l + h)) + 1, decomp_buf[ptr++], fparm); + EvalAutoOnline(tmp1, tmp2, ksk_b[GetAutokeyIdx((1ULL << (l + h)) + 1, expo)], + (1ULL << (l + h)) + 1, decomp_buf[ptr++], fparm); EltwiseAddMod(result.data(), result.data(), tmp2.data(), length, modulus); return result; } @@ -333,9 +325,8 @@ std::vector PackrlweOnlineImpl( // owned by the parent frame), eliminating the ~16 KB copy-on-return that the // previous return-by-value version produced at each of 1023 recursive calls. void PackrlweOnlineConstantRowsImpl( - std::vector& output, - const std::vector& b, uint64_t start, uint64_t stride, - uint64_t l, uint64_t h, + std::vector& output, const std::vector& b, + uint64_t start, uint64_t stride, uint64_t l, uint64_t h, const std::vector>>& ksk_b, std::vector>>& decomp_buf, uint64_t& ptr, const FheParams& fparm, uint64_t depth = 0) { @@ -354,9 +345,9 @@ void PackrlweOnlineConstantRowsImpl( // 0=tmp, 1=tmp1, 2=tmp2 (scratch) // 4=b_e (left child writes here), 5=b_o (right child writes here) // `output` is provided by the parent (or the top-level wrapper). - auto& tmp = g_packrlwe_pool.Get(depth, 0); - auto& tmp1 = g_packrlwe_pool.Get(depth, 1); - auto& tmp2 = g_packrlwe_pool.Get(depth, 2); + auto& tmp = g_packrlwe_pool.Get(depth, 0); + auto& tmp1 = g_packrlwe_pool.Get(depth, 1); + auto& tmp2 = g_packrlwe_pool.Get(depth, 2); if (l == 1) { const std::vector& pt = fparm.get_precomputed_pt(l + h); @@ -368,10 +359,9 @@ void PackrlweOnlineConstantRowsImpl( if (output[i] >= modulus) output[i] -= modulus; tmp1[i] = scalar >= tmp[i] ? scalar - tmp[i] : scalar + modulus - tmp[i]; } - EvalAutoOnline( - tmp1, tmp2, - ksk_b[GetAutokeyIdx((1ULL << (l + h)) + 1, expo)], - (1ULL << (l + h)) + 1, decomp_buf[ptr++], fparm); + EvalAutoOnline(tmp1, tmp2, + ksk_b[GetAutokeyIdx((1ULL << (l + h)) + 1, expo)], + (1ULL << (l + h)) + 1, decomp_buf[ptr++], fparm); EltwiseAddMod(output.data(), output.data(), tmp2.data(), length, modulus); return; } @@ -381,10 +371,10 @@ void PackrlweOnlineConstantRowsImpl( auto& b_e = g_packrlwe_pool.Get(depth, 4); auto& b_o = g_packrlwe_pool.Get(depth, 5); - PackrlweOnlineConstantRowsImpl(b_e, b, start, stride << 1, l - 1, h, + PackrlweOnlineConstantRowsImpl(b_e, b, start, stride << 1, l - 1, h, ksk_b, + decomp_buf, ptr, fparm, depth + 1); + PackrlweOnlineConstantRowsImpl(b_o, b, start + stride, stride << 1, l - 1, h, ksk_b, decomp_buf, ptr, fparm, depth + 1); - PackrlweOnlineConstantRowsImpl(b_o, b, start + stride, stride << 1, l - 1, - h, ksk_b, decomp_buf, ptr, fparm, depth + 1); const std::vector& pt = fparm.get_precomputed_pt(l + h); @@ -392,10 +382,8 @@ void PackrlweOnlineConstantRowsImpl( EltwiseAddMod(output.data(), b_e.data(), tmp.data(), length, modulus); EltwiseSubMod(tmp1.data(), b_e.data(), tmp.data(), length, modulus); - EvalAutoOnline( - tmp1, tmp2, - ksk_b[GetAutokeyIdx((1ULL << (l + h)) + 1, expo)], - (1ULL << (l + h)) + 1, decomp_buf[ptr++], fparm); + EvalAutoOnline(tmp1, tmp2, ksk_b[GetAutokeyIdx((1ULL << (l + h)) + 1, expo)], + (1ULL << (l + h)) + 1, decomp_buf[ptr++], fparm); EltwiseAddMod(output.data(), output.data(), tmp2.data(), length, modulus); } } // namespace @@ -424,8 +412,8 @@ std::vector PackrlweOnlineConstantRows( g_packrlwe_pool.Init(fparm.get_poly_degree()); // Use the depth-0 result slot as output; one final copy on return. auto& result = g_packrlwe_pool.Get(0, 3); - PackrlweOnlineConstantRowsImpl(result, b, 0, 1, l, h, ksk_b, decomp_buf, - ptr, fparm, 0); + PackrlweOnlineConstantRowsImpl(result, b, 0, 1, l, h, ksk_b, decomp_buf, ptr, + fparm, 0); return result; } diff --git a/psi/algorithm/ypir/legacy/ypir_util.cc b/psi/algorithm/ypir/legacy/ypir_util.cc index babea32a..9a01ee14 100644 --- a/psi/algorithm/ypir/legacy/ypir_util.cc +++ b/psi/algorithm/ypir/legacy/ypir_util.cc @@ -17,13 +17,13 @@ #include #include #include + #include "yacl/base/exception.h" #if defined(__x86_64__) || defined(_M_X64) #include #endif - namespace psi::ypir::ypir_internal { namespace { @@ -43,30 +43,28 @@ int64_t ExGcd(int64_t a, int64_t b, int64_t& x, int64_t& y) { unsigned char ReverseByte(unsigned char x) { static const unsigned char table[] = { - 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, 0x10, 0x90, 0x50, - 0xd0, 0x30, 0xb0, 0x70, 0xf0, 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, - 0x68, 0xe8, 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8, 0x04, - 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4, 0x14, 0x94, 0x54, 0xd4, - 0x34, 0xb4, 0x74, 0xf4, 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, - 0xec, 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc, 0x02, 0x82, - 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2, 0x12, 0x92, 0x52, 0xd2, 0x32, - 0xb2, 0x72, 0xf2, 0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea, - 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa, 0x06, 0x86, 0x46, - 0xc6, 0x26, 0xa6, 0x66, 0xe6, 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, - 0x76, 0xf6, 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee, 0x1e, - 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe, 0x01, 0x81, 0x41, 0xc1, - 0x21, 0xa1, 0x61, 0xe1, 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, - 0xf1, 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9, 0x19, 0x99, - 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9, 0x05, 0x85, 0x45, 0xc5, 0x25, - 0xa5, 0x65, 0xe5, 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5, - 0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed, 0x1d, 0x9d, 0x5d, - 0xdd, 0x3d, 0xbd, 0x7d, 0xfd, 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, - 0x63, 0xe3, 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3, 0x0b, - 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb, 0x1b, 0x9b, 0x5b, 0xdb, - 0x3b, 0xbb, 0x7b, 0xfb, 0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, - 0xe7, 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7, 0x0f, 0x8f, - 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef, 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, - 0xbf, 0x7f, 0xff, + 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, 0x10, 0x90, 0x50, 0xd0, + 0x30, 0xb0, 0x70, 0xf0, 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8, + 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8, 0x04, 0x84, 0x44, 0xc4, + 0x24, 0xa4, 0x64, 0xe4, 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4, + 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec, 0x1c, 0x9c, 0x5c, 0xdc, + 0x3c, 0xbc, 0x7c, 0xfc, 0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2, + 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2, 0x0a, 0x8a, 0x4a, 0xca, + 0x2a, 0xaa, 0x6a, 0xea, 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa, + 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6, 0x16, 0x96, 0x56, 0xd6, + 0x36, 0xb6, 0x76, 0xf6, 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee, + 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe, 0x01, 0x81, 0x41, 0xc1, + 0x21, 0xa1, 0x61, 0xe1, 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1, + 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9, 0x19, 0x99, 0x59, 0xd9, + 0x39, 0xb9, 0x79, 0xf9, 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5, + 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5, 0x0d, 0x8d, 0x4d, 0xcd, + 0x2d, 0xad, 0x6d, 0xed, 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd, + 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3, 0x13, 0x93, 0x53, 0xd3, + 0x33, 0xb3, 0x73, 0xf3, 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb, + 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb, 0x07, 0x87, 0x47, 0xc7, + 0x27, 0xa7, 0x67, 0xe7, 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7, + 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef, 0x1f, 0x9f, 0x5f, 0xdf, + 0x3f, 0xbf, 0x7f, 0xff, }; return table[x]; } @@ -78,8 +76,7 @@ uint32_t ReverseBits(uint32_t num, uint32_t msb) { case 1: return (ReverseByte(num & 0xff) >> shift_trick[msb & 0x7]); case 2: - return (ReverseByte(num & 0xff) << 8 | - ReverseByte((num >> 8) & 0xff)) >> + return (ReverseByte(num & 0xff) << 8 | ReverseByte((num >> 8) & 0xff)) >> shift_trick[msb & 0x7]; case 3: return (ReverseByte(num & 0xff) << 16 | @@ -99,9 +96,9 @@ uint32_t ReverseBits(uint32_t num, uint32_t msb) { #if defined(__x86_64__) || defined(_M_X64) #if defined(__GNUC__) || defined(__clang__) -__attribute__((target("avx512f,avx512bw,avx512vl"))) -void MatVecU8U32Mod2p32Avx512(const uint8_t* A, const uint32_t* x, - uint32_t* y, size_t rows, size_t cols) { +__attribute__((target("avx512f,avx512bw,avx512vl"))) void +MatVecU8U32Mod2p32Avx512(const uint8_t* A, const uint32_t* x, uint32_t* y, + size_t rows, size_t cols) { constexpr size_t kLanes = 16; for (size_t r = 0; r < rows; ++r) { @@ -148,8 +145,8 @@ void MatVecU8U32Mod2p32Avx512(const uint8_t* A, const uint32_t* x, } } -__attribute__((target("avx512f,avx512bw,avx512vl"))) -void MatrixVectorMultiplicationU16Avx512( +__attribute__((target("avx512f,avx512bw,avx512vl"))) void +MatrixVectorMultiplicationU16Avx512( std::vector& result, const std::vector>& matrix, const std::vector& vec, uint64_t mod) { @@ -332,8 +329,7 @@ void PseudorandomMatrixGenerate(std::vector>& matrix, prng.fill_bytes(ptr, sizeof(uint64_t) * cols); } for (uint64_t i = 0; i < rows; ++i) - for (uint64_t j = 0; j < cols; ++j) - matrix[i][j] %= modulus; + for (uint64_t j = 0; j < cols; ++j) matrix[i][j] %= modulus; } void SetPseudorandomMatrixSimplepir(std::vector>& matrix, @@ -367,9 +363,8 @@ void SetPseudorandomMatrixDoublepir(std::vector>& matrix, void SetPseudorandomHypercubeYpir( std::vector>>& cube, uint64_t layers, uint64_t rows, uint64_t cols, uint64_t modulus, AESCTR_PRNG& prng) { - cube.assign(layers, - std::vector>(rows, - std::vector(cols))); + cube.assign(layers, std::vector>( + rows, std::vector(cols))); prng.refresh(kThirdDimensionSeed); for (uint64_t i = 0; i < layers; ++i) { PseudorandomMatrixGenerate(cube[i], modulus, prng); @@ -433,10 +428,10 @@ void MatrixRowDecompose(const std::vector>& matrix, } } -void MatrixVectorFirstDimension(std::vector& result, - const std::vector>& matrix, - const std::vector& vec, - uint64_t mod) { +void MatrixVectorFirstDimension( + std::vector& result, + const std::vector>& matrix, + const std::vector& vec, uint64_t mod) { const uint64_t rows = matrix.size(); const uint64_t cols = rows == 0 ? 0 : matrix[0].size(); result.assign(cols, 0); @@ -446,10 +441,10 @@ void MatrixVectorFirstDimension(std::vector& result, } } -void MatrixMultiplicationFlat( - std::vector>& db_mul_matrix, - const std::vector>& db, const uint64_t* matrix_flat, - uint64_t matrix_col, uint64_t mod) { +void MatrixMultiplicationFlat(std::vector>& db_mul_matrix, + const std::vector>& db, + const uint64_t* matrix_flat, uint64_t matrix_col, + uint64_t mod) { const uint64_t db_row = db.size(); const uint64_t db_col = db_row == 0 ? 0 : db[0].size(); db_mul_matrix.assign(db_row, std::vector(matrix_col, 0)); @@ -461,7 +456,6 @@ void MatrixMultiplicationFlat( } } - void MatrixMultiplicationFlatU16( std::vector>& db_mul_matrix, const std::vector>& db, const uint64_t* matrix_flat, diff --git a/psi/algorithm/ypir/legacy/ypir_util.h b/psi/algorithm/ypir/legacy/ypir_util.h index 7076ddc7..679afa44 100644 --- a/psi/algorithm/ypir/legacy/ypir_util.h +++ b/psi/algorithm/ypir/legacy/ypir_util.h @@ -34,8 +34,7 @@ uint64_t GetLog2(uint64_t num); bool IsPowerOfTwo(uint64_t num); uint64_t GetAutokeyIdx(uint64_t idx, uint64_t expo); -uint64_t SampleGauss(double st_dev, uint64_t modulus, - std::mt19937_64& rng); +uint64_t SampleGauss(double st_dev, uint64_t modulus, std::mt19937_64& rng); void SampleGauss(std::vector& err, double st_dev, uint64_t modulus, std::mt19937_64& rng); @@ -88,15 +87,15 @@ void MatrixRowDecompose(const std::vector>& matrix, std::vector>& decomp_matrix, uint64_t b, uint64_t z, uint64_t t); -void MatrixVectorFirstDimension(std::vector& result, - const std::vector>& matrix, - const std::vector& vec, - uint64_t mod); +void MatrixVectorFirstDimension( + std::vector& result, + const std::vector>& matrix, + const std::vector& vec, uint64_t mod); -void MatrixMultiplicationFlat( - std::vector>& db_mul_matrix, - const std::vector>& db, const uint64_t* matrix_flat, - uint64_t matrix_col, uint64_t mod); +void MatrixMultiplicationFlat(std::vector>& db_mul_matrix, + const std::vector>& db, + const uint64_t* matrix_flat, uint64_t matrix_col, + uint64_t mod); void MatrixMultiplicationFlatU16( std::vector>& db_mul_matrix, @@ -104,7 +103,8 @@ void MatrixMultiplicationFlatU16( uint64_t matrix_col, uint64_t mod); void MatrixVectorMultiplicationU16( - std::vector& result, const std::vector>& matrix, + std::vector& result, + const std::vector>& matrix, const std::vector& vec, uint64_t mod); void MatVecU8U32Mod2p32(const uint8_t* A, const uint32_t* x, uint32_t* y, diff --git a/psi/algorithm/ypir/params.cc b/psi/algorithm/ypir/params.cc index 2c0354c1..a37bfe39 100644 --- a/psi/algorithm/ypir/params.cc +++ b/psi/algorithm/ypir/params.cc @@ -111,14 +111,12 @@ YpirParameters CreateParamsForScenarioDoublePIR(uint64_t num_items, return BuildDoublepirParamsForShape(shape.rows, shape.cols, item_size_bits); } -YpirParameters CreateParamsForShapeSimplePIR(uint64_t db_rows, - uint64_t db_cols, +YpirParameters CreateParamsForShapeSimplePIR(uint64_t db_rows, uint64_t db_cols, uint64_t item_size_bits) { return BuildSimplepirParamsForShape(db_rows, db_cols, item_size_bits); } -YpirParameters CreateParamsForShapeDoublePIR(uint64_t db_rows, - uint64_t db_cols, +YpirParameters CreateParamsForShapeDoublePIR(uint64_t db_rows, uint64_t db_cols, uint64_t item_size_bits) { return BuildDoublepirParamsForShape(db_rows, db_cols, item_size_bits); } diff --git a/psi/algorithm/ypir/params.h b/psi/algorithm/ypir/params.h index a3b01e73..c7d74324 100644 --- a/psi/algorithm/ypir/params.h +++ b/psi/algorithm/ypir/params.h @@ -22,11 +22,9 @@ YpirParameters CreateParamsForScenarioSimplePIR(uint64_t num_items, uint64_t item_size_bits); YpirParameters CreateParamsForScenarioDoublePIR(uint64_t num_items, uint64_t item_size_bits); -YpirParameters CreateParamsForShapeSimplePIR(uint64_t db_rows, - uint64_t db_cols, +YpirParameters CreateParamsForShapeSimplePIR(uint64_t db_rows, uint64_t db_cols, uint64_t item_size_bits); -YpirParameters CreateParamsForShapeDoublePIR(uint64_t db_rows, - uint64_t db_cols, +YpirParameters CreateParamsForShapeDoublePIR(uint64_t db_rows, uint64_t db_cols, uint64_t item_size_bits); YpirParameters CreateSmallTestParamsSimplePIR(); YpirParameters CreateSmallTestParamsDoublePIR(); diff --git a/psi/algorithm/ypir/params_test.cc b/psi/algorithm/ypir/params_test.cc index c1b4e67f..3350ab5b 100644 --- a/psi/algorithm/ypir/params_test.cc +++ b/psi/algorithm/ypir/params_test.cc @@ -34,10 +34,10 @@ TEST(YpirParamsTest, ScenarioHelpersRespectRequestedValueSize) { } TEST(YpirParamsTest, ShapeHelpersPreserveRequestedShape) { - const auto simple_params = CreateParamsForShapeSimplePIR(1ULL << 11, - 3ULL << 10, 16); - const auto double_params = CreateParamsForShapeDoublePIR(1ULL << 11, - 1ULL << 12, 8); + const auto simple_params = + CreateParamsForShapeSimplePIR(1ULL << 11, 3ULL << 10, 16); + const auto double_params = + CreateParamsForShapeDoublePIR(1ULL << 11, 1ULL << 12, 8); EXPECT_EQ(simple_params.db_rows, 1ULL << 11); EXPECT_EQ(simple_params.db_cols, 3ULL << 10); diff --git a/psi/algorithm/ypir/pir_interface_test.cc b/psi/algorithm/ypir/pir_interface_test.cc index c72b3cf2..8e2f279f 100644 --- a/psi/algorithm/ypir/pir_interface_test.cc +++ b/psi/algorithm/ypir/pir_interface_test.cc @@ -1,12 +1,12 @@ -#include "psi/algorithm/ypir/client.h" -#include "psi/algorithm/ypir/server.h" - #include #include #include #include "gtest/gtest.h" +#include "psi/algorithm/ypir/client.h" +#include "psi/algorithm/ypir/server.h" + namespace psi::ypir { namespace { @@ -38,12 +38,12 @@ TEST(YpirPirInterfaceTest, SimplepirImplementsIndexPirInterfaces) { psi::pir::IndexPirClient& client = concrete_client; psi::pir::IndexPirDataBase& server = concrete_server; - const auto raw_db = BuildItemDatabase( - params, [&](uint64_t raw_idx) { + const auto raw_db = + BuildItemDatabase(params, [&](uint64_t raw_idx) { const uint64_t row = raw_idx / params.db_cols; const uint64_t col = raw_idx % params.db_cols; - return static_cast( - (row * 17 + col * 3) % params.spiral_params.PtModulus()); + return static_cast((row * 17 + col * 3) % + params.spiral_params.PtModulus()); }); server.GenerateFromRawData(raw_db); @@ -69,12 +69,11 @@ TEST(YpirPirInterfaceTest, DoublepirImplementsIndexPirInterfaces) { psi::pir::IndexPirClient& client = concrete_client; psi::pir::IndexPirDataBase& server = concrete_server; - const auto raw_db = BuildItemDatabase( - params, [&](uint64_t raw_idx) { - const uint64_t row = raw_idx / params.db_cols; - const uint64_t col = raw_idx % params.db_cols; - return static_cast((row + col) % 251); - }); + const auto raw_db = BuildItemDatabase(params, [&](uint64_t raw_idx) { + const uint64_t row = raw_idx / params.db_cols; + const uint64_t col = raw_idx % params.db_cols; + return static_cast((row + col) % 251); + }); server.GenerateFromRawData(raw_db); const uint64_t raw_idx = 111ULL * params.db_cols + 222ULL; diff --git a/psi/algorithm/ypir/server.cc b/psi/algorithm/ypir/server.cc index 082e35b4..bfb4feb7 100644 --- a/psi/algorithm/ypir/server.cc +++ b/psi/algorithm/ypir/server.cc @@ -44,13 +44,13 @@ YpirServer::YpirServer(YpirParameters params) } template -void YpirServer::GenerateFromRawData(const psi::pir::RawDatabase& raw_database) { +void YpirServer::GenerateFromRawData( + const psi::pir::RawDatabase& raw_database) { static_assert(std::is_same_v || std::is_same_v, "YpirServer only supports uint8_t and uint16_t values"); - const bool item_layout = - raw_database.Rows() <= params_.NumItems() && - raw_database.RowByteLen() == params_.value_bytes; + const bool item_layout = raw_database.Rows() <= params_.NumItems() && + raw_database.RowByteLen() == params_.value_bytes; const bool matrix_layout = raw_database.Rows() == params_.db_rows && raw_database.RowByteLen() == params_.db_cols * sizeof(T); @@ -108,8 +108,9 @@ void YpirServer::Dump(std::ostream& out_stream) const { out_stream << "YpirServer{mode=" << (params_.mode == YpirMode::kSimplepir ? "simplepir" : "doublepir") - << ", db_rows=" << params_.db_rows << ", db_cols=" - << params_.db_cols << ", value_bytes=" << params_.value_bytes + << ", db_rows=" << params_.db_rows + << ", db_cols=" << params_.db_cols + << ", value_bytes=" << params_.value_bytes << ", db_set=" << db_set_ << "}"; } @@ -134,8 +135,8 @@ YpirResponse YpirServer::ProcessQuery(const YpirQuery& query) const { } template -YpirResponse YpirServer::ProcessQuery(const YpirQuery& query, - const YpirPrecomputedState& state) const { +YpirResponse YpirServer::ProcessQuery( + const YpirQuery& query, const YpirPrecomputedState& state) const { YACL_ENFORCE(db_set_, "database must be loaded before query processing"); YACL_ENFORCE(query.mode == params_.mode); @@ -173,9 +174,8 @@ yacl::Buffer YpirServer::Response( } template -std::string YpirServer::Response( - const yacl::ByteContainerView& query_buffer, - const std::string& /*pks_buffer*/) const { +std::string YpirServer::Response(const yacl::ByteContainerView& query_buffer, + const std::string& /*pks_buffer*/) const { auto buffer = Response(query_buffer); return std::string(static_cast(buffer)); } diff --git a/psi/algorithm/ypir/server.h b/psi/algorithm/ypir/server.h index 76499d3c..9f6c1e46 100644 --- a/psi/algorithm/ypir/server.h +++ b/psi/algorithm/ypir/server.h @@ -10,9 +10,9 @@ #include "yacl/base/byte_container_view.h" #include "psi/algorithm/pir_interface/pir_db.h" -#include "psi/algorithm/ypir/ypir_internal_server.h" #include "psi/algorithm/ypir/params.h" #include "psi/algorithm/ypir/types.h" +#include "psi/algorithm/ypir/ypir_internal_server.h" namespace psi::ypir { diff --git a/psi/algorithm/ypir/server_test.cc b/psi/algorithm/ypir/server_test.cc index 506cd55d..f1530d59 100644 --- a/psi/algorithm/ypir/server_test.cc +++ b/psi/algorithm/ypir/server_test.cc @@ -11,8 +11,8 @@ namespace { template psi::pir::RawDatabase BuildDatabase(const YpirParameters& params) { - std::vector> rows(params.db_rows, - std::vector(params.db_cols * sizeof(T), 0)); + std::vector> rows( + params.db_rows, std::vector(params.db_cols * sizeof(T), 0)); for (uint64_t row = 0; row < params.db_rows; ++row) { for (uint64_t col = 0; col < params.db_cols; ++col) { const T value = static_cast((row * 17 + col * 3) % 251); diff --git a/psi/algorithm/ypir/simplepir_flow_test.cc b/psi/algorithm/ypir/simplepir_flow_test.cc index 59c99328..320adb15 100644 --- a/psi/algorithm/ypir/simplepir_flow_test.cc +++ b/psi/algorithm/ypir/simplepir_flow_test.cc @@ -1,12 +1,12 @@ -#include "psi/algorithm/ypir/client.h" -#include "psi/algorithm/ypir/server.h" - #include #include #include #include "gtest/gtest.h" +#include "psi/algorithm/ypir/client.h" +#include "psi/algorithm/ypir/server.h" + namespace psi::ypir { namespace { @@ -19,12 +19,15 @@ uint64_t BytesToU64(const std::vector& bytes) { } psi::pir::RawDatabase BuildSimplepirDatabase(const YpirParameters& params) { - std::vector> rows(params.db_rows, - std::vector(params.db_cols * sizeof(uint16_t), 0)); + std::vector> rows( + params.db_rows, + std::vector(params.db_cols * sizeof(uint16_t), 0)); for (uint64_t row = 0; row < params.db_rows; ++row) { for (uint64_t col = 0; col < params.db_cols; ++col) { - const uint16_t value = static_cast((row * 17 + col * 3) % params.spiral_params.PtModulus()); - std::memcpy(rows[row].data() + col * sizeof(uint16_t), &value, sizeof(value)); + const uint16_t value = static_cast( + (row * 17 + col * 3) % params.spiral_params.PtModulus()); + std::memcpy(rows[row].data() + col * sizeof(uint16_t), &value, + sizeof(value)); } } return psi::pir::RawDatabase(std::move(rows)); @@ -44,7 +47,8 @@ TEST(YpirSimplepirFlowTest, EndToEndSmallDatabase) { const auto response_buffer = server.Response(query_buffer); const auto decoded = client.DecodeResponseBuffer(response_buffer, raw_idx); - const uint64_t expected = (row * 17 + col * 3) % params.spiral_params.PtModulus(); + const uint64_t expected = + (row * 17 + col * 3) % params.spiral_params.PtModulus(); EXPECT_EQ(BytesToU64(decoded), expected); } diff --git a/psi/algorithm/ypir/smoke_test.cc b/psi/algorithm/ypir/smoke_test.cc index 25aec4a4..71ef48e6 100644 --- a/psi/algorithm/ypir/smoke_test.cc +++ b/psi/algorithm/ypir/smoke_test.cc @@ -1,8 +1,8 @@ +#include "gtest/gtest.h" + #include "psi/algorithm/ypir/client.h" #include "psi/algorithm/ypir/server.h" -#include "gtest/gtest.h" - namespace psi::ypir { namespace { diff --git a/psi/algorithm/ypir/ypir_flow_test.cc b/psi/algorithm/ypir/ypir_flow_test.cc index 5c9e9196..c7099c4f 100644 --- a/psi/algorithm/ypir/ypir_flow_test.cc +++ b/psi/algorithm/ypir/ypir_flow_test.cc @@ -1,18 +1,18 @@ -#include "psi/algorithm/ypir/client.h" -#include "psi/algorithm/ypir/serialize.h" -#include "psi/algorithm/ypir/server.h" - #include #include #include "gtest/gtest.h" +#include "psi/algorithm/ypir/client.h" +#include "psi/algorithm/ypir/serialize.h" +#include "psi/algorithm/ypir/server.h" + namespace psi::ypir { namespace { psi::pir::RawDatabase BuildDoublepirDatabase(const YpirParameters& params) { - std::vector> rows(params.db_rows, - std::vector(params.db_cols, 0)); + std::vector> rows( + params.db_rows, std::vector(params.db_cols, 0)); for (uint64_t row = 0; row < params.db_rows; ++row) { for (uint64_t col = 0; col < params.db_cols; ++col) { rows[row][col] = static_cast((row + col) % 251); @@ -33,7 +33,8 @@ TEST(YpirDoublepirFlowTest, EndToEndSmallDatabase) { const uint64_t raw_idx = row * params.db_cols + col; const auto query_buffer = client.GenerateQueryBuffer(raw_idx); - const auto response = server.ProcessQuery(DeserializeQuery(query_buffer), state); + const auto response = + server.ProcessQuery(DeserializeQuery(query_buffer), state); const auto decoded = client.DecodeResponse(response, raw_idx); ASSERT_EQ(decoded.size(), 1U); diff --git a/psi/algorithm/ypir/ypir_internal_client.cc b/psi/algorithm/ypir/ypir_internal_client.cc index 6a38622a..4c675417 100644 --- a/psi/algorithm/ypir/ypir_internal_client.cc +++ b/psi/algorithm/ypir/ypir_internal_client.cc @@ -14,10 +14,12 @@ YpirQuery GenerateQuery(uint64_t raw_idx, const YpirParameters& params, const uint64_t row_idx = raw_idx / params.db_cols; const uint64_t col_idx = raw_idx % params.db_cols; - secrets.simple_secret = psi::ypir::ypir_internal::Secret( - context.fhe_params->get_lwe_dimension(), context.fhe_params->get_lwe_cmod()); - secrets.double_secret = psi::ypir::ypir_internal::Secret( - context.fhe_params->get_poly_degree(), context.fhe_params->get_rlwe_cmod()); + secrets.simple_secret = + psi::ypir::ypir_internal::Secret(context.fhe_params->get_lwe_dimension(), + context.fhe_params->get_lwe_cmod()); + secrets.double_secret = + psi::ypir::ypir_internal::Secret(context.fhe_params->get_poly_degree(), + context.fhe_params->get_rlwe_cmod()); secrets.initialized = true; auto legacy_query = psi::ypir::ypir_internal::Generate_query_ypir( @@ -37,7 +39,8 @@ std::vector RecoverResponse(const YpirResponse& response, const ClientSecrets& secrets, const Context& context) { YACL_ENFORCE(params.mode == YpirMode::kDoublepir); - YACL_ENFORCE(secrets.initialized, "GenerateQuery must be called before decode"); + YACL_ENFORCE(secrets.initialized, + "GenerateQuery must be called before decode"); YACL_ENFORCE(response.mode == YpirMode::kDoublepir); auto simple_secret = secrets.simple_secret; @@ -45,8 +48,9 @@ std::vector RecoverResponse(const YpirResponse& response, auto result = response.doublepir_response; uint64_t message = 0; - psi::ypir::ypir_internal::YpirRecover(simple_secret, double_secret, result, message, - *context.fhe_params, *context.pir_params); + psi::ypir::ypir_internal::YpirRecover(simple_secret, double_secret, result, + message, *context.fhe_params, + *context.pir_params); return EncodeIntegerValue(message, params.value_bytes); } diff --git a/psi/algorithm/ypir/ypir_internal_client.h b/psi/algorithm/ypir/ypir_internal_client.h index fab1a09a..29053ec7 100644 --- a/psi/algorithm/ypir/ypir_internal_client.h +++ b/psi/algorithm/ypir/ypir_internal_client.h @@ -3,8 +3,8 @@ #include #include "psi/algorithm/ypir/legacy/client.h" -#include "psi/algorithm/ypir/ypir_internal_params.h" #include "psi/algorithm/ypir/types.h" +#include "psi/algorithm/ypir/ypir_internal_params.h" namespace psi::ypir::internal::ypir { diff --git a/psi/algorithm/ypir/ypir_internal_params.cc b/psi/algorithm/ypir/ypir_internal_params.cc index 90f4e919..6ab1f052 100644 --- a/psi/algorithm/ypir/ypir_internal_params.cc +++ b/psi/algorithm/ypir/ypir_internal_params.cc @@ -9,7 +9,9 @@ namespace { thread_local psi::ypir::ypir_internal::YpirHexlNtt* g_ntt = nullptr; -void NttForwardWrapper(uint64_t* data, size_t len) { g_ntt->Forward(data, len); } +void NttForwardWrapper(uint64_t* data, size_t len) { + g_ntt->Forward(data, len); +} Context BuildContext(uint64_t rows, uint64_t cols) { using namespace psi::ypir::ypir_internal; diff --git a/psi/algorithm/ypir/ypir_internal_server.cc b/psi/algorithm/ypir/ypir_internal_server.cc index 07199210..526885e7 100644 --- a/psi/algorithm/ypir/ypir_internal_server.cc +++ b/psi/algorithm/ypir/ypir_internal_server.cc @@ -7,9 +7,8 @@ namespace psi::ypir::internal::ypir { namespace { -std::vector> ExpandDatabase(const std::vector& db, - uint64_t rows, - uint64_t cols) { +std::vector> ExpandDatabase( + const std::vector& db, uint64_t rows, uint64_t cols) { YACL_ENFORCE_EQ(db.size(), rows * cols); std::vector> out(rows, std::vector(cols, 0)); for (uint64_t row = 0; row < rows; ++row) { @@ -31,9 +30,9 @@ YpirPrecomputedState PrepareOfflineState(const std::vector& db, YpirPrecomputedState state; state.mode = YpirMode::kDoublepir; std::vector> server_hint; - psi::ypir::ypir_internal::YpirHintGenerate(db_matrix, state.hint_0, server_hint, - state.decomp_buf, *context.prng, - *context.fhe_params, *context.pir_params); + psi::ypir::ypir_internal::YpirHintGenerate( + db_matrix, state.hint_0, server_hint, state.decomp_buf, *context.prng, + *context.fhe_params, *context.pir_params); psi::ypir::ypir_internal::MatrixTranspose(server_hint, state.server_hint); return state; } @@ -58,9 +57,9 @@ YpirResponse ProcessQuery(const std::vector& db, std::vector> result; result.push_back(state.hint_0); - psi::ypir::ypir_internal::YpirAnswer(db.data(), qu0.data(), qu1, query.ksk_b, - decomp_buf, server_hint, result, - *context.fhe_params, *context.pir_params); + psi::ypir::ypir_internal::YpirAnswer( + db.data(), qu0.data(), qu1, query.ksk_b, decomp_buf, server_hint, result, + *context.fhe_params, *context.pir_params); YpirResponse response; response.mode = YpirMode::kDoublepir; diff --git a/psi/algorithm/ypir/ypir_internal_server.h b/psi/algorithm/ypir/ypir_internal_server.h index a8a06f72..dd3070e5 100644 --- a/psi/algorithm/ypir/ypir_internal_server.h +++ b/psi/algorithm/ypir/ypir_internal_server.h @@ -3,8 +3,8 @@ #include #include -#include "psi/algorithm/ypir/ypir_internal_params.h" #include "psi/algorithm/ypir/types.h" +#include "psi/algorithm/ypir/ypir_internal_params.h" namespace psi::ypir::internal::ypir { @@ -15,7 +15,6 @@ YpirPrecomputedState PrepareOfflineState(const std::vector& db, YpirResponse ProcessQuery(const std::vector& db, const YpirQuery& query, const YpirPrecomputedState& state, - const YpirParameters& params, - const Context& context); + const YpirParameters& params, const Context& context); } // namespace psi::ypir::internal::ypir diff --git a/psi/apps/psi_launcher/ypir_launch.cc b/psi/apps/psi_launcher/ypir_launch.cc index 289d98e6..53f33255 100644 --- a/psi/apps/psi_launcher/ypir_launch.cc +++ b/psi/apps/psi_launcher/ypir_launch.cc @@ -1,8 +1,9 @@ #include "psi/apps/psi_launcher/ypir_launch.h" -#include "psi/algorithm/ypir/entry.h" #include "yacl/base/exception.h" +#include "psi/algorithm/ypir/entry.h" + namespace psi { namespace { diff --git a/psi/apps/psi_launcher/ypir_test.cc b/psi/apps/psi_launcher/ypir_test.cc index 4b510b6d..33bfb3c6 100644 --- a/psi/apps/psi_launcher/ypir_test.cc +++ b/psi/apps/psi_launcher/ypir_test.cc @@ -1,5 +1,3 @@ -#include "psi/apps/psi_launcher/ypir_launch.h" - #include #include #include @@ -10,6 +8,8 @@ #include "gtest/gtest.h" #include "yacl/link/test_util.h" +#include "psi/apps/psi_launcher/ypir_launch.h" + namespace psi { namespace { @@ -81,12 +81,10 @@ TEST(YpirLauncherTest, RunPirSimplepirUsesLauncherEntry) { receiver_config.set_output_file(output_path); auto lctxs = yacl::link::test::SetupWorld(2); - auto sender = std::async(std::launch::async, [&] { - return RunPir(sender_config, lctxs[0]); - }); - auto receiver = std::async(std::launch::async, [&] { - return RunPir(receiver_config, lctxs[1]); - }); + auto sender = std::async(std::launch::async, + [&] { return RunPir(sender_config, lctxs[0]); }); + auto receiver = std::async(std::launch::async, + [&] { return RunPir(receiver_config, lctxs[1]); }); EXPECT_EQ(sender.get().match_cnt(), 0); EXPECT_EQ(receiver.get().match_cnt(), 0); @@ -131,12 +129,10 @@ TEST(YpirLauncherTest, RunPirDoublepirUsesLauncherEntry) { receiver_config.set_output_file(output_path); auto lctxs = yacl::link::test::SetupWorld(2); - auto sender = std::async(std::launch::async, [&] { - return RunPir(sender_config, lctxs[0]); - }); - auto receiver = std::async(std::launch::async, [&] { - return RunPir(receiver_config, lctxs[1]); - }); + auto sender = std::async(std::launch::async, + [&] { return RunPir(sender_config, lctxs[0]); }); + auto receiver = std::async(std::launch::async, + [&] { return RunPir(receiver_config, lctxs[1]); }); EXPECT_EQ(sender.get().match_cnt(), 0); EXPECT_EQ(receiver.get().match_cnt(), 0); From 9efab1dbbd759f23e5e6fdaeaf98c4bbe3c219aa Mon Sep 17 00:00:00 2001 From: sh1k4ku Date: Thu, 26 Mar 2026 17:19:15 +0800 Subject: [PATCH 05/12] fix unittest and ci issues --- .circleci/test.yml | 4 ++-- bazel/install_hexl.sh | 11 ++++++++++ psi/algorithm/spiral/poly_matrix.cc | 3 ++- psi/algorithm/ypir/BUILD.bazel | 23 +++++++++++++++++++++ psi/apps/psi_launcher/BUILD.bazel | 25 ++++++++++++++++------- psi/apps/psi_launcher/ypir_launch_stub.cc | 17 +++++++++++++++ 6 files changed, 73 insertions(+), 10 deletions(-) create mode 100644 psi/apps/psi_launcher/ypir_launch_stub.cc diff --git a/.circleci/test.yml b/.circleci/test.yml index 33db7a34..c9ac788f 100644 --- a/.circleci/test.yml +++ b/.circleci/test.yml @@ -82,8 +82,8 @@ jobs: - build_and_test macos_ut: macos: - xcode: 16.2.0 - resource_class: macos.m1.large.gen1 + xcode: 16.4.0 + resource_class: m4pro.medium steps: - checkout - run: diff --git a/bazel/install_hexl.sh b/bazel/install_hexl.sh index e0cc64f9..05d2a686 100755 --- a/bazel/install_hexl.sh +++ b/bazel/install_hexl.sh @@ -4,6 +4,17 @@ set -euo pipefail hexl_version="${HEXL_VERSION:-v1.2.6}" install_prefix="${1:-${HEXL_ROOT:-${HOME}/.local/hexl}}" +arch="$(uname -m)" + +case "${arch}" in + x86_64|amd64) + ;; + *) + printf 'Skipping Intel HEXL installation on unsupported architecture %s\n' \ + "${arch}" + exit 0 + ;; +esac if [[ -f "${install_prefix}/lib/libhexl.a" && -d "${install_prefix}/include/hexl" ]]; then printf 'Intel HEXL already installed at %s\n' "${install_prefix}" diff --git a/psi/algorithm/spiral/poly_matrix.cc b/psi/algorithm/spiral/poly_matrix.cc index 2b1bbf84..28f67817 100644 --- a/psi/algorithm/spiral/poly_matrix.cc +++ b/psi/algorithm/spiral/poly_matrix.cc @@ -248,7 +248,8 @@ PolyMatrixRaw PolyMatrixRaw::Recover(const Params& params, uint64_t q_1, const size_t total_sz_bits = (q_1_bits + q_2_bits) * params.PolyLen(); const size_t total_sz_bytes = (total_sz_bits + 7) / 8; - assert(ciphertext.size() == total_sz_bytes && "Ciphertext size mismatch"); + YACL_ENFORCE_EQ(ciphertext.size(), total_sz_bytes, + "Ciphertext size mismatch"); PolyMatrixRaw res = PolyMatrixRaw::Zero(params.PolyLen(), 2, 1); size_t bit_offs = 0; diff --git a/psi/algorithm/ypir/BUILD.bazel b/psi/algorithm/ypir/BUILD.bazel index e3503c1c..81426b39 100644 --- a/psi/algorithm/ypir/BUILD.bazel +++ b/psi/algorithm/ypir/BUILD.bazel @@ -4,6 +4,8 @@ load("//bazel:psi.bzl", "psi_cc_library", "psi_cc_test") package(default_visibility = ["//visibility:public"]) +X86_64_COMPATIBLE = ["@platforms//cpu:x86_64"] + psi_cc_library( name = "legacy_ypir_impl", srcs = [ @@ -23,6 +25,7 @@ psi_cc_library( "legacy/ypir_util.h", ], copts = ["-maes"], + target_compatible_with = X86_64_COMPATIBLE, deps = [ "@hexl", "@yacl//yacl/base:exception", @@ -39,6 +42,7 @@ psi_cc_library( "legacy/types.h", "legacy/util.h", ], + target_compatible_with = X86_64_COMPATIBLE, deps = [ "//psi/algorithm/spiral:discrete_gaussian", "//psi/algorithm/spiral:gadget", @@ -57,12 +61,14 @@ psi_cc_library( psi_cc_library( name = "types", hdrs = ["types.h"], + target_compatible_with = X86_64_COMPATIBLE, ) psi_cc_library( name = "params", srcs = ["params.cc"], hdrs = ["params.h"], + target_compatible_with = X86_64_COMPATIBLE, deps = [ ":types", "//psi/algorithm/spiral:params", @@ -74,6 +80,7 @@ psi_cc_library( name = "util", srcs = ["util.cc"], hdrs = ["util.h"], + target_compatible_with = X86_64_COMPATIBLE, deps = [ ":params", "//psi/algorithm/spiral/arith", @@ -85,6 +92,7 @@ psi_cc_library( name = "serialize", srcs = ["serialize.cc"], hdrs = ["serialize.h"], + target_compatible_with = X86_64_COMPATIBLE, deps = [ ":types", "@yacl//yacl/base:buffer", @@ -97,6 +105,7 @@ psi_cc_library( name = "ypir_internal_params", srcs = ["ypir_internal_params.cc"], hdrs = ["ypir_internal_params.h"], + target_compatible_with = X86_64_COMPATIBLE, deps = [ ":legacy_ypir_impl", ":params", @@ -108,6 +117,7 @@ psi_cc_library( name = "ypir_internal_client", srcs = ["ypir_internal_client.cc"], hdrs = ["ypir_internal_client.h"], + target_compatible_with = X86_64_COMPATIBLE, deps = [ ":legacy_ypir_impl", ":types", @@ -121,6 +131,7 @@ psi_cc_library( name = "ypir_internal_server", srcs = ["ypir_internal_server.cc"], hdrs = ["ypir_internal_server.h"], + target_compatible_with = X86_64_COMPATIBLE, deps = [ ":legacy_ypir_impl", ":types", @@ -133,6 +144,7 @@ psi_cc_library( name = "client", srcs = ["client.cc"], hdrs = ["client.h"], + target_compatible_with = X86_64_COMPATIBLE, deps = [ ":params", ":serialize", @@ -150,6 +162,7 @@ psi_cc_library( name = "server", srcs = ["server.cc"], hdrs = ["server.h"], + target_compatible_with = X86_64_COMPATIBLE, deps = [ ":legacy_simplepir", ":params", @@ -166,6 +179,7 @@ psi_cc_library( name = "entry", srcs = ["entry.cc"], hdrs = ["entry.h"], + target_compatible_with = X86_64_COMPATIBLE, deps = [ ":client", ":params", @@ -179,6 +193,7 @@ psi_cc_library( psi_cc_test( name = "smoke_test", srcs = ["smoke_test.cc"], + target_compatible_with = X86_64_COMPATIBLE, deps = [ ":client", ":server", @@ -188,18 +203,21 @@ psi_cc_test( psi_cc_test( name = "params_test", srcs = ["params_test.cc"], + target_compatible_with = X86_64_COMPATIBLE, deps = [":params"], ) psi_cc_test( name = "serialize_test", srcs = ["serialize_test.cc"], + target_compatible_with = X86_64_COMPATIBLE, deps = [":serialize"], ) psi_cc_test( name = "client_test", srcs = ["client_test.cc"], + target_compatible_with = X86_64_COMPATIBLE, deps = [ ":client", ":serialize", @@ -210,12 +228,14 @@ psi_cc_test( psi_cc_test( name = "server_test", srcs = ["server_test.cc"], + target_compatible_with = X86_64_COMPATIBLE, deps = [":server"], ) psi_cc_test( name = "pir_interface_test", srcs = ["pir_interface_test.cc"], + target_compatible_with = X86_64_COMPATIBLE, deps = [ ":client", ":server", @@ -226,6 +246,7 @@ psi_cc_test( psi_cc_test( name = "simplepir_flow_test", srcs = ["simplepir_flow_test.cc"], + target_compatible_with = X86_64_COMPATIBLE, deps = [ ":client", ":server", @@ -235,6 +256,7 @@ psi_cc_test( psi_cc_test( name = "ypir_flow_test", srcs = ["ypir_flow_test.cc"], + target_compatible_with = X86_64_COMPATIBLE, deps = [ ":client", ":server", @@ -244,6 +266,7 @@ psi_cc_test( psi_cc_test( name = "entry_test", srcs = ["entry_test.cc"], + target_compatible_with = X86_64_COMPATIBLE, deps = [ ":entry", "@abseil-cpp//absl/strings", diff --git a/psi/apps/psi_launcher/BUILD.bazel b/psi/apps/psi_launcher/BUILD.bazel index 250dac05..05aea38e 100644 --- a/psi/apps/psi_launcher/BUILD.bazel +++ b/psi/apps/psi_launcher/BUILD.bazel @@ -44,14 +44,24 @@ psi_cc_library( psi_cc_library( name = "launch_ypir", - srcs = ["ypir_launch.cc"], + srcs = select({ + "@platforms//cpu:x86_64": ["ypir_launch.cc"], + "//conditions:default": ["ypir_launch_stub.cc"], + }), hdrs = ["ypir_launch.h"], - deps = [ - "//psi/algorithm/ypir:entry", - "//psi/proto:pir_cc_proto", - "@yacl//yacl/base:exception", - "@yacl//yacl/link:context", - ], + deps = select({ + "@platforms//cpu:x86_64": [ + "//psi/algorithm/ypir:entry", + "//psi/proto:pir_cc_proto", + "@yacl//yacl/base:exception", + "@yacl//yacl/link:context", + ], + "//conditions:default": [ + "//psi/proto:pir_cc_proto", + "@yacl//yacl/base:exception", + "@yacl//yacl/link:context", + ], + }), ) psi_cc_library( @@ -88,6 +98,7 @@ psi_cc_test( psi_cc_test( name = "ypir_test", srcs = ["ypir_test.cc"], + target_compatible_with = ["@platforms//cpu:x86_64"], deps = [ ":launch_ypir", "@abseil-cpp//absl/strings", diff --git a/psi/apps/psi_launcher/ypir_launch_stub.cc b/psi/apps/psi_launcher/ypir_launch_stub.cc new file mode 100644 index 00000000..0ff45eb9 --- /dev/null +++ b/psi/apps/psi_launcher/ypir_launch_stub.cc @@ -0,0 +1,17 @@ +#include "psi/apps/psi_launcher/ypir_launch.h" + +#include "yacl/base/exception.h" + +namespace psi { + +PirResultReport RunPir(const YpirReceiverConfig&, + const std::shared_ptr&) { + YACL_THROW("YPIR is only supported on x86_64"); +} + +PirResultReport RunPir(const YpirSenderConfig&, + const std::shared_ptr&) { + YACL_THROW("YPIR is only supported on x86_64"); +} + +} // namespace psi From 6a0bd25dab1af5ada8f92f93283f37faef718906 Mon Sep 17 00:00:00 2001 From: sh1k4ku Date: Thu, 26 Mar 2026 17:35:02 +0800 Subject: [PATCH 06/12] fix clang format --- psi/apps/psi_launcher/ypir_launch_stub.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/psi/apps/psi_launcher/ypir_launch_stub.cc b/psi/apps/psi_launcher/ypir_launch_stub.cc index 0ff45eb9..793f6acd 100644 --- a/psi/apps/psi_launcher/ypir_launch_stub.cc +++ b/psi/apps/psi_launcher/ypir_launch_stub.cc @@ -1,7 +1,7 @@ -#include "psi/apps/psi_launcher/ypir_launch.h" - #include "yacl/base/exception.h" +#include "psi/apps/psi_launcher/ypir_launch.h" + namespace psi { PirResultReport RunPir(const YpirReceiverConfig&, From f776f213e5ee6be36c87b71f352898196acbb3dd Mon Sep 17 00:00:00 2001 From: sh1k4ku Date: Tue, 31 Mar 2026 15:20:26 +0800 Subject: [PATCH 07/12] fix sth Co-Authored-By: Claude Opus 4.6 (1M context) --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 3e78deae..18c0faa0 100644 --- a/README.md +++ b/README.md @@ -218,3 +218,4 @@ Please refer to [PSI V2 Benchmark](docs/user_guide/psi_v2_benchmark.md) ## APSI Benchmark Please refer to [APSI Benchmark](docs/user_guide/apsi_benchmark.md) + From 47b72757e246dc43e32baac5a7f2bc141ff68687 Mon Sep 17 00:00:00 2001 From: sh1k4ku Date: Tue, 7 Apr 2026 16:24:43 +0800 Subject: [PATCH 08/12] no avx implementation --- MODULE.bazel.lock | 3791 +++--------------------- bazel/hexl_repo.bzl | 19 +- psi/algorithm/ypir/legacy/ypir_util.cc | 16 +- 3 files changed, 417 insertions(+), 3409 deletions(-) diff --git a/MODULE.bazel.lock b/MODULE.bazel.lock index 2b1e424d..2cc0a487 100644 --- a/MODULE.bazel.lock +++ b/MODULE.bazel.lock @@ -1,5 +1,5 @@ { - "lockFileVersion": 13, + "lockFileVersion": 26, "registryFileHashes": { "https://bcr.bazel.build/bazel_registry.json": "8a28e4aff06ee60aed2a8c281907fb8bcbf3b753c91fb5a5c57da3215d5b3497", "https://bcr.bazel.build/modules/abseil-cpp/20210324.2/MODULE.bazel": "7cd0312e064fde87c8d1cd79ba06c876bd23630c83466e9500321be55c96ace2", @@ -13,14 +13,19 @@ "https://bcr.bazel.build/modules/abseil-cpp/20240116.1/MODULE.bazel": "37bcdb4440fbb61df6a1c296ae01b327f19e9bb521f9b8e26ec854b6f97309ed", "https://bcr.bazel.build/modules/abseil-cpp/20240116.2/MODULE.bazel": "73939767a4686cd9a520d16af5ab440071ed75cec1a876bf2fcfaf1f71987a16", "https://bcr.bazel.build/modules/abseil-cpp/20240722.0.bcr.1/MODULE.bazel": "c0aa5eaefff1121b40208397f229604c717bd2fdf214ff67586d627118e17720", - "https://bcr.bazel.build/modules/abseil-cpp/20240722.0.bcr.1/source.json": "e067fdd217bacbe74c88a975434be5df0b44315a247be180f0e20f891715210c", "https://bcr.bazel.build/modules/abseil-cpp/20240722.0/MODULE.bazel": "88668a07647adbdc14cb3a7cd116fb23c9dda37a90a1681590b6c9d8339a5b84", + "https://bcr.bazel.build/modules/abseil-cpp/20250127.1/MODULE.bazel": "c4a89e7ceb9bf1e25cf84a9f830ff6b817b72874088bf5141b314726e46a57c1", + "https://bcr.bazel.build/modules/abseil-cpp/20250512.1/MODULE.bazel": "d209fdb6f36ffaf61c509fcc81b19e81b411a999a934a032e10cd009a0226215", + "https://bcr.bazel.build/modules/abseil-cpp/20250814.1/MODULE.bazel": "51f2312901470cdab0dbdf3b88c40cd21c62a7ed58a3de45b365ddc5b11bcab2", + "https://bcr.bazel.build/modules/abseil-cpp/20250814.1/source.json": "cea3901d7e299da7320700abbaafe57a65d039f10d0d7ea601c4a66938ea4b0c", "https://bcr.bazel.build/modules/apple_support/1.11.1/MODULE.bazel": "1843d7cd8a58369a444fc6000e7304425fba600ff641592161d9f15b179fb896", "https://bcr.bazel.build/modules/apple_support/1.13.0/MODULE.bazel": "7c8cdea7e031b7f9f67f0b497adf6d2c6a2675e9304ca93a9af6ed84eef5a524", "https://bcr.bazel.build/modules/apple_support/1.15.1/MODULE.bazel": "a0556fefca0b1bb2de8567b8827518f94db6a6e7e7d632b4c48dc5f865bc7c85", "https://bcr.bazel.build/modules/apple_support/1.17.1/MODULE.bazel": "655c922ab1209978a94ef6ca7d9d43e940cd97d9c172fb55f94d91ac53f8610b", - "https://bcr.bazel.build/modules/apple_support/1.17.1/source.json": "6b2b8c74d14e8d485528a938e44bdb72a5ba17632b9e14ef6e68a5ee96c8347f", - "https://bcr.bazel.build/modules/apple_support/1.5.0/MODULE.bazel": "50341a62efbc483e8a2a6aec30994a58749bd7b885e18dd96aa8c33031e558ef", + "https://bcr.bazel.build/modules/apple_support/1.21.0/MODULE.bazel": "ac1824ed5edf17dee2fdd4927ada30c9f8c3b520be1b5fd02a5da15bc10bff3e", + "https://bcr.bazel.build/modules/apple_support/1.21.1/MODULE.bazel": "5809fa3efab15d1f3c3c635af6974044bac8a4919c62238cce06acee8a8c11f1", + "https://bcr.bazel.build/modules/apple_support/1.24.2/MODULE.bazel": "0e62471818affb9f0b26f128831d5c40b074d32e6dda5a0d3852847215a41ca4", + "https://bcr.bazel.build/modules/apple_support/1.24.2/source.json": "2c22c9827093250406c5568da6c54e6fdf0ef06238def3d99c71b12feb057a8d", "https://bcr.bazel.build/modules/aspect_bazel_lib/1.31.2/MODULE.bazel": "7bee702b4862612f29333590f4b658a5832d433d6f8e4395f090e8f4e85d442f", "https://bcr.bazel.build/modules/aspect_bazel_lib/1.38.0/MODULE.bazel": "6307fec451ba9962c1c969eb516ebfe1e46528f7fa92e1c9ac8646bef4cdaa3f", "https://bcr.bazel.build/modules/aspect_bazel_lib/1.40.3/MODULE.bazel": "668e6bcb4d957fc0e284316dba546b705c8d43c857f87119619ee83c4555b859", @@ -41,9 +46,14 @@ "https://bcr.bazel.build/modules/bazel_features/1.19.0/MODULE.bazel": "59adcdf28230d220f0067b1f435b8537dd033bfff8db21335ef9217919c7fb58", "https://bcr.bazel.build/modules/bazel_features/1.20.0/MODULE.bazel": "8b85300b9c8594752e0721a37210e34879d23adc219ed9dc8f4104a4a1750920", "https://bcr.bazel.build/modules/bazel_features/1.21.0/MODULE.bazel": "675642261665d8eea09989aa3b8afb5c37627f1be178382c320d1b46afba5e3b", + "https://bcr.bazel.build/modules/bazel_features/1.23.0/MODULE.bazel": "fd1ac84bc4e97a5a0816b7fd7d4d4f6d837b0047cf4cbd81652d616af3a6591a", "https://bcr.bazel.build/modules/bazel_features/1.24.0/MODULE.bazel": "4796b4c25b47053e9bbffa792b3792d07e228ff66cd0405faef56a978708acd4", - "https://bcr.bazel.build/modules/bazel_features/1.24.0/source.json": "aeb7dcafd9cfc342095d315def2f7bcfcd9da0b78572edeceff1d1c12db4e08c", + "https://bcr.bazel.build/modules/bazel_features/1.27.0/MODULE.bazel": "621eeee06c4458a9121d1f104efb80f39d34deff4984e778359c60eaf1a8cb65", + "https://bcr.bazel.build/modules/bazel_features/1.28.0/MODULE.bazel": "4b4200e6cbf8fa335b2c3f43e1d6ef3e240319c33d43d60cc0fbd4b87ece299d", "https://bcr.bazel.build/modules/bazel_features/1.3.0/MODULE.bazel": "cdcafe83ec318cda34e02948e81d790aab8df7a929cec6f6969f13a489ccecd9", + "https://bcr.bazel.build/modules/bazel_features/1.30.0/MODULE.bazel": "a14b62d05969a293b80257e72e597c2da7f717e1e69fa8b339703ed6731bec87", + "https://bcr.bazel.build/modules/bazel_features/1.33.0/MODULE.bazel": "8b8dc9d2a4c88609409c3191165bccec0e4cb044cd7a72ccbe826583303459f6", + "https://bcr.bazel.build/modules/bazel_features/1.33.0/source.json": "13617db3930328c2cd2807a0f13d52ca870ac05f96db9668655113265147b2a6", "https://bcr.bazel.build/modules/bazel_features/1.4.1/MODULE.bazel": "e45b6bb2350aff3e442ae1111c555e27eac1d915e77775f6fdc4b351b758b5d7", "https://bcr.bazel.build/modules/bazel_features/1.9.0/MODULE.bazel": "885151d58d90d8d9c811eb75e3288c11f850e1d6b481a8c9f766adee4712358b", "https://bcr.bazel.build/modules/bazel_features/1.9.1/MODULE.bazel": "8f679097876a9b609ad1f60249c49d68bfab783dd9be012faf9d82547b14815a", @@ -59,7 +69,9 @@ "https://bcr.bazel.build/modules/bazel_skylib/1.6.1/MODULE.bazel": "8fdee2dbaace6c252131c00e1de4b165dc65af02ea278476187765e1a617b917", "https://bcr.bazel.build/modules/bazel_skylib/1.7.0/MODULE.bazel": "0db596f4563de7938de764cc8deeabec291f55e8ec15299718b93c4423e9796d", "https://bcr.bazel.build/modules/bazel_skylib/1.7.1/MODULE.bazel": "3120d80c5861aa616222ec015332e5f8d3171e062e3e804a2a0253e1be26e59b", - "https://bcr.bazel.build/modules/bazel_skylib/1.7.1/source.json": "f121b43eeefc7c29efbd51b83d08631e2347297c95aac9764a701f2a6a2bb953", + "https://bcr.bazel.build/modules/bazel_skylib/1.8.1/MODULE.bazel": "88ade7293becda963e0e3ea33e7d54d3425127e0a326e0d17da085a5f1f03ff6", + "https://bcr.bazel.build/modules/bazel_skylib/1.8.2/MODULE.bazel": "69ad6927098316848b34a9142bcc975e018ba27f08c4ff403f50c1b6e646ca67", + "https://bcr.bazel.build/modules/bazel_skylib/1.8.2/source.json": "34a3c8bcf233b835eb74be9d628899bb32999d3e0eadef1947a0a562a2b16ffb", "https://bcr.bazel.build/modules/blake3/1.5.4/MODULE.bazel": "1a378cca01187c40c27347f7e245506340cb68db3557ce1fab59ed007532fa2d", "https://bcr.bazel.build/modules/blake3/1.5.4/source.json": "ac1099f9ad8abd9167899bb6253c3cc663620973c39ecd595c3c5114cf96e1e7", "https://bcr.bazel.build/modules/boost.algorithm/1.83.0.bcr.1/MODULE.bazel": "8657617ad7aa55d179078faa15c131f07ae1bc35e536343211eee2d942368881", @@ -204,8 +216,8 @@ "https://bcr.bazel.build/modules/boringssl/0.20241024.0/source.json": "d843092e682b84188c043ac742965d7f96e04c846c7e338187e03238674909a9", "https://bcr.bazel.build/modules/brotli/1.1.0/MODULE.bazel": "3b5b90488995183419c4b5c9b063a164f6c0bc4d0d6b40550a612a5e860cc0fe", "https://bcr.bazel.build/modules/brotli/1.1.0/source.json": "098a4fd315527166e8dfe1fd1537c96a737a83764be38fc43f4da231d600f3d0", - "https://bcr.bazel.build/modules/buildozer/7.1.2/MODULE.bazel": "2e8dd40ede9c454042645fd8d8d0cd1527966aa5c919de86661e62953cd73d84", - "https://bcr.bazel.build/modules/buildozer/7.1.2/source.json": "c9028a501d2db85793a6996205c8de120944f50a0d570438fcae0457a5f9d1f8", + "https://bcr.bazel.build/modules/buildozer/8.2.1/MODULE.bazel": "61e9433c574c2bd9519cad7fa66b9c1d2b8e8d5f3ae5d6528a2c2d26e68d874d", + "https://bcr.bazel.build/modules/buildozer/8.2.1/source.json": "7c33f6a26ee0216f85544b4bca5e9044579e0219b6898dd653f5fb449cf2e484", "https://bcr.bazel.build/modules/bzip2/1.0.8.bcr.2/MODULE.bazel": "43b570f55b7479bfa7c6675b227ccc3155d56377bb7782f178b2d1733196a435", "https://bcr.bazel.build/modules/bzip2/1.0.8.bcr.2/source.json": "9789bb6c0444ae84fb7f559c9da0fbb46d39219539f8d99c13b8db55357e8cf9", "https://bcr.bazel.build/modules/c-ares/1.15.0/MODULE.bazel": "ba0a78360fdc83f02f437a9e7df0532ad1fbaa59b722f6e715c11effebaa0166", @@ -248,7 +260,8 @@ "https://bcr.bazel.build/modules/googletest/1.14.0.bcr.1/MODULE.bazel": "22c31a561553727960057361aa33bf20fb2e98584bc4fec007906e27053f80c6", "https://bcr.bazel.build/modules/googletest/1.14.0/MODULE.bazel": "cfbcbf3e6eac06ef9d85900f64424708cc08687d1b527f0ef65aa7517af8118f", "https://bcr.bazel.build/modules/googletest/1.15.2/MODULE.bazel": "6de1edc1d26cafb0ea1a6ab3f4d4192d91a312fd2d360b63adaa213cd00b2108", - "https://bcr.bazel.build/modules/googletest/1.15.2/source.json": "dbdda654dcb3a0d7a8bc5d0ac5fc7e150b58c2a986025ae5bc634bb2cb61f470", + "https://bcr.bazel.build/modules/googletest/1.17.0/MODULE.bazel": "dbec758171594a705933a29fcf69293d2468c49ec1f2ebca65c36f504d72df46", + "https://bcr.bazel.build/modules/googletest/1.17.0/source.json": "38e4454b25fc30f15439c0378e57909ab1fd0a443158aa35aec685da727cd713", "https://bcr.bazel.build/modules/grpc-java/1.62.2/MODULE.bazel": "99b8771e8c7cacb130170fed2a10c9e8fed26334a93e73b42d2953250885a158", "https://bcr.bazel.build/modules/grpc-java/1.66.0/MODULE.bazel": "86ff26209fac846adb89db11f3714b3dc0090fb2fb81575673cc74880cda4e7e", "https://bcr.bazel.build/modules/grpc-java/1.66.0/source.json": "f841b339ff8516c86c3a5272cd053194dd0cb2fdd63157123835e1157a28328d", @@ -262,7 +275,8 @@ "https://bcr.bazel.build/modules/grpc/1.68.0/MODULE.bazel": "6691126221dbfd615990cc81d0d9705b74937dbc4206fb9921cb0fc7b4fd4c6a", "https://bcr.bazel.build/modules/grpc/1.68.0/source.json": "790c364e4f4be3d3ce28cdaa919eafb6667bce242b9e252aa880af2018303130", "https://bcr.bazel.build/modules/jsoncpp/1.9.5/MODULE.bazel": "31271aedc59e815656f5736f282bb7509a97c7ecb43e927ac1a37966e0578075", - "https://bcr.bazel.build/modules/jsoncpp/1.9.5/source.json": "4108ee5085dd2885a341c7fab149429db457b3169b86eb081fa245eadf69169d", + "https://bcr.bazel.build/modules/jsoncpp/1.9.6/MODULE.bazel": "2f8d20d3b7d54143213c4dfc3d98225c42de7d666011528dc8fe91591e2e17b0", + "https://bcr.bazel.build/modules/jsoncpp/1.9.6/source.json": "a04756d367a2126c3541682864ecec52f92cdee80a35735a3cb249ce015ca000", "https://bcr.bazel.build/modules/libpfm/4.11.0/MODULE.bazel": "45061ff025b301940f1e30d2c16bea596c25b176c8b6b3087e92615adbd52902", "https://bcr.bazel.build/modules/libpfm/4.11.0/source.json": "caaffb3ac2b59b8aac456917a4ecf3167d40478ee79f15ab7a877ec9273937c9", "https://bcr.bazel.build/modules/lz4/1.9.4/MODULE.bazel": "e3d307b1d354d70f6c809167eafecf5d622c3f27e3971ab7273410f429c7f83a", @@ -284,13 +298,14 @@ "https://bcr.bazel.build/modules/opentracing-cpp/1.6.0/source.json": "da1cb1add160f5e5074b7272e9db6fd8f1b3336c15032cd0a653af9d2f484aed", "https://bcr.bazel.build/modules/platforms/0.0.10/MODULE.bazel": "8cb8efaf200bdeb2150d93e162c40f388529a25852b332cec879373771e48ed5", "https://bcr.bazel.build/modules/platforms/0.0.11/MODULE.bazel": "0daefc49732e227caa8bfa834d65dc52e8cc18a2faf80df25e8caea151a9413f", - "https://bcr.bazel.build/modules/platforms/0.0.11/source.json": "f7e188b79ebedebfe75e9e1d098b8845226c7992b307e28e1496f23112e8fc29", "https://bcr.bazel.build/modules/platforms/0.0.4/MODULE.bazel": "9b328e31ee156f53f3c416a64f8491f7eb731742655a47c9eec4703a71644aee", "https://bcr.bazel.build/modules/platforms/0.0.5/MODULE.bazel": "5733b54ea419d5eaf7997054bb55f6a1d0b5ff8aedf0176fef9eea44f3acda37", "https://bcr.bazel.build/modules/platforms/0.0.6/MODULE.bazel": "ad6eeef431dc52aefd2d77ed20a4b353f8ebf0f4ecdd26a807d2da5aa8cd0615", "https://bcr.bazel.build/modules/platforms/0.0.7/MODULE.bazel": "72fd4a0ede9ee5c021f6a8dd92b503e089f46c227ba2813ff183b71616034814", "https://bcr.bazel.build/modules/platforms/0.0.8/MODULE.bazel": "9f142c03e348f6d263719f5074b21ef3adf0b139ee4c5133e2aa35664da9eb2d", "https://bcr.bazel.build/modules/platforms/0.0.9/MODULE.bazel": "4a87a60c927b56ddd67db50c89acaa62f4ce2a1d2149ccb63ffd871d5ce29ebc", + "https://bcr.bazel.build/modules/platforms/1.0.0/MODULE.bazel": "f05feb42b48f1b3c225e4ccf351f367be0371411a803198ec34a389fb22aa580", + "https://bcr.bazel.build/modules/platforms/1.0.0/source.json": "f4ff1fd412e0246fd38c82328eb209130ead81d62dcd5a9e40910f867f733d96", "https://bcr.bazel.build/modules/prometheus-cpp/1.2.4/MODULE.bazel": "0fbe5dcff66311947a3f6b86ebc6a6d9328e31a28413ca864debc4a043f371e5", "https://bcr.bazel.build/modules/prometheus-cpp/1.3.0/MODULE.bazel": "ce82e086bbc0b60267e970f6a54b2ca6d0f22d3eb6633e00e2cc2899c700f3d8", "https://bcr.bazel.build/modules/prometheus-cpp/1.3.0/source.json": "8cb66b4e535afc718e9d104a3db96ccb71a42ee816a100e50fd0d5ac843c0606", @@ -307,10 +322,13 @@ "https://bcr.bazel.build/modules/protobuf/28.3/MODULE.bazel": "2b3764bbab2e46703412bd3b859efcf0322638ed015e88432df3bb740507a1e9", "https://bcr.bazel.build/modules/protobuf/29.0-rc2/MODULE.bazel": "6241d35983510143049943fc0d57937937122baf1b287862f9dc8590fc4c37df", "https://bcr.bazel.build/modules/protobuf/29.0-rc3/MODULE.bazel": "33c2dfa286578573afc55a7acaea3cada4122b9631007c594bf0729f41c8de92", - "https://bcr.bazel.build/modules/protobuf/29.0-rc3/source.json": "c16a6488fb279ef578da7098e605082d72ed85fc8d843eaae81e7d27d0f4625d", + "https://bcr.bazel.build/modules/protobuf/29.1/MODULE.bazel": "557c3457560ff49e122ed76c0bc3397a64af9574691cb8201b4e46d4ab2ecb95", "https://bcr.bazel.build/modules/protobuf/3.19.0/MODULE.bazel": "6b5fbb433f760a99a22b18b6850ed5784ef0e9928a72668b66e4d7ccd47db9b0", "https://bcr.bazel.build/modules/protobuf/3.19.2/MODULE.bazel": "532ffe5f2186b69fdde039efe6df13ba726ff338c6bc82275ad433013fa10573", "https://bcr.bazel.build/modules/protobuf/3.19.6/MODULE.bazel": "9233edc5e1f2ee276a60de3eaa47ac4132302ef9643238f23128fea53ea12858", + "https://bcr.bazel.build/modules/protobuf/32.1/MODULE.bazel": "89cd2866a9cb07fee9ff74c41ceace11554f32e0d849de4e23ac55515cfada4d", + "https://bcr.bazel.build/modules/protobuf/33.4/MODULE.bazel": "114775b816b38b6d0ca620450d6b02550c60ceedfdc8d9a229833b34a223dc42", + "https://bcr.bazel.build/modules/protobuf/33.4/source.json": "555f8686b4c7d6b5ba731fbea13bf656b4bfd9a7ff629c1d9d3f6e1d6155de79", "https://bcr.bazel.build/modules/protoc-gen-validate/1.0.4/MODULE.bazel": "b8913c154b16177990f6126d2d2477d187f9ddc568e95ee3e2d50fc65d2c494a", "https://bcr.bazel.build/modules/protoc-gen-validate/1.0.4/source.json": "541f6bbab589ea06cca29235d178bf6d2f282576593b2ce4b3802132d8ad740b", "https://bcr.bazel.build/modules/pybind11_bazel/2.11.1/MODULE.bazel": "88af1c246226d87e65be78ed49ecd1e6f5e98648558c14ce99176da041dc378e", @@ -322,13 +340,16 @@ "https://bcr.bazel.build/modules/re2/2021-09-01/MODULE.bazel": "bcb6b96f3b071e6fe2d8bed9cc8ada137a105f9d2c5912e91d27528b3d123833", "https://bcr.bazel.build/modules/re2/2023-09-01/MODULE.bazel": "cb3d511531b16cfc78a225a9e2136007a48cf8a677e4264baeab57fe78a80206", "https://bcr.bazel.build/modules/re2/2024-05-01/MODULE.bazel": "55a3f059538f381107824e7d00df5df6d061ba1fb80e874e4909c0f0549e8f3e", + "https://bcr.bazel.build/modules/re2/2024-07-02.bcr.1/MODULE.bazel": "b4963dda9b31080be1905ef085ecd7dd6cd47c05c79b9cdf83ade83ab2ab271a", + "https://bcr.bazel.build/modules/re2/2024-07-02.bcr.1/source.json": "2ff292be6ef3340325ce8a045ecc326e92cbfab47c7cbab4bd85d28971b97ac4", "https://bcr.bazel.build/modules/re2/2024-07-02/MODULE.bazel": "0eadc4395959969297cbcf31a249ff457f2f1d456228c67719480205aa306daa", - "https://bcr.bazel.build/modules/re2/2024-07-02/source.json": "547d0111a9d4f362db32196fef805abbf3676e8d6afbe44d395d87816c1130ca", "https://bcr.bazel.build/modules/rules_android/0.1.1/MODULE.bazel": "48809ab0091b07ad0182defb787c4c5328bd3a278938415c00a7b69b50c4d3a8", "https://bcr.bazel.build/modules/rules_android/0.1.1/source.json": "e6986b41626ee10bdc864937ffb6d6bf275bb5b9c65120e6137d56e6331f089e", "https://bcr.bazel.build/modules/rules_apple/3.13.0/MODULE.bazel": "b4559a2c6281ca3165275bb36c1f0ac74666632adc5bdb680e366de7ce845f43", - "https://bcr.bazel.build/modules/rules_apple/3.13.0/source.json": "fe31c678e2256daa91a802664b578c1de71dc43a49a7ccc16db001378f312cd3", + "https://bcr.bazel.build/modules/rules_apple/3.16.0/MODULE.bazel": "0d1caf0b8375942ce98ea944be754a18874041e4e0459401d925577624d3a54a", "https://bcr.bazel.build/modules/rules_apple/3.5.1/MODULE.bazel": "3d1bbf65ad3692003d36d8a29eff54d4e5c1c5f4bfb60f79e28646a924d9101c", + "https://bcr.bazel.build/modules/rules_apple/4.1.0/MODULE.bazel": "76e10fd4a48038d3fc7c5dc6e63b7063bbf5304a2e3bd42edda6ec660eebea68", + "https://bcr.bazel.build/modules/rules_apple/4.1.0/source.json": "8ee81e1708756f81b343a5eb2b2f0b953f1d25c4ab3d4a68dc02754872e80715", "https://bcr.bazel.build/modules/rules_buf/0.1.1/MODULE.bazel": "6189aec18a4f7caff599ad41b851ab7645d4f1e114aa6431acf9b0666eb92162", "https://bcr.bazel.build/modules/rules_buf/0.1.1/source.json": "021363d254f7438f3f10725355969c974bb2c67e0c28667782ade31a9cdb747f", "https://bcr.bazel.build/modules/rules_cc/0.0.1/MODULE.bazel": "cb2aa0747f84c6c3a78dad4e2049c154f08ab9d166b1273835a8174940365647", @@ -345,7 +366,13 @@ "https://bcr.bazel.build/modules/rules_cc/0.0.8/MODULE.bazel": "964c85c82cfeb6f3855e6a07054fdb159aced38e99a5eecf7bce9d53990afa3e", "https://bcr.bazel.build/modules/rules_cc/0.0.9/MODULE.bazel": "836e76439f354b89afe6a911a7adf59a6b2518fafb174483ad78a2a2fde7b1c5", "https://bcr.bazel.build/modules/rules_cc/0.1.1/MODULE.bazel": "2f0222a6f229f0bf44cd711dc13c858dad98c62d52bd51d8fc3a764a83125513", - "https://bcr.bazel.build/modules/rules_cc/0.1.1/source.json": "d61627377bd7dd1da4652063e368d9366fc9a73920bfa396798ad92172cf645c", + "https://bcr.bazel.build/modules/rules_cc/0.1.2/MODULE.bazel": "557ddc3a96858ec0d465a87c0a931054d7dcfd6583af2c7ed3baf494407fd8d0", + "https://bcr.bazel.build/modules/rules_cc/0.1.5/MODULE.bazel": "88dfc9361e8b5ae1008ac38f7cdfd45ad738e4fa676a3ad67d19204f045a1fd8", + "https://bcr.bazel.build/modules/rules_cc/0.2.0/MODULE.bazel": "b5c17f90458caae90d2ccd114c81970062946f49f355610ed89bebf954f5783c", + "https://bcr.bazel.build/modules/rules_cc/0.2.13/MODULE.bazel": "eecdd666eda6be16a8d9dc15e44b5c75133405e820f620a234acc4b1fdc5aa37", + "https://bcr.bazel.build/modules/rules_cc/0.2.14/MODULE.bazel": "353c99ed148887ee89c54a17d4100ae7e7e436593d104b668476019023b58df8", + "https://bcr.bazel.build/modules/rules_cc/0.2.14/source.json": "55d0a4587c5592fad350f6e698530f4faf0e7dd15e69d43f8d87e220c78bea54", + "https://bcr.bazel.build/modules/rules_cc/0.2.8/MODULE.bazel": "f1df20f0bf22c28192a794f29b501ee2018fa37a3862a1a2132ae2940a23a642", "https://bcr.bazel.build/modules/rules_cuda/0.2.3/MODULE.bazel": "34f74fba6882781153461e62aded821ed3e5197f15e0f2b9b3eef76c9be0f44c", "https://bcr.bazel.build/modules/rules_cuda/0.2.3/source.json": "a2e128ec4699c65db24d9305215090d95bbd0cbb98e98058f82328f194a8ec68", "https://bcr.bazel.build/modules/rules_foreign_cc/0.10.1/MODULE.bazel": "b9527010e5fef060af92b6724edb3691970a5b1f76f74b21d39f7d433641be60", @@ -354,7 +381,6 @@ "https://bcr.bazel.build/modules/rules_foreign_cc/0.14.0/source.json": "64ccb6c4bff8afc336a24af2487b4557b8d2b13f981f2d8190983bc196b36a68", "https://bcr.bazel.build/modules/rules_foreign_cc/0.9.0/MODULE.bazel": "c9e8c682bf75b0e7c704166d79b599f93b72cfca5ad7477df596947891feeef6", "https://bcr.bazel.build/modules/rules_fuzzing/0.5.2/MODULE.bazel": "40c97d1144356f52905566c55811f13b299453a14ac7769dfba2ac38192337a8", - "https://bcr.bazel.build/modules/rules_fuzzing/0.5.2/source.json": "c8b1e2c717646f1702290959a3302a178fb639d987ab61d548105019f11e527e", "https://bcr.bazel.build/modules/rules_go/0.33.0/MODULE.bazel": "a2b11b64cd24bf94f57454f53288a5dacfe6cb86453eee7761b7637728c1910c", "https://bcr.bazel.build/modules/rules_go/0.38.1/MODULE.bazel": "fb8e73dd3b6fc4ff9d260ceacd830114891d49904f5bda1c16bc147bcc254f71", "https://bcr.bazel.build/modules/rules_go/0.39.1/MODULE.bazel": "d34fb2a249403a5f4339c754f1e63dc9e5ad70b47c5e97faee1441fc6636cd61", @@ -379,11 +405,12 @@ "https://bcr.bazel.build/modules/rules_java/7.3.2/MODULE.bazel": "50dece891cfdf1741ea230d001aa9c14398062f2b7c066470accace78e412bc2", "https://bcr.bazel.build/modules/rules_java/7.4.0/MODULE.bazel": "a592852f8a3dd539e82ee6542013bf2cadfc4c6946be8941e189d224500a8934", "https://bcr.bazel.build/modules/rules_java/7.6.1/MODULE.bazel": "2f14b7e8a1aa2f67ae92bc69d1ec0fa8d9f827c4e17ff5e5f02e91caa3b2d0fe", - "https://bcr.bazel.build/modules/rules_java/7.6.5/MODULE.bazel": "481164be5e02e4cab6e77a36927683263be56b7e36fef918b458d7a8a1ebadb1", "https://bcr.bazel.build/modules/rules_java/8.3.2/MODULE.bazel": "7336d5511ad5af0b8615fdc7477535a2e4e723a357b6713af439fe8cf0195017", "https://bcr.bazel.build/modules/rules_java/8.5.0/MODULE.bazel": "c081eda83625b6d97144f2da9dd5f074ecd56ba10f238257e7a90f56ee8a9c3c", "https://bcr.bazel.build/modules/rules_java/8.5.1/MODULE.bazel": "d8a9e38cc5228881f7055a6079f6f7821a073df3744d441978e7a43e20226939", - "https://bcr.bazel.build/modules/rules_java/8.5.1/source.json": "db1a77d81b059e0f84985db67a22f3f579a529a86b7997605be3d214a0abe38e", + "https://bcr.bazel.build/modules/rules_java/8.6.1/MODULE.bazel": "f4808e2ab5b0197f094cabce9f4b006a27766beb6a9975931da07099560ca9c2", + "https://bcr.bazel.build/modules/rules_java/9.0.3/MODULE.bazel": "1f98ed015f7e744a745e0df6e898a7c5e83562d6b759dfd475c76456dda5ccea", + "https://bcr.bazel.build/modules/rules_java/9.0.3/source.json": "b038c0c07e12e658135bbc32cc1a2ded6e33785105c9d41958014c592de4593e", "https://bcr.bazel.build/modules/rules_jvm_external/4.4.2/MODULE.bazel": "a56b85e418c83eb1839819f0b515c431010160383306d13ec21959ac412d2fe7", "https://bcr.bazel.build/modules/rules_jvm_external/5.1/MODULE.bazel": "33f6f999e03183f7d088c9be518a63467dfd0be94a11d0055fe2d210f89aa909", "https://bcr.bazel.build/modules/rules_jvm_external/5.2/MODULE.bazel": "d9351ba35217ad0de03816ef3ed63f89d411349353077348a45348b096615036", @@ -391,7 +418,8 @@ "https://bcr.bazel.build/modules/rules_jvm_external/6.0/MODULE.bazel": "37c93a5a78d32e895d52f86a8d0416176e915daabd029ccb5594db422e87c495", "https://bcr.bazel.build/modules/rules_jvm_external/6.1/MODULE.bazel": "75b5fec090dbd46cf9b7d8ea08cf84a0472d92ba3585b476f44c326eda8059c4", "https://bcr.bazel.build/modules/rules_jvm_external/6.3/MODULE.bazel": "c998e060b85f71e00de5ec552019347c8bca255062c990ac02d051bb80a38df0", - "https://bcr.bazel.build/modules/rules_jvm_external/6.3/source.json": "6f5f5a5a4419ae4e37c35a5bb0a6ae657ed40b7abc5a5189111b47fcebe43197", + "https://bcr.bazel.build/modules/rules_jvm_external/6.7/MODULE.bazel": "e717beabc4d091ecb2c803c2d341b88590e9116b8bf7947915eeb33aab4f96dd", + "https://bcr.bazel.build/modules/rules_jvm_external/6.7/source.json": "5426f412d0a7fc6b611643376c7e4a82dec991491b9ce5cb1cfdd25fe2e92be4", "https://bcr.bazel.build/modules/rules_kotlin/1.9.0/MODULE.bazel": "ef85697305025e5a61f395d4eaede272a5393cee479ace6686dba707de804d59", "https://bcr.bazel.build/modules/rules_kotlin/1.9.6/MODULE.bazel": "d269a01a18ee74d0335450b10f62c9ed81f2321d7958a2934e44272fe82dcef3", "https://bcr.bazel.build/modules/rules_kotlin/1.9.6/source.json": "2faa4794364282db7c06600b7e5e34867a564ae91bda7cae7c29c64e9466b7d5", @@ -412,7 +440,8 @@ "https://bcr.bazel.build/modules/rules_proto/6.0.0/MODULE.bazel": "b531d7f09f58dce456cd61b4579ce8c86b38544da75184eadaf0a7cb7966453f", "https://bcr.bazel.build/modules/rules_proto/6.0.2/MODULE.bazel": "ce916b775a62b90b61888052a416ccdda405212b6aaeb39522f7dc53431a5e73", "https://bcr.bazel.build/modules/rules_proto/7.0.2/MODULE.bazel": "bf81793bd6d2ad89a37a40693e56c61b0ee30f7a7fdbaf3eabbf5f39de47dea2", - "https://bcr.bazel.build/modules/rules_proto/7.0.2/source.json": "1e5e7260ae32ef4f2b52fd1d0de8d03b606a44c91b694d2f1afb1d3b28a48ce1", + "https://bcr.bazel.build/modules/rules_proto/7.1.0/MODULE.bazel": "002d62d9108f75bb807cd56245d45648f38275cb3a99dcd45dfb864c5d74cb96", + "https://bcr.bazel.build/modules/rules_proto/7.1.0/source.json": "39f89066c12c24097854e8f57ab8558929f9c8d474d34b2c00ac04630ad8940e", "https://bcr.bazel.build/modules/rules_proto_grpc/5.0.1/MODULE.bazel": "af7a76546e6fb5cfb37d30ece061bad276ceb785eb4ea43d6f74fc35cff71dfc", "https://bcr.bazel.build/modules/rules_proto_grpc/5.0.1/source.json": "eb2a5cd4344970803514e64bce3bb16840fe9476a4e9695d95c6e0475d821606", "https://bcr.bazel.build/modules/rules_proto_grpc_cpp/5.0.1/MODULE.bazel": "2bd7210df98e3690c7146b7679b1361a802eb01ec9431167ef5cafc641d9c94d", @@ -432,17 +461,24 @@ "https://bcr.bazel.build/modules/rules_python/0.4.0/MODULE.bazel": "9208ee05fd48bf09ac60ed269791cf17fb343db56c8226a720fbb1cdf467166c", "https://bcr.bazel.build/modules/rules_python/0.40.0/MODULE.bazel": "9d1a3cd88ed7d8e39583d9ffe56ae8a244f67783ae89b60caafc9f5cf318ada7", "https://bcr.bazel.build/modules/rules_python/1.1.0/MODULE.bazel": "57e01abae22956eb96d891572490d20e07d983e0c065de0b2170cafe5053e788", - "https://bcr.bazel.build/modules/rules_python/1.1.0/source.json": "29f1fdfd23a40808c622f813bc93e29c3aae277333f03293f667e76159750a0f", + "https://bcr.bazel.build/modules/rules_python/1.3.0/MODULE.bazel": "8361d57eafb67c09b75bf4bbe6be360e1b8f4f18118ab48037f2bd50aa2ccb13", + "https://bcr.bazel.build/modules/rules_python/1.4.1/MODULE.bazel": "8991ad45bdc25018301d6b7e1d3626afc3c8af8aaf4bc04f23d0b99c938b73a6", + "https://bcr.bazel.build/modules/rules_python/1.6.0/MODULE.bazel": "7e04ad8f8d5bea40451cf80b1bd8262552aa73f841415d20db96b7241bd027d8", + "https://bcr.bazel.build/modules/rules_python/1.7.0/MODULE.bazel": "d01f995ecd137abf30238ad9ce97f8fc3ac57289c8b24bd0bf53324d937a14f8", + "https://bcr.bazel.build/modules/rules_python/1.7.0/source.json": "028a084b65dcf8f4dc4f82f8778dbe65df133f234b316828a82e060d81bdce32", "https://bcr.bazel.build/modules/rules_rust/0.45.1/MODULE.bazel": "a69d0db3a958fab2c6520961e1b2287afcc8b36690fd31bbc4f6f7391397150d", "https://bcr.bazel.build/modules/rules_rust/0.53.0/MODULE.bazel": "00d5143caaa8d2caa7cc06f6c28e57510e76aa1eee0dfc9ba4914c1a2a5ac046", "https://bcr.bazel.build/modules/rules_rust/0.53.0/source.json": "084705abc2de9216e75a3d012993d3ea86999ecbc6e3f93fa9e986925343b513", "https://bcr.bazel.build/modules/rules_shell/0.2.0/MODULE.bazel": "fda8a652ab3c7d8fee214de05e7a9916d8b28082234e8d2c0094505c5268ed3c", "https://bcr.bazel.build/modules/rules_shell/0.3.0/MODULE.bazel": "de4402cd12f4cc8fda2354fce179fdb068c0b9ca1ec2d2b17b3e21b24c1a937b", - "https://bcr.bazel.build/modules/rules_shell/0.3.0/source.json": "c55ed591aa5009401ddf80ded9762ac32c358d2517ee7820be981e2de9756cf3", + "https://bcr.bazel.build/modules/rules_shell/0.6.1/MODULE.bazel": "72e76b0eea4e81611ef5452aa82b3da34caca0c8b7b5c0c9584338aa93bae26b", + "https://bcr.bazel.build/modules/rules_shell/0.6.1/source.json": "20ec05cd5e592055e214b2da8ccb283c7f2a421ea0dc2acbf1aa792e11c03d0c", "https://bcr.bazel.build/modules/rules_swift/1.16.0/MODULE.bazel": "4a09f199545a60d09895e8281362b1ff3bb08bbde69c6fc87aff5b92fcc916ca", "https://bcr.bazel.build/modules/rules_swift/1.18.0/MODULE.bazel": "a6aba73625d0dc64c7b4a1e831549b6e375fbddb9d2dde9d80c9de6ec45b24c9", "https://bcr.bazel.build/modules/rules_swift/2.1.1/MODULE.bazel": "494900a80f944fc7aa61500c2073d9729dff0b764f0e89b824eb746959bc1046", - "https://bcr.bazel.build/modules/rules_swift/2.1.1/source.json": "40fc69dfaac64deddbb75bd99cdac55f4427d9ca0afbe408576a65428427a186", + "https://bcr.bazel.build/modules/rules_swift/2.4.0/MODULE.bazel": "1639617eb1ede28d774d967a738b4a68b0accb40650beadb57c21846beab5efd", + "https://bcr.bazel.build/modules/rules_swift/3.1.2/MODULE.bazel": "72c8f5cf9d26427cee6c76c8e3853eb46ce6b0412a081b2b6db6e8ad56267400", + "https://bcr.bazel.build/modules/rules_swift/3.1.2/source.json": "e85761f3098a6faf40b8187695e3de6d97944e98abd0d8ce579cb2daf6319a66", "https://bcr.bazel.build/modules/snappy/1.1.8/MODULE.bazel": "46aa045007302f9f20392147893f27652f1f862b5bf2151f33ecf1d96ec311f7", "https://bcr.bazel.build/modules/snappy/1.2.1/MODULE.bazel": "ccfc05c2f321f33fa4190a57280f3b0b428982f7c66618f2acadf162fa0bbb95", "https://bcr.bazel.build/modules/snappy/1.2.1/source.json": "9a3e0181edc27543b4304f377a216ad09e014859db57921261552d0a4939ee1d", @@ -458,7 +494,8 @@ "https://bcr.bazel.build/modules/stardoc/0.7.2/MODULE.bazel": "fc152419aa2ea0f51c29583fab1e8c99ddefd5b3778421845606ee628629e0e5", "https://bcr.bazel.build/modules/stardoc/0.7.2/source.json": "58b029e5e901d6802967754adf0a9056747e8176f017cfe3607c0851f4d42216", "https://bcr.bazel.build/modules/swift_argument_parser/1.3.1.1/MODULE.bazel": "5e463fbfba7b1701d957555ed45097d7f984211330106ccd1352c6e0af0dcf91", - "https://bcr.bazel.build/modules/swift_argument_parser/1.3.1.1/source.json": "32bd87e5f4d7acc57c5b2ff7c325ae3061d5e242c0c4c214ae87e0f1c13e54cb", + "https://bcr.bazel.build/modules/swift_argument_parser/1.3.1.2/MODULE.bazel": "75aab2373a4bbe2a1260b9bf2a1ebbdbf872d3bd36f80bff058dccd82e89422f", + "https://bcr.bazel.build/modules/swift_argument_parser/1.3.1.2/source.json": "5fba48bbe0ba48761f9e9f75f92876cafb5d07c0ce059cc7a8027416de94a05b", "https://bcr.bazel.build/modules/toolchains_protoc/0.3.1/MODULE.bazel": "b6574a2a314cbd40cafb5ed87b03d1996e015315f80a7e33116c8b2e209cb5cf", "https://bcr.bazel.build/modules/toolchains_protoc/0.3.6/MODULE.bazel": "33add32ebda5f8167b3086585d0f7720086d24b764a06b99c02cf705889ae9bb", "https://bcr.bazel.build/modules/toolchains_protoc/0.3.6/source.json": "10276ae623c4f16fa3c35654e1949ef72bb5fa79ece3a8b93d05c4a6b1b25865", @@ -475,7 +512,8 @@ "https://bcr.bazel.build/modules/zlib/1.2.13/MODULE.bazel": "aa6deb1b83c18ffecd940c4119aff9567cd0a671d7bba756741cb2ef043a29d5", "https://bcr.bazel.build/modules/zlib/1.3.1.bcr.1/MODULE.bazel": "6a9fe6e3fc865715a7be9823ce694ceb01e364c35f7a846bf0d2b34762bc066b", "https://bcr.bazel.build/modules/zlib/1.3.1.bcr.3/MODULE.bazel": "af322bc08976524477c79d1e45e241b6efbeb918c497e8840b8ab116802dda79", - "https://bcr.bazel.build/modules/zlib/1.3.1.bcr.3/source.json": "2be409ac3c7601245958cd4fcdff4288be79ed23bd690b4b951f500d54ee6e7d", + "https://bcr.bazel.build/modules/zlib/1.3.1.bcr.5/MODULE.bazel": "eec517b5bbe5492629466e11dae908d043364302283de25581e3eb944326c4ca", + "https://bcr.bazel.build/modules/zlib/1.3.1.bcr.5/source.json": "22bc55c47af97246cfc093d0acf683a7869377de362b5d1c552c2c2e16b7a806", "https://bcr.bazel.build/modules/zlib/1.3.1/MODULE.bazel": "751c9940dcfe869f5f7274e1295422a34623555916eb98c174c1e945594bf198", "https://bcr.bazel.build/modules/zlib/1.3/MODULE.bazel": "6a9c02f19a24dcedb05572b2381446e27c272cd383aed11d41d99da9e3167a72", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/bazel_registry.json": "8a28e4aff06ee60aed2a8c281907fb8bcbf3b753c91fb5a5c57da3215d5b3497", @@ -491,11 +529,16 @@ "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/abseil-cpp/20240116.2/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/abseil-cpp/20240722.0.bcr.1/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/abseil-cpp/20240722.0/MODULE.bazel": "not found", + "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/abseil-cpp/20250127.1/MODULE.bazel": "not found", + "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/abseil-cpp/20250512.1/MODULE.bazel": "not found", + "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/abseil-cpp/20250814.1/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/apple_support/1.11.1/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/apple_support/1.13.0/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/apple_support/1.15.1/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/apple_support/1.17.1/MODULE.bazel": "not found", - "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/apple_support/1.5.0/MODULE.bazel": "not found", + "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/apple_support/1.21.0/MODULE.bazel": "not found", + "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/apple_support/1.21.1/MODULE.bazel": "not found", + "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/apple_support/1.24.2/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/arrow/14.0.2.bcr.1/MODULE.bazel": "0945ecdab89e7ebf9f12476909c8e17774edb923540c73a5d0472efd6ed2bbf1", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/arrow/14.0.2.bcr.1/source.json": "0bc16f5f464b746ae87bf70d12c00448b92728474a9bff6828d51aaf638e91f8", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/aspect_bazel_lib/1.31.2/MODULE.bazel": "not found", @@ -523,8 +566,13 @@ "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/bazel_features/1.19.0/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/bazel_features/1.20.0/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/bazel_features/1.21.0/MODULE.bazel": "not found", + "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/bazel_features/1.23.0/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/bazel_features/1.24.0/MODULE.bazel": "not found", + "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/bazel_features/1.27.0/MODULE.bazel": "not found", + "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/bazel_features/1.28.0/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/bazel_features/1.3.0/MODULE.bazel": "not found", + "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/bazel_features/1.30.0/MODULE.bazel": "not found", + "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/bazel_features/1.33.0/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/bazel_features/1.4.1/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/bazel_features/1.9.0/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/bazel_features/1.9.1/MODULE.bazel": "not found", @@ -540,6 +588,8 @@ "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/bazel_skylib/1.6.1/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/bazel_skylib/1.7.0/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/bazel_skylib/1.7.1/MODULE.bazel": "not found", + "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/bazel_skylib/1.8.1/MODULE.bazel": "not found", + "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/bazel_skylib/1.8.2/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/blake3/1.5.4/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/boost.algorithm/1.83.0.bcr.1/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/boost.array/1.83.0.bcr.1/MODULE.bazel": "not found", @@ -637,7 +687,7 @@ "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/brotli/1.1.0/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/brpc/1.11.0-20241212-282bc90/MODULE.bazel": "5a196ed0f1f129bde2001f3db5f1a991812714b207aa61ade34dcc78ec02a054", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/brpc/1.11.0-20241212-282bc90/source.json": "f6e42db7df330bf035a012fe56130ddd8e64bfacfbb007c3798ac417a9635665", - "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/buildozer/7.1.2/MODULE.bazel": "not found", + "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/buildozer/8.2.1/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/bzip2/1.0.8.bcr.2/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/c-ares/1.15.0/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/c-ares/1.16.1/MODULE.bazel": "not found", @@ -673,6 +723,7 @@ "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/googletest/1.14.0.bcr.1/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/googletest/1.14.0/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/googletest/1.15.2/MODULE.bazel": "not found", + "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/googletest/1.17.0/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/grpc-java/1.62.2/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/grpc-java/1.66.0/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/grpc-proto/0.0.0-20240627-ec30f58/MODULE.bazel": "not found", @@ -691,6 +742,7 @@ "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/ippcp/2021.8.bcr.2/MODULE.bazel": "34e4bf82778258a13393ecf7828fee728124c3d4c07941fed56f5fcafe73f04d", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/ippcp/2021.8.bcr.2/source.json": "4a4a758ddf4292e9af6f7c6b1cd014758982a54c2dd3c50fb1912ceec68a5b69", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/jsoncpp/1.9.5/MODULE.bazel": "not found", + "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/jsoncpp/1.9.6/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/kuscia/0.14.0b0/MODULE.bazel": "ca497d1769276104afd4df13c080db068a790e0e073a13ff5564520ea695f312", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/kuscia/0.14.0b0/source.json": "03e55f9cfeaef0339a5c5f0bda7ae1cbccad98203a9cfc28023af16d0db1b719", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/leveldb/1.23/MODULE.bazel": "450b5dafff03fd68d2c57544e0cdca1411e9cf42ae599e31fbbbfdf1ddea92b3", @@ -736,6 +788,7 @@ "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/platforms/0.0.7/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/platforms/0.0.8/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/platforms/0.0.9/MODULE.bazel": "not found", + "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/platforms/1.0.0/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/prometheus-cpp/1.2.4/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/prometheus-cpp/1.3.0/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/protobuf/21.7/MODULE.bazel": "not found", @@ -751,9 +804,12 @@ "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/protobuf/28.3/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/protobuf/29.0-rc2/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/protobuf/29.0-rc3/MODULE.bazel": "not found", + "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/protobuf/29.1/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/protobuf/3.19.0/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/protobuf/3.19.2/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/protobuf/3.19.6/MODULE.bazel": "not found", + "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/protobuf/32.1/MODULE.bazel": "not found", + "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/protobuf/33.4/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/protoc-gen-validate/1.0.4/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/pybind11_bazel/2.11.1/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/pybind11_bazel/2.12.0/MODULE.bazel": "not found", @@ -762,10 +818,13 @@ "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/re2/2021-09-01/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/re2/2023-09-01/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/re2/2024-05-01/MODULE.bazel": "not found", + "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/re2/2024-07-02.bcr.1/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/re2/2024-07-02/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_android/0.1.1/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_apple/3.13.0/MODULE.bazel": "not found", + "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_apple/3.16.0/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_apple/3.5.1/MODULE.bazel": "not found", + "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_apple/4.1.0/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_buf/0.1.1/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_cc/0.0.1/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_cc/0.0.10/MODULE.bazel": "not found", @@ -781,6 +840,12 @@ "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_cc/0.0.8/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_cc/0.0.9/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_cc/0.1.1/MODULE.bazel": "not found", + "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_cc/0.1.2/MODULE.bazel": "not found", + "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_cc/0.1.5/MODULE.bazel": "not found", + "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_cc/0.2.0/MODULE.bazel": "not found", + "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_cc/0.2.13/MODULE.bazel": "not found", + "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_cc/0.2.14/MODULE.bazel": "not found", + "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_cc/0.2.8/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_cuda/0.2.3/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_foreign_cc/0.10.1/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_foreign_cc/0.12.0/MODULE.bazel": "not found", @@ -810,10 +875,11 @@ "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_java/7.3.2/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_java/7.4.0/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_java/7.6.1/MODULE.bazel": "not found", - "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_java/7.6.5/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_java/8.3.2/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_java/8.5.0/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_java/8.5.1/MODULE.bazel": "not found", + "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_java/8.6.1/MODULE.bazel": "not found", + "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_java/9.0.3/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_jvm_external/4.4.2/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_jvm_external/5.1/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_jvm_external/5.2/MODULE.bazel": "not found", @@ -821,6 +887,7 @@ "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_jvm_external/6.0/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_jvm_external/6.1/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_jvm_external/6.3/MODULE.bazel": "not found", + "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_jvm_external/6.7/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_kotlin/1.9.0/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_kotlin/1.9.6/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_license/0.0.3/MODULE.bazel": "not found", @@ -837,6 +904,7 @@ "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_proto/6.0.0/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_proto/6.0.2/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_proto/7.0.2/MODULE.bazel": "not found", + "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_proto/7.1.0/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_proto_grpc/5.0.1/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_proto_grpc_cpp/5.0.1/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_python/0.10.2/MODULE.bazel": "not found", @@ -854,13 +922,20 @@ "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_python/0.4.0/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_python/0.40.0/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_python/1.1.0/MODULE.bazel": "not found", + "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_python/1.3.0/MODULE.bazel": "not found", + "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_python/1.4.1/MODULE.bazel": "not found", + "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_python/1.6.0/MODULE.bazel": "not found", + "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_python/1.7.0/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_rust/0.45.1/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_rust/0.53.0/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_shell/0.2.0/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_shell/0.3.0/MODULE.bazel": "not found", + "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_shell/0.6.1/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_swift/1.16.0/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_swift/1.18.0/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_swift/2.1.1/MODULE.bazel": "not found", + "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_swift/2.4.0/MODULE.bazel": "not found", + "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_swift/3.1.2/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/seal/3.6.6/MODULE.bazel": "4304d0e7a29a1ce6d9a30c8d8a0b7bda723137969a418a01e9e5b440972d7e54", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/seal/4.1.1/MODULE.bazel": "aed9d12e7fd3140779228eaf700e7e1efe71e80594dd589f433a60f408e0fc08", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/seal/4.1.1/source.json": "783bcceef2a67354c537dcf24b51a4494445d7244c1a76943e916bacab5011ba", @@ -882,6 +957,7 @@ "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/stardoc/0.7.1/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/stardoc/0.7.2/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/swift_argument_parser/1.3.1.1/MODULE.bazel": "not found", + "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/swift_argument_parser/1.3.1.2/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/thrift/0.21.0/MODULE.bazel": "f157630e05b8183ad1d592ff3e7fb8cf534cc0fd99d86b0ebc98006a16aeb83a", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/thrift/0.21.0/source.json": "c80ef0d1672b469221b142bd338330d0f9c2077015c7e28b7e0018c42bdd1d6c", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/tongsuo/8.4.0/MODULE.bazel": "3dc48d7ed3ab2b713fe4b6466d0f99aa1991f8a0b654ef292c39ec7811b350d1", @@ -903,6 +979,7 @@ "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/zlib/1.2.13/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/zlib/1.3.1.bcr.1/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/zlib/1.3.1.bcr.3/MODULE.bazel": "not found", + "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/zlib/1.3.1.bcr.5/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/zlib/1.3.1/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/zlib/1.3/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/zstd/1.5.6/MODULE.bazel": "b838bc765643a0b30bc0292173f514d61eea67a521f70579c1bc3856fd2a0b44", @@ -910,429 +987,328 @@ }, "selectedYankedVersions": {}, "moduleExtensions": { - "@@apple_support~//crosstool:setup.bzl%apple_cc_configure_extension": { + "@@aspect_bazel_lib+//lib:extensions.bzl%toolchains": { "general": { - "bzlTransitiveDigest": "7ii+gFxWSxHhQPrBxfMEHhtrGvHmBTvsh+KOyGunP/s=", - "usagesDigest": "UiAF9938di1gOhJwL28iBIAxs2tFSyv4b53rv5EZZpA=", - "recordedFileInputs": {}, - "recordedDirentsInputs": {}, - "envVariables": {}, - "generatedRepoSpecs": { - "local_config_apple_cc_toolchains": { - "bzlFile": "@@apple_support~//crosstool:setup.bzl", - "ruleClassName": "_apple_cc_autoconf_toolchains", - "attributes": {} - }, - "local_config_apple_cc": { - "bzlFile": "@@apple_support~//crosstool:setup.bzl", - "ruleClassName": "_apple_cc_autoconf", - "attributes": {} - } - }, - "recordedRepoMappingEntries": [ - [ - "apple_support~", - "bazel_tools", - "bazel_tools" - ] - ] - } - }, - "@@aspect_bazel_lib~//lib:extensions.bzl%toolchains": { - "general": { - "bzlTransitiveDigest": "wbW/fEUW6Ya4TMFK5PPIgAwWuJm4AQFeqnOO5DbiZjw=", - "usagesDigest": "2yV4A8xZ6FZbGGe74q8xCktC2QFZ9qOJZI8VbIbhxtE=", - "recordedFileInputs": {}, - "recordedDirentsInputs": {}, - "envVariables": {}, + "bzlTransitiveDigest": "TTIezBlspKf+C7ObNCRk34UzJh8iuPbdabNBviSufqU=", + "usagesDigest": "HyCD/AMcHKcynL86oRSbi4rhw9cjPb8yfXrC363gBKE=", + "recordedInputs": [ + "REPO_MAPPING:aspect_bazel_lib+,aspect_bazel_lib aspect_bazel_lib+", + "REPO_MAPPING:aspect_bazel_lib+,bazel_skylib bazel_skylib+", + "REPO_MAPPING:aspect_bazel_lib+,bazel_tools bazel_tools" + ], "generatedRepoSpecs": { "copy_directory_darwin_amd64": { - "bzlFile": "@@aspect_bazel_lib~//lib/private:copy_directory_toolchain.bzl", - "ruleClassName": "copy_directory_platform_repo", + "repoRuleId": "@@aspect_bazel_lib+//lib/private:copy_directory_toolchain.bzl%copy_directory_platform_repo", "attributes": { "platform": "darwin_amd64" } }, "copy_directory_darwin_arm64": { - "bzlFile": "@@aspect_bazel_lib~//lib/private:copy_directory_toolchain.bzl", - "ruleClassName": "copy_directory_platform_repo", + "repoRuleId": "@@aspect_bazel_lib+//lib/private:copy_directory_toolchain.bzl%copy_directory_platform_repo", "attributes": { "platform": "darwin_arm64" } }, "copy_directory_freebsd_amd64": { - "bzlFile": "@@aspect_bazel_lib~//lib/private:copy_directory_toolchain.bzl", - "ruleClassName": "copy_directory_platform_repo", + "repoRuleId": "@@aspect_bazel_lib+//lib/private:copy_directory_toolchain.bzl%copy_directory_platform_repo", "attributes": { "platform": "freebsd_amd64" } }, "copy_directory_linux_amd64": { - "bzlFile": "@@aspect_bazel_lib~//lib/private:copy_directory_toolchain.bzl", - "ruleClassName": "copy_directory_platform_repo", + "repoRuleId": "@@aspect_bazel_lib+//lib/private:copy_directory_toolchain.bzl%copy_directory_platform_repo", "attributes": { "platform": "linux_amd64" } }, "copy_directory_linux_arm64": { - "bzlFile": "@@aspect_bazel_lib~//lib/private:copy_directory_toolchain.bzl", - "ruleClassName": "copy_directory_platform_repo", + "repoRuleId": "@@aspect_bazel_lib+//lib/private:copy_directory_toolchain.bzl%copy_directory_platform_repo", "attributes": { "platform": "linux_arm64" } }, "copy_directory_windows_amd64": { - "bzlFile": "@@aspect_bazel_lib~//lib/private:copy_directory_toolchain.bzl", - "ruleClassName": "copy_directory_platform_repo", + "repoRuleId": "@@aspect_bazel_lib+//lib/private:copy_directory_toolchain.bzl%copy_directory_platform_repo", "attributes": { "platform": "windows_amd64" } }, "copy_directory_toolchains": { - "bzlFile": "@@aspect_bazel_lib~//lib/private:copy_directory_toolchain.bzl", - "ruleClassName": "copy_directory_toolchains_repo", + "repoRuleId": "@@aspect_bazel_lib+//lib/private:copy_directory_toolchain.bzl%copy_directory_toolchains_repo", "attributes": { "user_repository_name": "copy_directory" } }, "copy_to_directory_darwin_amd64": { - "bzlFile": "@@aspect_bazel_lib~//lib/private:copy_to_directory_toolchain.bzl", - "ruleClassName": "copy_to_directory_platform_repo", + "repoRuleId": "@@aspect_bazel_lib+//lib/private:copy_to_directory_toolchain.bzl%copy_to_directory_platform_repo", "attributes": { "platform": "darwin_amd64" } }, "copy_to_directory_darwin_arm64": { - "bzlFile": "@@aspect_bazel_lib~//lib/private:copy_to_directory_toolchain.bzl", - "ruleClassName": "copy_to_directory_platform_repo", + "repoRuleId": "@@aspect_bazel_lib+//lib/private:copy_to_directory_toolchain.bzl%copy_to_directory_platform_repo", "attributes": { "platform": "darwin_arm64" } }, "copy_to_directory_freebsd_amd64": { - "bzlFile": "@@aspect_bazel_lib~//lib/private:copy_to_directory_toolchain.bzl", - "ruleClassName": "copy_to_directory_platform_repo", + "repoRuleId": "@@aspect_bazel_lib+//lib/private:copy_to_directory_toolchain.bzl%copy_to_directory_platform_repo", "attributes": { "platform": "freebsd_amd64" } }, "copy_to_directory_linux_amd64": { - "bzlFile": "@@aspect_bazel_lib~//lib/private:copy_to_directory_toolchain.bzl", - "ruleClassName": "copy_to_directory_platform_repo", + "repoRuleId": "@@aspect_bazel_lib+//lib/private:copy_to_directory_toolchain.bzl%copy_to_directory_platform_repo", "attributes": { "platform": "linux_amd64" } }, "copy_to_directory_linux_arm64": { - "bzlFile": "@@aspect_bazel_lib~//lib/private:copy_to_directory_toolchain.bzl", - "ruleClassName": "copy_to_directory_platform_repo", + "repoRuleId": "@@aspect_bazel_lib+//lib/private:copy_to_directory_toolchain.bzl%copy_to_directory_platform_repo", "attributes": { "platform": "linux_arm64" } }, "copy_to_directory_windows_amd64": { - "bzlFile": "@@aspect_bazel_lib~//lib/private:copy_to_directory_toolchain.bzl", - "ruleClassName": "copy_to_directory_platform_repo", + "repoRuleId": "@@aspect_bazel_lib+//lib/private:copy_to_directory_toolchain.bzl%copy_to_directory_platform_repo", "attributes": { "platform": "windows_amd64" } }, "copy_to_directory_toolchains": { - "bzlFile": "@@aspect_bazel_lib~//lib/private:copy_to_directory_toolchain.bzl", - "ruleClassName": "copy_to_directory_toolchains_repo", + "repoRuleId": "@@aspect_bazel_lib+//lib/private:copy_to_directory_toolchain.bzl%copy_to_directory_toolchains_repo", "attributes": { "user_repository_name": "copy_to_directory" } }, "jq_darwin_amd64": { - "bzlFile": "@@aspect_bazel_lib~//lib/private:jq_toolchain.bzl", - "ruleClassName": "jq_platform_repo", + "repoRuleId": "@@aspect_bazel_lib+//lib/private:jq_toolchain.bzl%jq_platform_repo", "attributes": { "platform": "darwin_amd64", "version": "1.6" } }, "jq_darwin_arm64": { - "bzlFile": "@@aspect_bazel_lib~//lib/private:jq_toolchain.bzl", - "ruleClassName": "jq_platform_repo", + "repoRuleId": "@@aspect_bazel_lib+//lib/private:jq_toolchain.bzl%jq_platform_repo", "attributes": { "platform": "darwin_arm64", "version": "1.6" } }, "jq_linux_amd64": { - "bzlFile": "@@aspect_bazel_lib~//lib/private:jq_toolchain.bzl", - "ruleClassName": "jq_platform_repo", + "repoRuleId": "@@aspect_bazel_lib+//lib/private:jq_toolchain.bzl%jq_platform_repo", "attributes": { "platform": "linux_amd64", "version": "1.6" } }, "jq_windows_amd64": { - "bzlFile": "@@aspect_bazel_lib~//lib/private:jq_toolchain.bzl", - "ruleClassName": "jq_platform_repo", + "repoRuleId": "@@aspect_bazel_lib+//lib/private:jq_toolchain.bzl%jq_platform_repo", "attributes": { "platform": "windows_amd64", "version": "1.6" } }, "jq": { - "bzlFile": "@@aspect_bazel_lib~//lib/private:jq_toolchain.bzl", - "ruleClassName": "jq_host_alias_repo", + "repoRuleId": "@@aspect_bazel_lib+//lib/private:jq_toolchain.bzl%jq_host_alias_repo", "attributes": {} }, "jq_toolchains": { - "bzlFile": "@@aspect_bazel_lib~//lib/private:jq_toolchain.bzl", - "ruleClassName": "jq_toolchains_repo", + "repoRuleId": "@@aspect_bazel_lib+//lib/private:jq_toolchain.bzl%jq_toolchains_repo", "attributes": { "user_repository_name": "jq" } }, "yq_darwin_amd64": { - "bzlFile": "@@aspect_bazel_lib~//lib/private:yq_toolchain.bzl", - "ruleClassName": "yq_platform_repo", + "repoRuleId": "@@aspect_bazel_lib+//lib/private:yq_toolchain.bzl%yq_platform_repo", "attributes": { "platform": "darwin_amd64", "version": "4.25.2" } }, "yq_darwin_arm64": { - "bzlFile": "@@aspect_bazel_lib~//lib/private:yq_toolchain.bzl", - "ruleClassName": "yq_platform_repo", + "repoRuleId": "@@aspect_bazel_lib+//lib/private:yq_toolchain.bzl%yq_platform_repo", "attributes": { "platform": "darwin_arm64", "version": "4.25.2" } }, "yq_linux_amd64": { - "bzlFile": "@@aspect_bazel_lib~//lib/private:yq_toolchain.bzl", - "ruleClassName": "yq_platform_repo", + "repoRuleId": "@@aspect_bazel_lib+//lib/private:yq_toolchain.bzl%yq_platform_repo", "attributes": { "platform": "linux_amd64", "version": "4.25.2" } }, "yq_linux_arm64": { - "bzlFile": "@@aspect_bazel_lib~//lib/private:yq_toolchain.bzl", - "ruleClassName": "yq_platform_repo", + "repoRuleId": "@@aspect_bazel_lib+//lib/private:yq_toolchain.bzl%yq_platform_repo", "attributes": { "platform": "linux_arm64", "version": "4.25.2" } }, "yq_linux_s390x": { - "bzlFile": "@@aspect_bazel_lib~//lib/private:yq_toolchain.bzl", - "ruleClassName": "yq_platform_repo", + "repoRuleId": "@@aspect_bazel_lib+//lib/private:yq_toolchain.bzl%yq_platform_repo", "attributes": { "platform": "linux_s390x", "version": "4.25.2" } }, "yq_linux_ppc64le": { - "bzlFile": "@@aspect_bazel_lib~//lib/private:yq_toolchain.bzl", - "ruleClassName": "yq_platform_repo", + "repoRuleId": "@@aspect_bazel_lib+//lib/private:yq_toolchain.bzl%yq_platform_repo", "attributes": { "platform": "linux_ppc64le", "version": "4.25.2" } }, "yq_windows_amd64": { - "bzlFile": "@@aspect_bazel_lib~//lib/private:yq_toolchain.bzl", - "ruleClassName": "yq_platform_repo", + "repoRuleId": "@@aspect_bazel_lib+//lib/private:yq_toolchain.bzl%yq_platform_repo", "attributes": { "platform": "windows_amd64", "version": "4.25.2" } }, "yq": { - "bzlFile": "@@aspect_bazel_lib~//lib/private:yq_toolchain.bzl", - "ruleClassName": "yq_host_alias_repo", + "repoRuleId": "@@aspect_bazel_lib+//lib/private:yq_toolchain.bzl%yq_host_alias_repo", "attributes": {} }, "yq_toolchains": { - "bzlFile": "@@aspect_bazel_lib~//lib/private:yq_toolchain.bzl", - "ruleClassName": "yq_toolchains_repo", + "repoRuleId": "@@aspect_bazel_lib+//lib/private:yq_toolchain.bzl%yq_toolchains_repo", "attributes": { "user_repository_name": "yq" } }, "coreutils_darwin_amd64": { - "bzlFile": "@@aspect_bazel_lib~//lib/private:coreutils_toolchain.bzl", - "ruleClassName": "coreutils_platform_repo", + "repoRuleId": "@@aspect_bazel_lib+//lib/private:coreutils_toolchain.bzl%coreutils_platform_repo", "attributes": { "platform": "darwin_amd64", "version": "0.0.16" } }, "coreutils_darwin_arm64": { - "bzlFile": "@@aspect_bazel_lib~//lib/private:coreutils_toolchain.bzl", - "ruleClassName": "coreutils_platform_repo", + "repoRuleId": "@@aspect_bazel_lib+//lib/private:coreutils_toolchain.bzl%coreutils_platform_repo", "attributes": { "platform": "darwin_arm64", "version": "0.0.16" } }, "coreutils_linux_amd64": { - "bzlFile": "@@aspect_bazel_lib~//lib/private:coreutils_toolchain.bzl", - "ruleClassName": "coreutils_platform_repo", + "repoRuleId": "@@aspect_bazel_lib+//lib/private:coreutils_toolchain.bzl%coreutils_platform_repo", "attributes": { "platform": "linux_amd64", "version": "0.0.16" } }, "coreutils_linux_arm64": { - "bzlFile": "@@aspect_bazel_lib~//lib/private:coreutils_toolchain.bzl", - "ruleClassName": "coreutils_platform_repo", + "repoRuleId": "@@aspect_bazel_lib+//lib/private:coreutils_toolchain.bzl%coreutils_platform_repo", "attributes": { "platform": "linux_arm64", "version": "0.0.16" } }, "coreutils_windows_amd64": { - "bzlFile": "@@aspect_bazel_lib~//lib/private:coreutils_toolchain.bzl", - "ruleClassName": "coreutils_platform_repo", + "repoRuleId": "@@aspect_bazel_lib+//lib/private:coreutils_toolchain.bzl%coreutils_platform_repo", "attributes": { "platform": "windows_amd64", "version": "0.0.16" } }, "coreutils_toolchains": { - "bzlFile": "@@aspect_bazel_lib~//lib/private:coreutils_toolchain.bzl", - "ruleClassName": "coreutils_toolchains_repo", + "repoRuleId": "@@aspect_bazel_lib+//lib/private:coreutils_toolchain.bzl%coreutils_toolchains_repo", "attributes": { "user_repository_name": "coreutils" } }, "expand_template_darwin_amd64": { - "bzlFile": "@@aspect_bazel_lib~//lib/private:expand_template_toolchain.bzl", - "ruleClassName": "expand_template_platform_repo", + "repoRuleId": "@@aspect_bazel_lib+//lib/private:expand_template_toolchain.bzl%expand_template_platform_repo", "attributes": { "platform": "darwin_amd64" } }, "expand_template_darwin_arm64": { - "bzlFile": "@@aspect_bazel_lib~//lib/private:expand_template_toolchain.bzl", - "ruleClassName": "expand_template_platform_repo", + "repoRuleId": "@@aspect_bazel_lib+//lib/private:expand_template_toolchain.bzl%expand_template_platform_repo", "attributes": { "platform": "darwin_arm64" } }, "expand_template_freebsd_amd64": { - "bzlFile": "@@aspect_bazel_lib~//lib/private:expand_template_toolchain.bzl", - "ruleClassName": "expand_template_platform_repo", + "repoRuleId": "@@aspect_bazel_lib+//lib/private:expand_template_toolchain.bzl%expand_template_platform_repo", "attributes": { "platform": "freebsd_amd64" } }, "expand_template_linux_amd64": { - "bzlFile": "@@aspect_bazel_lib~//lib/private:expand_template_toolchain.bzl", - "ruleClassName": "expand_template_platform_repo", + "repoRuleId": "@@aspect_bazel_lib+//lib/private:expand_template_toolchain.bzl%expand_template_platform_repo", "attributes": { "platform": "linux_amd64" } }, "expand_template_linux_arm64": { - "bzlFile": "@@aspect_bazel_lib~//lib/private:expand_template_toolchain.bzl", - "ruleClassName": "expand_template_platform_repo", + "repoRuleId": "@@aspect_bazel_lib+//lib/private:expand_template_toolchain.bzl%expand_template_platform_repo", "attributes": { "platform": "linux_arm64" } }, "expand_template_windows_amd64": { - "bzlFile": "@@aspect_bazel_lib~//lib/private:expand_template_toolchain.bzl", - "ruleClassName": "expand_template_platform_repo", + "repoRuleId": "@@aspect_bazel_lib+//lib/private:expand_template_toolchain.bzl%expand_template_platform_repo", "attributes": { "platform": "windows_amd64" } }, "expand_template_toolchains": { - "bzlFile": "@@aspect_bazel_lib~//lib/private:expand_template_toolchain.bzl", - "ruleClassName": "expand_template_toolchains_repo", + "repoRuleId": "@@aspect_bazel_lib+//lib/private:expand_template_toolchain.bzl%expand_template_toolchains_repo", "attributes": { "user_repository_name": "expand_template" } } - }, - "recordedRepoMappingEntries": [ - [ - "aspect_bazel_lib~", - "aspect_bazel_lib", - "aspect_bazel_lib~" - ], - [ - "aspect_bazel_lib~", - "bazel_skylib", - "bazel_skylib~" - ], - [ - "aspect_bazel_lib~", - "bazel_tools", - "bazel_tools" - ] - ] + } } }, - "@@rules_buf~//buf:extensions.bzl%ext": { + "@@rules_buf+//buf:extensions.bzl%ext": { "general": { - "bzlTransitiveDigest": "gmPmM7QT5Jez2VVFcwbbMf/QWSRag+nJ1elFJFFTcn0=", - "usagesDigest": "1E3NeLCRI6VyKiersXVtONCbNopc5jIVqoHBOpcWb0A=", - "recordedFileInputs": {}, - "recordedDirentsInputs": {}, - "envVariables": {}, + "bzlTransitiveDigest": "jPVNXOmzZswjd7FZCQk0mOXkvt6/dS9OuJa4wwbDE5M=", + "usagesDigest": "RTc2BMQ2b0wGU8CRvN3EoPz34m3LMe+K/oSkFkN83+M=", + "recordedInputs": [ + "REPO_MAPPING:rules_buf+,bazel_tools bazel_tools" + ], "generatedRepoSpecs": { "rules_buf_toolchains": { - "bzlFile": "@@rules_buf~//buf/internal:toolchain.bzl", - "ruleClassName": "buf_download_releases", + "repoRuleId": "@@rules_buf+//buf/internal:toolchain.bzl%buf_download_releases", "attributes": { "version": "v1.27.0" } } - }, - "recordedRepoMappingEntries": [ - [ - "rules_buf~", - "bazel_tools", - "bazel_tools" - ] - ] + } } }, - "@@rules_cuda~//cuda:extensions.bzl%toolchain": { + "@@rules_cuda+//cuda:extensions.bzl%toolchain": { "general": { - "bzlTransitiveDigest": "BnYM6/SSxkN/7InBOUBKIuviq2l1hk6LC7EDB59vI80=", - "usagesDigest": "EAEeKc1m5Va0f+woRsvfF/se9J527ZmyBMMyJIiwjxs=", - "recordedFileInputs": {}, - "recordedDirentsInputs": {}, - "envVariables": {}, + "bzlTransitiveDigest": "ZQkRQ5xMl085Tw1GvBO2R7cmlxjV6FAJG0Az8ZPsKsk=", + "usagesDigest": "OBowg8qCb7GfXoSd0Hl98pvfIWaorf8BdjkUOM4Lb7w=", + "recordedInputs": [ + "REPO_MAPPING:rules_cuda+,bazel_tools bazel_tools" + ], "generatedRepoSpecs": { "local_cuda": { - "bzlFile": "@@rules_cuda~//cuda/private:repositories.bzl", - "ruleClassName": "local_cuda", + "repoRuleId": "@@rules_cuda+//cuda/private:repositories.bzl%local_cuda", "attributes": { "toolkit_path": "" } } - }, - "recordedRepoMappingEntries": [ - [ - "rules_cuda~", - "bazel_tools", - "bazel_tools" - ] - ] + } } }, - "@@rules_foreign_cc~//foreign_cc:extensions.bzl%tools": { + "@@rules_foreign_cc+//foreign_cc:extensions.bzl%tools": { "general": { - "bzlTransitiveDigest": "xXsVxU9RFlxF0FwwZymap5U/lRd3z9Hlcys4Tq+b+Bo=", - "usagesDigest": "SGA58zMG01aPzmHLVqPyMo79785P3+nsw3FlBXZ/2vg=", - "recordedFileInputs": {}, - "recordedDirentsInputs": {}, - "envVariables": {}, + "bzlTransitiveDigest": "dWWiLQWKST2+NU4SkbVS2OhS6KgYdZ4jBI5MBsDEBt0=", + "usagesDigest": "Eyh4mAOi6L+Nn/lY/wQBJclQrmBnWdQM+B4lZeq6azA=", + "recordedInputs": [ + "REPO_MAPPING:rules_foreign_cc+,bazel_tools bazel_tools", + "REPO_MAPPING:rules_foreign_cc+,rules_foreign_cc rules_foreign_cc+" + ], "generatedRepoSpecs": { "rules_foreign_cc_framework_toolchain_linux": { - "bzlFile": "@@rules_foreign_cc~//foreign_cc/private/framework:toolchain.bzl", - "ruleClassName": "framework_toolchain_repository", + "repoRuleId": "@@rules_foreign_cc+//foreign_cc/private/framework:toolchain.bzl%framework_toolchain_repository", "attributes": { "commands_src": "@rules_foreign_cc//foreign_cc/private/framework/toolchains:linux_commands.bzl", "exec_compatible_with": [ @@ -1341,8 +1317,7 @@ } }, "rules_foreign_cc_framework_toolchain_freebsd": { - "bzlFile": "@@rules_foreign_cc~//foreign_cc/private/framework:toolchain.bzl", - "ruleClassName": "framework_toolchain_repository", + "repoRuleId": "@@rules_foreign_cc+//foreign_cc/private/framework:toolchain.bzl%framework_toolchain_repository", "attributes": { "commands_src": "@rules_foreign_cc//foreign_cc/private/framework/toolchains:freebsd_commands.bzl", "exec_compatible_with": [ @@ -1351,8 +1326,7 @@ } }, "rules_foreign_cc_framework_toolchain_windows": { - "bzlFile": "@@rules_foreign_cc~//foreign_cc/private/framework:toolchain.bzl", - "ruleClassName": "framework_toolchain_repository", + "repoRuleId": "@@rules_foreign_cc+//foreign_cc/private/framework:toolchain.bzl%framework_toolchain_repository", "attributes": { "commands_src": "@rules_foreign_cc//foreign_cc/private/framework/toolchains:windows_commands.bzl", "exec_compatible_with": [ @@ -1361,8 +1335,7 @@ } }, "rules_foreign_cc_framework_toolchain_macos": { - "bzlFile": "@@rules_foreign_cc~//foreign_cc/private/framework:toolchain.bzl", - "ruleClassName": "framework_toolchain_repository", + "repoRuleId": "@@rules_foreign_cc+//foreign_cc/private/framework:toolchain.bzl%framework_toolchain_repository", "attributes": { "commands_src": "@rules_foreign_cc//foreign_cc/private/framework/toolchains:macos_commands.bzl", "exec_compatible_with": [ @@ -1371,13 +1344,11 @@ } }, "rules_foreign_cc_framework_toolchains": { - "bzlFile": "@@rules_foreign_cc~//foreign_cc/private/framework:toolchain.bzl", - "ruleClassName": "framework_toolchain_repository_hub", + "repoRuleId": "@@rules_foreign_cc+//foreign_cc/private/framework:toolchain.bzl%framework_toolchain_repository_hub", "attributes": {} }, "cmake_src": { - "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_archive", + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", "attributes": { "build_file_content": "filegroup(\n name = \"all_srcs\",\n srcs = glob([\"**\"]),\n visibility = [\"//visibility:public\"],\n)\n", "sha256": "f316b40053466f9a416adf981efda41b160ca859e97f6a484b447ea299ff26aa", @@ -1386,13 +1357,12 @@ "https://github.com/Kitware/CMake/releases/download/v3.23.2/cmake-3.23.2.tar.gz" ], "patches": [ - "@@rules_foreign_cc~//toolchains/patches:cmake-c++11.patch" + "@@rules_foreign_cc+//toolchains/patches:cmake-c++11.patch" ] } }, "gnumake_src": { - "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_archive", + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", "attributes": { "build_file_content": "filegroup(\n name = \"all_srcs\",\n srcs = glob([\"**\"]),\n visibility = [\"//visibility:public\"],\n)\n", "sha256": "dd16fb1d67bfab79a72f5e8390735c49e3e8e70b4945a15ab1f81ddb78658fb3", @@ -1404,8 +1374,7 @@ } }, "ninja_build_src": { - "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_archive", + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", "attributes": { "build_file_content": "filegroup(\n name = \"all_srcs\",\n srcs = glob([\"**\"]),\n visibility = [\"//visibility:public\"],\n)\n", "integrity": "sha256-ghvf9Io/aDvEuztvC1/nstZHz2XVKutjMoyRpsbfKFo=", @@ -1417,8 +1386,7 @@ } }, "meson_src": { - "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_archive", + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", "attributes": { "build_file_content": "exports_files([\"meson.py\"])\n\nfilegroup(\n name = \"runtime\",\n # NOTE: excluding __pycache__ is important to avoid rebuilding due to pyc\n # files, see https://github.com/bazel-contrib/rules_foreign_cc/issues/1342\n srcs = glob([\"mesonbuild/**\"], exclude = [\"**/__pycache__/*\"]),\n visibility = [\"//visibility:public\"],\n)\n", "sha256": "567e533adf255de73a2de35049b99923caf872a455af9ce03e01077e0d384bed", @@ -1430,8 +1398,7 @@ } }, "glib_dev": { - "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_archive", + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", "attributes": { "build_file_content": "\ncc_import(\n name = \"glib_dev\",\n hdrs = glob([\"include/**\"]),\n shared_library = \"@glib_runtime//:bin/libglib-2.0-0.dll\",\n visibility = [\"//visibility:public\"],\n)\n ", "sha256": "bdf18506df304d38be98a4b3f18055b8b8cca81beabecad0eece6ce95319c369", @@ -1442,8 +1409,7 @@ } }, "glib_src": { - "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_archive", + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", "attributes": { "build_file_content": "\ncc_import(\n name = \"msvc_hdr\",\n hdrs = [\"msvc_recommended_pragmas.h\"],\n visibility = [\"//visibility:public\"],\n)\n ", "sha256": "bc96f63112823b7d6c9f06572d2ad626ddac7eb452c04d762592197f6e07898e", @@ -1455,8 +1421,7 @@ } }, "glib_runtime": { - "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_archive", + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", "attributes": { "build_file_content": "\nexports_files(\n [\n \"bin/libgio-2.0-0.dll\",\n \"bin/libglib-2.0-0.dll\",\n \"bin/libgmodule-2.0-0.dll\",\n \"bin/libgobject-2.0-0.dll\",\n \"bin/libgthread-2.0-0.dll\",\n ],\n visibility = [\"//visibility:public\"],\n)\n ", "sha256": "88d857087e86f16a9be651ee7021880b3f7ba050d34a1ed9f06113b8799cb973", @@ -1467,8 +1432,7 @@ } }, "gettext_runtime": { - "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_archive", + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", "attributes": { "build_file_content": "\ncc_import(\n name = \"gettext_runtime\",\n shared_library = \"bin/libintl-8.dll\",\n visibility = [\"//visibility:public\"],\n)\n ", "sha256": "1f4269c0e021076d60a54e98da6f978a3195013f6de21674ba0edbc339c5b079", @@ -1479,16 +1443,15 @@ } }, "pkgconfig_src": { - "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_archive", + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", "attributes": { "build_file_content": "filegroup(\n name = \"all_srcs\",\n srcs = glob([\"**\"]),\n visibility = [\"//visibility:public\"],\n)\n", "sha256": "6fc69c01688c9458a57eb9a1664c9aba372ccda420a02bf4429fe610e7e7d591", "strip_prefix": "pkg-config-0.29.2", "patches": [ - "@@rules_foreign_cc~//toolchains/patches:pkgconfig-detectenv.patch", - "@@rules_foreign_cc~//toolchains/patches:pkgconfig-makefile-vc.patch", - "@@rules_foreign_cc~//toolchains/patches:pkgconfig-builtin-glib-int-conversion.patch" + "@@rules_foreign_cc+//toolchains/patches:pkgconfig-detectenv.patch", + "@@rules_foreign_cc+//toolchains/patches:pkgconfig-makefile-vc.patch", + "@@rules_foreign_cc+//toolchains/patches:pkgconfig-builtin-glib-int-conversion.patch" ], "urls": [ "https://pkgconfig.freedesktop.org/releases/pkg-config-0.29.2.tar.gz", @@ -1497,8 +1460,7 @@ } }, "bazel_features": { - "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_archive", + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", "attributes": { "sha256": "ba1282c1aa1d1fffdcf994ab32131d7c7551a9bc960fbf05f42d55a1b930cbfb", "strip_prefix": "bazel_features-1.15.0", @@ -1506,8 +1468,7 @@ } }, "bazel_skylib": { - "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_archive", + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", "attributes": { "sha256": "bc283cdfcd526a52c3201279cda4bc298652efa898b10b4db0837dc51652756f", "urls": [ @@ -1517,8 +1478,7 @@ } }, "rules_cc": { - "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_archive", + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", "attributes": { "urls": [ "https://github.com/bazelbuild/rules_cc/releases/download/0.0.17/rules_cc-0.0.17.tar.gz" @@ -1528,8 +1488,7 @@ } }, "rules_python": { - "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_archive", + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", "attributes": { "sha256": "0a158f883fc494724f25e2ce6a5c3d31fd52163a92d4b7180aef0ff9a0622f70", "strip_prefix": "rules_python-1.1.0-rc0", @@ -1537,8 +1496,7 @@ } }, "rules_shell": { - "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_archive", + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", "attributes": { "sha256": "d8cd4a3a91fc1dc68d4c7d6b655f09def109f7186437e3f50a9b60ab436a0c53", "strip_prefix": "rules_shell-0.3.0", @@ -1546,8 +1504,7 @@ } }, "cmake-3.23.2-linux-aarch64": { - "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_archive", + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", "attributes": { "urls": [ "https://github.com/Kitware/CMake/releases/download/v3.23.2/cmake-3.23.2-linux-aarch64.tar.gz" @@ -1558,8 +1515,7 @@ } }, "cmake-3.23.2-linux-x86_64": { - "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_archive", + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", "attributes": { "urls": [ "https://github.com/Kitware/CMake/releases/download/v3.23.2/cmake-3.23.2-linux-x86_64.tar.gz" @@ -1570,8 +1526,7 @@ } }, "cmake-3.23.2-macos-universal": { - "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_archive", + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", "attributes": { "urls": [ "https://github.com/Kitware/CMake/releases/download/v3.23.2/cmake-3.23.2-macos-universal.tar.gz" @@ -1582,8 +1537,7 @@ } }, "cmake-3.23.2-windows-i386": { - "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_archive", + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", "attributes": { "urls": [ "https://github.com/Kitware/CMake/releases/download/v3.23.2/cmake-3.23.2-windows-i386.zip" @@ -1594,8 +1548,7 @@ } }, "cmake-3.23.2-windows-x86_64": { - "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_archive", + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", "attributes": { "urls": [ "https://github.com/Kitware/CMake/releases/download/v3.23.2/cmake-3.23.2-windows-x86_64.zip" @@ -1606,8 +1559,7 @@ } }, "cmake_3.23.2_toolchains": { - "bzlFile": "@@rules_foreign_cc~//toolchains:prebuilt_toolchains_repository.bzl", - "ruleClassName": "prebuilt_toolchains_repository", + "repoRuleId": "@@rules_foreign_cc+//toolchains:prebuilt_toolchains_repository.bzl%prebuilt_toolchains_repository", "attributes": { "repos": { "cmake-3.23.2-linux-aarch64": [ @@ -1634,8 +1586,7 @@ } }, "ninja_1.12.1_linux": { - "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_archive", + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", "attributes": { "urls": [ "https://github.com/ninja-build/ninja/releases/download/v1.12.1/ninja-linux.zip" @@ -1646,8 +1597,7 @@ } }, "ninja_1.12.1_linux-aarch64": { - "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_archive", + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", "attributes": { "urls": [ "https://github.com/ninja-build/ninja/releases/download/v1.12.1/ninja-linux-aarch64.zip" @@ -1658,8 +1608,7 @@ } }, "ninja_1.12.1_mac": { - "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_archive", + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", "attributes": { "urls": [ "https://github.com/ninja-build/ninja/releases/download/v1.12.1/ninja-mac.zip" @@ -1670,8 +1619,7 @@ } }, "ninja_1.12.1_mac_aarch64": { - "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_archive", + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", "attributes": { "urls": [ "https://github.com/ninja-build/ninja/releases/download/v1.12.1/ninja-mac.zip" @@ -1682,8 +1630,7 @@ } }, "ninja_1.12.1_win": { - "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_archive", + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", "attributes": { "urls": [ "https://github.com/ninja-build/ninja/releases/download/v1.12.1/ninja-win.zip" @@ -1694,8 +1641,7 @@ } }, "ninja_1.12.1_toolchains": { - "bzlFile": "@@rules_foreign_cc~//toolchains:prebuilt_toolchains_repository.bzl", - "ruleClassName": "prebuilt_toolchains_repository", + "repoRuleId": "@@rules_foreign_cc+//toolchains:prebuilt_toolchains_repository.bzl%prebuilt_toolchains_repository", "attributes": { "repos": { "ninja_1.12.1_linux": [ @@ -1722,55 +1668,19 @@ "tool": "ninja" } } - }, - "recordedRepoMappingEntries": [ - [ - "rules_foreign_cc~", - "bazel_tools", - "bazel_tools" - ], - [ - "rules_foreign_cc~", - "rules_foreign_cc", - "rules_foreign_cc~" - ] - ] + } } }, - "@@rules_java~//java:rules_java_deps.bzl%compatibility_proxy": { + "@@rules_kotlin+//src/main/starlark/core/repositories:bzlmod_setup.bzl%rules_kotlin_extensions": { "general": { - "bzlTransitiveDigest": "KIX40nDfygEWbU+rq3nYpt3tVgTK/iO8PKh5VMBlN7M=", - "usagesDigest": "pwHZ+26iLgQdwvdZeA5wnAjKnNI3y6XO2VbhOTeo5h8=", - "recordedFileInputs": {}, - "recordedDirentsInputs": {}, - "envVariables": {}, - "generatedRepoSpecs": { - "compatibility_proxy": { - "bzlFile": "@@rules_java~//java:rules_java_deps.bzl", - "ruleClassName": "_compatibility_proxy_repo_rule", - "attributes": {} - } - }, - "recordedRepoMappingEntries": [ - [ - "rules_java~", - "bazel_tools", - "bazel_tools" - ] - ] - } - }, - "@@rules_kotlin~//src/main/starlark/core/repositories:bzlmod_setup.bzl%rules_kotlin_extensions": { - "general": { - "bzlTransitiveDigest": "fus14IFJ/1LGWWGKPH/U18VnJCoMjfDt1ckahqCnM0A=", - "usagesDigest": "aJF6fLy82rR95Ff5CZPAqxNoFgOMLMN5ImfBS0nhnkg=", - "recordedFileInputs": {}, - "recordedDirentsInputs": {}, - "envVariables": {}, + "bzlTransitiveDigest": "ABI1D/sbS1ovwaW/kHDoj8nnXjQ0oKU9fzmzEG4iT8o=", + "usagesDigest": "QI2z8ZUR+mqtbwsf2fLqYdJAkPOHdOV+tF2yVAUgRzw=", + "recordedInputs": [ + "REPO_MAPPING:rules_kotlin+,bazel_tools bazel_tools" + ], "generatedRepoSpecs": { "com_github_jetbrains_kotlin_git": { - "bzlFile": "@@rules_kotlin~//src/main/starlark/core/repositories:compiler.bzl", - "ruleClassName": "kotlin_compiler_git_repository", + "repoRuleId": "@@rules_kotlin+//src/main/starlark/core/repositories:compiler.bzl%kotlin_compiler_git_repository", "attributes": { "urls": [ "https://github.com/JetBrains/kotlin/releases/download/v1.9.23/kotlin-compiler-1.9.23.zip" @@ -1779,16 +1689,14 @@ } }, "com_github_jetbrains_kotlin": { - "bzlFile": "@@rules_kotlin~//src/main/starlark/core/repositories:compiler.bzl", - "ruleClassName": "kotlin_capabilities_repository", + "repoRuleId": "@@rules_kotlin+//src/main/starlark/core/repositories:compiler.bzl%kotlin_capabilities_repository", "attributes": { "git_repository_name": "com_github_jetbrains_kotlin_git", "compiler_version": "1.9.23" } }, "com_github_google_ksp": { - "bzlFile": "@@rules_kotlin~//src/main/starlark/core/repositories:ksp.bzl", - "ruleClassName": "ksp_compiler_plugin_repository", + "repoRuleId": "@@rules_kotlin+//src/main/starlark/core/repositories:ksp.bzl%ksp_compiler_plugin_repository", "attributes": { "urls": [ "https://github.com/google/ksp/releases/download/1.9.23-1.0.20/artifacts.zip" @@ -1798,8 +1706,7 @@ } }, "com_github_pinterest_ktlint": { - "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_file", + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_file", "attributes": { "sha256": "01b2e0ef893383a50dbeb13970fe7fa3be36ca3e83259e01649945b09d736985", "urls": [ @@ -1809,8 +1716,7 @@ } }, "rules_android": { - "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_archive", + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", "attributes": { "sha256": "cd06d15dd8bb59926e4d65f9003bfc20f9da4b2519985c27e190cddc8b7a7806", "strip_prefix": "rules_android-0.1.1", @@ -1819,3203 +1725,286 @@ ] } } - }, - "recordedRepoMappingEntries": [ - [ - "rules_kotlin~", - "bazel_tools", - "bazel_tools" - ] - ] + } } }, - "@@rules_nodejs~//nodejs:extensions.bzl%node": { + "@@rules_nodejs+//nodejs:extensions.bzl%node": { "general": { - "bzlTransitiveDigest": "xRRX0NuyvfLtjtzM4AqJgxdMSWWnLIw28rUUi10y6k0=", - "usagesDigest": "9IUJvk13jWE1kE+N3sP2y0mw9exjO9CGQ2oAgwKTNK4=", - "recordedFileInputs": {}, - "recordedDirentsInputs": {}, - "envVariables": {}, + "bzlTransitiveDigest": "Imgzqqemb9gc8RyTW2SKONMe0WiFBua/vf0q3SiOwH0=", + "usagesDigest": "CtwJeycIo1YVyKAUrO/7bkpB6yqctQd8XUnRtqUbwRI=", + "recordedInputs": [ + "REPO_MAPPING:rules_nodejs+,bazel_skylib bazel_skylib+", + "REPO_MAPPING:rules_nodejs+,bazel_tools bazel_tools" + ], "generatedRepoSpecs": { "nodejs_linux_amd64": { - "bzlFile": "@@rules_nodejs~//nodejs:repositories.bzl", - "ruleClassName": "node_repositories", + "repoRuleId": "@@rules_nodejs+//nodejs:repositories.bzl%node_repositories", "attributes": { "platform": "linux_amd64", "node_version": "16.19.0" } }, "nodejs_linux_arm64": { - "bzlFile": "@@rules_nodejs~//nodejs:repositories.bzl", - "ruleClassName": "node_repositories", + "repoRuleId": "@@rules_nodejs+//nodejs:repositories.bzl%node_repositories", "attributes": { "platform": "linux_arm64", "node_version": "16.19.0" } }, "nodejs_linux_s390x": { - "bzlFile": "@@rules_nodejs~//nodejs:repositories.bzl", - "ruleClassName": "node_repositories", + "repoRuleId": "@@rules_nodejs+//nodejs:repositories.bzl%node_repositories", "attributes": { "platform": "linux_s390x", "node_version": "16.19.0" } }, "nodejs_linux_ppc64le": { - "bzlFile": "@@rules_nodejs~//nodejs:repositories.bzl", - "ruleClassName": "node_repositories", + "repoRuleId": "@@rules_nodejs+//nodejs:repositories.bzl%node_repositories", "attributes": { "platform": "linux_ppc64le", "node_version": "16.19.0" } }, "nodejs_darwin_amd64": { - "bzlFile": "@@rules_nodejs~//nodejs:repositories.bzl", - "ruleClassName": "node_repositories", + "repoRuleId": "@@rules_nodejs+//nodejs:repositories.bzl%node_repositories", "attributes": { "platform": "darwin_amd64", "node_version": "16.19.0" } }, "nodejs_darwin_arm64": { - "bzlFile": "@@rules_nodejs~//nodejs:repositories.bzl", - "ruleClassName": "node_repositories", + "repoRuleId": "@@rules_nodejs+//nodejs:repositories.bzl%node_repositories", "attributes": { "platform": "darwin_arm64", "node_version": "16.19.0" } }, "nodejs_windows_amd64": { - "bzlFile": "@@rules_nodejs~//nodejs:repositories.bzl", - "ruleClassName": "node_repositories", + "repoRuleId": "@@rules_nodejs+//nodejs:repositories.bzl%node_repositories", "attributes": { "platform": "windows_amd64", "node_version": "16.19.0" } }, "nodejs": { - "bzlFile": "@@rules_nodejs~//nodejs/private:nodejs_repo_host_os_alias.bzl", - "ruleClassName": "nodejs_repo_host_os_alias", + "repoRuleId": "@@rules_nodejs+//nodejs/private:nodejs_repo_host_os_alias.bzl%nodejs_repo_host_os_alias", "attributes": { "user_node_repository_name": "nodejs" } }, "nodejs_host": { - "bzlFile": "@@rules_nodejs~//nodejs/private:nodejs_repo_host_os_alias.bzl", - "ruleClassName": "nodejs_repo_host_os_alias", + "repoRuleId": "@@rules_nodejs+//nodejs/private:nodejs_repo_host_os_alias.bzl%nodejs_repo_host_os_alias", "attributes": { "user_node_repository_name": "nodejs" } }, "nodejs_toolchains": { - "bzlFile": "@@rules_nodejs~//nodejs/private:toolchains_repo.bzl", - "ruleClassName": "toolchains_repo", + "repoRuleId": "@@rules_nodejs+//nodejs/private:toolchains_repo.bzl%toolchains_repo", "attributes": { "user_node_repository_name": "nodejs" } } - }, - "recordedRepoMappingEntries": [ - [ - "rules_nodejs~", - "bazel_skylib", - "bazel_skylib~" - ], - [ - "rules_nodejs~", - "bazel_tools", - "bazel_tools" - ] - ] + } } }, - "@@rules_rust~//rust:extensions.bzl%rust": { + "@@rules_python+//python/extensions:config.bzl%config": { "general": { - "bzlTransitiveDigest": "38mS84XG0CcVNTJg1FK59Jp6LQGkDqSDkfNEz0D9s18=", - "usagesDigest": "rV+PuweiVabXYal8kLLNKaL4Tx6LbDJmoCxxMI6XmeA=", - "recordedFileInputs": {}, - "recordedDirentsInputs": {}, - "envVariables": {}, + "bzlTransitiveDigest": "2hLgIvNVTLgxus0ZuXtleBe70intCfo0cHs8qvt6cdM=", + "usagesDigest": "ZVSXMAGpD+xzVNPuvF1IoLBkty7TROO0+akMapt1pAg=", + "recordedInputs": [ + "REPO_MAPPING:rules_python+,bazel_tools bazel_tools", + "REPO_MAPPING:rules_python+,pypi__build rules_python++config+pypi__build", + "REPO_MAPPING:rules_python+,pypi__click rules_python++config+pypi__click", + "REPO_MAPPING:rules_python+,pypi__colorama rules_python++config+pypi__colorama", + "REPO_MAPPING:rules_python+,pypi__importlib_metadata rules_python++config+pypi__importlib_metadata", + "REPO_MAPPING:rules_python+,pypi__installer rules_python++config+pypi__installer", + "REPO_MAPPING:rules_python+,pypi__more_itertools rules_python++config+pypi__more_itertools", + "REPO_MAPPING:rules_python+,pypi__packaging rules_python++config+pypi__packaging", + "REPO_MAPPING:rules_python+,pypi__pep517 rules_python++config+pypi__pep517", + "REPO_MAPPING:rules_python+,pypi__pip rules_python++config+pypi__pip", + "REPO_MAPPING:rules_python+,pypi__pip_tools rules_python++config+pypi__pip_tools", + "REPO_MAPPING:rules_python+,pypi__pyproject_hooks rules_python++config+pypi__pyproject_hooks", + "REPO_MAPPING:rules_python+,pypi__setuptools rules_python++config+pypi__setuptools", + "REPO_MAPPING:rules_python+,pypi__tomli rules_python++config+pypi__tomli", + "REPO_MAPPING:rules_python+,pypi__wheel rules_python++config+pypi__wheel", + "REPO_MAPPING:rules_python+,pypi__zipp rules_python++config+pypi__zipp" + ], "generatedRepoSpecs": { - "rust_analyzer_1.81.0_tools": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "rust_analyzer_toolchain_tools_repository", - "attributes": { - "version": "1.81.0", - "sha256s": {}, - "urls": [ - "https://static.rust-lang.org/dist/{}.tar.xz" - ], - "auth": {}, - "netrc": "", - "auth_patterns": [] - } - }, - "rust_analyzer_1.81.0": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "toolchain_repository_proxy", - "attributes": { - "toolchain": "@rust_analyzer_1.81.0_tools//:rust_analyzer_toolchain", - "toolchain_type": "@rules_rust//rust/rust_analyzer:toolchain_type", - "exec_compatible_with": [], - "target_compatible_with": [] - } - }, - "rust_darwin_aarch64__aarch64-apple-darwin__stable_tools": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "rust_toolchain_tools_repository", - "attributes": { - "exec_triple": "aarch64-apple-darwin", - "allocator_library": "@rules_rust//ffi/cc/allocator_library", - "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", - "target_triple": "aarch64-apple-darwin", - "version": "1.81.0", - "rustfmt_version": "nightly/2024-09-05", - "edition": "2021", - "dev_components": false, - "extra_rustc_flags": [], - "extra_exec_rustc_flags": [], - "opt_level": {}, - "sha256s": {}, - "urls": [ - "https://static.rust-lang.org/dist/{}.tar.xz" - ], - "auth": {}, - "netrc": "", - "auth_patterns": [] - } - }, - "rust_darwin_aarch64__aarch64-apple-darwin__stable": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "toolchain_repository_proxy", - "attributes": { - "toolchain": "@rust_darwin_aarch64__aarch64-apple-darwin__stable_tools//:rust_toolchain", - "target_settings": [ - "@rules_rust//rust/toolchain/channel:stable" - ], - "toolchain_type": "@rules_rust//rust:toolchain", - "exec_compatible_with": [ - "@platforms//cpu:aarch64", - "@platforms//os:osx" - ], - "target_compatible_with": [ - "@platforms//cpu:aarch64", - "@platforms//os:osx" - ] - } - }, - "rust_darwin_aarch64__aarch64-apple-darwin__nightly_tools": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "rust_toolchain_tools_repository", - "attributes": { - "exec_triple": "aarch64-apple-darwin", - "allocator_library": "@rules_rust//ffi/cc/allocator_library", - "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", - "target_triple": "aarch64-apple-darwin", - "version": "nightly/2024-09-05", - "rustfmt_version": "nightly/2024-09-05", - "edition": "2021", - "dev_components": false, - "extra_rustc_flags": [], - "extra_exec_rustc_flags": [], - "opt_level": {}, - "sha256s": {}, - "urls": [ - "https://static.rust-lang.org/dist/{}.tar.xz" - ], - "auth": {}, - "netrc": "", - "auth_patterns": [] - } - }, - "rust_darwin_aarch64__aarch64-apple-darwin__nightly": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "toolchain_repository_proxy", - "attributes": { - "toolchain": "@rust_darwin_aarch64__aarch64-apple-darwin__nightly_tools//:rust_toolchain", - "target_settings": [ - "@rules_rust//rust/toolchain/channel:nightly" - ], - "toolchain_type": "@rules_rust//rust:toolchain", - "exec_compatible_with": [ - "@platforms//cpu:aarch64", - "@platforms//os:osx" - ], - "target_compatible_with": [ - "@platforms//cpu:aarch64", - "@platforms//os:osx" - ] - } - }, - "rust_darwin_aarch64__wasm32-unknown-unknown__stable_tools": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "rust_toolchain_tools_repository", - "attributes": { - "exec_triple": "aarch64-apple-darwin", - "allocator_library": "@rules_rust//ffi/cc/allocator_library", - "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", - "target_triple": "wasm32-unknown-unknown", - "version": "1.81.0", - "rustfmt_version": "nightly/2024-09-05", - "edition": "2021", - "dev_components": false, - "extra_rustc_flags": [], - "extra_exec_rustc_flags": [], - "opt_level": {}, - "sha256s": {}, - "urls": [ - "https://static.rust-lang.org/dist/{}.tar.xz" - ], - "auth": {}, - "netrc": "", - "auth_patterns": [] - } - }, - "rust_darwin_aarch64__wasm32-unknown-unknown__stable": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "toolchain_repository_proxy", - "attributes": { - "toolchain": "@rust_darwin_aarch64__wasm32-unknown-unknown__stable_tools//:rust_toolchain", - "target_settings": [ - "@rules_rust//rust/toolchain/channel:stable" - ], - "toolchain_type": "@rules_rust//rust:toolchain", - "exec_compatible_with": [ - "@platforms//cpu:aarch64", - "@platforms//os:osx" - ], - "target_compatible_with": [ - "@platforms//cpu:wasm32", - "@platforms//os:none" - ] - } - }, - "rust_darwin_aarch64__wasm32-unknown-unknown__nightly_tools": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "rust_toolchain_tools_repository", - "attributes": { - "exec_triple": "aarch64-apple-darwin", - "allocator_library": "@rules_rust//ffi/cc/allocator_library", - "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", - "target_triple": "wasm32-unknown-unknown", - "version": "nightly/2024-09-05", - "rustfmt_version": "nightly/2024-09-05", - "edition": "2021", - "dev_components": false, - "extra_rustc_flags": [], - "extra_exec_rustc_flags": [], - "opt_level": {}, - "sha256s": {}, - "urls": [ - "https://static.rust-lang.org/dist/{}.tar.xz" - ], - "auth": {}, - "netrc": "", - "auth_patterns": [] - } - }, - "rust_darwin_aarch64__wasm32-unknown-unknown__nightly": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "toolchain_repository_proxy", - "attributes": { - "toolchain": "@rust_darwin_aarch64__wasm32-unknown-unknown__nightly_tools//:rust_toolchain", - "target_settings": [ - "@rules_rust//rust/toolchain/channel:nightly" - ], - "toolchain_type": "@rules_rust//rust:toolchain", - "exec_compatible_with": [ - "@platforms//cpu:aarch64", - "@platforms//os:osx" - ], - "target_compatible_with": [ - "@platforms//cpu:wasm32", - "@platforms//os:none" - ] - } - }, - "rust_darwin_aarch64__wasm32-wasi__stable_tools": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "rust_toolchain_tools_repository", - "attributes": { - "exec_triple": "aarch64-apple-darwin", - "allocator_library": "@rules_rust//ffi/cc/allocator_library", - "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", - "target_triple": "wasm32-wasi", - "version": "1.81.0", - "rustfmt_version": "nightly/2024-09-05", - "edition": "2021", - "dev_components": false, - "extra_rustc_flags": [], - "extra_exec_rustc_flags": [], - "opt_level": {}, - "sha256s": {}, - "urls": [ - "https://static.rust-lang.org/dist/{}.tar.xz" - ], - "auth": {}, - "netrc": "", - "auth_patterns": [] - } - }, - "rust_darwin_aarch64__wasm32-wasi__stable": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "toolchain_repository_proxy", - "attributes": { - "toolchain": "@rust_darwin_aarch64__wasm32-wasi__stable_tools//:rust_toolchain", - "target_settings": [ - "@rules_rust//rust/toolchain/channel:stable" - ], - "toolchain_type": "@rules_rust//rust:toolchain", - "exec_compatible_with": [ - "@platforms//cpu:aarch64", - "@platforms//os:osx" - ], - "target_compatible_with": [ - "@platforms//cpu:wasm32", - "@platforms//os:wasi" - ] - } - }, - "rust_darwin_aarch64__wasm32-wasi__nightly_tools": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "rust_toolchain_tools_repository", - "attributes": { - "exec_triple": "aarch64-apple-darwin", - "allocator_library": "@rules_rust//ffi/cc/allocator_library", - "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", - "target_triple": "wasm32-wasi", - "version": "nightly/2024-09-05", - "rustfmt_version": "nightly/2024-09-05", - "edition": "2021", - "dev_components": false, - "extra_rustc_flags": [], - "extra_exec_rustc_flags": [], - "opt_level": {}, - "sha256s": {}, - "urls": [ - "https://static.rust-lang.org/dist/{}.tar.xz" - ], - "auth": {}, - "netrc": "", - "auth_patterns": [] - } - }, - "rust_darwin_aarch64__wasm32-wasi__nightly": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "toolchain_repository_proxy", - "attributes": { - "toolchain": "@rust_darwin_aarch64__wasm32-wasi__nightly_tools//:rust_toolchain", - "target_settings": [ - "@rules_rust//rust/toolchain/channel:nightly" - ], - "toolchain_type": "@rules_rust//rust:toolchain", - "exec_compatible_with": [ - "@platforms//cpu:aarch64", - "@platforms//os:osx" - ], - "target_compatible_with": [ - "@platforms//cpu:wasm32", - "@platforms//os:wasi" - ] - } - }, - "rust_darwin_aarch64": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "rust_toolchain_set_repository", - "attributes": { - "toolchains": [ - "@rust_darwin_aarch64__aarch64-apple-darwin__stable//:toolchain", - "@rust_darwin_aarch64__aarch64-apple-darwin__nightly//:toolchain", - "@rust_darwin_aarch64__wasm32-unknown-unknown__stable//:toolchain", - "@rust_darwin_aarch64__wasm32-unknown-unknown__nightly//:toolchain", - "@rust_darwin_aarch64__wasm32-wasi__stable//:toolchain", - "@rust_darwin_aarch64__wasm32-wasi__nightly//:toolchain" - ] - } - }, - "rustfmt_nightly-2024-09-05__aarch64-apple-darwin_tools": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "rustfmt_toolchain_tools_repository", - "attributes": { - "version": "nightly/2024-09-05", - "sha256s": {}, - "urls": [ - "https://static.rust-lang.org/dist/{}.tar.xz" - ], - "auth": {}, - "netrc": "", - "auth_patterns": {}, - "exec_triple": "aarch64-apple-darwin" - } - }, - "rustfmt_nightly-2024-09-05__aarch64-apple-darwin": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "toolchain_repository_proxy", - "attributes": { - "toolchain": "@rustfmt_nightly-2024-09-05__aarch64-apple-darwin_tools//:rustfmt_toolchain", - "toolchain_type": "@rules_rust//rust/rustfmt:toolchain_type", - "target_settings": [], - "exec_compatible_with": [ - "@platforms//cpu:aarch64", - "@platforms//os:osx" - ], - "target_compatible_with": [] - } - }, - "rust_windows_aarch64__aarch64-pc-windows-msvc__stable_tools": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "rust_toolchain_tools_repository", - "attributes": { - "exec_triple": "aarch64-pc-windows-msvc", - "allocator_library": "@rules_rust//ffi/cc/allocator_library", - "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", - "target_triple": "aarch64-pc-windows-msvc", - "version": "1.81.0", - "rustfmt_version": "nightly/2024-09-05", - "edition": "2021", - "dev_components": false, - "extra_rustc_flags": [], - "extra_exec_rustc_flags": [], - "opt_level": {}, - "sha256s": {}, - "urls": [ - "https://static.rust-lang.org/dist/{}.tar.xz" - ], - "auth": {}, - "netrc": "", - "auth_patterns": [] - } - }, - "rust_windows_aarch64__aarch64-pc-windows-msvc__stable": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "toolchain_repository_proxy", - "attributes": { - "toolchain": "@rust_windows_aarch64__aarch64-pc-windows-msvc__stable_tools//:rust_toolchain", - "target_settings": [ - "@rules_rust//rust/toolchain/channel:stable" - ], - "toolchain_type": "@rules_rust//rust:toolchain", - "exec_compatible_with": [ - "@platforms//cpu:aarch64", - "@platforms//os:windows" - ], - "target_compatible_with": [ - "@platforms//cpu:aarch64", - "@platforms//os:windows" - ] - } - }, - "rust_windows_aarch64__aarch64-pc-windows-msvc__nightly_tools": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "rust_toolchain_tools_repository", - "attributes": { - "exec_triple": "aarch64-pc-windows-msvc", - "allocator_library": "@rules_rust//ffi/cc/allocator_library", - "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", - "target_triple": "aarch64-pc-windows-msvc", - "version": "nightly/2024-09-05", - "rustfmt_version": "nightly/2024-09-05", - "edition": "2021", - "dev_components": false, - "extra_rustc_flags": [], - "extra_exec_rustc_flags": [], - "opt_level": {}, - "sha256s": {}, - "urls": [ - "https://static.rust-lang.org/dist/{}.tar.xz" - ], - "auth": {}, - "netrc": "", - "auth_patterns": [] - } - }, - "rust_windows_aarch64__aarch64-pc-windows-msvc__nightly": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "toolchain_repository_proxy", - "attributes": { - "toolchain": "@rust_windows_aarch64__aarch64-pc-windows-msvc__nightly_tools//:rust_toolchain", - "target_settings": [ - "@rules_rust//rust/toolchain/channel:nightly" - ], - "toolchain_type": "@rules_rust//rust:toolchain", - "exec_compatible_with": [ - "@platforms//cpu:aarch64", - "@platforms//os:windows" - ], - "target_compatible_with": [ - "@platforms//cpu:aarch64", - "@platforms//os:windows" - ] - } - }, - "rust_windows_aarch64__wasm32-unknown-unknown__stable_tools": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "rust_toolchain_tools_repository", - "attributes": { - "exec_triple": "aarch64-pc-windows-msvc", - "allocator_library": "@rules_rust//ffi/cc/allocator_library", - "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", - "target_triple": "wasm32-unknown-unknown", - "version": "1.81.0", - "rustfmt_version": "nightly/2024-09-05", - "edition": "2021", - "dev_components": false, - "extra_rustc_flags": [], - "extra_exec_rustc_flags": [], - "opt_level": {}, - "sha256s": {}, - "urls": [ - "https://static.rust-lang.org/dist/{}.tar.xz" - ], - "auth": {}, - "netrc": "", - "auth_patterns": [] - } - }, - "rust_windows_aarch64__wasm32-unknown-unknown__stable": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "toolchain_repository_proxy", - "attributes": { - "toolchain": "@rust_windows_aarch64__wasm32-unknown-unknown__stable_tools//:rust_toolchain", - "target_settings": [ - "@rules_rust//rust/toolchain/channel:stable" - ], - "toolchain_type": "@rules_rust//rust:toolchain", - "exec_compatible_with": [ - "@platforms//cpu:aarch64", - "@platforms//os:windows" - ], - "target_compatible_with": [ - "@platforms//cpu:wasm32", - "@platforms//os:none" - ] - } - }, - "rust_windows_aarch64__wasm32-unknown-unknown__nightly_tools": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "rust_toolchain_tools_repository", - "attributes": { - "exec_triple": "aarch64-pc-windows-msvc", - "allocator_library": "@rules_rust//ffi/cc/allocator_library", - "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", - "target_triple": "wasm32-unknown-unknown", - "version": "nightly/2024-09-05", - "rustfmt_version": "nightly/2024-09-05", - "edition": "2021", - "dev_components": false, - "extra_rustc_flags": [], - "extra_exec_rustc_flags": [], - "opt_level": {}, - "sha256s": {}, - "urls": [ - "https://static.rust-lang.org/dist/{}.tar.xz" - ], - "auth": {}, - "netrc": "", - "auth_patterns": [] - } - }, - "rust_windows_aarch64__wasm32-unknown-unknown__nightly": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "toolchain_repository_proxy", - "attributes": { - "toolchain": "@rust_windows_aarch64__wasm32-unknown-unknown__nightly_tools//:rust_toolchain", - "target_settings": [ - "@rules_rust//rust/toolchain/channel:nightly" - ], - "toolchain_type": "@rules_rust//rust:toolchain", - "exec_compatible_with": [ - "@platforms//cpu:aarch64", - "@platforms//os:windows" - ], - "target_compatible_with": [ - "@platforms//cpu:wasm32", - "@platforms//os:none" - ] - } - }, - "rust_windows_aarch64__wasm32-wasi__stable_tools": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "rust_toolchain_tools_repository", - "attributes": { - "exec_triple": "aarch64-pc-windows-msvc", - "allocator_library": "@rules_rust//ffi/cc/allocator_library", - "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", - "target_triple": "wasm32-wasi", - "version": "1.81.0", - "rustfmt_version": "nightly/2024-09-05", - "edition": "2021", - "dev_components": false, - "extra_rustc_flags": [], - "extra_exec_rustc_flags": [], - "opt_level": {}, - "sha256s": {}, - "urls": [ - "https://static.rust-lang.org/dist/{}.tar.xz" - ], - "auth": {}, - "netrc": "", - "auth_patterns": [] - } - }, - "rust_windows_aarch64__wasm32-wasi__stable": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "toolchain_repository_proxy", - "attributes": { - "toolchain": "@rust_windows_aarch64__wasm32-wasi__stable_tools//:rust_toolchain", - "target_settings": [ - "@rules_rust//rust/toolchain/channel:stable" - ], - "toolchain_type": "@rules_rust//rust:toolchain", - "exec_compatible_with": [ - "@platforms//cpu:aarch64", - "@platforms//os:windows" - ], - "target_compatible_with": [ - "@platforms//cpu:wasm32", - "@platforms//os:wasi" - ] - } - }, - "rust_windows_aarch64__wasm32-wasi__nightly_tools": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "rust_toolchain_tools_repository", - "attributes": { - "exec_triple": "aarch64-pc-windows-msvc", - "allocator_library": "@rules_rust//ffi/cc/allocator_library", - "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", - "target_triple": "wasm32-wasi", - "version": "nightly/2024-09-05", - "rustfmt_version": "nightly/2024-09-05", - "edition": "2021", - "dev_components": false, - "extra_rustc_flags": [], - "extra_exec_rustc_flags": [], - "opt_level": {}, - "sha256s": {}, - "urls": [ - "https://static.rust-lang.org/dist/{}.tar.xz" - ], - "auth": {}, - "netrc": "", - "auth_patterns": [] - } - }, - "rust_windows_aarch64__wasm32-wasi__nightly": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "toolchain_repository_proxy", - "attributes": { - "toolchain": "@rust_windows_aarch64__wasm32-wasi__nightly_tools//:rust_toolchain", - "target_settings": [ - "@rules_rust//rust/toolchain/channel:nightly" - ], - "toolchain_type": "@rules_rust//rust:toolchain", - "exec_compatible_with": [ - "@platforms//cpu:aarch64", - "@platforms//os:windows" - ], - "target_compatible_with": [ - "@platforms//cpu:wasm32", - "@platforms//os:wasi" - ] - } - }, - "rust_windows_aarch64": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "rust_toolchain_set_repository", - "attributes": { - "toolchains": [ - "@rust_windows_aarch64__aarch64-pc-windows-msvc__stable//:toolchain", - "@rust_windows_aarch64__aarch64-pc-windows-msvc__nightly//:toolchain", - "@rust_windows_aarch64__wasm32-unknown-unknown__stable//:toolchain", - "@rust_windows_aarch64__wasm32-unknown-unknown__nightly//:toolchain", - "@rust_windows_aarch64__wasm32-wasi__stable//:toolchain", - "@rust_windows_aarch64__wasm32-wasi__nightly//:toolchain" - ] - } - }, - "rustfmt_nightly-2024-09-05__aarch64-pc-windows-msvc_tools": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "rustfmt_toolchain_tools_repository", + "rules_python_internal": { + "repoRuleId": "@@rules_python+//python/private:internal_config_repo.bzl%internal_config_repo", "attributes": { - "version": "nightly/2024-09-05", - "sha256s": {}, - "urls": [ - "https://static.rust-lang.org/dist/{}.tar.xz" - ], - "auth": {}, - "netrc": "", - "auth_patterns": {}, - "exec_triple": "aarch64-pc-windows-msvc" + "transition_setting_generators": {}, + "transition_settings": [] } }, - "rustfmt_nightly-2024-09-05__aarch64-pc-windows-msvc": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "toolchain_repository_proxy", + "pypi__build": { + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", "attributes": { - "toolchain": "@rustfmt_nightly-2024-09-05__aarch64-pc-windows-msvc_tools//:rustfmt_toolchain", - "toolchain_type": "@rules_rust//rust/rustfmt:toolchain_type", - "target_settings": [], - "exec_compatible_with": [ - "@platforms//cpu:aarch64", - "@platforms//os:windows" - ], - "target_compatible_with": [] + "url": "https://files.pythonhosted.org/packages/e2/03/f3c8ba0a6b6e30d7d18c40faab90807c9bb5e9a1e3b2fe2008af624a9c97/build-1.2.1-py3-none-any.whl", + "sha256": "75e10f767a433d9a86e50d83f418e83efc18ede923ee5ff7df93b6cb0306c5d4", + "type": "zip", + "build_file_content": "package(default_visibility = [\"//visibility:public\"])\n\nload(\"@rules_python//python:py_library.bzl\", \"py_library\")\n\npy_library(\n name = \"lib\",\n srcs = glob([\"**/*.py\"]),\n data = glob([\"**/*\"], exclude=[\n # These entries include those put into user-installed dependencies by\n # data_exclude to avoid non-determinism.\n \"**/*.py\",\n \"**/*.pyc\",\n \"**/*.pyc.*\", # During pyc creation, temp files named *.pyc.NNN are created\n \"**/*.dist-info/RECORD\",\n \"BUILD\",\n \"WORKSPACE\",\n ]),\n # This makes this directory a top-level in the python import\n # search path for anything that depends on this.\n imports = [\".\"],\n)\n" } }, - "rust_linux_aarch64__aarch64-unknown-linux-gnu__stable_tools": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "rust_toolchain_tools_repository", + "pypi__click": { + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", "attributes": { - "exec_triple": "aarch64-unknown-linux-gnu", - "allocator_library": "@rules_rust//ffi/cc/allocator_library", - "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", - "target_triple": "aarch64-unknown-linux-gnu", - "version": "1.81.0", - "rustfmt_version": "nightly/2024-09-05", - "edition": "2021", - "dev_components": false, - "extra_rustc_flags": [], - "extra_exec_rustc_flags": [], - "opt_level": {}, - "sha256s": {}, - "urls": [ - "https://static.rust-lang.org/dist/{}.tar.xz" - ], - "auth": {}, - "netrc": "", - "auth_patterns": [] + "url": "https://files.pythonhosted.org/packages/00/2e/d53fa4befbf2cfa713304affc7ca780ce4fc1fd8710527771b58311a3229/click-8.1.7-py3-none-any.whl", + "sha256": "ae74fb96c20a0277a1d615f1e4d73c8414f5a98db8b799a7931d1582f3390c28", + "type": "zip", + "build_file_content": "package(default_visibility = [\"//visibility:public\"])\n\nload(\"@rules_python//python:py_library.bzl\", \"py_library\")\n\npy_library(\n name = \"lib\",\n srcs = glob([\"**/*.py\"]),\n data = glob([\"**/*\"], exclude=[\n # These entries include those put into user-installed dependencies by\n # data_exclude to avoid non-determinism.\n \"**/*.py\",\n \"**/*.pyc\",\n \"**/*.pyc.*\", # During pyc creation, temp files named *.pyc.NNN are created\n \"**/*.dist-info/RECORD\",\n \"BUILD\",\n \"WORKSPACE\",\n ]),\n # This makes this directory a top-level in the python import\n # search path for anything that depends on this.\n imports = [\".\"],\n)\n" } }, - "rust_linux_aarch64__aarch64-unknown-linux-gnu__stable": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "toolchain_repository_proxy", + "pypi__colorama": { + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", "attributes": { - "toolchain": "@rust_linux_aarch64__aarch64-unknown-linux-gnu__stable_tools//:rust_toolchain", - "target_settings": [ - "@rules_rust//rust/toolchain/channel:stable" - ], - "toolchain_type": "@rules_rust//rust:toolchain", - "exec_compatible_with": [ - "@platforms//cpu:aarch64", - "@platforms//os:linux" - ], - "target_compatible_with": [ - "@platforms//cpu:aarch64", - "@platforms//os:linux" - ] + "url": "https://files.pythonhosted.org/packages/d1/d6/3965ed04c63042e047cb6a3e6ed1a63a35087b6a609aa3a15ed8ac56c221/colorama-0.4.6-py2.py3-none-any.whl", + "sha256": "4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6", + "type": "zip", + "build_file_content": "package(default_visibility = [\"//visibility:public\"])\n\nload(\"@rules_python//python:py_library.bzl\", \"py_library\")\n\npy_library(\n name = \"lib\",\n srcs = glob([\"**/*.py\"]),\n data = glob([\"**/*\"], exclude=[\n # These entries include those put into user-installed dependencies by\n # data_exclude to avoid non-determinism.\n \"**/*.py\",\n \"**/*.pyc\",\n \"**/*.pyc.*\", # During pyc creation, temp files named *.pyc.NNN are created\n \"**/*.dist-info/RECORD\",\n \"BUILD\",\n \"WORKSPACE\",\n ]),\n # This makes this directory a top-level in the python import\n # search path for anything that depends on this.\n imports = [\".\"],\n)\n" } }, - "rust_linux_aarch64__aarch64-unknown-linux-gnu__nightly_tools": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "rust_toolchain_tools_repository", + "pypi__importlib_metadata": { + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", "attributes": { - "exec_triple": "aarch64-unknown-linux-gnu", - "allocator_library": "@rules_rust//ffi/cc/allocator_library", - "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", - "target_triple": "aarch64-unknown-linux-gnu", - "version": "nightly/2024-09-05", - "rustfmt_version": "nightly/2024-09-05", - "edition": "2021", - "dev_components": false, - "extra_rustc_flags": [], - "extra_exec_rustc_flags": [], - "opt_level": {}, - "sha256s": {}, - "urls": [ - "https://static.rust-lang.org/dist/{}.tar.xz" - ], - "auth": {}, - "netrc": "", - "auth_patterns": [] + "url": "https://files.pythonhosted.org/packages/2d/0a/679461c511447ffaf176567d5c496d1de27cbe34a87df6677d7171b2fbd4/importlib_metadata-7.1.0-py3-none-any.whl", + "sha256": "30962b96c0c223483ed6cc7280e7f0199feb01a0e40cfae4d4450fc6fab1f570", + "type": "zip", + "build_file_content": "package(default_visibility = [\"//visibility:public\"])\n\nload(\"@rules_python//python:py_library.bzl\", \"py_library\")\n\npy_library(\n name = \"lib\",\n srcs = glob([\"**/*.py\"]),\n data = glob([\"**/*\"], exclude=[\n # These entries include those put into user-installed dependencies by\n # data_exclude to avoid non-determinism.\n \"**/*.py\",\n \"**/*.pyc\",\n \"**/*.pyc.*\", # During pyc creation, temp files named *.pyc.NNN are created\n \"**/*.dist-info/RECORD\",\n \"BUILD\",\n \"WORKSPACE\",\n ]),\n # This makes this directory a top-level in the python import\n # search path for anything that depends on this.\n imports = [\".\"],\n)\n" } }, - "rust_linux_aarch64__aarch64-unknown-linux-gnu__nightly": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "toolchain_repository_proxy", + "pypi__installer": { + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", "attributes": { - "toolchain": "@rust_linux_aarch64__aarch64-unknown-linux-gnu__nightly_tools//:rust_toolchain", - "target_settings": [ - "@rules_rust//rust/toolchain/channel:nightly" - ], - "toolchain_type": "@rules_rust//rust:toolchain", - "exec_compatible_with": [ - "@platforms//cpu:aarch64", - "@platforms//os:linux" - ], - "target_compatible_with": [ - "@platforms//cpu:aarch64", - "@platforms//os:linux" - ] + "url": "https://files.pythonhosted.org/packages/e5/ca/1172b6638d52f2d6caa2dd262ec4c811ba59eee96d54a7701930726bce18/installer-0.7.0-py3-none-any.whl", + "sha256": "05d1933f0a5ba7d8d6296bb6d5018e7c94fa473ceb10cf198a92ccea19c27b53", + "type": "zip", + "build_file_content": "package(default_visibility = [\"//visibility:public\"])\n\nload(\"@rules_python//python:py_library.bzl\", \"py_library\")\n\npy_library(\n name = \"lib\",\n srcs = glob([\"**/*.py\"]),\n data = glob([\"**/*\"], exclude=[\n # These entries include those put into user-installed dependencies by\n # data_exclude to avoid non-determinism.\n \"**/*.py\",\n \"**/*.pyc\",\n \"**/*.pyc.*\", # During pyc creation, temp files named *.pyc.NNN are created\n \"**/*.dist-info/RECORD\",\n \"BUILD\",\n \"WORKSPACE\",\n ]),\n # This makes this directory a top-level in the python import\n # search path for anything that depends on this.\n imports = [\".\"],\n)\n" } }, - "rust_linux_aarch64__wasm32-unknown-unknown__stable_tools": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "rust_toolchain_tools_repository", + "pypi__more_itertools": { + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", "attributes": { - "exec_triple": "aarch64-unknown-linux-gnu", - "allocator_library": "@rules_rust//ffi/cc/allocator_library", - "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", - "target_triple": "wasm32-unknown-unknown", - "version": "1.81.0", - "rustfmt_version": "nightly/2024-09-05", - "edition": "2021", - "dev_components": false, - "extra_rustc_flags": [], - "extra_exec_rustc_flags": [], - "opt_level": {}, - "sha256s": {}, - "urls": [ - "https://static.rust-lang.org/dist/{}.tar.xz" - ], - "auth": {}, - "netrc": "", - "auth_patterns": [] + "url": "https://files.pythonhosted.org/packages/50/e2/8e10e465ee3987bb7c9ab69efb91d867d93959095f4807db102d07995d94/more_itertools-10.2.0-py3-none-any.whl", + "sha256": "686b06abe565edfab151cb8fd385a05651e1fdf8f0a14191e4439283421f8684", + "type": "zip", + "build_file_content": "package(default_visibility = [\"//visibility:public\"])\n\nload(\"@rules_python//python:py_library.bzl\", \"py_library\")\n\npy_library(\n name = \"lib\",\n srcs = glob([\"**/*.py\"]),\n data = glob([\"**/*\"], exclude=[\n # These entries include those put into user-installed dependencies by\n # data_exclude to avoid non-determinism.\n \"**/*.py\",\n \"**/*.pyc\",\n \"**/*.pyc.*\", # During pyc creation, temp files named *.pyc.NNN are created\n \"**/*.dist-info/RECORD\",\n \"BUILD\",\n \"WORKSPACE\",\n ]),\n # This makes this directory a top-level in the python import\n # search path for anything that depends on this.\n imports = [\".\"],\n)\n" } }, - "rust_linux_aarch64__wasm32-unknown-unknown__stable": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "toolchain_repository_proxy", + "pypi__packaging": { + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", "attributes": { - "toolchain": "@rust_linux_aarch64__wasm32-unknown-unknown__stable_tools//:rust_toolchain", - "target_settings": [ - "@rules_rust//rust/toolchain/channel:stable" - ], - "toolchain_type": "@rules_rust//rust:toolchain", - "exec_compatible_with": [ - "@platforms//cpu:aarch64", - "@platforms//os:linux" - ], - "target_compatible_with": [ - "@platforms//cpu:wasm32", - "@platforms//os:none" - ] + "url": "https://files.pythonhosted.org/packages/49/df/1fceb2f8900f8639e278b056416d49134fb8d84c5942ffaa01ad34782422/packaging-24.0-py3-none-any.whl", + "sha256": "2ddfb553fdf02fb784c234c7ba6ccc288296ceabec964ad2eae3777778130bc5", + "type": "zip", + "build_file_content": "package(default_visibility = [\"//visibility:public\"])\n\nload(\"@rules_python//python:py_library.bzl\", \"py_library\")\n\npy_library(\n name = \"lib\",\n srcs = glob([\"**/*.py\"]),\n data = glob([\"**/*\"], exclude=[\n # These entries include those put into user-installed dependencies by\n # data_exclude to avoid non-determinism.\n \"**/*.py\",\n \"**/*.pyc\",\n \"**/*.pyc.*\", # During pyc creation, temp files named *.pyc.NNN are created\n \"**/*.dist-info/RECORD\",\n \"BUILD\",\n \"WORKSPACE\",\n ]),\n # This makes this directory a top-level in the python import\n # search path for anything that depends on this.\n imports = [\".\"],\n)\n" } }, - "rust_linux_aarch64__wasm32-unknown-unknown__nightly_tools": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "rust_toolchain_tools_repository", + "pypi__pep517": { + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", "attributes": { - "exec_triple": "aarch64-unknown-linux-gnu", - "allocator_library": "@rules_rust//ffi/cc/allocator_library", - "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", - "target_triple": "wasm32-unknown-unknown", - "version": "nightly/2024-09-05", - "rustfmt_version": "nightly/2024-09-05", - "edition": "2021", - "dev_components": false, - "extra_rustc_flags": [], - "extra_exec_rustc_flags": [], - "opt_level": {}, - "sha256s": {}, - "urls": [ - "https://static.rust-lang.org/dist/{}.tar.xz" - ], - "auth": {}, - "netrc": "", - "auth_patterns": [] + "url": "https://files.pythonhosted.org/packages/25/6e/ca4a5434eb0e502210f591b97537d322546e4833dcb4d470a48c375c5540/pep517-0.13.1-py3-none-any.whl", + "sha256": "31b206f67165b3536dd577c5c3f1518e8fbaf38cbc57efff8369a392feff1721", + "type": "zip", + "build_file_content": "package(default_visibility = [\"//visibility:public\"])\n\nload(\"@rules_python//python:py_library.bzl\", \"py_library\")\n\npy_library(\n name = \"lib\",\n srcs = glob([\"**/*.py\"]),\n data = glob([\"**/*\"], exclude=[\n # These entries include those put into user-installed dependencies by\n # data_exclude to avoid non-determinism.\n \"**/*.py\",\n \"**/*.pyc\",\n \"**/*.pyc.*\", # During pyc creation, temp files named *.pyc.NNN are created\n \"**/*.dist-info/RECORD\",\n \"BUILD\",\n \"WORKSPACE\",\n ]),\n # This makes this directory a top-level in the python import\n # search path for anything that depends on this.\n imports = [\".\"],\n)\n" } }, - "rust_linux_aarch64__wasm32-unknown-unknown__nightly": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "toolchain_repository_proxy", + "pypi__pip": { + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", "attributes": { - "toolchain": "@rust_linux_aarch64__wasm32-unknown-unknown__nightly_tools//:rust_toolchain", - "target_settings": [ - "@rules_rust//rust/toolchain/channel:nightly" - ], - "toolchain_type": "@rules_rust//rust:toolchain", - "exec_compatible_with": [ - "@platforms//cpu:aarch64", - "@platforms//os:linux" - ], - "target_compatible_with": [ - "@platforms//cpu:wasm32", - "@platforms//os:none" - ] + "url": "https://files.pythonhosted.org/packages/8a/6a/19e9fe04fca059ccf770861c7d5721ab4c2aebc539889e97c7977528a53b/pip-24.0-py3-none-any.whl", + "sha256": "ba0d021a166865d2265246961bec0152ff124de910c5cc39f1156ce3fa7c69dc", + "type": "zip", + "build_file_content": "package(default_visibility = [\"//visibility:public\"])\n\nload(\"@rules_python//python:py_library.bzl\", \"py_library\")\n\npy_library(\n name = \"lib\",\n srcs = glob([\"**/*.py\"]),\n data = glob([\"**/*\"], exclude=[\n # These entries include those put into user-installed dependencies by\n # data_exclude to avoid non-determinism.\n \"**/*.py\",\n \"**/*.pyc\",\n \"**/*.pyc.*\", # During pyc creation, temp files named *.pyc.NNN are created\n \"**/*.dist-info/RECORD\",\n \"BUILD\",\n \"WORKSPACE\",\n ]),\n # This makes this directory a top-level in the python import\n # search path for anything that depends on this.\n imports = [\".\"],\n)\n" } }, - "rust_linux_aarch64__wasm32-wasi__stable_tools": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "rust_toolchain_tools_repository", + "pypi__pip_tools": { + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", "attributes": { - "exec_triple": "aarch64-unknown-linux-gnu", - "allocator_library": "@rules_rust//ffi/cc/allocator_library", - "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", - "target_triple": "wasm32-wasi", - "version": "1.81.0", - "rustfmt_version": "nightly/2024-09-05", - "edition": "2021", - "dev_components": false, - "extra_rustc_flags": [], - "extra_exec_rustc_flags": [], - "opt_level": {}, - "sha256s": {}, - "urls": [ - "https://static.rust-lang.org/dist/{}.tar.xz" - ], - "auth": {}, - "netrc": "", - "auth_patterns": [] + "url": "https://files.pythonhosted.org/packages/0d/dc/38f4ce065e92c66f058ea7a368a9c5de4e702272b479c0992059f7693941/pip_tools-7.4.1-py3-none-any.whl", + "sha256": "4c690e5fbae2f21e87843e89c26191f0d9454f362d8acdbd695716493ec8b3a9", + "type": "zip", + "build_file_content": "package(default_visibility = [\"//visibility:public\"])\n\nload(\"@rules_python//python:py_library.bzl\", \"py_library\")\n\npy_library(\n name = \"lib\",\n srcs = glob([\"**/*.py\"]),\n data = glob([\"**/*\"], exclude=[\n # These entries include those put into user-installed dependencies by\n # data_exclude to avoid non-determinism.\n \"**/*.py\",\n \"**/*.pyc\",\n \"**/*.pyc.*\", # During pyc creation, temp files named *.pyc.NNN are created\n \"**/*.dist-info/RECORD\",\n \"BUILD\",\n \"WORKSPACE\",\n ]),\n # This makes this directory a top-level in the python import\n # search path for anything that depends on this.\n imports = [\".\"],\n)\n" } }, - "rust_linux_aarch64__wasm32-wasi__stable": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "toolchain_repository_proxy", + "pypi__pyproject_hooks": { + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", "attributes": { - "toolchain": "@rust_linux_aarch64__wasm32-wasi__stable_tools//:rust_toolchain", - "target_settings": [ - "@rules_rust//rust/toolchain/channel:stable" - ], - "toolchain_type": "@rules_rust//rust:toolchain", - "exec_compatible_with": [ - "@platforms//cpu:aarch64", - "@platforms//os:linux" - ], - "target_compatible_with": [ - "@platforms//cpu:wasm32", - "@platforms//os:wasi" - ] + "url": "https://files.pythonhosted.org/packages/ae/f3/431b9d5fe7d14af7a32340792ef43b8a714e7726f1d7b69cc4e8e7a3f1d7/pyproject_hooks-1.1.0-py3-none-any.whl", + "sha256": "7ceeefe9aec63a1064c18d939bdc3adf2d8aa1988a510afec15151578b232aa2", + "type": "zip", + "build_file_content": "package(default_visibility = [\"//visibility:public\"])\n\nload(\"@rules_python//python:py_library.bzl\", \"py_library\")\n\npy_library(\n name = \"lib\",\n srcs = glob([\"**/*.py\"]),\n data = glob([\"**/*\"], exclude=[\n # These entries include those put into user-installed dependencies by\n # data_exclude to avoid non-determinism.\n \"**/*.py\",\n \"**/*.pyc\",\n \"**/*.pyc.*\", # During pyc creation, temp files named *.pyc.NNN are created\n \"**/*.dist-info/RECORD\",\n \"BUILD\",\n \"WORKSPACE\",\n ]),\n # This makes this directory a top-level in the python import\n # search path for anything that depends on this.\n imports = [\".\"],\n)\n" } }, - "rust_linux_aarch64__wasm32-wasi__nightly_tools": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "rust_toolchain_tools_repository", + "pypi__setuptools": { + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", "attributes": { - "exec_triple": "aarch64-unknown-linux-gnu", - "allocator_library": "@rules_rust//ffi/cc/allocator_library", - "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", - "target_triple": "wasm32-wasi", - "version": "nightly/2024-09-05", - "rustfmt_version": "nightly/2024-09-05", - "edition": "2021", - "dev_components": false, - "extra_rustc_flags": [], - "extra_exec_rustc_flags": [], - "opt_level": {}, - "sha256s": {}, - "urls": [ - "https://static.rust-lang.org/dist/{}.tar.xz" - ], - "auth": {}, - "netrc": "", - "auth_patterns": [] + "url": "https://files.pythonhosted.org/packages/90/99/158ad0609729111163fc1f674a5a42f2605371a4cf036d0441070e2f7455/setuptools-78.1.1-py3-none-any.whl", + "sha256": "c3a9c4211ff4c309edb8b8c4f1cbfa7ae324c4ba9f91ff254e3d305b9fd54561", + "type": "zip", + "build_file_content": "package(default_visibility = [\"//visibility:public\"])\n\nload(\"@rules_python//python:py_library.bzl\", \"py_library\")\n\npy_library(\n name = \"lib\",\n srcs = glob([\"**/*.py\"]),\n data = glob([\"**/*\"], exclude=[\n # These entries include those put into user-installed dependencies by\n # data_exclude to avoid non-determinism.\n \"**/*.py\",\n \"**/*.pyc\",\n \"**/*.pyc.*\", # During pyc creation, temp files named *.pyc.NNN are created\n \"**/*.dist-info/RECORD\",\n \"BUILD\",\n \"WORKSPACE\",\n ]),\n # This makes this directory a top-level in the python import\n # search path for anything that depends on this.\n imports = [\".\"],\n)\n" } }, - "rust_linux_aarch64__wasm32-wasi__nightly": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "toolchain_repository_proxy", + "pypi__tomli": { + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", "attributes": { - "toolchain": "@rust_linux_aarch64__wasm32-wasi__nightly_tools//:rust_toolchain", - "target_settings": [ - "@rules_rust//rust/toolchain/channel:nightly" - ], - "toolchain_type": "@rules_rust//rust:toolchain", - "exec_compatible_with": [ - "@platforms//cpu:aarch64", - "@platforms//os:linux" - ], - "target_compatible_with": [ - "@platforms//cpu:wasm32", - "@platforms//os:wasi" - ] + "url": "https://files.pythonhosted.org/packages/97/75/10a9ebee3fd790d20926a90a2547f0bf78f371b2f13aa822c759680ca7b9/tomli-2.0.1-py3-none-any.whl", + "sha256": "939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc", + "type": "zip", + "build_file_content": "package(default_visibility = [\"//visibility:public\"])\n\nload(\"@rules_python//python:py_library.bzl\", \"py_library\")\n\npy_library(\n name = \"lib\",\n srcs = glob([\"**/*.py\"]),\n data = glob([\"**/*\"], exclude=[\n # These entries include those put into user-installed dependencies by\n # data_exclude to avoid non-determinism.\n \"**/*.py\",\n \"**/*.pyc\",\n \"**/*.pyc.*\", # During pyc creation, temp files named *.pyc.NNN are created\n \"**/*.dist-info/RECORD\",\n \"BUILD\",\n \"WORKSPACE\",\n ]),\n # This makes this directory a top-level in the python import\n # search path for anything that depends on this.\n imports = [\".\"],\n)\n" } }, - "rust_linux_aarch64": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "rust_toolchain_set_repository", + "pypi__wheel": { + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", "attributes": { - "toolchains": [ - "@rust_linux_aarch64__aarch64-unknown-linux-gnu__stable//:toolchain", - "@rust_linux_aarch64__aarch64-unknown-linux-gnu__nightly//:toolchain", - "@rust_linux_aarch64__wasm32-unknown-unknown__stable//:toolchain", - "@rust_linux_aarch64__wasm32-unknown-unknown__nightly//:toolchain", - "@rust_linux_aarch64__wasm32-wasi__stable//:toolchain", - "@rust_linux_aarch64__wasm32-wasi__nightly//:toolchain" - ] + "url": "https://files.pythonhosted.org/packages/7d/cd/d7460c9a869b16c3dd4e1e403cce337df165368c71d6af229a74699622ce/wheel-0.43.0-py3-none-any.whl", + "sha256": "55c570405f142630c6b9f72fe09d9b67cf1477fcf543ae5b8dcb1f5b7377da81", + "type": "zip", + "build_file_content": "package(default_visibility = [\"//visibility:public\"])\n\nload(\"@rules_python//python:py_library.bzl\", \"py_library\")\n\npy_library(\n name = \"lib\",\n srcs = glob([\"**/*.py\"]),\n data = glob([\"**/*\"], exclude=[\n # These entries include those put into user-installed dependencies by\n # data_exclude to avoid non-determinism.\n \"**/*.py\",\n \"**/*.pyc\",\n \"**/*.pyc.*\", # During pyc creation, temp files named *.pyc.NNN are created\n \"**/*.dist-info/RECORD\",\n \"BUILD\",\n \"WORKSPACE\",\n ]),\n # This makes this directory a top-level in the python import\n # search path for anything that depends on this.\n imports = [\".\"],\n)\n" } }, - "rustfmt_nightly-2024-09-05__aarch64-unknown-linux-gnu_tools": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "rustfmt_toolchain_tools_repository", + "pypi__zipp": { + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", "attributes": { - "version": "nightly/2024-09-05", - "sha256s": {}, - "urls": [ - "https://static.rust-lang.org/dist/{}.tar.xz" - ], - "auth": {}, - "netrc": "", - "auth_patterns": {}, - "exec_triple": "aarch64-unknown-linux-gnu" + "url": "https://files.pythonhosted.org/packages/da/55/a03fd7240714916507e1fcf7ae355bd9d9ed2e6db492595f1a67f61681be/zipp-3.18.2-py3-none-any.whl", + "sha256": "dce197b859eb796242b0622af1b8beb0a722d52aa2f57133ead08edd5bf5374e", + "type": "zip", + "build_file_content": "package(default_visibility = [\"//visibility:public\"])\n\nload(\"@rules_python//python:py_library.bzl\", \"py_library\")\n\npy_library(\n name = \"lib\",\n srcs = glob([\"**/*.py\"]),\n data = glob([\"**/*\"], exclude=[\n # These entries include those put into user-installed dependencies by\n # data_exclude to avoid non-determinism.\n \"**/*.py\",\n \"**/*.pyc\",\n \"**/*.pyc.*\", # During pyc creation, temp files named *.pyc.NNN are created\n \"**/*.dist-info/RECORD\",\n \"BUILD\",\n \"WORKSPACE\",\n ]),\n # This makes this directory a top-level in the python import\n # search path for anything that depends on this.\n imports = [\".\"],\n)\n" } - }, - "rustfmt_nightly-2024-09-05__aarch64-unknown-linux-gnu": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "toolchain_repository_proxy", + } + } + } + }, + "@@rules_python+//python/uv:uv.bzl%uv": { + "general": { + "bzlTransitiveDigest": "ijW9KS7qsIY+yBVvJ+Nr1mzwQox09j13DnE3iIwaeTM=", + "usagesDigest": "H8dQoNZcoqP+Mu0tHZTi4KHATzvNkM5ePuEqoQdklIU=", + "recordedInputs": [ + "REPO_MAPPING:rules_python+,bazel_tools bazel_tools", + "REPO_MAPPING:rules_python+,platforms platforms" + ], + "generatedRepoSpecs": { + "uv": { + "repoRuleId": "@@rules_python+//python/uv/private:uv_toolchains_repo.bzl%uv_toolchains_repo", "attributes": { - "toolchain": "@rustfmt_nightly-2024-09-05__aarch64-unknown-linux-gnu_tools//:rustfmt_toolchain", - "toolchain_type": "@rules_rust//rust/rustfmt:toolchain_type", - "target_settings": [], - "exec_compatible_with": [ - "@platforms//cpu:aarch64", - "@platforms//os:linux" + "toolchain_type": "'@@rules_python+//python/uv:uv_toolchain_type'", + "toolchain_names": [ + "none" ], - "target_compatible_with": [] - } - }, - "rust_linux_s390x__s390x-unknown-linux-gnu__stable_tools": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "rust_toolchain_tools_repository", - "attributes": { - "exec_triple": "s390x-unknown-linux-gnu", - "allocator_library": "@rules_rust//ffi/cc/allocator_library", - "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", - "target_triple": "s390x-unknown-linux-gnu", - "version": "1.81.0", - "rustfmt_version": "nightly/2024-09-05", - "edition": "2021", - "dev_components": false, - "extra_rustc_flags": [], - "extra_exec_rustc_flags": [], - "opt_level": {}, - "sha256s": {}, - "urls": [ - "https://static.rust-lang.org/dist/{}.tar.xz" - ], - "auth": {}, - "netrc": "", - "auth_patterns": [] - } - }, - "rust_linux_s390x__s390x-unknown-linux-gnu__stable": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "toolchain_repository_proxy", - "attributes": { - "toolchain": "@rust_linux_s390x__s390x-unknown-linux-gnu__stable_tools//:rust_toolchain", - "target_settings": [ - "@rules_rust//rust/toolchain/channel:stable" - ], - "toolchain_type": "@rules_rust//rust:toolchain", - "exec_compatible_with": [ - "@platforms//cpu:s390x", - "@platforms//os:linux" - ], - "target_compatible_with": [ - "@platforms//cpu:s390x", - "@platforms//os:linux" - ] - } - }, - "rust_linux_s390x__s390x-unknown-linux-gnu__nightly_tools": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "rust_toolchain_tools_repository", - "attributes": { - "exec_triple": "s390x-unknown-linux-gnu", - "allocator_library": "@rules_rust//ffi/cc/allocator_library", - "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", - "target_triple": "s390x-unknown-linux-gnu", - "version": "nightly/2024-09-05", - "rustfmt_version": "nightly/2024-09-05", - "edition": "2021", - "dev_components": false, - "extra_rustc_flags": [], - "extra_exec_rustc_flags": [], - "opt_level": {}, - "sha256s": {}, - "urls": [ - "https://static.rust-lang.org/dist/{}.tar.xz" - ], - "auth": {}, - "netrc": "", - "auth_patterns": [] - } - }, - "rust_linux_s390x__s390x-unknown-linux-gnu__nightly": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "toolchain_repository_proxy", - "attributes": { - "toolchain": "@rust_linux_s390x__s390x-unknown-linux-gnu__nightly_tools//:rust_toolchain", - "target_settings": [ - "@rules_rust//rust/toolchain/channel:nightly" - ], - "toolchain_type": "@rules_rust//rust:toolchain", - "exec_compatible_with": [ - "@platforms//cpu:s390x", - "@platforms//os:linux" - ], - "target_compatible_with": [ - "@platforms//cpu:s390x", - "@platforms//os:linux" - ] - } - }, - "rust_linux_s390x__wasm32-unknown-unknown__stable_tools": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "rust_toolchain_tools_repository", - "attributes": { - "exec_triple": "s390x-unknown-linux-gnu", - "allocator_library": "@rules_rust//ffi/cc/allocator_library", - "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", - "target_triple": "wasm32-unknown-unknown", - "version": "1.81.0", - "rustfmt_version": "nightly/2024-09-05", - "edition": "2021", - "dev_components": false, - "extra_rustc_flags": [], - "extra_exec_rustc_flags": [], - "opt_level": {}, - "sha256s": {}, - "urls": [ - "https://static.rust-lang.org/dist/{}.tar.xz" - ], - "auth": {}, - "netrc": "", - "auth_patterns": [] - } - }, - "rust_linux_s390x__wasm32-unknown-unknown__stable": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "toolchain_repository_proxy", - "attributes": { - "toolchain": "@rust_linux_s390x__wasm32-unknown-unknown__stable_tools//:rust_toolchain", - "target_settings": [ - "@rules_rust//rust/toolchain/channel:stable" - ], - "toolchain_type": "@rules_rust//rust:toolchain", - "exec_compatible_with": [ - "@platforms//cpu:s390x", - "@platforms//os:linux" - ], - "target_compatible_with": [ - "@platforms//cpu:wasm32", - "@platforms//os:none" - ] - } - }, - "rust_linux_s390x__wasm32-unknown-unknown__nightly_tools": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "rust_toolchain_tools_repository", - "attributes": { - "exec_triple": "s390x-unknown-linux-gnu", - "allocator_library": "@rules_rust//ffi/cc/allocator_library", - "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", - "target_triple": "wasm32-unknown-unknown", - "version": "nightly/2024-09-05", - "rustfmt_version": "nightly/2024-09-05", - "edition": "2021", - "dev_components": false, - "extra_rustc_flags": [], - "extra_exec_rustc_flags": [], - "opt_level": {}, - "sha256s": {}, - "urls": [ - "https://static.rust-lang.org/dist/{}.tar.xz" - ], - "auth": {}, - "netrc": "", - "auth_patterns": [] - } - }, - "rust_linux_s390x__wasm32-unknown-unknown__nightly": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "toolchain_repository_proxy", - "attributes": { - "toolchain": "@rust_linux_s390x__wasm32-unknown-unknown__nightly_tools//:rust_toolchain", - "target_settings": [ - "@rules_rust//rust/toolchain/channel:nightly" - ], - "toolchain_type": "@rules_rust//rust:toolchain", - "exec_compatible_with": [ - "@platforms//cpu:s390x", - "@platforms//os:linux" - ], - "target_compatible_with": [ - "@platforms//cpu:wasm32", - "@platforms//os:none" - ] - } - }, - "rust_linux_s390x__wasm32-wasi__stable_tools": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "rust_toolchain_tools_repository", - "attributes": { - "exec_triple": "s390x-unknown-linux-gnu", - "allocator_library": "@rules_rust//ffi/cc/allocator_library", - "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", - "target_triple": "wasm32-wasi", - "version": "1.81.0", - "rustfmt_version": "nightly/2024-09-05", - "edition": "2021", - "dev_components": false, - "extra_rustc_flags": [], - "extra_exec_rustc_flags": [], - "opt_level": {}, - "sha256s": {}, - "urls": [ - "https://static.rust-lang.org/dist/{}.tar.xz" - ], - "auth": {}, - "netrc": "", - "auth_patterns": [] - } - }, - "rust_linux_s390x__wasm32-wasi__stable": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "toolchain_repository_proxy", - "attributes": { - "toolchain": "@rust_linux_s390x__wasm32-wasi__stable_tools//:rust_toolchain", - "target_settings": [ - "@rules_rust//rust/toolchain/channel:stable" - ], - "toolchain_type": "@rules_rust//rust:toolchain", - "exec_compatible_with": [ - "@platforms//cpu:s390x", - "@platforms//os:linux" - ], - "target_compatible_with": [ - "@platforms//cpu:wasm32", - "@platforms//os:wasi" - ] - } - }, - "rust_linux_s390x__wasm32-wasi__nightly_tools": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "rust_toolchain_tools_repository", - "attributes": { - "exec_triple": "s390x-unknown-linux-gnu", - "allocator_library": "@rules_rust//ffi/cc/allocator_library", - "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", - "target_triple": "wasm32-wasi", - "version": "nightly/2024-09-05", - "rustfmt_version": "nightly/2024-09-05", - "edition": "2021", - "dev_components": false, - "extra_rustc_flags": [], - "extra_exec_rustc_flags": [], - "opt_level": {}, - "sha256s": {}, - "urls": [ - "https://static.rust-lang.org/dist/{}.tar.xz" - ], - "auth": {}, - "netrc": "", - "auth_patterns": [] - } - }, - "rust_linux_s390x__wasm32-wasi__nightly": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "toolchain_repository_proxy", - "attributes": { - "toolchain": "@rust_linux_s390x__wasm32-wasi__nightly_tools//:rust_toolchain", - "target_settings": [ - "@rules_rust//rust/toolchain/channel:nightly" - ], - "toolchain_type": "@rules_rust//rust:toolchain", - "exec_compatible_with": [ - "@platforms//cpu:s390x", - "@platforms//os:linux" - ], - "target_compatible_with": [ - "@platforms//cpu:wasm32", - "@platforms//os:wasi" - ] - } - }, - "rust_linux_s390x": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "rust_toolchain_set_repository", - "attributes": { - "toolchains": [ - "@rust_linux_s390x__s390x-unknown-linux-gnu__stable//:toolchain", - "@rust_linux_s390x__s390x-unknown-linux-gnu__nightly//:toolchain", - "@rust_linux_s390x__wasm32-unknown-unknown__stable//:toolchain", - "@rust_linux_s390x__wasm32-unknown-unknown__nightly//:toolchain", - "@rust_linux_s390x__wasm32-wasi__stable//:toolchain", - "@rust_linux_s390x__wasm32-wasi__nightly//:toolchain" - ] - } - }, - "rustfmt_nightly-2024-09-05__s390x-unknown-linux-gnu_tools": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "rustfmt_toolchain_tools_repository", - "attributes": { - "version": "nightly/2024-09-05", - "sha256s": {}, - "urls": [ - "https://static.rust-lang.org/dist/{}.tar.xz" - ], - "auth": {}, - "netrc": "", - "auth_patterns": {}, - "exec_triple": "s390x-unknown-linux-gnu" - } - }, - "rustfmt_nightly-2024-09-05__s390x-unknown-linux-gnu": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "toolchain_repository_proxy", - "attributes": { - "toolchain": "@rustfmt_nightly-2024-09-05__s390x-unknown-linux-gnu_tools//:rustfmt_toolchain", - "toolchain_type": "@rules_rust//rust/rustfmt:toolchain_type", - "target_settings": [], - "exec_compatible_with": [ - "@platforms//cpu:s390x", - "@platforms//os:linux" - ], - "target_compatible_with": [] - } - }, - "rust_darwin_x86_64__x86_64-apple-darwin__stable_tools": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "rust_toolchain_tools_repository", - "attributes": { - "exec_triple": "x86_64-apple-darwin", - "allocator_library": "@rules_rust//ffi/cc/allocator_library", - "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", - "target_triple": "x86_64-apple-darwin", - "version": "1.81.0", - "rustfmt_version": "nightly/2024-09-05", - "edition": "2021", - "dev_components": false, - "extra_rustc_flags": [], - "extra_exec_rustc_flags": [], - "opt_level": {}, - "sha256s": {}, - "urls": [ - "https://static.rust-lang.org/dist/{}.tar.xz" - ], - "auth": {}, - "netrc": "", - "auth_patterns": [] - } - }, - "rust_darwin_x86_64__x86_64-apple-darwin__stable": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "toolchain_repository_proxy", - "attributes": { - "toolchain": "@rust_darwin_x86_64__x86_64-apple-darwin__stable_tools//:rust_toolchain", - "target_settings": [ - "@rules_rust//rust/toolchain/channel:stable" - ], - "toolchain_type": "@rules_rust//rust:toolchain", - "exec_compatible_with": [ - "@platforms//cpu:x86_64", - "@platforms//os:osx" - ], - "target_compatible_with": [ - "@platforms//cpu:x86_64", - "@platforms//os:osx" - ] - } - }, - "rust_darwin_x86_64__x86_64-apple-darwin__nightly_tools": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "rust_toolchain_tools_repository", - "attributes": { - "exec_triple": "x86_64-apple-darwin", - "allocator_library": "@rules_rust//ffi/cc/allocator_library", - "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", - "target_triple": "x86_64-apple-darwin", - "version": "nightly/2024-09-05", - "rustfmt_version": "nightly/2024-09-05", - "edition": "2021", - "dev_components": false, - "extra_rustc_flags": [], - "extra_exec_rustc_flags": [], - "opt_level": {}, - "sha256s": {}, - "urls": [ - "https://static.rust-lang.org/dist/{}.tar.xz" - ], - "auth": {}, - "netrc": "", - "auth_patterns": [] - } - }, - "rust_darwin_x86_64__x86_64-apple-darwin__nightly": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "toolchain_repository_proxy", - "attributes": { - "toolchain": "@rust_darwin_x86_64__x86_64-apple-darwin__nightly_tools//:rust_toolchain", - "target_settings": [ - "@rules_rust//rust/toolchain/channel:nightly" - ], - "toolchain_type": "@rules_rust//rust:toolchain", - "exec_compatible_with": [ - "@platforms//cpu:x86_64", - "@platforms//os:osx" - ], - "target_compatible_with": [ - "@platforms//cpu:x86_64", - "@platforms//os:osx" - ] - } - }, - "rust_darwin_x86_64__wasm32-unknown-unknown__stable_tools": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "rust_toolchain_tools_repository", - "attributes": { - "exec_triple": "x86_64-apple-darwin", - "allocator_library": "@rules_rust//ffi/cc/allocator_library", - "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", - "target_triple": "wasm32-unknown-unknown", - "version": "1.81.0", - "rustfmt_version": "nightly/2024-09-05", - "edition": "2021", - "dev_components": false, - "extra_rustc_flags": [], - "extra_exec_rustc_flags": [], - "opt_level": {}, - "sha256s": {}, - "urls": [ - "https://static.rust-lang.org/dist/{}.tar.xz" - ], - "auth": {}, - "netrc": "", - "auth_patterns": [] - } - }, - "rust_darwin_x86_64__wasm32-unknown-unknown__stable": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "toolchain_repository_proxy", - "attributes": { - "toolchain": "@rust_darwin_x86_64__wasm32-unknown-unknown__stable_tools//:rust_toolchain", - "target_settings": [ - "@rules_rust//rust/toolchain/channel:stable" - ], - "toolchain_type": "@rules_rust//rust:toolchain", - "exec_compatible_with": [ - "@platforms//cpu:x86_64", - "@platforms//os:osx" - ], - "target_compatible_with": [ - "@platforms//cpu:wasm32", - "@platforms//os:none" - ] - } - }, - "rust_darwin_x86_64__wasm32-unknown-unknown__nightly_tools": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "rust_toolchain_tools_repository", - "attributes": { - "exec_triple": "x86_64-apple-darwin", - "allocator_library": "@rules_rust//ffi/cc/allocator_library", - "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", - "target_triple": "wasm32-unknown-unknown", - "version": "nightly/2024-09-05", - "rustfmt_version": "nightly/2024-09-05", - "edition": "2021", - "dev_components": false, - "extra_rustc_flags": [], - "extra_exec_rustc_flags": [], - "opt_level": {}, - "sha256s": {}, - "urls": [ - "https://static.rust-lang.org/dist/{}.tar.xz" - ], - "auth": {}, - "netrc": "", - "auth_patterns": [] - } - }, - "rust_darwin_x86_64__wasm32-unknown-unknown__nightly": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "toolchain_repository_proxy", - "attributes": { - "toolchain": "@rust_darwin_x86_64__wasm32-unknown-unknown__nightly_tools//:rust_toolchain", - "target_settings": [ - "@rules_rust//rust/toolchain/channel:nightly" - ], - "toolchain_type": "@rules_rust//rust:toolchain", - "exec_compatible_with": [ - "@platforms//cpu:x86_64", - "@platforms//os:osx" - ], - "target_compatible_with": [ - "@platforms//cpu:wasm32", - "@platforms//os:none" - ] - } - }, - "rust_darwin_x86_64__wasm32-wasi__stable_tools": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "rust_toolchain_tools_repository", - "attributes": { - "exec_triple": "x86_64-apple-darwin", - "allocator_library": "@rules_rust//ffi/cc/allocator_library", - "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", - "target_triple": "wasm32-wasi", - "version": "1.81.0", - "rustfmt_version": "nightly/2024-09-05", - "edition": "2021", - "dev_components": false, - "extra_rustc_flags": [], - "extra_exec_rustc_flags": [], - "opt_level": {}, - "sha256s": {}, - "urls": [ - "https://static.rust-lang.org/dist/{}.tar.xz" - ], - "auth": {}, - "netrc": "", - "auth_patterns": [] - } - }, - "rust_darwin_x86_64__wasm32-wasi__stable": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "toolchain_repository_proxy", - "attributes": { - "toolchain": "@rust_darwin_x86_64__wasm32-wasi__stable_tools//:rust_toolchain", - "target_settings": [ - "@rules_rust//rust/toolchain/channel:stable" - ], - "toolchain_type": "@rules_rust//rust:toolchain", - "exec_compatible_with": [ - "@platforms//cpu:x86_64", - "@platforms//os:osx" - ], - "target_compatible_with": [ - "@platforms//cpu:wasm32", - "@platforms//os:wasi" - ] - } - }, - "rust_darwin_x86_64__wasm32-wasi__nightly_tools": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "rust_toolchain_tools_repository", - "attributes": { - "exec_triple": "x86_64-apple-darwin", - "allocator_library": "@rules_rust//ffi/cc/allocator_library", - "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", - "target_triple": "wasm32-wasi", - "version": "nightly/2024-09-05", - "rustfmt_version": "nightly/2024-09-05", - "edition": "2021", - "dev_components": false, - "extra_rustc_flags": [], - "extra_exec_rustc_flags": [], - "opt_level": {}, - "sha256s": {}, - "urls": [ - "https://static.rust-lang.org/dist/{}.tar.xz" - ], - "auth": {}, - "netrc": "", - "auth_patterns": [] - } - }, - "rust_darwin_x86_64__wasm32-wasi__nightly": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "toolchain_repository_proxy", - "attributes": { - "toolchain": "@rust_darwin_x86_64__wasm32-wasi__nightly_tools//:rust_toolchain", - "target_settings": [ - "@rules_rust//rust/toolchain/channel:nightly" - ], - "toolchain_type": "@rules_rust//rust:toolchain", - "exec_compatible_with": [ - "@platforms//cpu:x86_64", - "@platforms//os:osx" - ], - "target_compatible_with": [ - "@platforms//cpu:wasm32", - "@platforms//os:wasi" - ] - } - }, - "rust_darwin_x86_64": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "rust_toolchain_set_repository", - "attributes": { - "toolchains": [ - "@rust_darwin_x86_64__x86_64-apple-darwin__stable//:toolchain", - "@rust_darwin_x86_64__x86_64-apple-darwin__nightly//:toolchain", - "@rust_darwin_x86_64__wasm32-unknown-unknown__stable//:toolchain", - "@rust_darwin_x86_64__wasm32-unknown-unknown__nightly//:toolchain", - "@rust_darwin_x86_64__wasm32-wasi__stable//:toolchain", - "@rust_darwin_x86_64__wasm32-wasi__nightly//:toolchain" - ] - } - }, - "rustfmt_nightly-2024-09-05__x86_64-apple-darwin_tools": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "rustfmt_toolchain_tools_repository", - "attributes": { - "version": "nightly/2024-09-05", - "sha256s": {}, - "urls": [ - "https://static.rust-lang.org/dist/{}.tar.xz" - ], - "auth": {}, - "netrc": "", - "auth_patterns": {}, - "exec_triple": "x86_64-apple-darwin" - } - }, - "rustfmt_nightly-2024-09-05__x86_64-apple-darwin": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "toolchain_repository_proxy", - "attributes": { - "toolchain": "@rustfmt_nightly-2024-09-05__x86_64-apple-darwin_tools//:rustfmt_toolchain", - "toolchain_type": "@rules_rust//rust/rustfmt:toolchain_type", - "target_settings": [], - "exec_compatible_with": [ - "@platforms//cpu:x86_64", - "@platforms//os:osx" - ], - "target_compatible_with": [] - } - }, - "rust_windows_x86_64__x86_64-pc-windows-msvc__stable_tools": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "rust_toolchain_tools_repository", - "attributes": { - "exec_triple": "x86_64-pc-windows-msvc", - "allocator_library": "@rules_rust//ffi/cc/allocator_library", - "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", - "target_triple": "x86_64-pc-windows-msvc", - "version": "1.81.0", - "rustfmt_version": "nightly/2024-09-05", - "edition": "2021", - "dev_components": false, - "extra_rustc_flags": [], - "extra_exec_rustc_flags": [], - "opt_level": {}, - "sha256s": {}, - "urls": [ - "https://static.rust-lang.org/dist/{}.tar.xz" - ], - "auth": {}, - "netrc": "", - "auth_patterns": [] - } - }, - "rust_windows_x86_64__x86_64-pc-windows-msvc__stable": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "toolchain_repository_proxy", - "attributes": { - "toolchain": "@rust_windows_x86_64__x86_64-pc-windows-msvc__stable_tools//:rust_toolchain", - "target_settings": [ - "@rules_rust//rust/toolchain/channel:stable" - ], - "toolchain_type": "@rules_rust//rust:toolchain", - "exec_compatible_with": [ - "@platforms//cpu:x86_64", - "@platforms//os:windows" - ], - "target_compatible_with": [ - "@platforms//cpu:x86_64", - "@platforms//os:windows" - ] - } - }, - "rust_windows_x86_64__x86_64-pc-windows-msvc__nightly_tools": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "rust_toolchain_tools_repository", - "attributes": { - "exec_triple": "x86_64-pc-windows-msvc", - "allocator_library": "@rules_rust//ffi/cc/allocator_library", - "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", - "target_triple": "x86_64-pc-windows-msvc", - "version": "nightly/2024-09-05", - "rustfmt_version": "nightly/2024-09-05", - "edition": "2021", - "dev_components": false, - "extra_rustc_flags": [], - "extra_exec_rustc_flags": [], - "opt_level": {}, - "sha256s": {}, - "urls": [ - "https://static.rust-lang.org/dist/{}.tar.xz" - ], - "auth": {}, - "netrc": "", - "auth_patterns": [] - } - }, - "rust_windows_x86_64__x86_64-pc-windows-msvc__nightly": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "toolchain_repository_proxy", - "attributes": { - "toolchain": "@rust_windows_x86_64__x86_64-pc-windows-msvc__nightly_tools//:rust_toolchain", - "target_settings": [ - "@rules_rust//rust/toolchain/channel:nightly" - ], - "toolchain_type": "@rules_rust//rust:toolchain", - "exec_compatible_with": [ - "@platforms//cpu:x86_64", - "@platforms//os:windows" - ], - "target_compatible_with": [ - "@platforms//cpu:x86_64", - "@platforms//os:windows" - ] - } - }, - "rust_windows_x86_64__wasm32-unknown-unknown__stable_tools": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "rust_toolchain_tools_repository", - "attributes": { - "exec_triple": "x86_64-pc-windows-msvc", - "allocator_library": "@rules_rust//ffi/cc/allocator_library", - "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", - "target_triple": "wasm32-unknown-unknown", - "version": "1.81.0", - "rustfmt_version": "nightly/2024-09-05", - "edition": "2021", - "dev_components": false, - "extra_rustc_flags": [], - "extra_exec_rustc_flags": [], - "opt_level": {}, - "sha256s": {}, - "urls": [ - "https://static.rust-lang.org/dist/{}.tar.xz" - ], - "auth": {}, - "netrc": "", - "auth_patterns": [] - } - }, - "rust_windows_x86_64__wasm32-unknown-unknown__stable": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "toolchain_repository_proxy", - "attributes": { - "toolchain": "@rust_windows_x86_64__wasm32-unknown-unknown__stable_tools//:rust_toolchain", - "target_settings": [ - "@rules_rust//rust/toolchain/channel:stable" - ], - "toolchain_type": "@rules_rust//rust:toolchain", - "exec_compatible_with": [ - "@platforms//cpu:x86_64", - "@platforms//os:windows" - ], - "target_compatible_with": [ - "@platforms//cpu:wasm32", - "@platforms//os:none" - ] - } - }, - "rust_windows_x86_64__wasm32-unknown-unknown__nightly_tools": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "rust_toolchain_tools_repository", - "attributes": { - "exec_triple": "x86_64-pc-windows-msvc", - "allocator_library": "@rules_rust//ffi/cc/allocator_library", - "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", - "target_triple": "wasm32-unknown-unknown", - "version": "nightly/2024-09-05", - "rustfmt_version": "nightly/2024-09-05", - "edition": "2021", - "dev_components": false, - "extra_rustc_flags": [], - "extra_exec_rustc_flags": [], - "opt_level": {}, - "sha256s": {}, - "urls": [ - "https://static.rust-lang.org/dist/{}.tar.xz" - ], - "auth": {}, - "netrc": "", - "auth_patterns": [] - } - }, - "rust_windows_x86_64__wasm32-unknown-unknown__nightly": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "toolchain_repository_proxy", - "attributes": { - "toolchain": "@rust_windows_x86_64__wasm32-unknown-unknown__nightly_tools//:rust_toolchain", - "target_settings": [ - "@rules_rust//rust/toolchain/channel:nightly" - ], - "toolchain_type": "@rules_rust//rust:toolchain", - "exec_compatible_with": [ - "@platforms//cpu:x86_64", - "@platforms//os:windows" - ], - "target_compatible_with": [ - "@platforms//cpu:wasm32", - "@platforms//os:none" - ] - } - }, - "rust_windows_x86_64__wasm32-wasi__stable_tools": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "rust_toolchain_tools_repository", - "attributes": { - "exec_triple": "x86_64-pc-windows-msvc", - "allocator_library": "@rules_rust//ffi/cc/allocator_library", - "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", - "target_triple": "wasm32-wasi", - "version": "1.81.0", - "rustfmt_version": "nightly/2024-09-05", - "edition": "2021", - "dev_components": false, - "extra_rustc_flags": [], - "extra_exec_rustc_flags": [], - "opt_level": {}, - "sha256s": {}, - "urls": [ - "https://static.rust-lang.org/dist/{}.tar.xz" - ], - "auth": {}, - "netrc": "", - "auth_patterns": [] - } - }, - "rust_windows_x86_64__wasm32-wasi__stable": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "toolchain_repository_proxy", - "attributes": { - "toolchain": "@rust_windows_x86_64__wasm32-wasi__stable_tools//:rust_toolchain", - "target_settings": [ - "@rules_rust//rust/toolchain/channel:stable" - ], - "toolchain_type": "@rules_rust//rust:toolchain", - "exec_compatible_with": [ - "@platforms//cpu:x86_64", - "@platforms//os:windows" - ], - "target_compatible_with": [ - "@platforms//cpu:wasm32", - "@platforms//os:wasi" - ] - } - }, - "rust_windows_x86_64__wasm32-wasi__nightly_tools": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "rust_toolchain_tools_repository", - "attributes": { - "exec_triple": "x86_64-pc-windows-msvc", - "allocator_library": "@rules_rust//ffi/cc/allocator_library", - "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", - "target_triple": "wasm32-wasi", - "version": "nightly/2024-09-05", - "rustfmt_version": "nightly/2024-09-05", - "edition": "2021", - "dev_components": false, - "extra_rustc_flags": [], - "extra_exec_rustc_flags": [], - "opt_level": {}, - "sha256s": {}, - "urls": [ - "https://static.rust-lang.org/dist/{}.tar.xz" - ], - "auth": {}, - "netrc": "", - "auth_patterns": [] - } - }, - "rust_windows_x86_64__wasm32-wasi__nightly": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "toolchain_repository_proxy", - "attributes": { - "toolchain": "@rust_windows_x86_64__wasm32-wasi__nightly_tools//:rust_toolchain", - "target_settings": [ - "@rules_rust//rust/toolchain/channel:nightly" - ], - "toolchain_type": "@rules_rust//rust:toolchain", - "exec_compatible_with": [ - "@platforms//cpu:x86_64", - "@platforms//os:windows" - ], - "target_compatible_with": [ - "@platforms//cpu:wasm32", - "@platforms//os:wasi" - ] - } - }, - "rust_windows_x86_64": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "rust_toolchain_set_repository", - "attributes": { - "toolchains": [ - "@rust_windows_x86_64__x86_64-pc-windows-msvc__stable//:toolchain", - "@rust_windows_x86_64__x86_64-pc-windows-msvc__nightly//:toolchain", - "@rust_windows_x86_64__wasm32-unknown-unknown__stable//:toolchain", - "@rust_windows_x86_64__wasm32-unknown-unknown__nightly//:toolchain", - "@rust_windows_x86_64__wasm32-wasi__stable//:toolchain", - "@rust_windows_x86_64__wasm32-wasi__nightly//:toolchain" - ] - } - }, - "rustfmt_nightly-2024-09-05__x86_64-pc-windows-msvc_tools": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "rustfmt_toolchain_tools_repository", - "attributes": { - "version": "nightly/2024-09-05", - "sha256s": {}, - "urls": [ - "https://static.rust-lang.org/dist/{}.tar.xz" - ], - "auth": {}, - "netrc": "", - "auth_patterns": {}, - "exec_triple": "x86_64-pc-windows-msvc" - } - }, - "rustfmt_nightly-2024-09-05__x86_64-pc-windows-msvc": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "toolchain_repository_proxy", - "attributes": { - "toolchain": "@rustfmt_nightly-2024-09-05__x86_64-pc-windows-msvc_tools//:rustfmt_toolchain", - "toolchain_type": "@rules_rust//rust/rustfmt:toolchain_type", - "target_settings": [], - "exec_compatible_with": [ - "@platforms//cpu:x86_64", - "@platforms//os:windows" - ], - "target_compatible_with": [] - } - }, - "rust_freebsd_x86_64__x86_64-unknown-freebsd__stable_tools": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "rust_toolchain_tools_repository", - "attributes": { - "exec_triple": "x86_64-unknown-freebsd", - "allocator_library": "@rules_rust//ffi/cc/allocator_library", - "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", - "target_triple": "x86_64-unknown-freebsd", - "version": "1.81.0", - "rustfmt_version": "nightly/2024-09-05", - "edition": "2021", - "dev_components": false, - "extra_rustc_flags": [], - "extra_exec_rustc_flags": [], - "opt_level": {}, - "sha256s": {}, - "urls": [ - "https://static.rust-lang.org/dist/{}.tar.xz" - ], - "auth": {}, - "netrc": "", - "auth_patterns": [] - } - }, - "rust_freebsd_x86_64__x86_64-unknown-freebsd__stable": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "toolchain_repository_proxy", - "attributes": { - "toolchain": "@rust_freebsd_x86_64__x86_64-unknown-freebsd__stable_tools//:rust_toolchain", - "target_settings": [ - "@rules_rust//rust/toolchain/channel:stable" - ], - "toolchain_type": "@rules_rust//rust:toolchain", - "exec_compatible_with": [ - "@platforms//cpu:x86_64", - "@platforms//os:freebsd" - ], - "target_compatible_with": [ - "@platforms//cpu:x86_64", - "@platforms//os:freebsd" - ] - } - }, - "rust_freebsd_x86_64__x86_64-unknown-freebsd__nightly_tools": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "rust_toolchain_tools_repository", - "attributes": { - "exec_triple": "x86_64-unknown-freebsd", - "allocator_library": "@rules_rust//ffi/cc/allocator_library", - "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", - "target_triple": "x86_64-unknown-freebsd", - "version": "nightly/2024-09-05", - "rustfmt_version": "nightly/2024-09-05", - "edition": "2021", - "dev_components": false, - "extra_rustc_flags": [], - "extra_exec_rustc_flags": [], - "opt_level": {}, - "sha256s": {}, - "urls": [ - "https://static.rust-lang.org/dist/{}.tar.xz" - ], - "auth": {}, - "netrc": "", - "auth_patterns": [] - } - }, - "rust_freebsd_x86_64__x86_64-unknown-freebsd__nightly": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "toolchain_repository_proxy", - "attributes": { - "toolchain": "@rust_freebsd_x86_64__x86_64-unknown-freebsd__nightly_tools//:rust_toolchain", - "target_settings": [ - "@rules_rust//rust/toolchain/channel:nightly" - ], - "toolchain_type": "@rules_rust//rust:toolchain", - "exec_compatible_with": [ - "@platforms//cpu:x86_64", - "@platforms//os:freebsd" - ], - "target_compatible_with": [ - "@platforms//cpu:x86_64", - "@platforms//os:freebsd" - ] - } - }, - "rust_freebsd_x86_64__wasm32-unknown-unknown__stable_tools": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "rust_toolchain_tools_repository", - "attributes": { - "exec_triple": "x86_64-unknown-freebsd", - "allocator_library": "@rules_rust//ffi/cc/allocator_library", - "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", - "target_triple": "wasm32-unknown-unknown", - "version": "1.81.0", - "rustfmt_version": "nightly/2024-09-05", - "edition": "2021", - "dev_components": false, - "extra_rustc_flags": [], - "extra_exec_rustc_flags": [], - "opt_level": {}, - "sha256s": {}, - "urls": [ - "https://static.rust-lang.org/dist/{}.tar.xz" - ], - "auth": {}, - "netrc": "", - "auth_patterns": [] - } - }, - "rust_freebsd_x86_64__wasm32-unknown-unknown__stable": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "toolchain_repository_proxy", - "attributes": { - "toolchain": "@rust_freebsd_x86_64__wasm32-unknown-unknown__stable_tools//:rust_toolchain", - "target_settings": [ - "@rules_rust//rust/toolchain/channel:stable" - ], - "toolchain_type": "@rules_rust//rust:toolchain", - "exec_compatible_with": [ - "@platforms//cpu:x86_64", - "@platforms//os:freebsd" - ], - "target_compatible_with": [ - "@platforms//cpu:wasm32", - "@platforms//os:none" - ] - } - }, - "rust_freebsd_x86_64__wasm32-unknown-unknown__nightly_tools": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "rust_toolchain_tools_repository", - "attributes": { - "exec_triple": "x86_64-unknown-freebsd", - "allocator_library": "@rules_rust//ffi/cc/allocator_library", - "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", - "target_triple": "wasm32-unknown-unknown", - "version": "nightly/2024-09-05", - "rustfmt_version": "nightly/2024-09-05", - "edition": "2021", - "dev_components": false, - "extra_rustc_flags": [], - "extra_exec_rustc_flags": [], - "opt_level": {}, - "sha256s": {}, - "urls": [ - "https://static.rust-lang.org/dist/{}.tar.xz" - ], - "auth": {}, - "netrc": "", - "auth_patterns": [] - } - }, - "rust_freebsd_x86_64__wasm32-unknown-unknown__nightly": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "toolchain_repository_proxy", - "attributes": { - "toolchain": "@rust_freebsd_x86_64__wasm32-unknown-unknown__nightly_tools//:rust_toolchain", - "target_settings": [ - "@rules_rust//rust/toolchain/channel:nightly" - ], - "toolchain_type": "@rules_rust//rust:toolchain", - "exec_compatible_with": [ - "@platforms//cpu:x86_64", - "@platforms//os:freebsd" - ], - "target_compatible_with": [ - "@platforms//cpu:wasm32", - "@platforms//os:none" - ] - } - }, - "rust_freebsd_x86_64__wasm32-wasi__stable_tools": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "rust_toolchain_tools_repository", - "attributes": { - "exec_triple": "x86_64-unknown-freebsd", - "allocator_library": "@rules_rust//ffi/cc/allocator_library", - "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", - "target_triple": "wasm32-wasi", - "version": "1.81.0", - "rustfmt_version": "nightly/2024-09-05", - "edition": "2021", - "dev_components": false, - "extra_rustc_flags": [], - "extra_exec_rustc_flags": [], - "opt_level": {}, - "sha256s": {}, - "urls": [ - "https://static.rust-lang.org/dist/{}.tar.xz" - ], - "auth": {}, - "netrc": "", - "auth_patterns": [] - } - }, - "rust_freebsd_x86_64__wasm32-wasi__stable": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "toolchain_repository_proxy", - "attributes": { - "toolchain": "@rust_freebsd_x86_64__wasm32-wasi__stable_tools//:rust_toolchain", - "target_settings": [ - "@rules_rust//rust/toolchain/channel:stable" - ], - "toolchain_type": "@rules_rust//rust:toolchain", - "exec_compatible_with": [ - "@platforms//cpu:x86_64", - "@platforms//os:freebsd" - ], - "target_compatible_with": [ - "@platforms//cpu:wasm32", - "@platforms//os:wasi" - ] - } - }, - "rust_freebsd_x86_64__wasm32-wasi__nightly_tools": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "rust_toolchain_tools_repository", - "attributes": { - "exec_triple": "x86_64-unknown-freebsd", - "allocator_library": "@rules_rust//ffi/cc/allocator_library", - "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", - "target_triple": "wasm32-wasi", - "version": "nightly/2024-09-05", - "rustfmt_version": "nightly/2024-09-05", - "edition": "2021", - "dev_components": false, - "extra_rustc_flags": [], - "extra_exec_rustc_flags": [], - "opt_level": {}, - "sha256s": {}, - "urls": [ - "https://static.rust-lang.org/dist/{}.tar.xz" - ], - "auth": {}, - "netrc": "", - "auth_patterns": [] - } - }, - "rust_freebsd_x86_64__wasm32-wasi__nightly": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "toolchain_repository_proxy", - "attributes": { - "toolchain": "@rust_freebsd_x86_64__wasm32-wasi__nightly_tools//:rust_toolchain", - "target_settings": [ - "@rules_rust//rust/toolchain/channel:nightly" - ], - "toolchain_type": "@rules_rust//rust:toolchain", - "exec_compatible_with": [ - "@platforms//cpu:x86_64", - "@platforms//os:freebsd" - ], - "target_compatible_with": [ - "@platforms//cpu:wasm32", - "@platforms//os:wasi" - ] - } - }, - "rust_freebsd_x86_64": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "rust_toolchain_set_repository", - "attributes": { - "toolchains": [ - "@rust_freebsd_x86_64__x86_64-unknown-freebsd__stable//:toolchain", - "@rust_freebsd_x86_64__x86_64-unknown-freebsd__nightly//:toolchain", - "@rust_freebsd_x86_64__wasm32-unknown-unknown__stable//:toolchain", - "@rust_freebsd_x86_64__wasm32-unknown-unknown__nightly//:toolchain", - "@rust_freebsd_x86_64__wasm32-wasi__stable//:toolchain", - "@rust_freebsd_x86_64__wasm32-wasi__nightly//:toolchain" - ] - } - }, - "rustfmt_nightly-2024-09-05__x86_64-unknown-freebsd_tools": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "rustfmt_toolchain_tools_repository", - "attributes": { - "version": "nightly/2024-09-05", - "sha256s": {}, - "urls": [ - "https://static.rust-lang.org/dist/{}.tar.xz" - ], - "auth": {}, - "netrc": "", - "auth_patterns": {}, - "exec_triple": "x86_64-unknown-freebsd" - } - }, - "rustfmt_nightly-2024-09-05__x86_64-unknown-freebsd": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "toolchain_repository_proxy", - "attributes": { - "toolchain": "@rustfmt_nightly-2024-09-05__x86_64-unknown-freebsd_tools//:rustfmt_toolchain", - "toolchain_type": "@rules_rust//rust/rustfmt:toolchain_type", - "target_settings": [], - "exec_compatible_with": [ - "@platforms//cpu:x86_64", - "@platforms//os:freebsd" - ], - "target_compatible_with": [] - } - }, - "rust_linux_x86_64__x86_64-unknown-linux-gnu__stable_tools": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "rust_toolchain_tools_repository", - "attributes": { - "exec_triple": "x86_64-unknown-linux-gnu", - "allocator_library": "@rules_rust//ffi/cc/allocator_library", - "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", - "target_triple": "x86_64-unknown-linux-gnu", - "version": "1.81.0", - "rustfmt_version": "nightly/2024-09-05", - "edition": "2021", - "dev_components": false, - "extra_rustc_flags": [], - "extra_exec_rustc_flags": [], - "opt_level": {}, - "sha256s": {}, - "urls": [ - "https://static.rust-lang.org/dist/{}.tar.xz" - ], - "auth": {}, - "netrc": "", - "auth_patterns": [] - } - }, - "rust_linux_x86_64__x86_64-unknown-linux-gnu__stable": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "toolchain_repository_proxy", - "attributes": { - "toolchain": "@rust_linux_x86_64__x86_64-unknown-linux-gnu__stable_tools//:rust_toolchain", - "target_settings": [ - "@rules_rust//rust/toolchain/channel:stable" - ], - "toolchain_type": "@rules_rust//rust:toolchain", - "exec_compatible_with": [ - "@platforms//cpu:x86_64", - "@platforms//os:linux" - ], - "target_compatible_with": [ - "@platforms//cpu:x86_64", - "@platforms//os:linux" - ] - } - }, - "rust_linux_x86_64__x86_64-unknown-linux-gnu__nightly_tools": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "rust_toolchain_tools_repository", - "attributes": { - "exec_triple": "x86_64-unknown-linux-gnu", - "allocator_library": "@rules_rust//ffi/cc/allocator_library", - "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", - "target_triple": "x86_64-unknown-linux-gnu", - "version": "nightly/2024-09-05", - "rustfmt_version": "nightly/2024-09-05", - "edition": "2021", - "dev_components": false, - "extra_rustc_flags": [], - "extra_exec_rustc_flags": [], - "opt_level": {}, - "sha256s": {}, - "urls": [ - "https://static.rust-lang.org/dist/{}.tar.xz" - ], - "auth": {}, - "netrc": "", - "auth_patterns": [] - } - }, - "rust_linux_x86_64__x86_64-unknown-linux-gnu__nightly": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "toolchain_repository_proxy", - "attributes": { - "toolchain": "@rust_linux_x86_64__x86_64-unknown-linux-gnu__nightly_tools//:rust_toolchain", - "target_settings": [ - "@rules_rust//rust/toolchain/channel:nightly" - ], - "toolchain_type": "@rules_rust//rust:toolchain", - "exec_compatible_with": [ - "@platforms//cpu:x86_64", - "@platforms//os:linux" - ], - "target_compatible_with": [ - "@platforms//cpu:x86_64", - "@platforms//os:linux" - ] - } - }, - "rust_linux_x86_64__wasm32-unknown-unknown__stable_tools": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "rust_toolchain_tools_repository", - "attributes": { - "exec_triple": "x86_64-unknown-linux-gnu", - "allocator_library": "@rules_rust//ffi/cc/allocator_library", - "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", - "target_triple": "wasm32-unknown-unknown", - "version": "1.81.0", - "rustfmt_version": "nightly/2024-09-05", - "edition": "2021", - "dev_components": false, - "extra_rustc_flags": [], - "extra_exec_rustc_flags": [], - "opt_level": {}, - "sha256s": {}, - "urls": [ - "https://static.rust-lang.org/dist/{}.tar.xz" - ], - "auth": {}, - "netrc": "", - "auth_patterns": [] - } - }, - "rust_linux_x86_64__wasm32-unknown-unknown__stable": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "toolchain_repository_proxy", - "attributes": { - "toolchain": "@rust_linux_x86_64__wasm32-unknown-unknown__stable_tools//:rust_toolchain", - "target_settings": [ - "@rules_rust//rust/toolchain/channel:stable" - ], - "toolchain_type": "@rules_rust//rust:toolchain", - "exec_compatible_with": [ - "@platforms//cpu:x86_64", - "@platforms//os:linux" - ], - "target_compatible_with": [ - "@platforms//cpu:wasm32", - "@platforms//os:none" - ] - } - }, - "rust_linux_x86_64__wasm32-unknown-unknown__nightly_tools": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "rust_toolchain_tools_repository", - "attributes": { - "exec_triple": "x86_64-unknown-linux-gnu", - "allocator_library": "@rules_rust//ffi/cc/allocator_library", - "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", - "target_triple": "wasm32-unknown-unknown", - "version": "nightly/2024-09-05", - "rustfmt_version": "nightly/2024-09-05", - "edition": "2021", - "dev_components": false, - "extra_rustc_flags": [], - "extra_exec_rustc_flags": [], - "opt_level": {}, - "sha256s": {}, - "urls": [ - "https://static.rust-lang.org/dist/{}.tar.xz" - ], - "auth": {}, - "netrc": "", - "auth_patterns": [] - } - }, - "rust_linux_x86_64__wasm32-unknown-unknown__nightly": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "toolchain_repository_proxy", - "attributes": { - "toolchain": "@rust_linux_x86_64__wasm32-unknown-unknown__nightly_tools//:rust_toolchain", - "target_settings": [ - "@rules_rust//rust/toolchain/channel:nightly" - ], - "toolchain_type": "@rules_rust//rust:toolchain", - "exec_compatible_with": [ - "@platforms//cpu:x86_64", - "@platforms//os:linux" - ], - "target_compatible_with": [ - "@platforms//cpu:wasm32", - "@platforms//os:none" - ] - } - }, - "rust_linux_x86_64__wasm32-wasi__stable_tools": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "rust_toolchain_tools_repository", - "attributes": { - "exec_triple": "x86_64-unknown-linux-gnu", - "allocator_library": "@rules_rust//ffi/cc/allocator_library", - "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", - "target_triple": "wasm32-wasi", - "version": "1.81.0", - "rustfmt_version": "nightly/2024-09-05", - "edition": "2021", - "dev_components": false, - "extra_rustc_flags": [], - "extra_exec_rustc_flags": [], - "opt_level": {}, - "sha256s": {}, - "urls": [ - "https://static.rust-lang.org/dist/{}.tar.xz" - ], - "auth": {}, - "netrc": "", - "auth_patterns": [] - } - }, - "rust_linux_x86_64__wasm32-wasi__stable": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "toolchain_repository_proxy", - "attributes": { - "toolchain": "@rust_linux_x86_64__wasm32-wasi__stable_tools//:rust_toolchain", - "target_settings": [ - "@rules_rust//rust/toolchain/channel:stable" - ], - "toolchain_type": "@rules_rust//rust:toolchain", - "exec_compatible_with": [ - "@platforms//cpu:x86_64", - "@platforms//os:linux" - ], - "target_compatible_with": [ - "@platforms//cpu:wasm32", - "@platforms//os:wasi" - ] - } - }, - "rust_linux_x86_64__wasm32-wasi__nightly_tools": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "rust_toolchain_tools_repository", - "attributes": { - "exec_triple": "x86_64-unknown-linux-gnu", - "allocator_library": "@rules_rust//ffi/cc/allocator_library", - "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", - "target_triple": "wasm32-wasi", - "version": "nightly/2024-09-05", - "rustfmt_version": "nightly/2024-09-05", - "edition": "2021", - "dev_components": false, - "extra_rustc_flags": [], - "extra_exec_rustc_flags": [], - "opt_level": {}, - "sha256s": {}, - "urls": [ - "https://static.rust-lang.org/dist/{}.tar.xz" - ], - "auth": {}, - "netrc": "", - "auth_patterns": [] - } - }, - "rust_linux_x86_64__wasm32-wasi__nightly": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "toolchain_repository_proxy", - "attributes": { - "toolchain": "@rust_linux_x86_64__wasm32-wasi__nightly_tools//:rust_toolchain", - "target_settings": [ - "@rules_rust//rust/toolchain/channel:nightly" - ], - "toolchain_type": "@rules_rust//rust:toolchain", - "exec_compatible_with": [ - "@platforms//cpu:x86_64", - "@platforms//os:linux" - ], - "target_compatible_with": [ - "@platforms//cpu:wasm32", - "@platforms//os:wasi" - ] - } - }, - "rust_linux_x86_64": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "rust_toolchain_set_repository", - "attributes": { - "toolchains": [ - "@rust_linux_x86_64__x86_64-unknown-linux-gnu__stable//:toolchain", - "@rust_linux_x86_64__x86_64-unknown-linux-gnu__nightly//:toolchain", - "@rust_linux_x86_64__wasm32-unknown-unknown__stable//:toolchain", - "@rust_linux_x86_64__wasm32-unknown-unknown__nightly//:toolchain", - "@rust_linux_x86_64__wasm32-wasi__stable//:toolchain", - "@rust_linux_x86_64__wasm32-wasi__nightly//:toolchain" - ] - } - }, - "rustfmt_nightly-2024-09-05__x86_64-unknown-linux-gnu_tools": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "rustfmt_toolchain_tools_repository", - "attributes": { - "version": "nightly/2024-09-05", - "sha256s": {}, - "urls": [ - "https://static.rust-lang.org/dist/{}.tar.xz" - ], - "auth": {}, - "netrc": "", - "auth_patterns": {}, - "exec_triple": "x86_64-unknown-linux-gnu" - } - }, - "rustfmt_nightly-2024-09-05__x86_64-unknown-linux-gnu": { - "bzlFile": "@@rules_rust~//rust:repositories.bzl", - "ruleClassName": "toolchain_repository_proxy", - "attributes": { - "toolchain": "@rustfmt_nightly-2024-09-05__x86_64-unknown-linux-gnu_tools//:rustfmt_toolchain", - "toolchain_type": "@rules_rust//rust/rustfmt:toolchain_type", - "target_settings": [], - "exec_compatible_with": [ - "@platforms//cpu:x86_64", - "@platforms//os:linux" - ], - "target_compatible_with": [] - } - }, - "rust_toolchains": { - "bzlFile": "@@rules_rust~//rust/private:repository_utils.bzl", - "ruleClassName": "toolchain_repository_hub", - "attributes": { - "toolchain_names": [ - "rust_analyzer_1.81.0", - "rust_darwin_aarch64__aarch64-apple-darwin__stable", - "rust_darwin_aarch64__aarch64-apple-darwin__nightly", - "rust_darwin_aarch64__wasm32-unknown-unknown__stable", - "rust_darwin_aarch64__wasm32-unknown-unknown__nightly", - "rust_darwin_aarch64__wasm32-wasi__stable", - "rust_darwin_aarch64__wasm32-wasi__nightly", - "rustfmt_nightly-2024-09-05__aarch64-apple-darwin", - "rust_windows_aarch64__aarch64-pc-windows-msvc__stable", - "rust_windows_aarch64__aarch64-pc-windows-msvc__nightly", - "rust_windows_aarch64__wasm32-unknown-unknown__stable", - "rust_windows_aarch64__wasm32-unknown-unknown__nightly", - "rust_windows_aarch64__wasm32-wasi__stable", - "rust_windows_aarch64__wasm32-wasi__nightly", - "rustfmt_nightly-2024-09-05__aarch64-pc-windows-msvc", - "rust_linux_aarch64__aarch64-unknown-linux-gnu__stable", - "rust_linux_aarch64__aarch64-unknown-linux-gnu__nightly", - "rust_linux_aarch64__wasm32-unknown-unknown__stable", - "rust_linux_aarch64__wasm32-unknown-unknown__nightly", - "rust_linux_aarch64__wasm32-wasi__stable", - "rust_linux_aarch64__wasm32-wasi__nightly", - "rustfmt_nightly-2024-09-05__aarch64-unknown-linux-gnu", - "rust_linux_s390x__s390x-unknown-linux-gnu__stable", - "rust_linux_s390x__s390x-unknown-linux-gnu__nightly", - "rust_linux_s390x__wasm32-unknown-unknown__stable", - "rust_linux_s390x__wasm32-unknown-unknown__nightly", - "rust_linux_s390x__wasm32-wasi__stable", - "rust_linux_s390x__wasm32-wasi__nightly", - "rustfmt_nightly-2024-09-05__s390x-unknown-linux-gnu", - "rust_darwin_x86_64__x86_64-apple-darwin__stable", - "rust_darwin_x86_64__x86_64-apple-darwin__nightly", - "rust_darwin_x86_64__wasm32-unknown-unknown__stable", - "rust_darwin_x86_64__wasm32-unknown-unknown__nightly", - "rust_darwin_x86_64__wasm32-wasi__stable", - "rust_darwin_x86_64__wasm32-wasi__nightly", - "rustfmt_nightly-2024-09-05__x86_64-apple-darwin", - "rust_windows_x86_64__x86_64-pc-windows-msvc__stable", - "rust_windows_x86_64__x86_64-pc-windows-msvc__nightly", - "rust_windows_x86_64__wasm32-unknown-unknown__stable", - "rust_windows_x86_64__wasm32-unknown-unknown__nightly", - "rust_windows_x86_64__wasm32-wasi__stable", - "rust_windows_x86_64__wasm32-wasi__nightly", - "rustfmt_nightly-2024-09-05__x86_64-pc-windows-msvc", - "rust_freebsd_x86_64__x86_64-unknown-freebsd__stable", - "rust_freebsd_x86_64__x86_64-unknown-freebsd__nightly", - "rust_freebsd_x86_64__wasm32-unknown-unknown__stable", - "rust_freebsd_x86_64__wasm32-unknown-unknown__nightly", - "rust_freebsd_x86_64__wasm32-wasi__stable", - "rust_freebsd_x86_64__wasm32-wasi__nightly", - "rustfmt_nightly-2024-09-05__x86_64-unknown-freebsd", - "rust_linux_x86_64__x86_64-unknown-linux-gnu__stable", - "rust_linux_x86_64__x86_64-unknown-linux-gnu__nightly", - "rust_linux_x86_64__wasm32-unknown-unknown__stable", - "rust_linux_x86_64__wasm32-unknown-unknown__nightly", - "rust_linux_x86_64__wasm32-wasi__stable", - "rust_linux_x86_64__wasm32-wasi__nightly", - "rustfmt_nightly-2024-09-05__x86_64-unknown-linux-gnu" - ], - "toolchain_labels": { - "rust_analyzer_1.81.0": "@rust_analyzer_1.81.0_tools//:rust_analyzer_toolchain", - "rust_darwin_aarch64__aarch64-apple-darwin__stable": "@rust_darwin_aarch64__aarch64-apple-darwin__stable_tools//:rust_toolchain", - "rust_darwin_aarch64__aarch64-apple-darwin__nightly": "@rust_darwin_aarch64__aarch64-apple-darwin__nightly_tools//:rust_toolchain", - "rust_darwin_aarch64__wasm32-unknown-unknown__stable": "@rust_darwin_aarch64__wasm32-unknown-unknown__stable_tools//:rust_toolchain", - "rust_darwin_aarch64__wasm32-unknown-unknown__nightly": "@rust_darwin_aarch64__wasm32-unknown-unknown__nightly_tools//:rust_toolchain", - "rust_darwin_aarch64__wasm32-wasi__stable": "@rust_darwin_aarch64__wasm32-wasi__stable_tools//:rust_toolchain", - "rust_darwin_aarch64__wasm32-wasi__nightly": "@rust_darwin_aarch64__wasm32-wasi__nightly_tools//:rust_toolchain", - "rustfmt_nightly-2024-09-05__aarch64-apple-darwin": "@rustfmt_nightly-2024-09-05__aarch64-apple-darwin_tools//:rustfmt_toolchain", - "rust_windows_aarch64__aarch64-pc-windows-msvc__stable": "@rust_windows_aarch64__aarch64-pc-windows-msvc__stable_tools//:rust_toolchain", - "rust_windows_aarch64__aarch64-pc-windows-msvc__nightly": "@rust_windows_aarch64__aarch64-pc-windows-msvc__nightly_tools//:rust_toolchain", - "rust_windows_aarch64__wasm32-unknown-unknown__stable": "@rust_windows_aarch64__wasm32-unknown-unknown__stable_tools//:rust_toolchain", - "rust_windows_aarch64__wasm32-unknown-unknown__nightly": "@rust_windows_aarch64__wasm32-unknown-unknown__nightly_tools//:rust_toolchain", - "rust_windows_aarch64__wasm32-wasi__stable": "@rust_windows_aarch64__wasm32-wasi__stable_tools//:rust_toolchain", - "rust_windows_aarch64__wasm32-wasi__nightly": "@rust_windows_aarch64__wasm32-wasi__nightly_tools//:rust_toolchain", - "rustfmt_nightly-2024-09-05__aarch64-pc-windows-msvc": "@rustfmt_nightly-2024-09-05__aarch64-pc-windows-msvc_tools//:rustfmt_toolchain", - "rust_linux_aarch64__aarch64-unknown-linux-gnu__stable": "@rust_linux_aarch64__aarch64-unknown-linux-gnu__stable_tools//:rust_toolchain", - "rust_linux_aarch64__aarch64-unknown-linux-gnu__nightly": "@rust_linux_aarch64__aarch64-unknown-linux-gnu__nightly_tools//:rust_toolchain", - "rust_linux_aarch64__wasm32-unknown-unknown__stable": "@rust_linux_aarch64__wasm32-unknown-unknown__stable_tools//:rust_toolchain", - "rust_linux_aarch64__wasm32-unknown-unknown__nightly": "@rust_linux_aarch64__wasm32-unknown-unknown__nightly_tools//:rust_toolchain", - "rust_linux_aarch64__wasm32-wasi__stable": "@rust_linux_aarch64__wasm32-wasi__stable_tools//:rust_toolchain", - "rust_linux_aarch64__wasm32-wasi__nightly": "@rust_linux_aarch64__wasm32-wasi__nightly_tools//:rust_toolchain", - "rustfmt_nightly-2024-09-05__aarch64-unknown-linux-gnu": "@rustfmt_nightly-2024-09-05__aarch64-unknown-linux-gnu_tools//:rustfmt_toolchain", - "rust_linux_s390x__s390x-unknown-linux-gnu__stable": "@rust_linux_s390x__s390x-unknown-linux-gnu__stable_tools//:rust_toolchain", - "rust_linux_s390x__s390x-unknown-linux-gnu__nightly": "@rust_linux_s390x__s390x-unknown-linux-gnu__nightly_tools//:rust_toolchain", - "rust_linux_s390x__wasm32-unknown-unknown__stable": "@rust_linux_s390x__wasm32-unknown-unknown__stable_tools//:rust_toolchain", - "rust_linux_s390x__wasm32-unknown-unknown__nightly": "@rust_linux_s390x__wasm32-unknown-unknown__nightly_tools//:rust_toolchain", - "rust_linux_s390x__wasm32-wasi__stable": "@rust_linux_s390x__wasm32-wasi__stable_tools//:rust_toolchain", - "rust_linux_s390x__wasm32-wasi__nightly": "@rust_linux_s390x__wasm32-wasi__nightly_tools//:rust_toolchain", - "rustfmt_nightly-2024-09-05__s390x-unknown-linux-gnu": "@rustfmt_nightly-2024-09-05__s390x-unknown-linux-gnu_tools//:rustfmt_toolchain", - "rust_darwin_x86_64__x86_64-apple-darwin__stable": "@rust_darwin_x86_64__x86_64-apple-darwin__stable_tools//:rust_toolchain", - "rust_darwin_x86_64__x86_64-apple-darwin__nightly": "@rust_darwin_x86_64__x86_64-apple-darwin__nightly_tools//:rust_toolchain", - "rust_darwin_x86_64__wasm32-unknown-unknown__stable": "@rust_darwin_x86_64__wasm32-unknown-unknown__stable_tools//:rust_toolchain", - "rust_darwin_x86_64__wasm32-unknown-unknown__nightly": "@rust_darwin_x86_64__wasm32-unknown-unknown__nightly_tools//:rust_toolchain", - "rust_darwin_x86_64__wasm32-wasi__stable": "@rust_darwin_x86_64__wasm32-wasi__stable_tools//:rust_toolchain", - "rust_darwin_x86_64__wasm32-wasi__nightly": "@rust_darwin_x86_64__wasm32-wasi__nightly_tools//:rust_toolchain", - "rustfmt_nightly-2024-09-05__x86_64-apple-darwin": "@rustfmt_nightly-2024-09-05__x86_64-apple-darwin_tools//:rustfmt_toolchain", - "rust_windows_x86_64__x86_64-pc-windows-msvc__stable": "@rust_windows_x86_64__x86_64-pc-windows-msvc__stable_tools//:rust_toolchain", - "rust_windows_x86_64__x86_64-pc-windows-msvc__nightly": "@rust_windows_x86_64__x86_64-pc-windows-msvc__nightly_tools//:rust_toolchain", - "rust_windows_x86_64__wasm32-unknown-unknown__stable": "@rust_windows_x86_64__wasm32-unknown-unknown__stable_tools//:rust_toolchain", - "rust_windows_x86_64__wasm32-unknown-unknown__nightly": "@rust_windows_x86_64__wasm32-unknown-unknown__nightly_tools//:rust_toolchain", - "rust_windows_x86_64__wasm32-wasi__stable": "@rust_windows_x86_64__wasm32-wasi__stable_tools//:rust_toolchain", - "rust_windows_x86_64__wasm32-wasi__nightly": "@rust_windows_x86_64__wasm32-wasi__nightly_tools//:rust_toolchain", - "rustfmt_nightly-2024-09-05__x86_64-pc-windows-msvc": "@rustfmt_nightly-2024-09-05__x86_64-pc-windows-msvc_tools//:rustfmt_toolchain", - "rust_freebsd_x86_64__x86_64-unknown-freebsd__stable": "@rust_freebsd_x86_64__x86_64-unknown-freebsd__stable_tools//:rust_toolchain", - "rust_freebsd_x86_64__x86_64-unknown-freebsd__nightly": "@rust_freebsd_x86_64__x86_64-unknown-freebsd__nightly_tools//:rust_toolchain", - "rust_freebsd_x86_64__wasm32-unknown-unknown__stable": "@rust_freebsd_x86_64__wasm32-unknown-unknown__stable_tools//:rust_toolchain", - "rust_freebsd_x86_64__wasm32-unknown-unknown__nightly": "@rust_freebsd_x86_64__wasm32-unknown-unknown__nightly_tools//:rust_toolchain", - "rust_freebsd_x86_64__wasm32-wasi__stable": "@rust_freebsd_x86_64__wasm32-wasi__stable_tools//:rust_toolchain", - "rust_freebsd_x86_64__wasm32-wasi__nightly": "@rust_freebsd_x86_64__wasm32-wasi__nightly_tools//:rust_toolchain", - "rustfmt_nightly-2024-09-05__x86_64-unknown-freebsd": "@rustfmt_nightly-2024-09-05__x86_64-unknown-freebsd_tools//:rustfmt_toolchain", - "rust_linux_x86_64__x86_64-unknown-linux-gnu__stable": "@rust_linux_x86_64__x86_64-unknown-linux-gnu__stable_tools//:rust_toolchain", - "rust_linux_x86_64__x86_64-unknown-linux-gnu__nightly": "@rust_linux_x86_64__x86_64-unknown-linux-gnu__nightly_tools//:rust_toolchain", - "rust_linux_x86_64__wasm32-unknown-unknown__stable": "@rust_linux_x86_64__wasm32-unknown-unknown__stable_tools//:rust_toolchain", - "rust_linux_x86_64__wasm32-unknown-unknown__nightly": "@rust_linux_x86_64__wasm32-unknown-unknown__nightly_tools//:rust_toolchain", - "rust_linux_x86_64__wasm32-wasi__stable": "@rust_linux_x86_64__wasm32-wasi__stable_tools//:rust_toolchain", - "rust_linux_x86_64__wasm32-wasi__nightly": "@rust_linux_x86_64__wasm32-wasi__nightly_tools//:rust_toolchain", - "rustfmt_nightly-2024-09-05__x86_64-unknown-linux-gnu": "@rustfmt_nightly-2024-09-05__x86_64-unknown-linux-gnu_tools//:rustfmt_toolchain" - }, - "toolchain_types": { - "rust_analyzer_1.81.0": "@rules_rust//rust/rust_analyzer:toolchain_type", - "rust_darwin_aarch64__aarch64-apple-darwin__stable": "@rules_rust//rust:toolchain", - "rust_darwin_aarch64__aarch64-apple-darwin__nightly": "@rules_rust//rust:toolchain", - "rust_darwin_aarch64__wasm32-unknown-unknown__stable": "@rules_rust//rust:toolchain", - "rust_darwin_aarch64__wasm32-unknown-unknown__nightly": "@rules_rust//rust:toolchain", - "rust_darwin_aarch64__wasm32-wasi__stable": "@rules_rust//rust:toolchain", - "rust_darwin_aarch64__wasm32-wasi__nightly": "@rules_rust//rust:toolchain", - "rustfmt_nightly-2024-09-05__aarch64-apple-darwin": "@rules_rust//rust/rustfmt:toolchain_type", - "rust_windows_aarch64__aarch64-pc-windows-msvc__stable": "@rules_rust//rust:toolchain", - "rust_windows_aarch64__aarch64-pc-windows-msvc__nightly": "@rules_rust//rust:toolchain", - "rust_windows_aarch64__wasm32-unknown-unknown__stable": "@rules_rust//rust:toolchain", - "rust_windows_aarch64__wasm32-unknown-unknown__nightly": "@rules_rust//rust:toolchain", - "rust_windows_aarch64__wasm32-wasi__stable": "@rules_rust//rust:toolchain", - "rust_windows_aarch64__wasm32-wasi__nightly": "@rules_rust//rust:toolchain", - "rustfmt_nightly-2024-09-05__aarch64-pc-windows-msvc": "@rules_rust//rust/rustfmt:toolchain_type", - "rust_linux_aarch64__aarch64-unknown-linux-gnu__stable": "@rules_rust//rust:toolchain", - "rust_linux_aarch64__aarch64-unknown-linux-gnu__nightly": "@rules_rust//rust:toolchain", - "rust_linux_aarch64__wasm32-unknown-unknown__stable": "@rules_rust//rust:toolchain", - "rust_linux_aarch64__wasm32-unknown-unknown__nightly": "@rules_rust//rust:toolchain", - "rust_linux_aarch64__wasm32-wasi__stable": "@rules_rust//rust:toolchain", - "rust_linux_aarch64__wasm32-wasi__nightly": "@rules_rust//rust:toolchain", - "rustfmt_nightly-2024-09-05__aarch64-unknown-linux-gnu": "@rules_rust//rust/rustfmt:toolchain_type", - "rust_linux_s390x__s390x-unknown-linux-gnu__stable": "@rules_rust//rust:toolchain", - "rust_linux_s390x__s390x-unknown-linux-gnu__nightly": "@rules_rust//rust:toolchain", - "rust_linux_s390x__wasm32-unknown-unknown__stable": "@rules_rust//rust:toolchain", - "rust_linux_s390x__wasm32-unknown-unknown__nightly": "@rules_rust//rust:toolchain", - "rust_linux_s390x__wasm32-wasi__stable": "@rules_rust//rust:toolchain", - "rust_linux_s390x__wasm32-wasi__nightly": "@rules_rust//rust:toolchain", - "rustfmt_nightly-2024-09-05__s390x-unknown-linux-gnu": "@rules_rust//rust/rustfmt:toolchain_type", - "rust_darwin_x86_64__x86_64-apple-darwin__stable": "@rules_rust//rust:toolchain", - "rust_darwin_x86_64__x86_64-apple-darwin__nightly": "@rules_rust//rust:toolchain", - "rust_darwin_x86_64__wasm32-unknown-unknown__stable": "@rules_rust//rust:toolchain", - "rust_darwin_x86_64__wasm32-unknown-unknown__nightly": "@rules_rust//rust:toolchain", - "rust_darwin_x86_64__wasm32-wasi__stable": "@rules_rust//rust:toolchain", - "rust_darwin_x86_64__wasm32-wasi__nightly": "@rules_rust//rust:toolchain", - "rustfmt_nightly-2024-09-05__x86_64-apple-darwin": "@rules_rust//rust/rustfmt:toolchain_type", - "rust_windows_x86_64__x86_64-pc-windows-msvc__stable": "@rules_rust//rust:toolchain", - "rust_windows_x86_64__x86_64-pc-windows-msvc__nightly": "@rules_rust//rust:toolchain", - "rust_windows_x86_64__wasm32-unknown-unknown__stable": "@rules_rust//rust:toolchain", - "rust_windows_x86_64__wasm32-unknown-unknown__nightly": "@rules_rust//rust:toolchain", - "rust_windows_x86_64__wasm32-wasi__stable": "@rules_rust//rust:toolchain", - "rust_windows_x86_64__wasm32-wasi__nightly": "@rules_rust//rust:toolchain", - "rustfmt_nightly-2024-09-05__x86_64-pc-windows-msvc": "@rules_rust//rust/rustfmt:toolchain_type", - "rust_freebsd_x86_64__x86_64-unknown-freebsd__stable": "@rules_rust//rust:toolchain", - "rust_freebsd_x86_64__x86_64-unknown-freebsd__nightly": "@rules_rust//rust:toolchain", - "rust_freebsd_x86_64__wasm32-unknown-unknown__stable": "@rules_rust//rust:toolchain", - "rust_freebsd_x86_64__wasm32-unknown-unknown__nightly": "@rules_rust//rust:toolchain", - "rust_freebsd_x86_64__wasm32-wasi__stable": "@rules_rust//rust:toolchain", - "rust_freebsd_x86_64__wasm32-wasi__nightly": "@rules_rust//rust:toolchain", - "rustfmt_nightly-2024-09-05__x86_64-unknown-freebsd": "@rules_rust//rust/rustfmt:toolchain_type", - "rust_linux_x86_64__x86_64-unknown-linux-gnu__stable": "@rules_rust//rust:toolchain", - "rust_linux_x86_64__x86_64-unknown-linux-gnu__nightly": "@rules_rust//rust:toolchain", - "rust_linux_x86_64__wasm32-unknown-unknown__stable": "@rules_rust//rust:toolchain", - "rust_linux_x86_64__wasm32-unknown-unknown__nightly": "@rules_rust//rust:toolchain", - "rust_linux_x86_64__wasm32-wasi__stable": "@rules_rust//rust:toolchain", - "rust_linux_x86_64__wasm32-wasi__nightly": "@rules_rust//rust:toolchain", - "rustfmt_nightly-2024-09-05__x86_64-unknown-linux-gnu": "@rules_rust//rust/rustfmt:toolchain_type" - }, - "exec_compatible_with": { - "rust_analyzer_1.81.0": [], - "rust_darwin_aarch64__aarch64-apple-darwin__stable": [ - "@platforms//cpu:aarch64", - "@platforms//os:osx" - ], - "rust_darwin_aarch64__aarch64-apple-darwin__nightly": [ - "@platforms//cpu:aarch64", - "@platforms//os:osx" - ], - "rust_darwin_aarch64__wasm32-unknown-unknown__stable": [ - "@platforms//cpu:aarch64", - "@platforms//os:osx" - ], - "rust_darwin_aarch64__wasm32-unknown-unknown__nightly": [ - "@platforms//cpu:aarch64", - "@platforms//os:osx" - ], - "rust_darwin_aarch64__wasm32-wasi__stable": [ - "@platforms//cpu:aarch64", - "@platforms//os:osx" - ], - "rust_darwin_aarch64__wasm32-wasi__nightly": [ - "@platforms//cpu:aarch64", - "@platforms//os:osx" - ], - "rustfmt_nightly-2024-09-05__aarch64-apple-darwin": [ - "@platforms//cpu:aarch64", - "@platforms//os:osx" - ], - "rust_windows_aarch64__aarch64-pc-windows-msvc__stable": [ - "@platforms//cpu:aarch64", - "@platforms//os:windows" - ], - "rust_windows_aarch64__aarch64-pc-windows-msvc__nightly": [ - "@platforms//cpu:aarch64", - "@platforms//os:windows" - ], - "rust_windows_aarch64__wasm32-unknown-unknown__stable": [ - "@platforms//cpu:aarch64", - "@platforms//os:windows" - ], - "rust_windows_aarch64__wasm32-unknown-unknown__nightly": [ - "@platforms//cpu:aarch64", - "@platforms//os:windows" - ], - "rust_windows_aarch64__wasm32-wasi__stable": [ - "@platforms//cpu:aarch64", - "@platforms//os:windows" - ], - "rust_windows_aarch64__wasm32-wasi__nightly": [ - "@platforms//cpu:aarch64", - "@platforms//os:windows" - ], - "rustfmt_nightly-2024-09-05__aarch64-pc-windows-msvc": [ - "@platforms//cpu:aarch64", - "@platforms//os:windows" - ], - "rust_linux_aarch64__aarch64-unknown-linux-gnu__stable": [ - "@platforms//cpu:aarch64", - "@platforms//os:linux" - ], - "rust_linux_aarch64__aarch64-unknown-linux-gnu__nightly": [ - "@platforms//cpu:aarch64", - "@platforms//os:linux" - ], - "rust_linux_aarch64__wasm32-unknown-unknown__stable": [ - "@platforms//cpu:aarch64", - "@platforms//os:linux" - ], - "rust_linux_aarch64__wasm32-unknown-unknown__nightly": [ - "@platforms//cpu:aarch64", - "@platforms//os:linux" - ], - "rust_linux_aarch64__wasm32-wasi__stable": [ - "@platforms//cpu:aarch64", - "@platforms//os:linux" - ], - "rust_linux_aarch64__wasm32-wasi__nightly": [ - "@platforms//cpu:aarch64", - "@platforms//os:linux" - ], - "rustfmt_nightly-2024-09-05__aarch64-unknown-linux-gnu": [ - "@platforms//cpu:aarch64", - "@platforms//os:linux" - ], - "rust_linux_s390x__s390x-unknown-linux-gnu__stable": [ - "@platforms//cpu:s390x", - "@platforms//os:linux" - ], - "rust_linux_s390x__s390x-unknown-linux-gnu__nightly": [ - "@platforms//cpu:s390x", - "@platforms//os:linux" - ], - "rust_linux_s390x__wasm32-unknown-unknown__stable": [ - "@platforms//cpu:s390x", - "@platforms//os:linux" - ], - "rust_linux_s390x__wasm32-unknown-unknown__nightly": [ - "@platforms//cpu:s390x", - "@platforms//os:linux" - ], - "rust_linux_s390x__wasm32-wasi__stable": [ - "@platforms//cpu:s390x", - "@platforms//os:linux" - ], - "rust_linux_s390x__wasm32-wasi__nightly": [ - "@platforms//cpu:s390x", - "@platforms//os:linux" - ], - "rustfmt_nightly-2024-09-05__s390x-unknown-linux-gnu": [ - "@platforms//cpu:s390x", - "@platforms//os:linux" - ], - "rust_darwin_x86_64__x86_64-apple-darwin__stable": [ - "@platforms//cpu:x86_64", - "@platforms//os:osx" - ], - "rust_darwin_x86_64__x86_64-apple-darwin__nightly": [ - "@platforms//cpu:x86_64", - "@platforms//os:osx" - ], - "rust_darwin_x86_64__wasm32-unknown-unknown__stable": [ - "@platforms//cpu:x86_64", - "@platforms//os:osx" - ], - "rust_darwin_x86_64__wasm32-unknown-unknown__nightly": [ - "@platforms//cpu:x86_64", - "@platforms//os:osx" - ], - "rust_darwin_x86_64__wasm32-wasi__stable": [ - "@platforms//cpu:x86_64", - "@platforms//os:osx" - ], - "rust_darwin_x86_64__wasm32-wasi__nightly": [ - "@platforms//cpu:x86_64", - "@platforms//os:osx" - ], - "rustfmt_nightly-2024-09-05__x86_64-apple-darwin": [ - "@platforms//cpu:x86_64", - "@platforms//os:osx" - ], - "rust_windows_x86_64__x86_64-pc-windows-msvc__stable": [ - "@platforms//cpu:x86_64", - "@platforms//os:windows" - ], - "rust_windows_x86_64__x86_64-pc-windows-msvc__nightly": [ - "@platforms//cpu:x86_64", - "@platforms//os:windows" - ], - "rust_windows_x86_64__wasm32-unknown-unknown__stable": [ - "@platforms//cpu:x86_64", - "@platforms//os:windows" - ], - "rust_windows_x86_64__wasm32-unknown-unknown__nightly": [ - "@platforms//cpu:x86_64", - "@platforms//os:windows" - ], - "rust_windows_x86_64__wasm32-wasi__stable": [ - "@platforms//cpu:x86_64", - "@platforms//os:windows" - ], - "rust_windows_x86_64__wasm32-wasi__nightly": [ - "@platforms//cpu:x86_64", - "@platforms//os:windows" - ], - "rustfmt_nightly-2024-09-05__x86_64-pc-windows-msvc": [ - "@platforms//cpu:x86_64", - "@platforms//os:windows" - ], - "rust_freebsd_x86_64__x86_64-unknown-freebsd__stable": [ - "@platforms//cpu:x86_64", - "@platforms//os:freebsd" - ], - "rust_freebsd_x86_64__x86_64-unknown-freebsd__nightly": [ - "@platforms//cpu:x86_64", - "@platforms//os:freebsd" - ], - "rust_freebsd_x86_64__wasm32-unknown-unknown__stable": [ - "@platforms//cpu:x86_64", - "@platforms//os:freebsd" - ], - "rust_freebsd_x86_64__wasm32-unknown-unknown__nightly": [ - "@platforms//cpu:x86_64", - "@platforms//os:freebsd" - ], - "rust_freebsd_x86_64__wasm32-wasi__stable": [ - "@platforms//cpu:x86_64", - "@platforms//os:freebsd" - ], - "rust_freebsd_x86_64__wasm32-wasi__nightly": [ - "@platforms//cpu:x86_64", - "@platforms//os:freebsd" - ], - "rustfmt_nightly-2024-09-05__x86_64-unknown-freebsd": [ - "@platforms//cpu:x86_64", - "@platforms//os:freebsd" - ], - "rust_linux_x86_64__x86_64-unknown-linux-gnu__stable": [ - "@platforms//cpu:x86_64", - "@platforms//os:linux" - ], - "rust_linux_x86_64__x86_64-unknown-linux-gnu__nightly": [ - "@platforms//cpu:x86_64", - "@platforms//os:linux" - ], - "rust_linux_x86_64__wasm32-unknown-unknown__stable": [ - "@platforms//cpu:x86_64", - "@platforms//os:linux" - ], - "rust_linux_x86_64__wasm32-unknown-unknown__nightly": [ - "@platforms//cpu:x86_64", - "@platforms//os:linux" - ], - "rust_linux_x86_64__wasm32-wasi__stable": [ - "@platforms//cpu:x86_64", - "@platforms//os:linux" - ], - "rust_linux_x86_64__wasm32-wasi__nightly": [ - "@platforms//cpu:x86_64", - "@platforms//os:linux" - ], - "rustfmt_nightly-2024-09-05__x86_64-unknown-linux-gnu": [ - "@platforms//cpu:x86_64", - "@platforms//os:linux" - ] - }, - "target_compatible_with": { - "rust_analyzer_1.81.0": [], - "rust_darwin_aarch64__aarch64-apple-darwin__stable": [ - "@platforms//cpu:aarch64", - "@platforms//os:osx" - ], - "rust_darwin_aarch64__aarch64-apple-darwin__nightly": [ - "@platforms//cpu:aarch64", - "@platforms//os:osx" - ], - "rust_darwin_aarch64__wasm32-unknown-unknown__stable": [ - "@platforms//cpu:wasm32", - "@platforms//os:none" - ], - "rust_darwin_aarch64__wasm32-unknown-unknown__nightly": [ - "@platforms//cpu:wasm32", - "@platforms//os:none" - ], - "rust_darwin_aarch64__wasm32-wasi__stable": [ - "@platforms//cpu:wasm32", - "@platforms//os:wasi" - ], - "rust_darwin_aarch64__wasm32-wasi__nightly": [ - "@platforms//cpu:wasm32", - "@platforms//os:wasi" - ], - "rustfmt_nightly-2024-09-05__aarch64-apple-darwin": [], - "rust_windows_aarch64__aarch64-pc-windows-msvc__stable": [ - "@platforms//cpu:aarch64", - "@platforms//os:windows" - ], - "rust_windows_aarch64__aarch64-pc-windows-msvc__nightly": [ - "@platforms//cpu:aarch64", - "@platforms//os:windows" - ], - "rust_windows_aarch64__wasm32-unknown-unknown__stable": [ - "@platforms//cpu:wasm32", - "@platforms//os:none" - ], - "rust_windows_aarch64__wasm32-unknown-unknown__nightly": [ - "@platforms//cpu:wasm32", - "@platforms//os:none" - ], - "rust_windows_aarch64__wasm32-wasi__stable": [ - "@platforms//cpu:wasm32", - "@platforms//os:wasi" - ], - "rust_windows_aarch64__wasm32-wasi__nightly": [ - "@platforms//cpu:wasm32", - "@platforms//os:wasi" - ], - "rustfmt_nightly-2024-09-05__aarch64-pc-windows-msvc": [], - "rust_linux_aarch64__aarch64-unknown-linux-gnu__stable": [ - "@platforms//cpu:aarch64", - "@platforms//os:linux" - ], - "rust_linux_aarch64__aarch64-unknown-linux-gnu__nightly": [ - "@platforms//cpu:aarch64", - "@platforms//os:linux" - ], - "rust_linux_aarch64__wasm32-unknown-unknown__stable": [ - "@platforms//cpu:wasm32", - "@platforms//os:none" - ], - "rust_linux_aarch64__wasm32-unknown-unknown__nightly": [ - "@platforms//cpu:wasm32", - "@platforms//os:none" - ], - "rust_linux_aarch64__wasm32-wasi__stable": [ - "@platforms//cpu:wasm32", - "@platforms//os:wasi" - ], - "rust_linux_aarch64__wasm32-wasi__nightly": [ - "@platforms//cpu:wasm32", - "@platforms//os:wasi" - ], - "rustfmt_nightly-2024-09-05__aarch64-unknown-linux-gnu": [], - "rust_linux_s390x__s390x-unknown-linux-gnu__stable": [ - "@platforms//cpu:s390x", - "@platforms//os:linux" - ], - "rust_linux_s390x__s390x-unknown-linux-gnu__nightly": [ - "@platforms//cpu:s390x", - "@platforms//os:linux" - ], - "rust_linux_s390x__wasm32-unknown-unknown__stable": [ - "@platforms//cpu:wasm32", - "@platforms//os:none" - ], - "rust_linux_s390x__wasm32-unknown-unknown__nightly": [ - "@platforms//cpu:wasm32", - "@platforms//os:none" - ], - "rust_linux_s390x__wasm32-wasi__stable": [ - "@platforms//cpu:wasm32", - "@platforms//os:wasi" - ], - "rust_linux_s390x__wasm32-wasi__nightly": [ - "@platforms//cpu:wasm32", - "@platforms//os:wasi" - ], - "rustfmt_nightly-2024-09-05__s390x-unknown-linux-gnu": [], - "rust_darwin_x86_64__x86_64-apple-darwin__stable": [ - "@platforms//cpu:x86_64", - "@platforms//os:osx" - ], - "rust_darwin_x86_64__x86_64-apple-darwin__nightly": [ - "@platforms//cpu:x86_64", - "@platforms//os:osx" - ], - "rust_darwin_x86_64__wasm32-unknown-unknown__stable": [ - "@platforms//cpu:wasm32", - "@platforms//os:none" - ], - "rust_darwin_x86_64__wasm32-unknown-unknown__nightly": [ - "@platforms//cpu:wasm32", - "@platforms//os:none" - ], - "rust_darwin_x86_64__wasm32-wasi__stable": [ - "@platforms//cpu:wasm32", - "@platforms//os:wasi" - ], - "rust_darwin_x86_64__wasm32-wasi__nightly": [ - "@platforms//cpu:wasm32", - "@platforms//os:wasi" - ], - "rustfmt_nightly-2024-09-05__x86_64-apple-darwin": [], - "rust_windows_x86_64__x86_64-pc-windows-msvc__stable": [ - "@platforms//cpu:x86_64", - "@platforms//os:windows" - ], - "rust_windows_x86_64__x86_64-pc-windows-msvc__nightly": [ - "@platforms//cpu:x86_64", - "@platforms//os:windows" - ], - "rust_windows_x86_64__wasm32-unknown-unknown__stable": [ - "@platforms//cpu:wasm32", - "@platforms//os:none" - ], - "rust_windows_x86_64__wasm32-unknown-unknown__nightly": [ - "@platforms//cpu:wasm32", - "@platforms//os:none" - ], - "rust_windows_x86_64__wasm32-wasi__stable": [ - "@platforms//cpu:wasm32", - "@platforms//os:wasi" - ], - "rust_windows_x86_64__wasm32-wasi__nightly": [ - "@platforms//cpu:wasm32", - "@platforms//os:wasi" - ], - "rustfmt_nightly-2024-09-05__x86_64-pc-windows-msvc": [], - "rust_freebsd_x86_64__x86_64-unknown-freebsd__stable": [ - "@platforms//cpu:x86_64", - "@platforms//os:freebsd" - ], - "rust_freebsd_x86_64__x86_64-unknown-freebsd__nightly": [ - "@platforms//cpu:x86_64", - "@platforms//os:freebsd" - ], - "rust_freebsd_x86_64__wasm32-unknown-unknown__stable": [ - "@platforms//cpu:wasm32", - "@platforms//os:none" - ], - "rust_freebsd_x86_64__wasm32-unknown-unknown__nightly": [ - "@platforms//cpu:wasm32", - "@platforms//os:none" - ], - "rust_freebsd_x86_64__wasm32-wasi__stable": [ - "@platforms//cpu:wasm32", - "@platforms//os:wasi" - ], - "rust_freebsd_x86_64__wasm32-wasi__nightly": [ - "@platforms//cpu:wasm32", - "@platforms//os:wasi" - ], - "rustfmt_nightly-2024-09-05__x86_64-unknown-freebsd": [], - "rust_linux_x86_64__x86_64-unknown-linux-gnu__stable": [ - "@platforms//cpu:x86_64", - "@platforms//os:linux" - ], - "rust_linux_x86_64__x86_64-unknown-linux-gnu__nightly": [ - "@platforms//cpu:x86_64", - "@platforms//os:linux" - ], - "rust_linux_x86_64__wasm32-unknown-unknown__stable": [ - "@platforms//cpu:wasm32", - "@platforms//os:none" - ], - "rust_linux_x86_64__wasm32-unknown-unknown__nightly": [ - "@platforms//cpu:wasm32", - "@platforms//os:none" - ], - "rust_linux_x86_64__wasm32-wasi__stable": [ - "@platforms//cpu:wasm32", - "@platforms//os:wasi" - ], - "rust_linux_x86_64__wasm32-wasi__nightly": [ - "@platforms//cpu:wasm32", - "@platforms//os:wasi" - ], - "rustfmt_nightly-2024-09-05__x86_64-unknown-linux-gnu": [] - } + "toolchain_implementations": { + "none": "'@@rules_python+//python:none'" + }, + "toolchain_compatible_with": { + "none": [ + "@platforms//:incompatible" + ] + }, + "toolchain_target_settings": {} } } - }, - "recordedRepoMappingEntries": [ - [ - "bazel_features~", - "bazel_features_globals", - "bazel_features~~version_extension~bazel_features_globals" - ], - [ - "bazel_features~", - "bazel_features_version", - "bazel_features~~version_extension~bazel_features_version" - ], - [ - "rules_rust~", - "bazel_features", - "bazel_features~" - ], - [ - "rules_rust~", - "bazel_skylib", - "bazel_skylib~" - ], - [ - "rules_rust~", - "bazel_tools", - "bazel_tools" - ], - [ - "rules_rust~", - "rules_rust", - "rules_rust~" - ] - ] + } } } - } + }, + "facts": {} } diff --git a/bazel/hexl_repo.bzl b/bazel/hexl_repo.bzl index 76b60707..b41edc5e 100644 --- a/bazel/hexl_repo.bzl +++ b/bazel/hexl_repo.bzl @@ -15,6 +15,15 @@ cc_library( ) """ +_HEXL_STUB_BUILD = """load("@rules_cc//cc:defs.bzl", "cc_library") + +package(default_visibility = ["//visibility:public"]) + +cc_library( + name = "hexl", +) +""" + def _hexl_repository_impl(repository_ctx): roots = [] env_root = repository_ctx.os.environ.get("HEXL_ROOT", "") @@ -42,10 +51,12 @@ def _hexl_repository_impl(repository_ctx): repository_ctx.file("WORKSPACE.bazel", "workspace(name = \"hexl\")\n") return - fail( - "HEXL was not found. Set HEXL_ROOT to the installation prefix, " + - "or install HEXL under /usr/local or /usr.", - ) + # HEXL not found — create a stub so the workspace resolves on non-x86 + # platforms. Targets that actually depend on @hexl are gated by + # target_compatible_with = ["@platforms//cpu:x86_64"] and will never be + # built on ARM / macOS Apple Silicon. + repository_ctx.file("BUILD.bazel", _HEXL_STUB_BUILD) + repository_ctx.file("WORKSPACE.bazel", "workspace(name = \"hexl\")\n") hexl_repository = repository_rule( implementation = _hexl_repository_impl, diff --git a/psi/algorithm/ypir/legacy/ypir_util.cc b/psi/algorithm/ypir/legacy/ypir_util.cc index 9a01ee14..0f98fcf2 100644 --- a/psi/algorithm/ypir/legacy/ypir_util.cc +++ b/psi/algorithm/ypir/legacy/ypir_util.cc @@ -480,8 +480,12 @@ void MatrixVectorMultiplicationU16( const std::vector& vec, uint64_t mod) { #if defined(__x86_64__) || defined(_M_X64) #if defined(__GNUC__) || defined(__clang__) - MatrixVectorMultiplicationU16Avx512(result, matrix, vec, mod); - return; + if (__builtin_cpu_supports("avx512f") && + __builtin_cpu_supports("avx512bw") && + __builtin_cpu_supports("avx512vl")) { + MatrixVectorMultiplicationU16Avx512(result, matrix, vec, mod); + return; + } #endif #endif const uint64_t mat_row = matrix.size(); @@ -503,8 +507,12 @@ void MatVecU8U32Mod2p32(const uint8_t* A, const uint32_t* x, uint32_t* y, size_t rows, size_t cols) { #if defined(__x86_64__) || defined(_M_X64) #if defined(__GNUC__) || defined(__clang__) - MatVecU8U32Mod2p32Avx512(A, x, y, rows, cols); - return; + if (__builtin_cpu_supports("avx512f") && + __builtin_cpu_supports("avx512bw") && + __builtin_cpu_supports("avx512vl")) { + MatVecU8U32Mod2p32Avx512(A, x, y, rows, cols); + return; + } #endif #endif MatVecU8U32Mod2p32Scalar(A, x, y, rows, cols); From a1cc2abbd92384224596ba14a325ca12c3d6d5df Mon Sep 17 00:00:00 2001 From: sh1k4ku Date: Tue, 7 Apr 2026 22:06:50 +0800 Subject: [PATCH 09/12] fix linux_ut-2xlarge --- .codex | 0 MODULE.bazel.lock | 3797 ++++++++++++++++++++++++++--- psi/algorithm/ypir/legacy/util.cc | 9 +- 3 files changed, 3406 insertions(+), 400 deletions(-) create mode 100644 .codex diff --git a/.codex b/.codex new file mode 100644 index 00000000..e69de29b diff --git a/MODULE.bazel.lock b/MODULE.bazel.lock index 2cc0a487..2b1e424d 100644 --- a/MODULE.bazel.lock +++ b/MODULE.bazel.lock @@ -1,5 +1,5 @@ { - "lockFileVersion": 26, + "lockFileVersion": 13, "registryFileHashes": { "https://bcr.bazel.build/bazel_registry.json": "8a28e4aff06ee60aed2a8c281907fb8bcbf3b753c91fb5a5c57da3215d5b3497", "https://bcr.bazel.build/modules/abseil-cpp/20210324.2/MODULE.bazel": "7cd0312e064fde87c8d1cd79ba06c876bd23630c83466e9500321be55c96ace2", @@ -13,19 +13,14 @@ "https://bcr.bazel.build/modules/abseil-cpp/20240116.1/MODULE.bazel": "37bcdb4440fbb61df6a1c296ae01b327f19e9bb521f9b8e26ec854b6f97309ed", "https://bcr.bazel.build/modules/abseil-cpp/20240116.2/MODULE.bazel": "73939767a4686cd9a520d16af5ab440071ed75cec1a876bf2fcfaf1f71987a16", "https://bcr.bazel.build/modules/abseil-cpp/20240722.0.bcr.1/MODULE.bazel": "c0aa5eaefff1121b40208397f229604c717bd2fdf214ff67586d627118e17720", + "https://bcr.bazel.build/modules/abseil-cpp/20240722.0.bcr.1/source.json": "e067fdd217bacbe74c88a975434be5df0b44315a247be180f0e20f891715210c", "https://bcr.bazel.build/modules/abseil-cpp/20240722.0/MODULE.bazel": "88668a07647adbdc14cb3a7cd116fb23c9dda37a90a1681590b6c9d8339a5b84", - "https://bcr.bazel.build/modules/abseil-cpp/20250127.1/MODULE.bazel": "c4a89e7ceb9bf1e25cf84a9f830ff6b817b72874088bf5141b314726e46a57c1", - "https://bcr.bazel.build/modules/abseil-cpp/20250512.1/MODULE.bazel": "d209fdb6f36ffaf61c509fcc81b19e81b411a999a934a032e10cd009a0226215", - "https://bcr.bazel.build/modules/abseil-cpp/20250814.1/MODULE.bazel": "51f2312901470cdab0dbdf3b88c40cd21c62a7ed58a3de45b365ddc5b11bcab2", - "https://bcr.bazel.build/modules/abseil-cpp/20250814.1/source.json": "cea3901d7e299da7320700abbaafe57a65d039f10d0d7ea601c4a66938ea4b0c", "https://bcr.bazel.build/modules/apple_support/1.11.1/MODULE.bazel": "1843d7cd8a58369a444fc6000e7304425fba600ff641592161d9f15b179fb896", "https://bcr.bazel.build/modules/apple_support/1.13.0/MODULE.bazel": "7c8cdea7e031b7f9f67f0b497adf6d2c6a2675e9304ca93a9af6ed84eef5a524", "https://bcr.bazel.build/modules/apple_support/1.15.1/MODULE.bazel": "a0556fefca0b1bb2de8567b8827518f94db6a6e7e7d632b4c48dc5f865bc7c85", "https://bcr.bazel.build/modules/apple_support/1.17.1/MODULE.bazel": "655c922ab1209978a94ef6ca7d9d43e940cd97d9c172fb55f94d91ac53f8610b", - "https://bcr.bazel.build/modules/apple_support/1.21.0/MODULE.bazel": "ac1824ed5edf17dee2fdd4927ada30c9f8c3b520be1b5fd02a5da15bc10bff3e", - "https://bcr.bazel.build/modules/apple_support/1.21.1/MODULE.bazel": "5809fa3efab15d1f3c3c635af6974044bac8a4919c62238cce06acee8a8c11f1", - "https://bcr.bazel.build/modules/apple_support/1.24.2/MODULE.bazel": "0e62471818affb9f0b26f128831d5c40b074d32e6dda5a0d3852847215a41ca4", - "https://bcr.bazel.build/modules/apple_support/1.24.2/source.json": "2c22c9827093250406c5568da6c54e6fdf0ef06238def3d99c71b12feb057a8d", + "https://bcr.bazel.build/modules/apple_support/1.17.1/source.json": "6b2b8c74d14e8d485528a938e44bdb72a5ba17632b9e14ef6e68a5ee96c8347f", + "https://bcr.bazel.build/modules/apple_support/1.5.0/MODULE.bazel": "50341a62efbc483e8a2a6aec30994a58749bd7b885e18dd96aa8c33031e558ef", "https://bcr.bazel.build/modules/aspect_bazel_lib/1.31.2/MODULE.bazel": "7bee702b4862612f29333590f4b658a5832d433d6f8e4395f090e8f4e85d442f", "https://bcr.bazel.build/modules/aspect_bazel_lib/1.38.0/MODULE.bazel": "6307fec451ba9962c1c969eb516ebfe1e46528f7fa92e1c9ac8646bef4cdaa3f", "https://bcr.bazel.build/modules/aspect_bazel_lib/1.40.3/MODULE.bazel": "668e6bcb4d957fc0e284316dba546b705c8d43c857f87119619ee83c4555b859", @@ -46,14 +41,9 @@ "https://bcr.bazel.build/modules/bazel_features/1.19.0/MODULE.bazel": "59adcdf28230d220f0067b1f435b8537dd033bfff8db21335ef9217919c7fb58", "https://bcr.bazel.build/modules/bazel_features/1.20.0/MODULE.bazel": "8b85300b9c8594752e0721a37210e34879d23adc219ed9dc8f4104a4a1750920", "https://bcr.bazel.build/modules/bazel_features/1.21.0/MODULE.bazel": "675642261665d8eea09989aa3b8afb5c37627f1be178382c320d1b46afba5e3b", - "https://bcr.bazel.build/modules/bazel_features/1.23.0/MODULE.bazel": "fd1ac84bc4e97a5a0816b7fd7d4d4f6d837b0047cf4cbd81652d616af3a6591a", "https://bcr.bazel.build/modules/bazel_features/1.24.0/MODULE.bazel": "4796b4c25b47053e9bbffa792b3792d07e228ff66cd0405faef56a978708acd4", - "https://bcr.bazel.build/modules/bazel_features/1.27.0/MODULE.bazel": "621eeee06c4458a9121d1f104efb80f39d34deff4984e778359c60eaf1a8cb65", - "https://bcr.bazel.build/modules/bazel_features/1.28.0/MODULE.bazel": "4b4200e6cbf8fa335b2c3f43e1d6ef3e240319c33d43d60cc0fbd4b87ece299d", + "https://bcr.bazel.build/modules/bazel_features/1.24.0/source.json": "aeb7dcafd9cfc342095d315def2f7bcfcd9da0b78572edeceff1d1c12db4e08c", "https://bcr.bazel.build/modules/bazel_features/1.3.0/MODULE.bazel": "cdcafe83ec318cda34e02948e81d790aab8df7a929cec6f6969f13a489ccecd9", - "https://bcr.bazel.build/modules/bazel_features/1.30.0/MODULE.bazel": "a14b62d05969a293b80257e72e597c2da7f717e1e69fa8b339703ed6731bec87", - "https://bcr.bazel.build/modules/bazel_features/1.33.0/MODULE.bazel": "8b8dc9d2a4c88609409c3191165bccec0e4cb044cd7a72ccbe826583303459f6", - "https://bcr.bazel.build/modules/bazel_features/1.33.0/source.json": "13617db3930328c2cd2807a0f13d52ca870ac05f96db9668655113265147b2a6", "https://bcr.bazel.build/modules/bazel_features/1.4.1/MODULE.bazel": "e45b6bb2350aff3e442ae1111c555e27eac1d915e77775f6fdc4b351b758b5d7", "https://bcr.bazel.build/modules/bazel_features/1.9.0/MODULE.bazel": "885151d58d90d8d9c811eb75e3288c11f850e1d6b481a8c9f766adee4712358b", "https://bcr.bazel.build/modules/bazel_features/1.9.1/MODULE.bazel": "8f679097876a9b609ad1f60249c49d68bfab783dd9be012faf9d82547b14815a", @@ -69,9 +59,7 @@ "https://bcr.bazel.build/modules/bazel_skylib/1.6.1/MODULE.bazel": "8fdee2dbaace6c252131c00e1de4b165dc65af02ea278476187765e1a617b917", "https://bcr.bazel.build/modules/bazel_skylib/1.7.0/MODULE.bazel": "0db596f4563de7938de764cc8deeabec291f55e8ec15299718b93c4423e9796d", "https://bcr.bazel.build/modules/bazel_skylib/1.7.1/MODULE.bazel": "3120d80c5861aa616222ec015332e5f8d3171e062e3e804a2a0253e1be26e59b", - "https://bcr.bazel.build/modules/bazel_skylib/1.8.1/MODULE.bazel": "88ade7293becda963e0e3ea33e7d54d3425127e0a326e0d17da085a5f1f03ff6", - "https://bcr.bazel.build/modules/bazel_skylib/1.8.2/MODULE.bazel": "69ad6927098316848b34a9142bcc975e018ba27f08c4ff403f50c1b6e646ca67", - "https://bcr.bazel.build/modules/bazel_skylib/1.8.2/source.json": "34a3c8bcf233b835eb74be9d628899bb32999d3e0eadef1947a0a562a2b16ffb", + "https://bcr.bazel.build/modules/bazel_skylib/1.7.1/source.json": "f121b43eeefc7c29efbd51b83d08631e2347297c95aac9764a701f2a6a2bb953", "https://bcr.bazel.build/modules/blake3/1.5.4/MODULE.bazel": "1a378cca01187c40c27347f7e245506340cb68db3557ce1fab59ed007532fa2d", "https://bcr.bazel.build/modules/blake3/1.5.4/source.json": "ac1099f9ad8abd9167899bb6253c3cc663620973c39ecd595c3c5114cf96e1e7", "https://bcr.bazel.build/modules/boost.algorithm/1.83.0.bcr.1/MODULE.bazel": "8657617ad7aa55d179078faa15c131f07ae1bc35e536343211eee2d942368881", @@ -216,8 +204,8 @@ "https://bcr.bazel.build/modules/boringssl/0.20241024.0/source.json": "d843092e682b84188c043ac742965d7f96e04c846c7e338187e03238674909a9", "https://bcr.bazel.build/modules/brotli/1.1.0/MODULE.bazel": "3b5b90488995183419c4b5c9b063a164f6c0bc4d0d6b40550a612a5e860cc0fe", "https://bcr.bazel.build/modules/brotli/1.1.0/source.json": "098a4fd315527166e8dfe1fd1537c96a737a83764be38fc43f4da231d600f3d0", - "https://bcr.bazel.build/modules/buildozer/8.2.1/MODULE.bazel": "61e9433c574c2bd9519cad7fa66b9c1d2b8e8d5f3ae5d6528a2c2d26e68d874d", - "https://bcr.bazel.build/modules/buildozer/8.2.1/source.json": "7c33f6a26ee0216f85544b4bca5e9044579e0219b6898dd653f5fb449cf2e484", + "https://bcr.bazel.build/modules/buildozer/7.1.2/MODULE.bazel": "2e8dd40ede9c454042645fd8d8d0cd1527966aa5c919de86661e62953cd73d84", + "https://bcr.bazel.build/modules/buildozer/7.1.2/source.json": "c9028a501d2db85793a6996205c8de120944f50a0d570438fcae0457a5f9d1f8", "https://bcr.bazel.build/modules/bzip2/1.0.8.bcr.2/MODULE.bazel": "43b570f55b7479bfa7c6675b227ccc3155d56377bb7782f178b2d1733196a435", "https://bcr.bazel.build/modules/bzip2/1.0.8.bcr.2/source.json": "9789bb6c0444ae84fb7f559c9da0fbb46d39219539f8d99c13b8db55357e8cf9", "https://bcr.bazel.build/modules/c-ares/1.15.0/MODULE.bazel": "ba0a78360fdc83f02f437a9e7df0532ad1fbaa59b722f6e715c11effebaa0166", @@ -260,8 +248,7 @@ "https://bcr.bazel.build/modules/googletest/1.14.0.bcr.1/MODULE.bazel": "22c31a561553727960057361aa33bf20fb2e98584bc4fec007906e27053f80c6", "https://bcr.bazel.build/modules/googletest/1.14.0/MODULE.bazel": "cfbcbf3e6eac06ef9d85900f64424708cc08687d1b527f0ef65aa7517af8118f", "https://bcr.bazel.build/modules/googletest/1.15.2/MODULE.bazel": "6de1edc1d26cafb0ea1a6ab3f4d4192d91a312fd2d360b63adaa213cd00b2108", - "https://bcr.bazel.build/modules/googletest/1.17.0/MODULE.bazel": "dbec758171594a705933a29fcf69293d2468c49ec1f2ebca65c36f504d72df46", - "https://bcr.bazel.build/modules/googletest/1.17.0/source.json": "38e4454b25fc30f15439c0378e57909ab1fd0a443158aa35aec685da727cd713", + "https://bcr.bazel.build/modules/googletest/1.15.2/source.json": "dbdda654dcb3a0d7a8bc5d0ac5fc7e150b58c2a986025ae5bc634bb2cb61f470", "https://bcr.bazel.build/modules/grpc-java/1.62.2/MODULE.bazel": "99b8771e8c7cacb130170fed2a10c9e8fed26334a93e73b42d2953250885a158", "https://bcr.bazel.build/modules/grpc-java/1.66.0/MODULE.bazel": "86ff26209fac846adb89db11f3714b3dc0090fb2fb81575673cc74880cda4e7e", "https://bcr.bazel.build/modules/grpc-java/1.66.0/source.json": "f841b339ff8516c86c3a5272cd053194dd0cb2fdd63157123835e1157a28328d", @@ -275,8 +262,7 @@ "https://bcr.bazel.build/modules/grpc/1.68.0/MODULE.bazel": "6691126221dbfd615990cc81d0d9705b74937dbc4206fb9921cb0fc7b4fd4c6a", "https://bcr.bazel.build/modules/grpc/1.68.0/source.json": "790c364e4f4be3d3ce28cdaa919eafb6667bce242b9e252aa880af2018303130", "https://bcr.bazel.build/modules/jsoncpp/1.9.5/MODULE.bazel": "31271aedc59e815656f5736f282bb7509a97c7ecb43e927ac1a37966e0578075", - "https://bcr.bazel.build/modules/jsoncpp/1.9.6/MODULE.bazel": "2f8d20d3b7d54143213c4dfc3d98225c42de7d666011528dc8fe91591e2e17b0", - "https://bcr.bazel.build/modules/jsoncpp/1.9.6/source.json": "a04756d367a2126c3541682864ecec52f92cdee80a35735a3cb249ce015ca000", + "https://bcr.bazel.build/modules/jsoncpp/1.9.5/source.json": "4108ee5085dd2885a341c7fab149429db457b3169b86eb081fa245eadf69169d", "https://bcr.bazel.build/modules/libpfm/4.11.0/MODULE.bazel": "45061ff025b301940f1e30d2c16bea596c25b176c8b6b3087e92615adbd52902", "https://bcr.bazel.build/modules/libpfm/4.11.0/source.json": "caaffb3ac2b59b8aac456917a4ecf3167d40478ee79f15ab7a877ec9273937c9", "https://bcr.bazel.build/modules/lz4/1.9.4/MODULE.bazel": "e3d307b1d354d70f6c809167eafecf5d622c3f27e3971ab7273410f429c7f83a", @@ -298,14 +284,13 @@ "https://bcr.bazel.build/modules/opentracing-cpp/1.6.0/source.json": "da1cb1add160f5e5074b7272e9db6fd8f1b3336c15032cd0a653af9d2f484aed", "https://bcr.bazel.build/modules/platforms/0.0.10/MODULE.bazel": "8cb8efaf200bdeb2150d93e162c40f388529a25852b332cec879373771e48ed5", "https://bcr.bazel.build/modules/platforms/0.0.11/MODULE.bazel": "0daefc49732e227caa8bfa834d65dc52e8cc18a2faf80df25e8caea151a9413f", + "https://bcr.bazel.build/modules/platforms/0.0.11/source.json": "f7e188b79ebedebfe75e9e1d098b8845226c7992b307e28e1496f23112e8fc29", "https://bcr.bazel.build/modules/platforms/0.0.4/MODULE.bazel": "9b328e31ee156f53f3c416a64f8491f7eb731742655a47c9eec4703a71644aee", "https://bcr.bazel.build/modules/platforms/0.0.5/MODULE.bazel": "5733b54ea419d5eaf7997054bb55f6a1d0b5ff8aedf0176fef9eea44f3acda37", "https://bcr.bazel.build/modules/platforms/0.0.6/MODULE.bazel": "ad6eeef431dc52aefd2d77ed20a4b353f8ebf0f4ecdd26a807d2da5aa8cd0615", "https://bcr.bazel.build/modules/platforms/0.0.7/MODULE.bazel": "72fd4a0ede9ee5c021f6a8dd92b503e089f46c227ba2813ff183b71616034814", "https://bcr.bazel.build/modules/platforms/0.0.8/MODULE.bazel": "9f142c03e348f6d263719f5074b21ef3adf0b139ee4c5133e2aa35664da9eb2d", "https://bcr.bazel.build/modules/platforms/0.0.9/MODULE.bazel": "4a87a60c927b56ddd67db50c89acaa62f4ce2a1d2149ccb63ffd871d5ce29ebc", - "https://bcr.bazel.build/modules/platforms/1.0.0/MODULE.bazel": "f05feb42b48f1b3c225e4ccf351f367be0371411a803198ec34a389fb22aa580", - "https://bcr.bazel.build/modules/platforms/1.0.0/source.json": "f4ff1fd412e0246fd38c82328eb209130ead81d62dcd5a9e40910f867f733d96", "https://bcr.bazel.build/modules/prometheus-cpp/1.2.4/MODULE.bazel": "0fbe5dcff66311947a3f6b86ebc6a6d9328e31a28413ca864debc4a043f371e5", "https://bcr.bazel.build/modules/prometheus-cpp/1.3.0/MODULE.bazel": "ce82e086bbc0b60267e970f6a54b2ca6d0f22d3eb6633e00e2cc2899c700f3d8", "https://bcr.bazel.build/modules/prometheus-cpp/1.3.0/source.json": "8cb66b4e535afc718e9d104a3db96ccb71a42ee816a100e50fd0d5ac843c0606", @@ -322,13 +307,10 @@ "https://bcr.bazel.build/modules/protobuf/28.3/MODULE.bazel": "2b3764bbab2e46703412bd3b859efcf0322638ed015e88432df3bb740507a1e9", "https://bcr.bazel.build/modules/protobuf/29.0-rc2/MODULE.bazel": "6241d35983510143049943fc0d57937937122baf1b287862f9dc8590fc4c37df", "https://bcr.bazel.build/modules/protobuf/29.0-rc3/MODULE.bazel": "33c2dfa286578573afc55a7acaea3cada4122b9631007c594bf0729f41c8de92", - "https://bcr.bazel.build/modules/protobuf/29.1/MODULE.bazel": "557c3457560ff49e122ed76c0bc3397a64af9574691cb8201b4e46d4ab2ecb95", + "https://bcr.bazel.build/modules/protobuf/29.0-rc3/source.json": "c16a6488fb279ef578da7098e605082d72ed85fc8d843eaae81e7d27d0f4625d", "https://bcr.bazel.build/modules/protobuf/3.19.0/MODULE.bazel": "6b5fbb433f760a99a22b18b6850ed5784ef0e9928a72668b66e4d7ccd47db9b0", "https://bcr.bazel.build/modules/protobuf/3.19.2/MODULE.bazel": "532ffe5f2186b69fdde039efe6df13ba726ff338c6bc82275ad433013fa10573", "https://bcr.bazel.build/modules/protobuf/3.19.6/MODULE.bazel": "9233edc5e1f2ee276a60de3eaa47ac4132302ef9643238f23128fea53ea12858", - "https://bcr.bazel.build/modules/protobuf/32.1/MODULE.bazel": "89cd2866a9cb07fee9ff74c41ceace11554f32e0d849de4e23ac55515cfada4d", - "https://bcr.bazel.build/modules/protobuf/33.4/MODULE.bazel": "114775b816b38b6d0ca620450d6b02550c60ceedfdc8d9a229833b34a223dc42", - "https://bcr.bazel.build/modules/protobuf/33.4/source.json": "555f8686b4c7d6b5ba731fbea13bf656b4bfd9a7ff629c1d9d3f6e1d6155de79", "https://bcr.bazel.build/modules/protoc-gen-validate/1.0.4/MODULE.bazel": "b8913c154b16177990f6126d2d2477d187f9ddc568e95ee3e2d50fc65d2c494a", "https://bcr.bazel.build/modules/protoc-gen-validate/1.0.4/source.json": "541f6bbab589ea06cca29235d178bf6d2f282576593b2ce4b3802132d8ad740b", "https://bcr.bazel.build/modules/pybind11_bazel/2.11.1/MODULE.bazel": "88af1c246226d87e65be78ed49ecd1e6f5e98648558c14ce99176da041dc378e", @@ -340,16 +322,13 @@ "https://bcr.bazel.build/modules/re2/2021-09-01/MODULE.bazel": "bcb6b96f3b071e6fe2d8bed9cc8ada137a105f9d2c5912e91d27528b3d123833", "https://bcr.bazel.build/modules/re2/2023-09-01/MODULE.bazel": "cb3d511531b16cfc78a225a9e2136007a48cf8a677e4264baeab57fe78a80206", "https://bcr.bazel.build/modules/re2/2024-05-01/MODULE.bazel": "55a3f059538f381107824e7d00df5df6d061ba1fb80e874e4909c0f0549e8f3e", - "https://bcr.bazel.build/modules/re2/2024-07-02.bcr.1/MODULE.bazel": "b4963dda9b31080be1905ef085ecd7dd6cd47c05c79b9cdf83ade83ab2ab271a", - "https://bcr.bazel.build/modules/re2/2024-07-02.bcr.1/source.json": "2ff292be6ef3340325ce8a045ecc326e92cbfab47c7cbab4bd85d28971b97ac4", "https://bcr.bazel.build/modules/re2/2024-07-02/MODULE.bazel": "0eadc4395959969297cbcf31a249ff457f2f1d456228c67719480205aa306daa", + "https://bcr.bazel.build/modules/re2/2024-07-02/source.json": "547d0111a9d4f362db32196fef805abbf3676e8d6afbe44d395d87816c1130ca", "https://bcr.bazel.build/modules/rules_android/0.1.1/MODULE.bazel": "48809ab0091b07ad0182defb787c4c5328bd3a278938415c00a7b69b50c4d3a8", "https://bcr.bazel.build/modules/rules_android/0.1.1/source.json": "e6986b41626ee10bdc864937ffb6d6bf275bb5b9c65120e6137d56e6331f089e", "https://bcr.bazel.build/modules/rules_apple/3.13.0/MODULE.bazel": "b4559a2c6281ca3165275bb36c1f0ac74666632adc5bdb680e366de7ce845f43", - "https://bcr.bazel.build/modules/rules_apple/3.16.0/MODULE.bazel": "0d1caf0b8375942ce98ea944be754a18874041e4e0459401d925577624d3a54a", + "https://bcr.bazel.build/modules/rules_apple/3.13.0/source.json": "fe31c678e2256daa91a802664b578c1de71dc43a49a7ccc16db001378f312cd3", "https://bcr.bazel.build/modules/rules_apple/3.5.1/MODULE.bazel": "3d1bbf65ad3692003d36d8a29eff54d4e5c1c5f4bfb60f79e28646a924d9101c", - "https://bcr.bazel.build/modules/rules_apple/4.1.0/MODULE.bazel": "76e10fd4a48038d3fc7c5dc6e63b7063bbf5304a2e3bd42edda6ec660eebea68", - "https://bcr.bazel.build/modules/rules_apple/4.1.0/source.json": "8ee81e1708756f81b343a5eb2b2f0b953f1d25c4ab3d4a68dc02754872e80715", "https://bcr.bazel.build/modules/rules_buf/0.1.1/MODULE.bazel": "6189aec18a4f7caff599ad41b851ab7645d4f1e114aa6431acf9b0666eb92162", "https://bcr.bazel.build/modules/rules_buf/0.1.1/source.json": "021363d254f7438f3f10725355969c974bb2c67e0c28667782ade31a9cdb747f", "https://bcr.bazel.build/modules/rules_cc/0.0.1/MODULE.bazel": "cb2aa0747f84c6c3a78dad4e2049c154f08ab9d166b1273835a8174940365647", @@ -366,13 +345,7 @@ "https://bcr.bazel.build/modules/rules_cc/0.0.8/MODULE.bazel": "964c85c82cfeb6f3855e6a07054fdb159aced38e99a5eecf7bce9d53990afa3e", "https://bcr.bazel.build/modules/rules_cc/0.0.9/MODULE.bazel": "836e76439f354b89afe6a911a7adf59a6b2518fafb174483ad78a2a2fde7b1c5", "https://bcr.bazel.build/modules/rules_cc/0.1.1/MODULE.bazel": "2f0222a6f229f0bf44cd711dc13c858dad98c62d52bd51d8fc3a764a83125513", - "https://bcr.bazel.build/modules/rules_cc/0.1.2/MODULE.bazel": "557ddc3a96858ec0d465a87c0a931054d7dcfd6583af2c7ed3baf494407fd8d0", - "https://bcr.bazel.build/modules/rules_cc/0.1.5/MODULE.bazel": "88dfc9361e8b5ae1008ac38f7cdfd45ad738e4fa676a3ad67d19204f045a1fd8", - "https://bcr.bazel.build/modules/rules_cc/0.2.0/MODULE.bazel": "b5c17f90458caae90d2ccd114c81970062946f49f355610ed89bebf954f5783c", - "https://bcr.bazel.build/modules/rules_cc/0.2.13/MODULE.bazel": "eecdd666eda6be16a8d9dc15e44b5c75133405e820f620a234acc4b1fdc5aa37", - "https://bcr.bazel.build/modules/rules_cc/0.2.14/MODULE.bazel": "353c99ed148887ee89c54a17d4100ae7e7e436593d104b668476019023b58df8", - "https://bcr.bazel.build/modules/rules_cc/0.2.14/source.json": "55d0a4587c5592fad350f6e698530f4faf0e7dd15e69d43f8d87e220c78bea54", - "https://bcr.bazel.build/modules/rules_cc/0.2.8/MODULE.bazel": "f1df20f0bf22c28192a794f29b501ee2018fa37a3862a1a2132ae2940a23a642", + "https://bcr.bazel.build/modules/rules_cc/0.1.1/source.json": "d61627377bd7dd1da4652063e368d9366fc9a73920bfa396798ad92172cf645c", "https://bcr.bazel.build/modules/rules_cuda/0.2.3/MODULE.bazel": "34f74fba6882781153461e62aded821ed3e5197f15e0f2b9b3eef76c9be0f44c", "https://bcr.bazel.build/modules/rules_cuda/0.2.3/source.json": "a2e128ec4699c65db24d9305215090d95bbd0cbb98e98058f82328f194a8ec68", "https://bcr.bazel.build/modules/rules_foreign_cc/0.10.1/MODULE.bazel": "b9527010e5fef060af92b6724edb3691970a5b1f76f74b21d39f7d433641be60", @@ -381,6 +354,7 @@ "https://bcr.bazel.build/modules/rules_foreign_cc/0.14.0/source.json": "64ccb6c4bff8afc336a24af2487b4557b8d2b13f981f2d8190983bc196b36a68", "https://bcr.bazel.build/modules/rules_foreign_cc/0.9.0/MODULE.bazel": "c9e8c682bf75b0e7c704166d79b599f93b72cfca5ad7477df596947891feeef6", "https://bcr.bazel.build/modules/rules_fuzzing/0.5.2/MODULE.bazel": "40c97d1144356f52905566c55811f13b299453a14ac7769dfba2ac38192337a8", + "https://bcr.bazel.build/modules/rules_fuzzing/0.5.2/source.json": "c8b1e2c717646f1702290959a3302a178fb639d987ab61d548105019f11e527e", "https://bcr.bazel.build/modules/rules_go/0.33.0/MODULE.bazel": "a2b11b64cd24bf94f57454f53288a5dacfe6cb86453eee7761b7637728c1910c", "https://bcr.bazel.build/modules/rules_go/0.38.1/MODULE.bazel": "fb8e73dd3b6fc4ff9d260ceacd830114891d49904f5bda1c16bc147bcc254f71", "https://bcr.bazel.build/modules/rules_go/0.39.1/MODULE.bazel": "d34fb2a249403a5f4339c754f1e63dc9e5ad70b47c5e97faee1441fc6636cd61", @@ -405,12 +379,11 @@ "https://bcr.bazel.build/modules/rules_java/7.3.2/MODULE.bazel": "50dece891cfdf1741ea230d001aa9c14398062f2b7c066470accace78e412bc2", "https://bcr.bazel.build/modules/rules_java/7.4.0/MODULE.bazel": "a592852f8a3dd539e82ee6542013bf2cadfc4c6946be8941e189d224500a8934", "https://bcr.bazel.build/modules/rules_java/7.6.1/MODULE.bazel": "2f14b7e8a1aa2f67ae92bc69d1ec0fa8d9f827c4e17ff5e5f02e91caa3b2d0fe", + "https://bcr.bazel.build/modules/rules_java/7.6.5/MODULE.bazel": "481164be5e02e4cab6e77a36927683263be56b7e36fef918b458d7a8a1ebadb1", "https://bcr.bazel.build/modules/rules_java/8.3.2/MODULE.bazel": "7336d5511ad5af0b8615fdc7477535a2e4e723a357b6713af439fe8cf0195017", "https://bcr.bazel.build/modules/rules_java/8.5.0/MODULE.bazel": "c081eda83625b6d97144f2da9dd5f074ecd56ba10f238257e7a90f56ee8a9c3c", "https://bcr.bazel.build/modules/rules_java/8.5.1/MODULE.bazel": "d8a9e38cc5228881f7055a6079f6f7821a073df3744d441978e7a43e20226939", - "https://bcr.bazel.build/modules/rules_java/8.6.1/MODULE.bazel": "f4808e2ab5b0197f094cabce9f4b006a27766beb6a9975931da07099560ca9c2", - "https://bcr.bazel.build/modules/rules_java/9.0.3/MODULE.bazel": "1f98ed015f7e744a745e0df6e898a7c5e83562d6b759dfd475c76456dda5ccea", - "https://bcr.bazel.build/modules/rules_java/9.0.3/source.json": "b038c0c07e12e658135bbc32cc1a2ded6e33785105c9d41958014c592de4593e", + "https://bcr.bazel.build/modules/rules_java/8.5.1/source.json": "db1a77d81b059e0f84985db67a22f3f579a529a86b7997605be3d214a0abe38e", "https://bcr.bazel.build/modules/rules_jvm_external/4.4.2/MODULE.bazel": "a56b85e418c83eb1839819f0b515c431010160383306d13ec21959ac412d2fe7", "https://bcr.bazel.build/modules/rules_jvm_external/5.1/MODULE.bazel": "33f6f999e03183f7d088c9be518a63467dfd0be94a11d0055fe2d210f89aa909", "https://bcr.bazel.build/modules/rules_jvm_external/5.2/MODULE.bazel": "d9351ba35217ad0de03816ef3ed63f89d411349353077348a45348b096615036", @@ -418,8 +391,7 @@ "https://bcr.bazel.build/modules/rules_jvm_external/6.0/MODULE.bazel": "37c93a5a78d32e895d52f86a8d0416176e915daabd029ccb5594db422e87c495", "https://bcr.bazel.build/modules/rules_jvm_external/6.1/MODULE.bazel": "75b5fec090dbd46cf9b7d8ea08cf84a0472d92ba3585b476f44c326eda8059c4", "https://bcr.bazel.build/modules/rules_jvm_external/6.3/MODULE.bazel": "c998e060b85f71e00de5ec552019347c8bca255062c990ac02d051bb80a38df0", - "https://bcr.bazel.build/modules/rules_jvm_external/6.7/MODULE.bazel": "e717beabc4d091ecb2c803c2d341b88590e9116b8bf7947915eeb33aab4f96dd", - "https://bcr.bazel.build/modules/rules_jvm_external/6.7/source.json": "5426f412d0a7fc6b611643376c7e4a82dec991491b9ce5cb1cfdd25fe2e92be4", + "https://bcr.bazel.build/modules/rules_jvm_external/6.3/source.json": "6f5f5a5a4419ae4e37c35a5bb0a6ae657ed40b7abc5a5189111b47fcebe43197", "https://bcr.bazel.build/modules/rules_kotlin/1.9.0/MODULE.bazel": "ef85697305025e5a61f395d4eaede272a5393cee479ace6686dba707de804d59", "https://bcr.bazel.build/modules/rules_kotlin/1.9.6/MODULE.bazel": "d269a01a18ee74d0335450b10f62c9ed81f2321d7958a2934e44272fe82dcef3", "https://bcr.bazel.build/modules/rules_kotlin/1.9.6/source.json": "2faa4794364282db7c06600b7e5e34867a564ae91bda7cae7c29c64e9466b7d5", @@ -440,8 +412,7 @@ "https://bcr.bazel.build/modules/rules_proto/6.0.0/MODULE.bazel": "b531d7f09f58dce456cd61b4579ce8c86b38544da75184eadaf0a7cb7966453f", "https://bcr.bazel.build/modules/rules_proto/6.0.2/MODULE.bazel": "ce916b775a62b90b61888052a416ccdda405212b6aaeb39522f7dc53431a5e73", "https://bcr.bazel.build/modules/rules_proto/7.0.2/MODULE.bazel": "bf81793bd6d2ad89a37a40693e56c61b0ee30f7a7fdbaf3eabbf5f39de47dea2", - "https://bcr.bazel.build/modules/rules_proto/7.1.0/MODULE.bazel": "002d62d9108f75bb807cd56245d45648f38275cb3a99dcd45dfb864c5d74cb96", - "https://bcr.bazel.build/modules/rules_proto/7.1.0/source.json": "39f89066c12c24097854e8f57ab8558929f9c8d474d34b2c00ac04630ad8940e", + "https://bcr.bazel.build/modules/rules_proto/7.0.2/source.json": "1e5e7260ae32ef4f2b52fd1d0de8d03b606a44c91b694d2f1afb1d3b28a48ce1", "https://bcr.bazel.build/modules/rules_proto_grpc/5.0.1/MODULE.bazel": "af7a76546e6fb5cfb37d30ece061bad276ceb785eb4ea43d6f74fc35cff71dfc", "https://bcr.bazel.build/modules/rules_proto_grpc/5.0.1/source.json": "eb2a5cd4344970803514e64bce3bb16840fe9476a4e9695d95c6e0475d821606", "https://bcr.bazel.build/modules/rules_proto_grpc_cpp/5.0.1/MODULE.bazel": "2bd7210df98e3690c7146b7679b1361a802eb01ec9431167ef5cafc641d9c94d", @@ -461,24 +432,17 @@ "https://bcr.bazel.build/modules/rules_python/0.4.0/MODULE.bazel": "9208ee05fd48bf09ac60ed269791cf17fb343db56c8226a720fbb1cdf467166c", "https://bcr.bazel.build/modules/rules_python/0.40.0/MODULE.bazel": "9d1a3cd88ed7d8e39583d9ffe56ae8a244f67783ae89b60caafc9f5cf318ada7", "https://bcr.bazel.build/modules/rules_python/1.1.0/MODULE.bazel": "57e01abae22956eb96d891572490d20e07d983e0c065de0b2170cafe5053e788", - "https://bcr.bazel.build/modules/rules_python/1.3.0/MODULE.bazel": "8361d57eafb67c09b75bf4bbe6be360e1b8f4f18118ab48037f2bd50aa2ccb13", - "https://bcr.bazel.build/modules/rules_python/1.4.1/MODULE.bazel": "8991ad45bdc25018301d6b7e1d3626afc3c8af8aaf4bc04f23d0b99c938b73a6", - "https://bcr.bazel.build/modules/rules_python/1.6.0/MODULE.bazel": "7e04ad8f8d5bea40451cf80b1bd8262552aa73f841415d20db96b7241bd027d8", - "https://bcr.bazel.build/modules/rules_python/1.7.0/MODULE.bazel": "d01f995ecd137abf30238ad9ce97f8fc3ac57289c8b24bd0bf53324d937a14f8", - "https://bcr.bazel.build/modules/rules_python/1.7.0/source.json": "028a084b65dcf8f4dc4f82f8778dbe65df133f234b316828a82e060d81bdce32", + "https://bcr.bazel.build/modules/rules_python/1.1.0/source.json": "29f1fdfd23a40808c622f813bc93e29c3aae277333f03293f667e76159750a0f", "https://bcr.bazel.build/modules/rules_rust/0.45.1/MODULE.bazel": "a69d0db3a958fab2c6520961e1b2287afcc8b36690fd31bbc4f6f7391397150d", "https://bcr.bazel.build/modules/rules_rust/0.53.0/MODULE.bazel": "00d5143caaa8d2caa7cc06f6c28e57510e76aa1eee0dfc9ba4914c1a2a5ac046", "https://bcr.bazel.build/modules/rules_rust/0.53.0/source.json": "084705abc2de9216e75a3d012993d3ea86999ecbc6e3f93fa9e986925343b513", "https://bcr.bazel.build/modules/rules_shell/0.2.0/MODULE.bazel": "fda8a652ab3c7d8fee214de05e7a9916d8b28082234e8d2c0094505c5268ed3c", "https://bcr.bazel.build/modules/rules_shell/0.3.0/MODULE.bazel": "de4402cd12f4cc8fda2354fce179fdb068c0b9ca1ec2d2b17b3e21b24c1a937b", - "https://bcr.bazel.build/modules/rules_shell/0.6.1/MODULE.bazel": "72e76b0eea4e81611ef5452aa82b3da34caca0c8b7b5c0c9584338aa93bae26b", - "https://bcr.bazel.build/modules/rules_shell/0.6.1/source.json": "20ec05cd5e592055e214b2da8ccb283c7f2a421ea0dc2acbf1aa792e11c03d0c", + "https://bcr.bazel.build/modules/rules_shell/0.3.0/source.json": "c55ed591aa5009401ddf80ded9762ac32c358d2517ee7820be981e2de9756cf3", "https://bcr.bazel.build/modules/rules_swift/1.16.0/MODULE.bazel": "4a09f199545a60d09895e8281362b1ff3bb08bbde69c6fc87aff5b92fcc916ca", "https://bcr.bazel.build/modules/rules_swift/1.18.0/MODULE.bazel": "a6aba73625d0dc64c7b4a1e831549b6e375fbddb9d2dde9d80c9de6ec45b24c9", "https://bcr.bazel.build/modules/rules_swift/2.1.1/MODULE.bazel": "494900a80f944fc7aa61500c2073d9729dff0b764f0e89b824eb746959bc1046", - "https://bcr.bazel.build/modules/rules_swift/2.4.0/MODULE.bazel": "1639617eb1ede28d774d967a738b4a68b0accb40650beadb57c21846beab5efd", - "https://bcr.bazel.build/modules/rules_swift/3.1.2/MODULE.bazel": "72c8f5cf9d26427cee6c76c8e3853eb46ce6b0412a081b2b6db6e8ad56267400", - "https://bcr.bazel.build/modules/rules_swift/3.1.2/source.json": "e85761f3098a6faf40b8187695e3de6d97944e98abd0d8ce579cb2daf6319a66", + "https://bcr.bazel.build/modules/rules_swift/2.1.1/source.json": "40fc69dfaac64deddbb75bd99cdac55f4427d9ca0afbe408576a65428427a186", "https://bcr.bazel.build/modules/snappy/1.1.8/MODULE.bazel": "46aa045007302f9f20392147893f27652f1f862b5bf2151f33ecf1d96ec311f7", "https://bcr.bazel.build/modules/snappy/1.2.1/MODULE.bazel": "ccfc05c2f321f33fa4190a57280f3b0b428982f7c66618f2acadf162fa0bbb95", "https://bcr.bazel.build/modules/snappy/1.2.1/source.json": "9a3e0181edc27543b4304f377a216ad09e014859db57921261552d0a4939ee1d", @@ -494,8 +458,7 @@ "https://bcr.bazel.build/modules/stardoc/0.7.2/MODULE.bazel": "fc152419aa2ea0f51c29583fab1e8c99ddefd5b3778421845606ee628629e0e5", "https://bcr.bazel.build/modules/stardoc/0.7.2/source.json": "58b029e5e901d6802967754adf0a9056747e8176f017cfe3607c0851f4d42216", "https://bcr.bazel.build/modules/swift_argument_parser/1.3.1.1/MODULE.bazel": "5e463fbfba7b1701d957555ed45097d7f984211330106ccd1352c6e0af0dcf91", - "https://bcr.bazel.build/modules/swift_argument_parser/1.3.1.2/MODULE.bazel": "75aab2373a4bbe2a1260b9bf2a1ebbdbf872d3bd36f80bff058dccd82e89422f", - "https://bcr.bazel.build/modules/swift_argument_parser/1.3.1.2/source.json": "5fba48bbe0ba48761f9e9f75f92876cafb5d07c0ce059cc7a8027416de94a05b", + "https://bcr.bazel.build/modules/swift_argument_parser/1.3.1.1/source.json": "32bd87e5f4d7acc57c5b2ff7c325ae3061d5e242c0c4c214ae87e0f1c13e54cb", "https://bcr.bazel.build/modules/toolchains_protoc/0.3.1/MODULE.bazel": "b6574a2a314cbd40cafb5ed87b03d1996e015315f80a7e33116c8b2e209cb5cf", "https://bcr.bazel.build/modules/toolchains_protoc/0.3.6/MODULE.bazel": "33add32ebda5f8167b3086585d0f7720086d24b764a06b99c02cf705889ae9bb", "https://bcr.bazel.build/modules/toolchains_protoc/0.3.6/source.json": "10276ae623c4f16fa3c35654e1949ef72bb5fa79ece3a8b93d05c4a6b1b25865", @@ -512,8 +475,7 @@ "https://bcr.bazel.build/modules/zlib/1.2.13/MODULE.bazel": "aa6deb1b83c18ffecd940c4119aff9567cd0a671d7bba756741cb2ef043a29d5", "https://bcr.bazel.build/modules/zlib/1.3.1.bcr.1/MODULE.bazel": "6a9fe6e3fc865715a7be9823ce694ceb01e364c35f7a846bf0d2b34762bc066b", "https://bcr.bazel.build/modules/zlib/1.3.1.bcr.3/MODULE.bazel": "af322bc08976524477c79d1e45e241b6efbeb918c497e8840b8ab116802dda79", - "https://bcr.bazel.build/modules/zlib/1.3.1.bcr.5/MODULE.bazel": "eec517b5bbe5492629466e11dae908d043364302283de25581e3eb944326c4ca", - "https://bcr.bazel.build/modules/zlib/1.3.1.bcr.5/source.json": "22bc55c47af97246cfc093d0acf683a7869377de362b5d1c552c2c2e16b7a806", + "https://bcr.bazel.build/modules/zlib/1.3.1.bcr.3/source.json": "2be409ac3c7601245958cd4fcdff4288be79ed23bd690b4b951f500d54ee6e7d", "https://bcr.bazel.build/modules/zlib/1.3.1/MODULE.bazel": "751c9940dcfe869f5f7274e1295422a34623555916eb98c174c1e945594bf198", "https://bcr.bazel.build/modules/zlib/1.3/MODULE.bazel": "6a9c02f19a24dcedb05572b2381446e27c272cd383aed11d41d99da9e3167a72", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/bazel_registry.json": "8a28e4aff06ee60aed2a8c281907fb8bcbf3b753c91fb5a5c57da3215d5b3497", @@ -529,16 +491,11 @@ "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/abseil-cpp/20240116.2/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/abseil-cpp/20240722.0.bcr.1/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/abseil-cpp/20240722.0/MODULE.bazel": "not found", - "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/abseil-cpp/20250127.1/MODULE.bazel": "not found", - "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/abseil-cpp/20250512.1/MODULE.bazel": "not found", - "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/abseil-cpp/20250814.1/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/apple_support/1.11.1/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/apple_support/1.13.0/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/apple_support/1.15.1/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/apple_support/1.17.1/MODULE.bazel": "not found", - "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/apple_support/1.21.0/MODULE.bazel": "not found", - "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/apple_support/1.21.1/MODULE.bazel": "not found", - "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/apple_support/1.24.2/MODULE.bazel": "not found", + "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/apple_support/1.5.0/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/arrow/14.0.2.bcr.1/MODULE.bazel": "0945ecdab89e7ebf9f12476909c8e17774edb923540c73a5d0472efd6ed2bbf1", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/arrow/14.0.2.bcr.1/source.json": "0bc16f5f464b746ae87bf70d12c00448b92728474a9bff6828d51aaf638e91f8", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/aspect_bazel_lib/1.31.2/MODULE.bazel": "not found", @@ -566,13 +523,8 @@ "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/bazel_features/1.19.0/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/bazel_features/1.20.0/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/bazel_features/1.21.0/MODULE.bazel": "not found", - "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/bazel_features/1.23.0/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/bazel_features/1.24.0/MODULE.bazel": "not found", - "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/bazel_features/1.27.0/MODULE.bazel": "not found", - "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/bazel_features/1.28.0/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/bazel_features/1.3.0/MODULE.bazel": "not found", - "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/bazel_features/1.30.0/MODULE.bazel": "not found", - "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/bazel_features/1.33.0/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/bazel_features/1.4.1/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/bazel_features/1.9.0/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/bazel_features/1.9.1/MODULE.bazel": "not found", @@ -588,8 +540,6 @@ "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/bazel_skylib/1.6.1/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/bazel_skylib/1.7.0/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/bazel_skylib/1.7.1/MODULE.bazel": "not found", - "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/bazel_skylib/1.8.1/MODULE.bazel": "not found", - "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/bazel_skylib/1.8.2/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/blake3/1.5.4/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/boost.algorithm/1.83.0.bcr.1/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/boost.array/1.83.0.bcr.1/MODULE.bazel": "not found", @@ -687,7 +637,7 @@ "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/brotli/1.1.0/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/brpc/1.11.0-20241212-282bc90/MODULE.bazel": "5a196ed0f1f129bde2001f3db5f1a991812714b207aa61ade34dcc78ec02a054", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/brpc/1.11.0-20241212-282bc90/source.json": "f6e42db7df330bf035a012fe56130ddd8e64bfacfbb007c3798ac417a9635665", - "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/buildozer/8.2.1/MODULE.bazel": "not found", + "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/buildozer/7.1.2/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/bzip2/1.0.8.bcr.2/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/c-ares/1.15.0/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/c-ares/1.16.1/MODULE.bazel": "not found", @@ -723,7 +673,6 @@ "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/googletest/1.14.0.bcr.1/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/googletest/1.14.0/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/googletest/1.15.2/MODULE.bazel": "not found", - "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/googletest/1.17.0/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/grpc-java/1.62.2/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/grpc-java/1.66.0/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/grpc-proto/0.0.0-20240627-ec30f58/MODULE.bazel": "not found", @@ -742,7 +691,6 @@ "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/ippcp/2021.8.bcr.2/MODULE.bazel": "34e4bf82778258a13393ecf7828fee728124c3d4c07941fed56f5fcafe73f04d", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/ippcp/2021.8.bcr.2/source.json": "4a4a758ddf4292e9af6f7c6b1cd014758982a54c2dd3c50fb1912ceec68a5b69", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/jsoncpp/1.9.5/MODULE.bazel": "not found", - "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/jsoncpp/1.9.6/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/kuscia/0.14.0b0/MODULE.bazel": "ca497d1769276104afd4df13c080db068a790e0e073a13ff5564520ea695f312", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/kuscia/0.14.0b0/source.json": "03e55f9cfeaef0339a5c5f0bda7ae1cbccad98203a9cfc28023af16d0db1b719", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/leveldb/1.23/MODULE.bazel": "450b5dafff03fd68d2c57544e0cdca1411e9cf42ae599e31fbbbfdf1ddea92b3", @@ -788,7 +736,6 @@ "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/platforms/0.0.7/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/platforms/0.0.8/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/platforms/0.0.9/MODULE.bazel": "not found", - "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/platforms/1.0.0/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/prometheus-cpp/1.2.4/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/prometheus-cpp/1.3.0/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/protobuf/21.7/MODULE.bazel": "not found", @@ -804,12 +751,9 @@ "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/protobuf/28.3/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/protobuf/29.0-rc2/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/protobuf/29.0-rc3/MODULE.bazel": "not found", - "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/protobuf/29.1/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/protobuf/3.19.0/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/protobuf/3.19.2/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/protobuf/3.19.6/MODULE.bazel": "not found", - "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/protobuf/32.1/MODULE.bazel": "not found", - "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/protobuf/33.4/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/protoc-gen-validate/1.0.4/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/pybind11_bazel/2.11.1/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/pybind11_bazel/2.12.0/MODULE.bazel": "not found", @@ -818,13 +762,10 @@ "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/re2/2021-09-01/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/re2/2023-09-01/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/re2/2024-05-01/MODULE.bazel": "not found", - "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/re2/2024-07-02.bcr.1/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/re2/2024-07-02/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_android/0.1.1/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_apple/3.13.0/MODULE.bazel": "not found", - "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_apple/3.16.0/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_apple/3.5.1/MODULE.bazel": "not found", - "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_apple/4.1.0/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_buf/0.1.1/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_cc/0.0.1/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_cc/0.0.10/MODULE.bazel": "not found", @@ -840,12 +781,6 @@ "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_cc/0.0.8/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_cc/0.0.9/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_cc/0.1.1/MODULE.bazel": "not found", - "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_cc/0.1.2/MODULE.bazel": "not found", - "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_cc/0.1.5/MODULE.bazel": "not found", - "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_cc/0.2.0/MODULE.bazel": "not found", - "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_cc/0.2.13/MODULE.bazel": "not found", - "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_cc/0.2.14/MODULE.bazel": "not found", - "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_cc/0.2.8/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_cuda/0.2.3/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_foreign_cc/0.10.1/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_foreign_cc/0.12.0/MODULE.bazel": "not found", @@ -875,11 +810,10 @@ "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_java/7.3.2/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_java/7.4.0/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_java/7.6.1/MODULE.bazel": "not found", + "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_java/7.6.5/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_java/8.3.2/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_java/8.5.0/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_java/8.5.1/MODULE.bazel": "not found", - "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_java/8.6.1/MODULE.bazel": "not found", - "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_java/9.0.3/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_jvm_external/4.4.2/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_jvm_external/5.1/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_jvm_external/5.2/MODULE.bazel": "not found", @@ -887,7 +821,6 @@ "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_jvm_external/6.0/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_jvm_external/6.1/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_jvm_external/6.3/MODULE.bazel": "not found", - "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_jvm_external/6.7/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_kotlin/1.9.0/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_kotlin/1.9.6/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_license/0.0.3/MODULE.bazel": "not found", @@ -904,7 +837,6 @@ "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_proto/6.0.0/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_proto/6.0.2/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_proto/7.0.2/MODULE.bazel": "not found", - "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_proto/7.1.0/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_proto_grpc/5.0.1/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_proto_grpc_cpp/5.0.1/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_python/0.10.2/MODULE.bazel": "not found", @@ -922,20 +854,13 @@ "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_python/0.4.0/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_python/0.40.0/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_python/1.1.0/MODULE.bazel": "not found", - "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_python/1.3.0/MODULE.bazel": "not found", - "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_python/1.4.1/MODULE.bazel": "not found", - "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_python/1.6.0/MODULE.bazel": "not found", - "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_python/1.7.0/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_rust/0.45.1/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_rust/0.53.0/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_shell/0.2.0/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_shell/0.3.0/MODULE.bazel": "not found", - "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_shell/0.6.1/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_swift/1.16.0/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_swift/1.18.0/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_swift/2.1.1/MODULE.bazel": "not found", - "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_swift/2.4.0/MODULE.bazel": "not found", - "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/rules_swift/3.1.2/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/seal/3.6.6/MODULE.bazel": "4304d0e7a29a1ce6d9a30c8d8a0b7bda723137969a418a01e9e5b440972d7e54", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/seal/4.1.1/MODULE.bazel": "aed9d12e7fd3140779228eaf700e7e1efe71e80594dd589f433a60f408e0fc08", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/seal/4.1.1/source.json": "783bcceef2a67354c537dcf24b51a4494445d7244c1a76943e916bacab5011ba", @@ -957,7 +882,6 @@ "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/stardoc/0.7.1/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/stardoc/0.7.2/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/swift_argument_parser/1.3.1.1/MODULE.bazel": "not found", - "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/swift_argument_parser/1.3.1.2/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/thrift/0.21.0/MODULE.bazel": "f157630e05b8183ad1d592ff3e7fb8cf534cc0fd99d86b0ebc98006a16aeb83a", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/thrift/0.21.0/source.json": "c80ef0d1672b469221b142bd338330d0f9c2077015c7e28b7e0018c42bdd1d6c", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/tongsuo/8.4.0/MODULE.bazel": "3dc48d7ed3ab2b713fe4b6466d0f99aa1991f8a0b654ef292c39ec7811b350d1", @@ -979,7 +903,6 @@ "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/zlib/1.2.13/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/zlib/1.3.1.bcr.1/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/zlib/1.3.1.bcr.3/MODULE.bazel": "not found", - "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/zlib/1.3.1.bcr.5/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/zlib/1.3.1/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/zlib/1.3/MODULE.bazel": "not found", "https://raw.githubusercontent.com/secretflow/bazel-registry/main/modules/zstd/1.5.6/MODULE.bazel": "b838bc765643a0b30bc0292173f514d61eea67a521f70579c1bc3856fd2a0b44", @@ -987,328 +910,429 @@ }, "selectedYankedVersions": {}, "moduleExtensions": { - "@@aspect_bazel_lib+//lib:extensions.bzl%toolchains": { + "@@apple_support~//crosstool:setup.bzl%apple_cc_configure_extension": { "general": { - "bzlTransitiveDigest": "TTIezBlspKf+C7ObNCRk34UzJh8iuPbdabNBviSufqU=", - "usagesDigest": "HyCD/AMcHKcynL86oRSbi4rhw9cjPb8yfXrC363gBKE=", - "recordedInputs": [ - "REPO_MAPPING:aspect_bazel_lib+,aspect_bazel_lib aspect_bazel_lib+", - "REPO_MAPPING:aspect_bazel_lib+,bazel_skylib bazel_skylib+", - "REPO_MAPPING:aspect_bazel_lib+,bazel_tools bazel_tools" - ], + "bzlTransitiveDigest": "7ii+gFxWSxHhQPrBxfMEHhtrGvHmBTvsh+KOyGunP/s=", + "usagesDigest": "UiAF9938di1gOhJwL28iBIAxs2tFSyv4b53rv5EZZpA=", + "recordedFileInputs": {}, + "recordedDirentsInputs": {}, + "envVariables": {}, + "generatedRepoSpecs": { + "local_config_apple_cc_toolchains": { + "bzlFile": "@@apple_support~//crosstool:setup.bzl", + "ruleClassName": "_apple_cc_autoconf_toolchains", + "attributes": {} + }, + "local_config_apple_cc": { + "bzlFile": "@@apple_support~//crosstool:setup.bzl", + "ruleClassName": "_apple_cc_autoconf", + "attributes": {} + } + }, + "recordedRepoMappingEntries": [ + [ + "apple_support~", + "bazel_tools", + "bazel_tools" + ] + ] + } + }, + "@@aspect_bazel_lib~//lib:extensions.bzl%toolchains": { + "general": { + "bzlTransitiveDigest": "wbW/fEUW6Ya4TMFK5PPIgAwWuJm4AQFeqnOO5DbiZjw=", + "usagesDigest": "2yV4A8xZ6FZbGGe74q8xCktC2QFZ9qOJZI8VbIbhxtE=", + "recordedFileInputs": {}, + "recordedDirentsInputs": {}, + "envVariables": {}, "generatedRepoSpecs": { "copy_directory_darwin_amd64": { - "repoRuleId": "@@aspect_bazel_lib+//lib/private:copy_directory_toolchain.bzl%copy_directory_platform_repo", + "bzlFile": "@@aspect_bazel_lib~//lib/private:copy_directory_toolchain.bzl", + "ruleClassName": "copy_directory_platform_repo", "attributes": { "platform": "darwin_amd64" } }, "copy_directory_darwin_arm64": { - "repoRuleId": "@@aspect_bazel_lib+//lib/private:copy_directory_toolchain.bzl%copy_directory_platform_repo", + "bzlFile": "@@aspect_bazel_lib~//lib/private:copy_directory_toolchain.bzl", + "ruleClassName": "copy_directory_platform_repo", "attributes": { "platform": "darwin_arm64" } }, "copy_directory_freebsd_amd64": { - "repoRuleId": "@@aspect_bazel_lib+//lib/private:copy_directory_toolchain.bzl%copy_directory_platform_repo", + "bzlFile": "@@aspect_bazel_lib~//lib/private:copy_directory_toolchain.bzl", + "ruleClassName": "copy_directory_platform_repo", "attributes": { "platform": "freebsd_amd64" } }, "copy_directory_linux_amd64": { - "repoRuleId": "@@aspect_bazel_lib+//lib/private:copy_directory_toolchain.bzl%copy_directory_platform_repo", + "bzlFile": "@@aspect_bazel_lib~//lib/private:copy_directory_toolchain.bzl", + "ruleClassName": "copy_directory_platform_repo", "attributes": { "platform": "linux_amd64" } }, "copy_directory_linux_arm64": { - "repoRuleId": "@@aspect_bazel_lib+//lib/private:copy_directory_toolchain.bzl%copy_directory_platform_repo", + "bzlFile": "@@aspect_bazel_lib~//lib/private:copy_directory_toolchain.bzl", + "ruleClassName": "copy_directory_platform_repo", "attributes": { "platform": "linux_arm64" } }, "copy_directory_windows_amd64": { - "repoRuleId": "@@aspect_bazel_lib+//lib/private:copy_directory_toolchain.bzl%copy_directory_platform_repo", + "bzlFile": "@@aspect_bazel_lib~//lib/private:copy_directory_toolchain.bzl", + "ruleClassName": "copy_directory_platform_repo", "attributes": { "platform": "windows_amd64" } }, "copy_directory_toolchains": { - "repoRuleId": "@@aspect_bazel_lib+//lib/private:copy_directory_toolchain.bzl%copy_directory_toolchains_repo", + "bzlFile": "@@aspect_bazel_lib~//lib/private:copy_directory_toolchain.bzl", + "ruleClassName": "copy_directory_toolchains_repo", "attributes": { "user_repository_name": "copy_directory" } }, "copy_to_directory_darwin_amd64": { - "repoRuleId": "@@aspect_bazel_lib+//lib/private:copy_to_directory_toolchain.bzl%copy_to_directory_platform_repo", + "bzlFile": "@@aspect_bazel_lib~//lib/private:copy_to_directory_toolchain.bzl", + "ruleClassName": "copy_to_directory_platform_repo", "attributes": { "platform": "darwin_amd64" } }, "copy_to_directory_darwin_arm64": { - "repoRuleId": "@@aspect_bazel_lib+//lib/private:copy_to_directory_toolchain.bzl%copy_to_directory_platform_repo", + "bzlFile": "@@aspect_bazel_lib~//lib/private:copy_to_directory_toolchain.bzl", + "ruleClassName": "copy_to_directory_platform_repo", "attributes": { "platform": "darwin_arm64" } }, "copy_to_directory_freebsd_amd64": { - "repoRuleId": "@@aspect_bazel_lib+//lib/private:copy_to_directory_toolchain.bzl%copy_to_directory_platform_repo", + "bzlFile": "@@aspect_bazel_lib~//lib/private:copy_to_directory_toolchain.bzl", + "ruleClassName": "copy_to_directory_platform_repo", "attributes": { "platform": "freebsd_amd64" } }, "copy_to_directory_linux_amd64": { - "repoRuleId": "@@aspect_bazel_lib+//lib/private:copy_to_directory_toolchain.bzl%copy_to_directory_platform_repo", + "bzlFile": "@@aspect_bazel_lib~//lib/private:copy_to_directory_toolchain.bzl", + "ruleClassName": "copy_to_directory_platform_repo", "attributes": { "platform": "linux_amd64" } }, "copy_to_directory_linux_arm64": { - "repoRuleId": "@@aspect_bazel_lib+//lib/private:copy_to_directory_toolchain.bzl%copy_to_directory_platform_repo", + "bzlFile": "@@aspect_bazel_lib~//lib/private:copy_to_directory_toolchain.bzl", + "ruleClassName": "copy_to_directory_platform_repo", "attributes": { "platform": "linux_arm64" } }, "copy_to_directory_windows_amd64": { - "repoRuleId": "@@aspect_bazel_lib+//lib/private:copy_to_directory_toolchain.bzl%copy_to_directory_platform_repo", + "bzlFile": "@@aspect_bazel_lib~//lib/private:copy_to_directory_toolchain.bzl", + "ruleClassName": "copy_to_directory_platform_repo", "attributes": { "platform": "windows_amd64" } }, "copy_to_directory_toolchains": { - "repoRuleId": "@@aspect_bazel_lib+//lib/private:copy_to_directory_toolchain.bzl%copy_to_directory_toolchains_repo", + "bzlFile": "@@aspect_bazel_lib~//lib/private:copy_to_directory_toolchain.bzl", + "ruleClassName": "copy_to_directory_toolchains_repo", "attributes": { "user_repository_name": "copy_to_directory" } }, "jq_darwin_amd64": { - "repoRuleId": "@@aspect_bazel_lib+//lib/private:jq_toolchain.bzl%jq_platform_repo", + "bzlFile": "@@aspect_bazel_lib~//lib/private:jq_toolchain.bzl", + "ruleClassName": "jq_platform_repo", "attributes": { "platform": "darwin_amd64", "version": "1.6" } }, "jq_darwin_arm64": { - "repoRuleId": "@@aspect_bazel_lib+//lib/private:jq_toolchain.bzl%jq_platform_repo", + "bzlFile": "@@aspect_bazel_lib~//lib/private:jq_toolchain.bzl", + "ruleClassName": "jq_platform_repo", "attributes": { "platform": "darwin_arm64", "version": "1.6" } }, "jq_linux_amd64": { - "repoRuleId": "@@aspect_bazel_lib+//lib/private:jq_toolchain.bzl%jq_platform_repo", + "bzlFile": "@@aspect_bazel_lib~//lib/private:jq_toolchain.bzl", + "ruleClassName": "jq_platform_repo", "attributes": { "platform": "linux_amd64", "version": "1.6" } }, "jq_windows_amd64": { - "repoRuleId": "@@aspect_bazel_lib+//lib/private:jq_toolchain.bzl%jq_platform_repo", + "bzlFile": "@@aspect_bazel_lib~//lib/private:jq_toolchain.bzl", + "ruleClassName": "jq_platform_repo", "attributes": { "platform": "windows_amd64", "version": "1.6" } }, "jq": { - "repoRuleId": "@@aspect_bazel_lib+//lib/private:jq_toolchain.bzl%jq_host_alias_repo", + "bzlFile": "@@aspect_bazel_lib~//lib/private:jq_toolchain.bzl", + "ruleClassName": "jq_host_alias_repo", "attributes": {} }, "jq_toolchains": { - "repoRuleId": "@@aspect_bazel_lib+//lib/private:jq_toolchain.bzl%jq_toolchains_repo", + "bzlFile": "@@aspect_bazel_lib~//lib/private:jq_toolchain.bzl", + "ruleClassName": "jq_toolchains_repo", "attributes": { "user_repository_name": "jq" } }, "yq_darwin_amd64": { - "repoRuleId": "@@aspect_bazel_lib+//lib/private:yq_toolchain.bzl%yq_platform_repo", + "bzlFile": "@@aspect_bazel_lib~//lib/private:yq_toolchain.bzl", + "ruleClassName": "yq_platform_repo", "attributes": { "platform": "darwin_amd64", "version": "4.25.2" } }, "yq_darwin_arm64": { - "repoRuleId": "@@aspect_bazel_lib+//lib/private:yq_toolchain.bzl%yq_platform_repo", + "bzlFile": "@@aspect_bazel_lib~//lib/private:yq_toolchain.bzl", + "ruleClassName": "yq_platform_repo", "attributes": { "platform": "darwin_arm64", "version": "4.25.2" } }, "yq_linux_amd64": { - "repoRuleId": "@@aspect_bazel_lib+//lib/private:yq_toolchain.bzl%yq_platform_repo", + "bzlFile": "@@aspect_bazel_lib~//lib/private:yq_toolchain.bzl", + "ruleClassName": "yq_platform_repo", "attributes": { "platform": "linux_amd64", "version": "4.25.2" } }, "yq_linux_arm64": { - "repoRuleId": "@@aspect_bazel_lib+//lib/private:yq_toolchain.bzl%yq_platform_repo", + "bzlFile": "@@aspect_bazel_lib~//lib/private:yq_toolchain.bzl", + "ruleClassName": "yq_platform_repo", "attributes": { "platform": "linux_arm64", "version": "4.25.2" } }, "yq_linux_s390x": { - "repoRuleId": "@@aspect_bazel_lib+//lib/private:yq_toolchain.bzl%yq_platform_repo", + "bzlFile": "@@aspect_bazel_lib~//lib/private:yq_toolchain.bzl", + "ruleClassName": "yq_platform_repo", "attributes": { "platform": "linux_s390x", "version": "4.25.2" } }, "yq_linux_ppc64le": { - "repoRuleId": "@@aspect_bazel_lib+//lib/private:yq_toolchain.bzl%yq_platform_repo", + "bzlFile": "@@aspect_bazel_lib~//lib/private:yq_toolchain.bzl", + "ruleClassName": "yq_platform_repo", "attributes": { "platform": "linux_ppc64le", "version": "4.25.2" } }, "yq_windows_amd64": { - "repoRuleId": "@@aspect_bazel_lib+//lib/private:yq_toolchain.bzl%yq_platform_repo", + "bzlFile": "@@aspect_bazel_lib~//lib/private:yq_toolchain.bzl", + "ruleClassName": "yq_platform_repo", "attributes": { "platform": "windows_amd64", "version": "4.25.2" } }, "yq": { - "repoRuleId": "@@aspect_bazel_lib+//lib/private:yq_toolchain.bzl%yq_host_alias_repo", + "bzlFile": "@@aspect_bazel_lib~//lib/private:yq_toolchain.bzl", + "ruleClassName": "yq_host_alias_repo", "attributes": {} }, "yq_toolchains": { - "repoRuleId": "@@aspect_bazel_lib+//lib/private:yq_toolchain.bzl%yq_toolchains_repo", + "bzlFile": "@@aspect_bazel_lib~//lib/private:yq_toolchain.bzl", + "ruleClassName": "yq_toolchains_repo", "attributes": { "user_repository_name": "yq" } }, "coreutils_darwin_amd64": { - "repoRuleId": "@@aspect_bazel_lib+//lib/private:coreutils_toolchain.bzl%coreutils_platform_repo", + "bzlFile": "@@aspect_bazel_lib~//lib/private:coreutils_toolchain.bzl", + "ruleClassName": "coreutils_platform_repo", "attributes": { "platform": "darwin_amd64", "version": "0.0.16" } }, "coreutils_darwin_arm64": { - "repoRuleId": "@@aspect_bazel_lib+//lib/private:coreutils_toolchain.bzl%coreutils_platform_repo", + "bzlFile": "@@aspect_bazel_lib~//lib/private:coreutils_toolchain.bzl", + "ruleClassName": "coreutils_platform_repo", "attributes": { "platform": "darwin_arm64", "version": "0.0.16" } }, "coreutils_linux_amd64": { - "repoRuleId": "@@aspect_bazel_lib+//lib/private:coreutils_toolchain.bzl%coreutils_platform_repo", + "bzlFile": "@@aspect_bazel_lib~//lib/private:coreutils_toolchain.bzl", + "ruleClassName": "coreutils_platform_repo", "attributes": { "platform": "linux_amd64", "version": "0.0.16" } }, "coreutils_linux_arm64": { - "repoRuleId": "@@aspect_bazel_lib+//lib/private:coreutils_toolchain.bzl%coreutils_platform_repo", + "bzlFile": "@@aspect_bazel_lib~//lib/private:coreutils_toolchain.bzl", + "ruleClassName": "coreutils_platform_repo", "attributes": { "platform": "linux_arm64", "version": "0.0.16" } }, "coreutils_windows_amd64": { - "repoRuleId": "@@aspect_bazel_lib+//lib/private:coreutils_toolchain.bzl%coreutils_platform_repo", + "bzlFile": "@@aspect_bazel_lib~//lib/private:coreutils_toolchain.bzl", + "ruleClassName": "coreutils_platform_repo", "attributes": { "platform": "windows_amd64", "version": "0.0.16" } }, "coreutils_toolchains": { - "repoRuleId": "@@aspect_bazel_lib+//lib/private:coreutils_toolchain.bzl%coreutils_toolchains_repo", + "bzlFile": "@@aspect_bazel_lib~//lib/private:coreutils_toolchain.bzl", + "ruleClassName": "coreutils_toolchains_repo", "attributes": { "user_repository_name": "coreutils" } }, "expand_template_darwin_amd64": { - "repoRuleId": "@@aspect_bazel_lib+//lib/private:expand_template_toolchain.bzl%expand_template_platform_repo", + "bzlFile": "@@aspect_bazel_lib~//lib/private:expand_template_toolchain.bzl", + "ruleClassName": "expand_template_platform_repo", "attributes": { "platform": "darwin_amd64" } }, "expand_template_darwin_arm64": { - "repoRuleId": "@@aspect_bazel_lib+//lib/private:expand_template_toolchain.bzl%expand_template_platform_repo", + "bzlFile": "@@aspect_bazel_lib~//lib/private:expand_template_toolchain.bzl", + "ruleClassName": "expand_template_platform_repo", "attributes": { "platform": "darwin_arm64" } }, "expand_template_freebsd_amd64": { - "repoRuleId": "@@aspect_bazel_lib+//lib/private:expand_template_toolchain.bzl%expand_template_platform_repo", + "bzlFile": "@@aspect_bazel_lib~//lib/private:expand_template_toolchain.bzl", + "ruleClassName": "expand_template_platform_repo", "attributes": { "platform": "freebsd_amd64" } }, "expand_template_linux_amd64": { - "repoRuleId": "@@aspect_bazel_lib+//lib/private:expand_template_toolchain.bzl%expand_template_platform_repo", + "bzlFile": "@@aspect_bazel_lib~//lib/private:expand_template_toolchain.bzl", + "ruleClassName": "expand_template_platform_repo", "attributes": { "platform": "linux_amd64" } }, "expand_template_linux_arm64": { - "repoRuleId": "@@aspect_bazel_lib+//lib/private:expand_template_toolchain.bzl%expand_template_platform_repo", + "bzlFile": "@@aspect_bazel_lib~//lib/private:expand_template_toolchain.bzl", + "ruleClassName": "expand_template_platform_repo", "attributes": { "platform": "linux_arm64" } }, "expand_template_windows_amd64": { - "repoRuleId": "@@aspect_bazel_lib+//lib/private:expand_template_toolchain.bzl%expand_template_platform_repo", + "bzlFile": "@@aspect_bazel_lib~//lib/private:expand_template_toolchain.bzl", + "ruleClassName": "expand_template_platform_repo", "attributes": { "platform": "windows_amd64" } }, "expand_template_toolchains": { - "repoRuleId": "@@aspect_bazel_lib+//lib/private:expand_template_toolchain.bzl%expand_template_toolchains_repo", + "bzlFile": "@@aspect_bazel_lib~//lib/private:expand_template_toolchain.bzl", + "ruleClassName": "expand_template_toolchains_repo", "attributes": { "user_repository_name": "expand_template" } } - } + }, + "recordedRepoMappingEntries": [ + [ + "aspect_bazel_lib~", + "aspect_bazel_lib", + "aspect_bazel_lib~" + ], + [ + "aspect_bazel_lib~", + "bazel_skylib", + "bazel_skylib~" + ], + [ + "aspect_bazel_lib~", + "bazel_tools", + "bazel_tools" + ] + ] } }, - "@@rules_buf+//buf:extensions.bzl%ext": { + "@@rules_buf~//buf:extensions.bzl%ext": { "general": { - "bzlTransitiveDigest": "jPVNXOmzZswjd7FZCQk0mOXkvt6/dS9OuJa4wwbDE5M=", - "usagesDigest": "RTc2BMQ2b0wGU8CRvN3EoPz34m3LMe+K/oSkFkN83+M=", - "recordedInputs": [ - "REPO_MAPPING:rules_buf+,bazel_tools bazel_tools" - ], + "bzlTransitiveDigest": "gmPmM7QT5Jez2VVFcwbbMf/QWSRag+nJ1elFJFFTcn0=", + "usagesDigest": "1E3NeLCRI6VyKiersXVtONCbNopc5jIVqoHBOpcWb0A=", + "recordedFileInputs": {}, + "recordedDirentsInputs": {}, + "envVariables": {}, "generatedRepoSpecs": { "rules_buf_toolchains": { - "repoRuleId": "@@rules_buf+//buf/internal:toolchain.bzl%buf_download_releases", + "bzlFile": "@@rules_buf~//buf/internal:toolchain.bzl", + "ruleClassName": "buf_download_releases", "attributes": { "version": "v1.27.0" } } - } + }, + "recordedRepoMappingEntries": [ + [ + "rules_buf~", + "bazel_tools", + "bazel_tools" + ] + ] } }, - "@@rules_cuda+//cuda:extensions.bzl%toolchain": { + "@@rules_cuda~//cuda:extensions.bzl%toolchain": { "general": { - "bzlTransitiveDigest": "ZQkRQ5xMl085Tw1GvBO2R7cmlxjV6FAJG0Az8ZPsKsk=", - "usagesDigest": "OBowg8qCb7GfXoSd0Hl98pvfIWaorf8BdjkUOM4Lb7w=", - "recordedInputs": [ - "REPO_MAPPING:rules_cuda+,bazel_tools bazel_tools" - ], + "bzlTransitiveDigest": "BnYM6/SSxkN/7InBOUBKIuviq2l1hk6LC7EDB59vI80=", + "usagesDigest": "EAEeKc1m5Va0f+woRsvfF/se9J527ZmyBMMyJIiwjxs=", + "recordedFileInputs": {}, + "recordedDirentsInputs": {}, + "envVariables": {}, "generatedRepoSpecs": { "local_cuda": { - "repoRuleId": "@@rules_cuda+//cuda/private:repositories.bzl%local_cuda", + "bzlFile": "@@rules_cuda~//cuda/private:repositories.bzl", + "ruleClassName": "local_cuda", "attributes": { "toolkit_path": "" } } - } + }, + "recordedRepoMappingEntries": [ + [ + "rules_cuda~", + "bazel_tools", + "bazel_tools" + ] + ] } }, - "@@rules_foreign_cc+//foreign_cc:extensions.bzl%tools": { + "@@rules_foreign_cc~//foreign_cc:extensions.bzl%tools": { "general": { - "bzlTransitiveDigest": "dWWiLQWKST2+NU4SkbVS2OhS6KgYdZ4jBI5MBsDEBt0=", - "usagesDigest": "Eyh4mAOi6L+Nn/lY/wQBJclQrmBnWdQM+B4lZeq6azA=", - "recordedInputs": [ - "REPO_MAPPING:rules_foreign_cc+,bazel_tools bazel_tools", - "REPO_MAPPING:rules_foreign_cc+,rules_foreign_cc rules_foreign_cc+" - ], + "bzlTransitiveDigest": "xXsVxU9RFlxF0FwwZymap5U/lRd3z9Hlcys4Tq+b+Bo=", + "usagesDigest": "SGA58zMG01aPzmHLVqPyMo79785P3+nsw3FlBXZ/2vg=", + "recordedFileInputs": {}, + "recordedDirentsInputs": {}, + "envVariables": {}, "generatedRepoSpecs": { "rules_foreign_cc_framework_toolchain_linux": { - "repoRuleId": "@@rules_foreign_cc+//foreign_cc/private/framework:toolchain.bzl%framework_toolchain_repository", + "bzlFile": "@@rules_foreign_cc~//foreign_cc/private/framework:toolchain.bzl", + "ruleClassName": "framework_toolchain_repository", "attributes": { "commands_src": "@rules_foreign_cc//foreign_cc/private/framework/toolchains:linux_commands.bzl", "exec_compatible_with": [ @@ -1317,7 +1341,8 @@ } }, "rules_foreign_cc_framework_toolchain_freebsd": { - "repoRuleId": "@@rules_foreign_cc+//foreign_cc/private/framework:toolchain.bzl%framework_toolchain_repository", + "bzlFile": "@@rules_foreign_cc~//foreign_cc/private/framework:toolchain.bzl", + "ruleClassName": "framework_toolchain_repository", "attributes": { "commands_src": "@rules_foreign_cc//foreign_cc/private/framework/toolchains:freebsd_commands.bzl", "exec_compatible_with": [ @@ -1326,7 +1351,8 @@ } }, "rules_foreign_cc_framework_toolchain_windows": { - "repoRuleId": "@@rules_foreign_cc+//foreign_cc/private/framework:toolchain.bzl%framework_toolchain_repository", + "bzlFile": "@@rules_foreign_cc~//foreign_cc/private/framework:toolchain.bzl", + "ruleClassName": "framework_toolchain_repository", "attributes": { "commands_src": "@rules_foreign_cc//foreign_cc/private/framework/toolchains:windows_commands.bzl", "exec_compatible_with": [ @@ -1335,7 +1361,8 @@ } }, "rules_foreign_cc_framework_toolchain_macos": { - "repoRuleId": "@@rules_foreign_cc+//foreign_cc/private/framework:toolchain.bzl%framework_toolchain_repository", + "bzlFile": "@@rules_foreign_cc~//foreign_cc/private/framework:toolchain.bzl", + "ruleClassName": "framework_toolchain_repository", "attributes": { "commands_src": "@rules_foreign_cc//foreign_cc/private/framework/toolchains:macos_commands.bzl", "exec_compatible_with": [ @@ -1344,11 +1371,13 @@ } }, "rules_foreign_cc_framework_toolchains": { - "repoRuleId": "@@rules_foreign_cc+//foreign_cc/private/framework:toolchain.bzl%framework_toolchain_repository_hub", + "bzlFile": "@@rules_foreign_cc~//foreign_cc/private/framework:toolchain.bzl", + "ruleClassName": "framework_toolchain_repository_hub", "attributes": {} }, "cmake_src": { - "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", "attributes": { "build_file_content": "filegroup(\n name = \"all_srcs\",\n srcs = glob([\"**\"]),\n visibility = [\"//visibility:public\"],\n)\n", "sha256": "f316b40053466f9a416adf981efda41b160ca859e97f6a484b447ea299ff26aa", @@ -1357,12 +1386,13 @@ "https://github.com/Kitware/CMake/releases/download/v3.23.2/cmake-3.23.2.tar.gz" ], "patches": [ - "@@rules_foreign_cc+//toolchains/patches:cmake-c++11.patch" + "@@rules_foreign_cc~//toolchains/patches:cmake-c++11.patch" ] } }, "gnumake_src": { - "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", "attributes": { "build_file_content": "filegroup(\n name = \"all_srcs\",\n srcs = glob([\"**\"]),\n visibility = [\"//visibility:public\"],\n)\n", "sha256": "dd16fb1d67bfab79a72f5e8390735c49e3e8e70b4945a15ab1f81ddb78658fb3", @@ -1374,7 +1404,8 @@ } }, "ninja_build_src": { - "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", "attributes": { "build_file_content": "filegroup(\n name = \"all_srcs\",\n srcs = glob([\"**\"]),\n visibility = [\"//visibility:public\"],\n)\n", "integrity": "sha256-ghvf9Io/aDvEuztvC1/nstZHz2XVKutjMoyRpsbfKFo=", @@ -1386,7 +1417,8 @@ } }, "meson_src": { - "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", "attributes": { "build_file_content": "exports_files([\"meson.py\"])\n\nfilegroup(\n name = \"runtime\",\n # NOTE: excluding __pycache__ is important to avoid rebuilding due to pyc\n # files, see https://github.com/bazel-contrib/rules_foreign_cc/issues/1342\n srcs = glob([\"mesonbuild/**\"], exclude = [\"**/__pycache__/*\"]),\n visibility = [\"//visibility:public\"],\n)\n", "sha256": "567e533adf255de73a2de35049b99923caf872a455af9ce03e01077e0d384bed", @@ -1398,7 +1430,8 @@ } }, "glib_dev": { - "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", "attributes": { "build_file_content": "\ncc_import(\n name = \"glib_dev\",\n hdrs = glob([\"include/**\"]),\n shared_library = \"@glib_runtime//:bin/libglib-2.0-0.dll\",\n visibility = [\"//visibility:public\"],\n)\n ", "sha256": "bdf18506df304d38be98a4b3f18055b8b8cca81beabecad0eece6ce95319c369", @@ -1409,7 +1442,8 @@ } }, "glib_src": { - "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", "attributes": { "build_file_content": "\ncc_import(\n name = \"msvc_hdr\",\n hdrs = [\"msvc_recommended_pragmas.h\"],\n visibility = [\"//visibility:public\"],\n)\n ", "sha256": "bc96f63112823b7d6c9f06572d2ad626ddac7eb452c04d762592197f6e07898e", @@ -1421,7 +1455,8 @@ } }, "glib_runtime": { - "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", "attributes": { "build_file_content": "\nexports_files(\n [\n \"bin/libgio-2.0-0.dll\",\n \"bin/libglib-2.0-0.dll\",\n \"bin/libgmodule-2.0-0.dll\",\n \"bin/libgobject-2.0-0.dll\",\n \"bin/libgthread-2.0-0.dll\",\n ],\n visibility = [\"//visibility:public\"],\n)\n ", "sha256": "88d857087e86f16a9be651ee7021880b3f7ba050d34a1ed9f06113b8799cb973", @@ -1432,7 +1467,8 @@ } }, "gettext_runtime": { - "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", "attributes": { "build_file_content": "\ncc_import(\n name = \"gettext_runtime\",\n shared_library = \"bin/libintl-8.dll\",\n visibility = [\"//visibility:public\"],\n)\n ", "sha256": "1f4269c0e021076d60a54e98da6f978a3195013f6de21674ba0edbc339c5b079", @@ -1443,15 +1479,16 @@ } }, "pkgconfig_src": { - "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", "attributes": { "build_file_content": "filegroup(\n name = \"all_srcs\",\n srcs = glob([\"**\"]),\n visibility = [\"//visibility:public\"],\n)\n", "sha256": "6fc69c01688c9458a57eb9a1664c9aba372ccda420a02bf4429fe610e7e7d591", "strip_prefix": "pkg-config-0.29.2", "patches": [ - "@@rules_foreign_cc+//toolchains/patches:pkgconfig-detectenv.patch", - "@@rules_foreign_cc+//toolchains/patches:pkgconfig-makefile-vc.patch", - "@@rules_foreign_cc+//toolchains/patches:pkgconfig-builtin-glib-int-conversion.patch" + "@@rules_foreign_cc~//toolchains/patches:pkgconfig-detectenv.patch", + "@@rules_foreign_cc~//toolchains/patches:pkgconfig-makefile-vc.patch", + "@@rules_foreign_cc~//toolchains/patches:pkgconfig-builtin-glib-int-conversion.patch" ], "urls": [ "https://pkgconfig.freedesktop.org/releases/pkg-config-0.29.2.tar.gz", @@ -1460,7 +1497,8 @@ } }, "bazel_features": { - "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", "attributes": { "sha256": "ba1282c1aa1d1fffdcf994ab32131d7c7551a9bc960fbf05f42d55a1b930cbfb", "strip_prefix": "bazel_features-1.15.0", @@ -1468,7 +1506,8 @@ } }, "bazel_skylib": { - "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", "attributes": { "sha256": "bc283cdfcd526a52c3201279cda4bc298652efa898b10b4db0837dc51652756f", "urls": [ @@ -1478,7 +1517,8 @@ } }, "rules_cc": { - "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", "attributes": { "urls": [ "https://github.com/bazelbuild/rules_cc/releases/download/0.0.17/rules_cc-0.0.17.tar.gz" @@ -1488,7 +1528,8 @@ } }, "rules_python": { - "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", "attributes": { "sha256": "0a158f883fc494724f25e2ce6a5c3d31fd52163a92d4b7180aef0ff9a0622f70", "strip_prefix": "rules_python-1.1.0-rc0", @@ -1496,7 +1537,8 @@ } }, "rules_shell": { - "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", "attributes": { "sha256": "d8cd4a3a91fc1dc68d4c7d6b655f09def109f7186437e3f50a9b60ab436a0c53", "strip_prefix": "rules_shell-0.3.0", @@ -1504,7 +1546,8 @@ } }, "cmake-3.23.2-linux-aarch64": { - "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", "attributes": { "urls": [ "https://github.com/Kitware/CMake/releases/download/v3.23.2/cmake-3.23.2-linux-aarch64.tar.gz" @@ -1515,7 +1558,8 @@ } }, "cmake-3.23.2-linux-x86_64": { - "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", "attributes": { "urls": [ "https://github.com/Kitware/CMake/releases/download/v3.23.2/cmake-3.23.2-linux-x86_64.tar.gz" @@ -1526,7 +1570,8 @@ } }, "cmake-3.23.2-macos-universal": { - "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", "attributes": { "urls": [ "https://github.com/Kitware/CMake/releases/download/v3.23.2/cmake-3.23.2-macos-universal.tar.gz" @@ -1537,7 +1582,8 @@ } }, "cmake-3.23.2-windows-i386": { - "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", "attributes": { "urls": [ "https://github.com/Kitware/CMake/releases/download/v3.23.2/cmake-3.23.2-windows-i386.zip" @@ -1548,7 +1594,8 @@ } }, "cmake-3.23.2-windows-x86_64": { - "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", "attributes": { "urls": [ "https://github.com/Kitware/CMake/releases/download/v3.23.2/cmake-3.23.2-windows-x86_64.zip" @@ -1559,7 +1606,8 @@ } }, "cmake_3.23.2_toolchains": { - "repoRuleId": "@@rules_foreign_cc+//toolchains:prebuilt_toolchains_repository.bzl%prebuilt_toolchains_repository", + "bzlFile": "@@rules_foreign_cc~//toolchains:prebuilt_toolchains_repository.bzl", + "ruleClassName": "prebuilt_toolchains_repository", "attributes": { "repos": { "cmake-3.23.2-linux-aarch64": [ @@ -1586,7 +1634,8 @@ } }, "ninja_1.12.1_linux": { - "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", "attributes": { "urls": [ "https://github.com/ninja-build/ninja/releases/download/v1.12.1/ninja-linux.zip" @@ -1597,7 +1646,8 @@ } }, "ninja_1.12.1_linux-aarch64": { - "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", "attributes": { "urls": [ "https://github.com/ninja-build/ninja/releases/download/v1.12.1/ninja-linux-aarch64.zip" @@ -1608,7 +1658,8 @@ } }, "ninja_1.12.1_mac": { - "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", "attributes": { "urls": [ "https://github.com/ninja-build/ninja/releases/download/v1.12.1/ninja-mac.zip" @@ -1619,7 +1670,8 @@ } }, "ninja_1.12.1_mac_aarch64": { - "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", "attributes": { "urls": [ "https://github.com/ninja-build/ninja/releases/download/v1.12.1/ninja-mac.zip" @@ -1630,7 +1682,8 @@ } }, "ninja_1.12.1_win": { - "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", "attributes": { "urls": [ "https://github.com/ninja-build/ninja/releases/download/v1.12.1/ninja-win.zip" @@ -1641,7 +1694,8 @@ } }, "ninja_1.12.1_toolchains": { - "repoRuleId": "@@rules_foreign_cc+//toolchains:prebuilt_toolchains_repository.bzl%prebuilt_toolchains_repository", + "bzlFile": "@@rules_foreign_cc~//toolchains:prebuilt_toolchains_repository.bzl", + "ruleClassName": "prebuilt_toolchains_repository", "attributes": { "repos": { "ninja_1.12.1_linux": [ @@ -1668,19 +1722,55 @@ "tool": "ninja" } } - } + }, + "recordedRepoMappingEntries": [ + [ + "rules_foreign_cc~", + "bazel_tools", + "bazel_tools" + ], + [ + "rules_foreign_cc~", + "rules_foreign_cc", + "rules_foreign_cc~" + ] + ] } }, - "@@rules_kotlin+//src/main/starlark/core/repositories:bzlmod_setup.bzl%rules_kotlin_extensions": { + "@@rules_java~//java:rules_java_deps.bzl%compatibility_proxy": { "general": { - "bzlTransitiveDigest": "ABI1D/sbS1ovwaW/kHDoj8nnXjQ0oKU9fzmzEG4iT8o=", - "usagesDigest": "QI2z8ZUR+mqtbwsf2fLqYdJAkPOHdOV+tF2yVAUgRzw=", - "recordedInputs": [ - "REPO_MAPPING:rules_kotlin+,bazel_tools bazel_tools" - ], + "bzlTransitiveDigest": "KIX40nDfygEWbU+rq3nYpt3tVgTK/iO8PKh5VMBlN7M=", + "usagesDigest": "pwHZ+26iLgQdwvdZeA5wnAjKnNI3y6XO2VbhOTeo5h8=", + "recordedFileInputs": {}, + "recordedDirentsInputs": {}, + "envVariables": {}, + "generatedRepoSpecs": { + "compatibility_proxy": { + "bzlFile": "@@rules_java~//java:rules_java_deps.bzl", + "ruleClassName": "_compatibility_proxy_repo_rule", + "attributes": {} + } + }, + "recordedRepoMappingEntries": [ + [ + "rules_java~", + "bazel_tools", + "bazel_tools" + ] + ] + } + }, + "@@rules_kotlin~//src/main/starlark/core/repositories:bzlmod_setup.bzl%rules_kotlin_extensions": { + "general": { + "bzlTransitiveDigest": "fus14IFJ/1LGWWGKPH/U18VnJCoMjfDt1ckahqCnM0A=", + "usagesDigest": "aJF6fLy82rR95Ff5CZPAqxNoFgOMLMN5ImfBS0nhnkg=", + "recordedFileInputs": {}, + "recordedDirentsInputs": {}, + "envVariables": {}, "generatedRepoSpecs": { "com_github_jetbrains_kotlin_git": { - "repoRuleId": "@@rules_kotlin+//src/main/starlark/core/repositories:compiler.bzl%kotlin_compiler_git_repository", + "bzlFile": "@@rules_kotlin~//src/main/starlark/core/repositories:compiler.bzl", + "ruleClassName": "kotlin_compiler_git_repository", "attributes": { "urls": [ "https://github.com/JetBrains/kotlin/releases/download/v1.9.23/kotlin-compiler-1.9.23.zip" @@ -1689,14 +1779,16 @@ } }, "com_github_jetbrains_kotlin": { - "repoRuleId": "@@rules_kotlin+//src/main/starlark/core/repositories:compiler.bzl%kotlin_capabilities_repository", + "bzlFile": "@@rules_kotlin~//src/main/starlark/core/repositories:compiler.bzl", + "ruleClassName": "kotlin_capabilities_repository", "attributes": { "git_repository_name": "com_github_jetbrains_kotlin_git", "compiler_version": "1.9.23" } }, "com_github_google_ksp": { - "repoRuleId": "@@rules_kotlin+//src/main/starlark/core/repositories:ksp.bzl%ksp_compiler_plugin_repository", + "bzlFile": "@@rules_kotlin~//src/main/starlark/core/repositories:ksp.bzl", + "ruleClassName": "ksp_compiler_plugin_repository", "attributes": { "urls": [ "https://github.com/google/ksp/releases/download/1.9.23-1.0.20/artifacts.zip" @@ -1706,7 +1798,8 @@ } }, "com_github_pinterest_ktlint": { - "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_file", + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_file", "attributes": { "sha256": "01b2e0ef893383a50dbeb13970fe7fa3be36ca3e83259e01649945b09d736985", "urls": [ @@ -1716,7 +1809,8 @@ } }, "rules_android": { - "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", "attributes": { "sha256": "cd06d15dd8bb59926e4d65f9003bfc20f9da4b2519985c27e190cddc8b7a7806", "strip_prefix": "rules_android-0.1.1", @@ -1725,286 +1819,3203 @@ ] } } - } + }, + "recordedRepoMappingEntries": [ + [ + "rules_kotlin~", + "bazel_tools", + "bazel_tools" + ] + ] } }, - "@@rules_nodejs+//nodejs:extensions.bzl%node": { + "@@rules_nodejs~//nodejs:extensions.bzl%node": { "general": { - "bzlTransitiveDigest": "Imgzqqemb9gc8RyTW2SKONMe0WiFBua/vf0q3SiOwH0=", - "usagesDigest": "CtwJeycIo1YVyKAUrO/7bkpB6yqctQd8XUnRtqUbwRI=", - "recordedInputs": [ - "REPO_MAPPING:rules_nodejs+,bazel_skylib bazel_skylib+", - "REPO_MAPPING:rules_nodejs+,bazel_tools bazel_tools" - ], + "bzlTransitiveDigest": "xRRX0NuyvfLtjtzM4AqJgxdMSWWnLIw28rUUi10y6k0=", + "usagesDigest": "9IUJvk13jWE1kE+N3sP2y0mw9exjO9CGQ2oAgwKTNK4=", + "recordedFileInputs": {}, + "recordedDirentsInputs": {}, + "envVariables": {}, "generatedRepoSpecs": { "nodejs_linux_amd64": { - "repoRuleId": "@@rules_nodejs+//nodejs:repositories.bzl%node_repositories", + "bzlFile": "@@rules_nodejs~//nodejs:repositories.bzl", + "ruleClassName": "node_repositories", "attributes": { "platform": "linux_amd64", "node_version": "16.19.0" } }, "nodejs_linux_arm64": { - "repoRuleId": "@@rules_nodejs+//nodejs:repositories.bzl%node_repositories", + "bzlFile": "@@rules_nodejs~//nodejs:repositories.bzl", + "ruleClassName": "node_repositories", "attributes": { "platform": "linux_arm64", "node_version": "16.19.0" } }, "nodejs_linux_s390x": { - "repoRuleId": "@@rules_nodejs+//nodejs:repositories.bzl%node_repositories", + "bzlFile": "@@rules_nodejs~//nodejs:repositories.bzl", + "ruleClassName": "node_repositories", "attributes": { "platform": "linux_s390x", "node_version": "16.19.0" } }, "nodejs_linux_ppc64le": { - "repoRuleId": "@@rules_nodejs+//nodejs:repositories.bzl%node_repositories", + "bzlFile": "@@rules_nodejs~//nodejs:repositories.bzl", + "ruleClassName": "node_repositories", "attributes": { "platform": "linux_ppc64le", "node_version": "16.19.0" } }, "nodejs_darwin_amd64": { - "repoRuleId": "@@rules_nodejs+//nodejs:repositories.bzl%node_repositories", + "bzlFile": "@@rules_nodejs~//nodejs:repositories.bzl", + "ruleClassName": "node_repositories", "attributes": { "platform": "darwin_amd64", "node_version": "16.19.0" } }, "nodejs_darwin_arm64": { - "repoRuleId": "@@rules_nodejs+//nodejs:repositories.bzl%node_repositories", + "bzlFile": "@@rules_nodejs~//nodejs:repositories.bzl", + "ruleClassName": "node_repositories", "attributes": { "platform": "darwin_arm64", "node_version": "16.19.0" } }, "nodejs_windows_amd64": { - "repoRuleId": "@@rules_nodejs+//nodejs:repositories.bzl%node_repositories", + "bzlFile": "@@rules_nodejs~//nodejs:repositories.bzl", + "ruleClassName": "node_repositories", "attributes": { "platform": "windows_amd64", "node_version": "16.19.0" } }, "nodejs": { - "repoRuleId": "@@rules_nodejs+//nodejs/private:nodejs_repo_host_os_alias.bzl%nodejs_repo_host_os_alias", + "bzlFile": "@@rules_nodejs~//nodejs/private:nodejs_repo_host_os_alias.bzl", + "ruleClassName": "nodejs_repo_host_os_alias", "attributes": { "user_node_repository_name": "nodejs" } }, "nodejs_host": { - "repoRuleId": "@@rules_nodejs+//nodejs/private:nodejs_repo_host_os_alias.bzl%nodejs_repo_host_os_alias", + "bzlFile": "@@rules_nodejs~//nodejs/private:nodejs_repo_host_os_alias.bzl", + "ruleClassName": "nodejs_repo_host_os_alias", "attributes": { "user_node_repository_name": "nodejs" } }, "nodejs_toolchains": { - "repoRuleId": "@@rules_nodejs+//nodejs/private:toolchains_repo.bzl%toolchains_repo", + "bzlFile": "@@rules_nodejs~//nodejs/private:toolchains_repo.bzl", + "ruleClassName": "toolchains_repo", "attributes": { "user_node_repository_name": "nodejs" } } - } + }, + "recordedRepoMappingEntries": [ + [ + "rules_nodejs~", + "bazel_skylib", + "bazel_skylib~" + ], + [ + "rules_nodejs~", + "bazel_tools", + "bazel_tools" + ] + ] } }, - "@@rules_python+//python/extensions:config.bzl%config": { + "@@rules_rust~//rust:extensions.bzl%rust": { "general": { - "bzlTransitiveDigest": "2hLgIvNVTLgxus0ZuXtleBe70intCfo0cHs8qvt6cdM=", - "usagesDigest": "ZVSXMAGpD+xzVNPuvF1IoLBkty7TROO0+akMapt1pAg=", - "recordedInputs": [ - "REPO_MAPPING:rules_python+,bazel_tools bazel_tools", - "REPO_MAPPING:rules_python+,pypi__build rules_python++config+pypi__build", - "REPO_MAPPING:rules_python+,pypi__click rules_python++config+pypi__click", - "REPO_MAPPING:rules_python+,pypi__colorama rules_python++config+pypi__colorama", - "REPO_MAPPING:rules_python+,pypi__importlib_metadata rules_python++config+pypi__importlib_metadata", - "REPO_MAPPING:rules_python+,pypi__installer rules_python++config+pypi__installer", - "REPO_MAPPING:rules_python+,pypi__more_itertools rules_python++config+pypi__more_itertools", - "REPO_MAPPING:rules_python+,pypi__packaging rules_python++config+pypi__packaging", - "REPO_MAPPING:rules_python+,pypi__pep517 rules_python++config+pypi__pep517", - "REPO_MAPPING:rules_python+,pypi__pip rules_python++config+pypi__pip", - "REPO_MAPPING:rules_python+,pypi__pip_tools rules_python++config+pypi__pip_tools", - "REPO_MAPPING:rules_python+,pypi__pyproject_hooks rules_python++config+pypi__pyproject_hooks", - "REPO_MAPPING:rules_python+,pypi__setuptools rules_python++config+pypi__setuptools", - "REPO_MAPPING:rules_python+,pypi__tomli rules_python++config+pypi__tomli", - "REPO_MAPPING:rules_python+,pypi__wheel rules_python++config+pypi__wheel", - "REPO_MAPPING:rules_python+,pypi__zipp rules_python++config+pypi__zipp" - ], + "bzlTransitiveDigest": "38mS84XG0CcVNTJg1FK59Jp6LQGkDqSDkfNEz0D9s18=", + "usagesDigest": "rV+PuweiVabXYal8kLLNKaL4Tx6LbDJmoCxxMI6XmeA=", + "recordedFileInputs": {}, + "recordedDirentsInputs": {}, + "envVariables": {}, "generatedRepoSpecs": { - "rules_python_internal": { - "repoRuleId": "@@rules_python+//python/private:internal_config_repo.bzl%internal_config_repo", + "rust_analyzer_1.81.0_tools": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "rust_analyzer_toolchain_tools_repository", "attributes": { - "transition_setting_generators": {}, - "transition_settings": [] + "version": "1.81.0", + "sha256s": {}, + "urls": [ + "https://static.rust-lang.org/dist/{}.tar.xz" + ], + "auth": {}, + "netrc": "", + "auth_patterns": [] } }, - "pypi__build": { - "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", + "rust_analyzer_1.81.0": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "toolchain_repository_proxy", "attributes": { - "url": "https://files.pythonhosted.org/packages/e2/03/f3c8ba0a6b6e30d7d18c40faab90807c9bb5e9a1e3b2fe2008af624a9c97/build-1.2.1-py3-none-any.whl", - "sha256": "75e10f767a433d9a86e50d83f418e83efc18ede923ee5ff7df93b6cb0306c5d4", - "type": "zip", - "build_file_content": "package(default_visibility = [\"//visibility:public\"])\n\nload(\"@rules_python//python:py_library.bzl\", \"py_library\")\n\npy_library(\n name = \"lib\",\n srcs = glob([\"**/*.py\"]),\n data = glob([\"**/*\"], exclude=[\n # These entries include those put into user-installed dependencies by\n # data_exclude to avoid non-determinism.\n \"**/*.py\",\n \"**/*.pyc\",\n \"**/*.pyc.*\", # During pyc creation, temp files named *.pyc.NNN are created\n \"**/*.dist-info/RECORD\",\n \"BUILD\",\n \"WORKSPACE\",\n ]),\n # This makes this directory a top-level in the python import\n # search path for anything that depends on this.\n imports = [\".\"],\n)\n" + "toolchain": "@rust_analyzer_1.81.0_tools//:rust_analyzer_toolchain", + "toolchain_type": "@rules_rust//rust/rust_analyzer:toolchain_type", + "exec_compatible_with": [], + "target_compatible_with": [] } }, - "pypi__click": { - "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", + "rust_darwin_aarch64__aarch64-apple-darwin__stable_tools": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "rust_toolchain_tools_repository", "attributes": { - "url": "https://files.pythonhosted.org/packages/00/2e/d53fa4befbf2cfa713304affc7ca780ce4fc1fd8710527771b58311a3229/click-8.1.7-py3-none-any.whl", - "sha256": "ae74fb96c20a0277a1d615f1e4d73c8414f5a98db8b799a7931d1582f3390c28", - "type": "zip", - "build_file_content": "package(default_visibility = [\"//visibility:public\"])\n\nload(\"@rules_python//python:py_library.bzl\", \"py_library\")\n\npy_library(\n name = \"lib\",\n srcs = glob([\"**/*.py\"]),\n data = glob([\"**/*\"], exclude=[\n # These entries include those put into user-installed dependencies by\n # data_exclude to avoid non-determinism.\n \"**/*.py\",\n \"**/*.pyc\",\n \"**/*.pyc.*\", # During pyc creation, temp files named *.pyc.NNN are created\n \"**/*.dist-info/RECORD\",\n \"BUILD\",\n \"WORKSPACE\",\n ]),\n # This makes this directory a top-level in the python import\n # search path for anything that depends on this.\n imports = [\".\"],\n)\n" + "exec_triple": "aarch64-apple-darwin", + "allocator_library": "@rules_rust//ffi/cc/allocator_library", + "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", + "target_triple": "aarch64-apple-darwin", + "version": "1.81.0", + "rustfmt_version": "nightly/2024-09-05", + "edition": "2021", + "dev_components": false, + "extra_rustc_flags": [], + "extra_exec_rustc_flags": [], + "opt_level": {}, + "sha256s": {}, + "urls": [ + "https://static.rust-lang.org/dist/{}.tar.xz" + ], + "auth": {}, + "netrc": "", + "auth_patterns": [] } }, - "pypi__colorama": { - "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", + "rust_darwin_aarch64__aarch64-apple-darwin__stable": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "toolchain_repository_proxy", "attributes": { - "url": "https://files.pythonhosted.org/packages/d1/d6/3965ed04c63042e047cb6a3e6ed1a63a35087b6a609aa3a15ed8ac56c221/colorama-0.4.6-py2.py3-none-any.whl", - "sha256": "4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6", - "type": "zip", - "build_file_content": "package(default_visibility = [\"//visibility:public\"])\n\nload(\"@rules_python//python:py_library.bzl\", \"py_library\")\n\npy_library(\n name = \"lib\",\n srcs = glob([\"**/*.py\"]),\n data = glob([\"**/*\"], exclude=[\n # These entries include those put into user-installed dependencies by\n # data_exclude to avoid non-determinism.\n \"**/*.py\",\n \"**/*.pyc\",\n \"**/*.pyc.*\", # During pyc creation, temp files named *.pyc.NNN are created\n \"**/*.dist-info/RECORD\",\n \"BUILD\",\n \"WORKSPACE\",\n ]),\n # This makes this directory a top-level in the python import\n # search path for anything that depends on this.\n imports = [\".\"],\n)\n" + "toolchain": "@rust_darwin_aarch64__aarch64-apple-darwin__stable_tools//:rust_toolchain", + "target_settings": [ + "@rules_rust//rust/toolchain/channel:stable" + ], + "toolchain_type": "@rules_rust//rust:toolchain", + "exec_compatible_with": [ + "@platforms//cpu:aarch64", + "@platforms//os:osx" + ], + "target_compatible_with": [ + "@platforms//cpu:aarch64", + "@platforms//os:osx" + ] } }, - "pypi__importlib_metadata": { - "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", + "rust_darwin_aarch64__aarch64-apple-darwin__nightly_tools": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "rust_toolchain_tools_repository", "attributes": { - "url": "https://files.pythonhosted.org/packages/2d/0a/679461c511447ffaf176567d5c496d1de27cbe34a87df6677d7171b2fbd4/importlib_metadata-7.1.0-py3-none-any.whl", - "sha256": "30962b96c0c223483ed6cc7280e7f0199feb01a0e40cfae4d4450fc6fab1f570", - "type": "zip", - "build_file_content": "package(default_visibility = [\"//visibility:public\"])\n\nload(\"@rules_python//python:py_library.bzl\", \"py_library\")\n\npy_library(\n name = \"lib\",\n srcs = glob([\"**/*.py\"]),\n data = glob([\"**/*\"], exclude=[\n # These entries include those put into user-installed dependencies by\n # data_exclude to avoid non-determinism.\n \"**/*.py\",\n \"**/*.pyc\",\n \"**/*.pyc.*\", # During pyc creation, temp files named *.pyc.NNN are created\n \"**/*.dist-info/RECORD\",\n \"BUILD\",\n \"WORKSPACE\",\n ]),\n # This makes this directory a top-level in the python import\n # search path for anything that depends on this.\n imports = [\".\"],\n)\n" + "exec_triple": "aarch64-apple-darwin", + "allocator_library": "@rules_rust//ffi/cc/allocator_library", + "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", + "target_triple": "aarch64-apple-darwin", + "version": "nightly/2024-09-05", + "rustfmt_version": "nightly/2024-09-05", + "edition": "2021", + "dev_components": false, + "extra_rustc_flags": [], + "extra_exec_rustc_flags": [], + "opt_level": {}, + "sha256s": {}, + "urls": [ + "https://static.rust-lang.org/dist/{}.tar.xz" + ], + "auth": {}, + "netrc": "", + "auth_patterns": [] } }, - "pypi__installer": { - "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", + "rust_darwin_aarch64__aarch64-apple-darwin__nightly": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "toolchain_repository_proxy", "attributes": { - "url": "https://files.pythonhosted.org/packages/e5/ca/1172b6638d52f2d6caa2dd262ec4c811ba59eee96d54a7701930726bce18/installer-0.7.0-py3-none-any.whl", - "sha256": "05d1933f0a5ba7d8d6296bb6d5018e7c94fa473ceb10cf198a92ccea19c27b53", - "type": "zip", - "build_file_content": "package(default_visibility = [\"//visibility:public\"])\n\nload(\"@rules_python//python:py_library.bzl\", \"py_library\")\n\npy_library(\n name = \"lib\",\n srcs = glob([\"**/*.py\"]),\n data = glob([\"**/*\"], exclude=[\n # These entries include those put into user-installed dependencies by\n # data_exclude to avoid non-determinism.\n \"**/*.py\",\n \"**/*.pyc\",\n \"**/*.pyc.*\", # During pyc creation, temp files named *.pyc.NNN are created\n \"**/*.dist-info/RECORD\",\n \"BUILD\",\n \"WORKSPACE\",\n ]),\n # This makes this directory a top-level in the python import\n # search path for anything that depends on this.\n imports = [\".\"],\n)\n" + "toolchain": "@rust_darwin_aarch64__aarch64-apple-darwin__nightly_tools//:rust_toolchain", + "target_settings": [ + "@rules_rust//rust/toolchain/channel:nightly" + ], + "toolchain_type": "@rules_rust//rust:toolchain", + "exec_compatible_with": [ + "@platforms//cpu:aarch64", + "@platforms//os:osx" + ], + "target_compatible_with": [ + "@platforms//cpu:aarch64", + "@platforms//os:osx" + ] } }, - "pypi__more_itertools": { - "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", + "rust_darwin_aarch64__wasm32-unknown-unknown__stable_tools": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "rust_toolchain_tools_repository", "attributes": { - "url": "https://files.pythonhosted.org/packages/50/e2/8e10e465ee3987bb7c9ab69efb91d867d93959095f4807db102d07995d94/more_itertools-10.2.0-py3-none-any.whl", - "sha256": "686b06abe565edfab151cb8fd385a05651e1fdf8f0a14191e4439283421f8684", - "type": "zip", - "build_file_content": "package(default_visibility = [\"//visibility:public\"])\n\nload(\"@rules_python//python:py_library.bzl\", \"py_library\")\n\npy_library(\n name = \"lib\",\n srcs = glob([\"**/*.py\"]),\n data = glob([\"**/*\"], exclude=[\n # These entries include those put into user-installed dependencies by\n # data_exclude to avoid non-determinism.\n \"**/*.py\",\n \"**/*.pyc\",\n \"**/*.pyc.*\", # During pyc creation, temp files named *.pyc.NNN are created\n \"**/*.dist-info/RECORD\",\n \"BUILD\",\n \"WORKSPACE\",\n ]),\n # This makes this directory a top-level in the python import\n # search path for anything that depends on this.\n imports = [\".\"],\n)\n" + "exec_triple": "aarch64-apple-darwin", + "allocator_library": "@rules_rust//ffi/cc/allocator_library", + "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", + "target_triple": "wasm32-unknown-unknown", + "version": "1.81.0", + "rustfmt_version": "nightly/2024-09-05", + "edition": "2021", + "dev_components": false, + "extra_rustc_flags": [], + "extra_exec_rustc_flags": [], + "opt_level": {}, + "sha256s": {}, + "urls": [ + "https://static.rust-lang.org/dist/{}.tar.xz" + ], + "auth": {}, + "netrc": "", + "auth_patterns": [] } }, - "pypi__packaging": { - "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", + "rust_darwin_aarch64__wasm32-unknown-unknown__stable": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "toolchain_repository_proxy", "attributes": { - "url": "https://files.pythonhosted.org/packages/49/df/1fceb2f8900f8639e278b056416d49134fb8d84c5942ffaa01ad34782422/packaging-24.0-py3-none-any.whl", - "sha256": "2ddfb553fdf02fb784c234c7ba6ccc288296ceabec964ad2eae3777778130bc5", - "type": "zip", - "build_file_content": "package(default_visibility = [\"//visibility:public\"])\n\nload(\"@rules_python//python:py_library.bzl\", \"py_library\")\n\npy_library(\n name = \"lib\",\n srcs = glob([\"**/*.py\"]),\n data = glob([\"**/*\"], exclude=[\n # These entries include those put into user-installed dependencies by\n # data_exclude to avoid non-determinism.\n \"**/*.py\",\n \"**/*.pyc\",\n \"**/*.pyc.*\", # During pyc creation, temp files named *.pyc.NNN are created\n \"**/*.dist-info/RECORD\",\n \"BUILD\",\n \"WORKSPACE\",\n ]),\n # This makes this directory a top-level in the python import\n # search path for anything that depends on this.\n imports = [\".\"],\n)\n" + "toolchain": "@rust_darwin_aarch64__wasm32-unknown-unknown__stable_tools//:rust_toolchain", + "target_settings": [ + "@rules_rust//rust/toolchain/channel:stable" + ], + "toolchain_type": "@rules_rust//rust:toolchain", + "exec_compatible_with": [ + "@platforms//cpu:aarch64", + "@platforms//os:osx" + ], + "target_compatible_with": [ + "@platforms//cpu:wasm32", + "@platforms//os:none" + ] } }, - "pypi__pep517": { - "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", + "rust_darwin_aarch64__wasm32-unknown-unknown__nightly_tools": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "rust_toolchain_tools_repository", "attributes": { - "url": "https://files.pythonhosted.org/packages/25/6e/ca4a5434eb0e502210f591b97537d322546e4833dcb4d470a48c375c5540/pep517-0.13.1-py3-none-any.whl", - "sha256": "31b206f67165b3536dd577c5c3f1518e8fbaf38cbc57efff8369a392feff1721", - "type": "zip", - "build_file_content": "package(default_visibility = [\"//visibility:public\"])\n\nload(\"@rules_python//python:py_library.bzl\", \"py_library\")\n\npy_library(\n name = \"lib\",\n srcs = glob([\"**/*.py\"]),\n data = glob([\"**/*\"], exclude=[\n # These entries include those put into user-installed dependencies by\n # data_exclude to avoid non-determinism.\n \"**/*.py\",\n \"**/*.pyc\",\n \"**/*.pyc.*\", # During pyc creation, temp files named *.pyc.NNN are created\n \"**/*.dist-info/RECORD\",\n \"BUILD\",\n \"WORKSPACE\",\n ]),\n # This makes this directory a top-level in the python import\n # search path for anything that depends on this.\n imports = [\".\"],\n)\n" + "exec_triple": "aarch64-apple-darwin", + "allocator_library": "@rules_rust//ffi/cc/allocator_library", + "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", + "target_triple": "wasm32-unknown-unknown", + "version": "nightly/2024-09-05", + "rustfmt_version": "nightly/2024-09-05", + "edition": "2021", + "dev_components": false, + "extra_rustc_flags": [], + "extra_exec_rustc_flags": [], + "opt_level": {}, + "sha256s": {}, + "urls": [ + "https://static.rust-lang.org/dist/{}.tar.xz" + ], + "auth": {}, + "netrc": "", + "auth_patterns": [] } }, - "pypi__pip": { - "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", + "rust_darwin_aarch64__wasm32-unknown-unknown__nightly": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "toolchain_repository_proxy", "attributes": { - "url": "https://files.pythonhosted.org/packages/8a/6a/19e9fe04fca059ccf770861c7d5721ab4c2aebc539889e97c7977528a53b/pip-24.0-py3-none-any.whl", - "sha256": "ba0d021a166865d2265246961bec0152ff124de910c5cc39f1156ce3fa7c69dc", - "type": "zip", - "build_file_content": "package(default_visibility = [\"//visibility:public\"])\n\nload(\"@rules_python//python:py_library.bzl\", \"py_library\")\n\npy_library(\n name = \"lib\",\n srcs = glob([\"**/*.py\"]),\n data = glob([\"**/*\"], exclude=[\n # These entries include those put into user-installed dependencies by\n # data_exclude to avoid non-determinism.\n \"**/*.py\",\n \"**/*.pyc\",\n \"**/*.pyc.*\", # During pyc creation, temp files named *.pyc.NNN are created\n \"**/*.dist-info/RECORD\",\n \"BUILD\",\n \"WORKSPACE\",\n ]),\n # This makes this directory a top-level in the python import\n # search path for anything that depends on this.\n imports = [\".\"],\n)\n" + "toolchain": "@rust_darwin_aarch64__wasm32-unknown-unknown__nightly_tools//:rust_toolchain", + "target_settings": [ + "@rules_rust//rust/toolchain/channel:nightly" + ], + "toolchain_type": "@rules_rust//rust:toolchain", + "exec_compatible_with": [ + "@platforms//cpu:aarch64", + "@platforms//os:osx" + ], + "target_compatible_with": [ + "@platforms//cpu:wasm32", + "@platforms//os:none" + ] } }, - "pypi__pip_tools": { - "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", + "rust_darwin_aarch64__wasm32-wasi__stable_tools": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "rust_toolchain_tools_repository", "attributes": { - "url": "https://files.pythonhosted.org/packages/0d/dc/38f4ce065e92c66f058ea7a368a9c5de4e702272b479c0992059f7693941/pip_tools-7.4.1-py3-none-any.whl", - "sha256": "4c690e5fbae2f21e87843e89c26191f0d9454f362d8acdbd695716493ec8b3a9", - "type": "zip", - "build_file_content": "package(default_visibility = [\"//visibility:public\"])\n\nload(\"@rules_python//python:py_library.bzl\", \"py_library\")\n\npy_library(\n name = \"lib\",\n srcs = glob([\"**/*.py\"]),\n data = glob([\"**/*\"], exclude=[\n # These entries include those put into user-installed dependencies by\n # data_exclude to avoid non-determinism.\n \"**/*.py\",\n \"**/*.pyc\",\n \"**/*.pyc.*\", # During pyc creation, temp files named *.pyc.NNN are created\n \"**/*.dist-info/RECORD\",\n \"BUILD\",\n \"WORKSPACE\",\n ]),\n # This makes this directory a top-level in the python import\n # search path for anything that depends on this.\n imports = [\".\"],\n)\n" + "exec_triple": "aarch64-apple-darwin", + "allocator_library": "@rules_rust//ffi/cc/allocator_library", + "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", + "target_triple": "wasm32-wasi", + "version": "1.81.0", + "rustfmt_version": "nightly/2024-09-05", + "edition": "2021", + "dev_components": false, + "extra_rustc_flags": [], + "extra_exec_rustc_flags": [], + "opt_level": {}, + "sha256s": {}, + "urls": [ + "https://static.rust-lang.org/dist/{}.tar.xz" + ], + "auth": {}, + "netrc": "", + "auth_patterns": [] } }, - "pypi__pyproject_hooks": { - "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", + "rust_darwin_aarch64__wasm32-wasi__stable": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "toolchain_repository_proxy", "attributes": { - "url": "https://files.pythonhosted.org/packages/ae/f3/431b9d5fe7d14af7a32340792ef43b8a714e7726f1d7b69cc4e8e7a3f1d7/pyproject_hooks-1.1.0-py3-none-any.whl", - "sha256": "7ceeefe9aec63a1064c18d939bdc3adf2d8aa1988a510afec15151578b232aa2", - "type": "zip", - "build_file_content": "package(default_visibility = [\"//visibility:public\"])\n\nload(\"@rules_python//python:py_library.bzl\", \"py_library\")\n\npy_library(\n name = \"lib\",\n srcs = glob([\"**/*.py\"]),\n data = glob([\"**/*\"], exclude=[\n # These entries include those put into user-installed dependencies by\n # data_exclude to avoid non-determinism.\n \"**/*.py\",\n \"**/*.pyc\",\n \"**/*.pyc.*\", # During pyc creation, temp files named *.pyc.NNN are created\n \"**/*.dist-info/RECORD\",\n \"BUILD\",\n \"WORKSPACE\",\n ]),\n # This makes this directory a top-level in the python import\n # search path for anything that depends on this.\n imports = [\".\"],\n)\n" + "toolchain": "@rust_darwin_aarch64__wasm32-wasi__stable_tools//:rust_toolchain", + "target_settings": [ + "@rules_rust//rust/toolchain/channel:stable" + ], + "toolchain_type": "@rules_rust//rust:toolchain", + "exec_compatible_with": [ + "@platforms//cpu:aarch64", + "@platforms//os:osx" + ], + "target_compatible_with": [ + "@platforms//cpu:wasm32", + "@platforms//os:wasi" + ] } }, - "pypi__setuptools": { - "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", + "rust_darwin_aarch64__wasm32-wasi__nightly_tools": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "rust_toolchain_tools_repository", "attributes": { - "url": "https://files.pythonhosted.org/packages/90/99/158ad0609729111163fc1f674a5a42f2605371a4cf036d0441070e2f7455/setuptools-78.1.1-py3-none-any.whl", - "sha256": "c3a9c4211ff4c309edb8b8c4f1cbfa7ae324c4ba9f91ff254e3d305b9fd54561", - "type": "zip", - "build_file_content": "package(default_visibility = [\"//visibility:public\"])\n\nload(\"@rules_python//python:py_library.bzl\", \"py_library\")\n\npy_library(\n name = \"lib\",\n srcs = glob([\"**/*.py\"]),\n data = glob([\"**/*\"], exclude=[\n # These entries include those put into user-installed dependencies by\n # data_exclude to avoid non-determinism.\n \"**/*.py\",\n \"**/*.pyc\",\n \"**/*.pyc.*\", # During pyc creation, temp files named *.pyc.NNN are created\n \"**/*.dist-info/RECORD\",\n \"BUILD\",\n \"WORKSPACE\",\n ]),\n # This makes this directory a top-level in the python import\n # search path for anything that depends on this.\n imports = [\".\"],\n)\n" + "exec_triple": "aarch64-apple-darwin", + "allocator_library": "@rules_rust//ffi/cc/allocator_library", + "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", + "target_triple": "wasm32-wasi", + "version": "nightly/2024-09-05", + "rustfmt_version": "nightly/2024-09-05", + "edition": "2021", + "dev_components": false, + "extra_rustc_flags": [], + "extra_exec_rustc_flags": [], + "opt_level": {}, + "sha256s": {}, + "urls": [ + "https://static.rust-lang.org/dist/{}.tar.xz" + ], + "auth": {}, + "netrc": "", + "auth_patterns": [] } }, - "pypi__tomli": { - "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", + "rust_darwin_aarch64__wasm32-wasi__nightly": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "toolchain_repository_proxy", "attributes": { - "url": "https://files.pythonhosted.org/packages/97/75/10a9ebee3fd790d20926a90a2547f0bf78f371b2f13aa822c759680ca7b9/tomli-2.0.1-py3-none-any.whl", - "sha256": "939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc", - "type": "zip", - "build_file_content": "package(default_visibility = [\"//visibility:public\"])\n\nload(\"@rules_python//python:py_library.bzl\", \"py_library\")\n\npy_library(\n name = \"lib\",\n srcs = glob([\"**/*.py\"]),\n data = glob([\"**/*\"], exclude=[\n # These entries include those put into user-installed dependencies by\n # data_exclude to avoid non-determinism.\n \"**/*.py\",\n \"**/*.pyc\",\n \"**/*.pyc.*\", # During pyc creation, temp files named *.pyc.NNN are created\n \"**/*.dist-info/RECORD\",\n \"BUILD\",\n \"WORKSPACE\",\n ]),\n # This makes this directory a top-level in the python import\n # search path for anything that depends on this.\n imports = [\".\"],\n)\n" + "toolchain": "@rust_darwin_aarch64__wasm32-wasi__nightly_tools//:rust_toolchain", + "target_settings": [ + "@rules_rust//rust/toolchain/channel:nightly" + ], + "toolchain_type": "@rules_rust//rust:toolchain", + "exec_compatible_with": [ + "@platforms//cpu:aarch64", + "@platforms//os:osx" + ], + "target_compatible_with": [ + "@platforms//cpu:wasm32", + "@platforms//os:wasi" + ] } }, - "pypi__wheel": { - "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", + "rust_darwin_aarch64": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "rust_toolchain_set_repository", "attributes": { - "url": "https://files.pythonhosted.org/packages/7d/cd/d7460c9a869b16c3dd4e1e403cce337df165368c71d6af229a74699622ce/wheel-0.43.0-py3-none-any.whl", - "sha256": "55c570405f142630c6b9f72fe09d9b67cf1477fcf543ae5b8dcb1f5b7377da81", - "type": "zip", - "build_file_content": "package(default_visibility = [\"//visibility:public\"])\n\nload(\"@rules_python//python:py_library.bzl\", \"py_library\")\n\npy_library(\n name = \"lib\",\n srcs = glob([\"**/*.py\"]),\n data = glob([\"**/*\"], exclude=[\n # These entries include those put into user-installed dependencies by\n # data_exclude to avoid non-determinism.\n \"**/*.py\",\n \"**/*.pyc\",\n \"**/*.pyc.*\", # During pyc creation, temp files named *.pyc.NNN are created\n \"**/*.dist-info/RECORD\",\n \"BUILD\",\n \"WORKSPACE\",\n ]),\n # This makes this directory a top-level in the python import\n # search path for anything that depends on this.\n imports = [\".\"],\n)\n" + "toolchains": [ + "@rust_darwin_aarch64__aarch64-apple-darwin__stable//:toolchain", + "@rust_darwin_aarch64__aarch64-apple-darwin__nightly//:toolchain", + "@rust_darwin_aarch64__wasm32-unknown-unknown__stable//:toolchain", + "@rust_darwin_aarch64__wasm32-unknown-unknown__nightly//:toolchain", + "@rust_darwin_aarch64__wasm32-wasi__stable//:toolchain", + "@rust_darwin_aarch64__wasm32-wasi__nightly//:toolchain" + ] } }, - "pypi__zipp": { - "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", + "rustfmt_nightly-2024-09-05__aarch64-apple-darwin_tools": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "rustfmt_toolchain_tools_repository", "attributes": { - "url": "https://files.pythonhosted.org/packages/da/55/a03fd7240714916507e1fcf7ae355bd9d9ed2e6db492595f1a67f61681be/zipp-3.18.2-py3-none-any.whl", - "sha256": "dce197b859eb796242b0622af1b8beb0a722d52aa2f57133ead08edd5bf5374e", - "type": "zip", - "build_file_content": "package(default_visibility = [\"//visibility:public\"])\n\nload(\"@rules_python//python:py_library.bzl\", \"py_library\")\n\npy_library(\n name = \"lib\",\n srcs = glob([\"**/*.py\"]),\n data = glob([\"**/*\"], exclude=[\n # These entries include those put into user-installed dependencies by\n # data_exclude to avoid non-determinism.\n \"**/*.py\",\n \"**/*.pyc\",\n \"**/*.pyc.*\", # During pyc creation, temp files named *.pyc.NNN are created\n \"**/*.dist-info/RECORD\",\n \"BUILD\",\n \"WORKSPACE\",\n ]),\n # This makes this directory a top-level in the python import\n # search path for anything that depends on this.\n imports = [\".\"],\n)\n" + "version": "nightly/2024-09-05", + "sha256s": {}, + "urls": [ + "https://static.rust-lang.org/dist/{}.tar.xz" + ], + "auth": {}, + "netrc": "", + "auth_patterns": {}, + "exec_triple": "aarch64-apple-darwin" } - } - } - } - }, - "@@rules_python+//python/uv:uv.bzl%uv": { - "general": { - "bzlTransitiveDigest": "ijW9KS7qsIY+yBVvJ+Nr1mzwQox09j13DnE3iIwaeTM=", - "usagesDigest": "H8dQoNZcoqP+Mu0tHZTi4KHATzvNkM5ePuEqoQdklIU=", - "recordedInputs": [ - "REPO_MAPPING:rules_python+,bazel_tools bazel_tools", - "REPO_MAPPING:rules_python+,platforms platforms" - ], - "generatedRepoSpecs": { - "uv": { - "repoRuleId": "@@rules_python+//python/uv/private:uv_toolchains_repo.bzl%uv_toolchains_repo", + }, + "rustfmt_nightly-2024-09-05__aarch64-apple-darwin": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "toolchain_repository_proxy", "attributes": { - "toolchain_type": "'@@rules_python+//python/uv:uv_toolchain_type'", - "toolchain_names": [ - "none" + "toolchain": "@rustfmt_nightly-2024-09-05__aarch64-apple-darwin_tools//:rustfmt_toolchain", + "toolchain_type": "@rules_rust//rust/rustfmt:toolchain_type", + "target_settings": [], + "exec_compatible_with": [ + "@platforms//cpu:aarch64", + "@platforms//os:osx" ], - "toolchain_implementations": { - "none": "'@@rules_python+//python:none'" - }, - "toolchain_compatible_with": { - "none": [ - "@platforms//:incompatible" - ] - }, - "toolchain_target_settings": {} + "target_compatible_with": [] } - } - } - } - } - }, - "facts": {} + }, + "rust_windows_aarch64__aarch64-pc-windows-msvc__stable_tools": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "rust_toolchain_tools_repository", + "attributes": { + "exec_triple": "aarch64-pc-windows-msvc", + "allocator_library": "@rules_rust//ffi/cc/allocator_library", + "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", + "target_triple": "aarch64-pc-windows-msvc", + "version": "1.81.0", + "rustfmt_version": "nightly/2024-09-05", + "edition": "2021", + "dev_components": false, + "extra_rustc_flags": [], + "extra_exec_rustc_flags": [], + "opt_level": {}, + "sha256s": {}, + "urls": [ + "https://static.rust-lang.org/dist/{}.tar.xz" + ], + "auth": {}, + "netrc": "", + "auth_patterns": [] + } + }, + "rust_windows_aarch64__aarch64-pc-windows-msvc__stable": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "toolchain_repository_proxy", + "attributes": { + "toolchain": "@rust_windows_aarch64__aarch64-pc-windows-msvc__stable_tools//:rust_toolchain", + "target_settings": [ + "@rules_rust//rust/toolchain/channel:stable" + ], + "toolchain_type": "@rules_rust//rust:toolchain", + "exec_compatible_with": [ + "@platforms//cpu:aarch64", + "@platforms//os:windows" + ], + "target_compatible_with": [ + "@platforms//cpu:aarch64", + "@platforms//os:windows" + ] + } + }, + "rust_windows_aarch64__aarch64-pc-windows-msvc__nightly_tools": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "rust_toolchain_tools_repository", + "attributes": { + "exec_triple": "aarch64-pc-windows-msvc", + "allocator_library": "@rules_rust//ffi/cc/allocator_library", + "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", + "target_triple": "aarch64-pc-windows-msvc", + "version": "nightly/2024-09-05", + "rustfmt_version": "nightly/2024-09-05", + "edition": "2021", + "dev_components": false, + "extra_rustc_flags": [], + "extra_exec_rustc_flags": [], + "opt_level": {}, + "sha256s": {}, + "urls": [ + "https://static.rust-lang.org/dist/{}.tar.xz" + ], + "auth": {}, + "netrc": "", + "auth_patterns": [] + } + }, + "rust_windows_aarch64__aarch64-pc-windows-msvc__nightly": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "toolchain_repository_proxy", + "attributes": { + "toolchain": "@rust_windows_aarch64__aarch64-pc-windows-msvc__nightly_tools//:rust_toolchain", + "target_settings": [ + "@rules_rust//rust/toolchain/channel:nightly" + ], + "toolchain_type": "@rules_rust//rust:toolchain", + "exec_compatible_with": [ + "@platforms//cpu:aarch64", + "@platforms//os:windows" + ], + "target_compatible_with": [ + "@platforms//cpu:aarch64", + "@platforms//os:windows" + ] + } + }, + "rust_windows_aarch64__wasm32-unknown-unknown__stable_tools": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "rust_toolchain_tools_repository", + "attributes": { + "exec_triple": "aarch64-pc-windows-msvc", + "allocator_library": "@rules_rust//ffi/cc/allocator_library", + "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", + "target_triple": "wasm32-unknown-unknown", + "version": "1.81.0", + "rustfmt_version": "nightly/2024-09-05", + "edition": "2021", + "dev_components": false, + "extra_rustc_flags": [], + "extra_exec_rustc_flags": [], + "opt_level": {}, + "sha256s": {}, + "urls": [ + "https://static.rust-lang.org/dist/{}.tar.xz" + ], + "auth": {}, + "netrc": "", + "auth_patterns": [] + } + }, + "rust_windows_aarch64__wasm32-unknown-unknown__stable": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "toolchain_repository_proxy", + "attributes": { + "toolchain": "@rust_windows_aarch64__wasm32-unknown-unknown__stable_tools//:rust_toolchain", + "target_settings": [ + "@rules_rust//rust/toolchain/channel:stable" + ], + "toolchain_type": "@rules_rust//rust:toolchain", + "exec_compatible_with": [ + "@platforms//cpu:aarch64", + "@platforms//os:windows" + ], + "target_compatible_with": [ + "@platforms//cpu:wasm32", + "@platforms//os:none" + ] + } + }, + "rust_windows_aarch64__wasm32-unknown-unknown__nightly_tools": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "rust_toolchain_tools_repository", + "attributes": { + "exec_triple": "aarch64-pc-windows-msvc", + "allocator_library": "@rules_rust//ffi/cc/allocator_library", + "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", + "target_triple": "wasm32-unknown-unknown", + "version": "nightly/2024-09-05", + "rustfmt_version": "nightly/2024-09-05", + "edition": "2021", + "dev_components": false, + "extra_rustc_flags": [], + "extra_exec_rustc_flags": [], + "opt_level": {}, + "sha256s": {}, + "urls": [ + "https://static.rust-lang.org/dist/{}.tar.xz" + ], + "auth": {}, + "netrc": "", + "auth_patterns": [] + } + }, + "rust_windows_aarch64__wasm32-unknown-unknown__nightly": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "toolchain_repository_proxy", + "attributes": { + "toolchain": "@rust_windows_aarch64__wasm32-unknown-unknown__nightly_tools//:rust_toolchain", + "target_settings": [ + "@rules_rust//rust/toolchain/channel:nightly" + ], + "toolchain_type": "@rules_rust//rust:toolchain", + "exec_compatible_with": [ + "@platforms//cpu:aarch64", + "@platforms//os:windows" + ], + "target_compatible_with": [ + "@platforms//cpu:wasm32", + "@platforms//os:none" + ] + } + }, + "rust_windows_aarch64__wasm32-wasi__stable_tools": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "rust_toolchain_tools_repository", + "attributes": { + "exec_triple": "aarch64-pc-windows-msvc", + "allocator_library": "@rules_rust//ffi/cc/allocator_library", + "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", + "target_triple": "wasm32-wasi", + "version": "1.81.0", + "rustfmt_version": "nightly/2024-09-05", + "edition": "2021", + "dev_components": false, + "extra_rustc_flags": [], + "extra_exec_rustc_flags": [], + "opt_level": {}, + "sha256s": {}, + "urls": [ + "https://static.rust-lang.org/dist/{}.tar.xz" + ], + "auth": {}, + "netrc": "", + "auth_patterns": [] + } + }, + "rust_windows_aarch64__wasm32-wasi__stable": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "toolchain_repository_proxy", + "attributes": { + "toolchain": "@rust_windows_aarch64__wasm32-wasi__stable_tools//:rust_toolchain", + "target_settings": [ + "@rules_rust//rust/toolchain/channel:stable" + ], + "toolchain_type": "@rules_rust//rust:toolchain", + "exec_compatible_with": [ + "@platforms//cpu:aarch64", + "@platforms//os:windows" + ], + "target_compatible_with": [ + "@platforms//cpu:wasm32", + "@platforms//os:wasi" + ] + } + }, + "rust_windows_aarch64__wasm32-wasi__nightly_tools": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "rust_toolchain_tools_repository", + "attributes": { + "exec_triple": "aarch64-pc-windows-msvc", + "allocator_library": "@rules_rust//ffi/cc/allocator_library", + "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", + "target_triple": "wasm32-wasi", + "version": "nightly/2024-09-05", + "rustfmt_version": "nightly/2024-09-05", + "edition": "2021", + "dev_components": false, + "extra_rustc_flags": [], + "extra_exec_rustc_flags": [], + "opt_level": {}, + "sha256s": {}, + "urls": [ + "https://static.rust-lang.org/dist/{}.tar.xz" + ], + "auth": {}, + "netrc": "", + "auth_patterns": [] + } + }, + "rust_windows_aarch64__wasm32-wasi__nightly": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "toolchain_repository_proxy", + "attributes": { + "toolchain": "@rust_windows_aarch64__wasm32-wasi__nightly_tools//:rust_toolchain", + "target_settings": [ + "@rules_rust//rust/toolchain/channel:nightly" + ], + "toolchain_type": "@rules_rust//rust:toolchain", + "exec_compatible_with": [ + "@platforms//cpu:aarch64", + "@platforms//os:windows" + ], + "target_compatible_with": [ + "@platforms//cpu:wasm32", + "@platforms//os:wasi" + ] + } + }, + "rust_windows_aarch64": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "rust_toolchain_set_repository", + "attributes": { + "toolchains": [ + "@rust_windows_aarch64__aarch64-pc-windows-msvc__stable//:toolchain", + "@rust_windows_aarch64__aarch64-pc-windows-msvc__nightly//:toolchain", + "@rust_windows_aarch64__wasm32-unknown-unknown__stable//:toolchain", + "@rust_windows_aarch64__wasm32-unknown-unknown__nightly//:toolchain", + "@rust_windows_aarch64__wasm32-wasi__stable//:toolchain", + "@rust_windows_aarch64__wasm32-wasi__nightly//:toolchain" + ] + } + }, + "rustfmt_nightly-2024-09-05__aarch64-pc-windows-msvc_tools": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "rustfmt_toolchain_tools_repository", + "attributes": { + "version": "nightly/2024-09-05", + "sha256s": {}, + "urls": [ + "https://static.rust-lang.org/dist/{}.tar.xz" + ], + "auth": {}, + "netrc": "", + "auth_patterns": {}, + "exec_triple": "aarch64-pc-windows-msvc" + } + }, + "rustfmt_nightly-2024-09-05__aarch64-pc-windows-msvc": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "toolchain_repository_proxy", + "attributes": { + "toolchain": "@rustfmt_nightly-2024-09-05__aarch64-pc-windows-msvc_tools//:rustfmt_toolchain", + "toolchain_type": "@rules_rust//rust/rustfmt:toolchain_type", + "target_settings": [], + "exec_compatible_with": [ + "@platforms//cpu:aarch64", + "@platforms//os:windows" + ], + "target_compatible_with": [] + } + }, + "rust_linux_aarch64__aarch64-unknown-linux-gnu__stable_tools": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "rust_toolchain_tools_repository", + "attributes": { + "exec_triple": "aarch64-unknown-linux-gnu", + "allocator_library": "@rules_rust//ffi/cc/allocator_library", + "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", + "target_triple": "aarch64-unknown-linux-gnu", + "version": "1.81.0", + "rustfmt_version": "nightly/2024-09-05", + "edition": "2021", + "dev_components": false, + "extra_rustc_flags": [], + "extra_exec_rustc_flags": [], + "opt_level": {}, + "sha256s": {}, + "urls": [ + "https://static.rust-lang.org/dist/{}.tar.xz" + ], + "auth": {}, + "netrc": "", + "auth_patterns": [] + } + }, + "rust_linux_aarch64__aarch64-unknown-linux-gnu__stable": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "toolchain_repository_proxy", + "attributes": { + "toolchain": "@rust_linux_aarch64__aarch64-unknown-linux-gnu__stable_tools//:rust_toolchain", + "target_settings": [ + "@rules_rust//rust/toolchain/channel:stable" + ], + "toolchain_type": "@rules_rust//rust:toolchain", + "exec_compatible_with": [ + "@platforms//cpu:aarch64", + "@platforms//os:linux" + ], + "target_compatible_with": [ + "@platforms//cpu:aarch64", + "@platforms//os:linux" + ] + } + }, + "rust_linux_aarch64__aarch64-unknown-linux-gnu__nightly_tools": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "rust_toolchain_tools_repository", + "attributes": { + "exec_triple": "aarch64-unknown-linux-gnu", + "allocator_library": "@rules_rust//ffi/cc/allocator_library", + "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", + "target_triple": "aarch64-unknown-linux-gnu", + "version": "nightly/2024-09-05", + "rustfmt_version": "nightly/2024-09-05", + "edition": "2021", + "dev_components": false, + "extra_rustc_flags": [], + "extra_exec_rustc_flags": [], + "opt_level": {}, + "sha256s": {}, + "urls": [ + "https://static.rust-lang.org/dist/{}.tar.xz" + ], + "auth": {}, + "netrc": "", + "auth_patterns": [] + } + }, + "rust_linux_aarch64__aarch64-unknown-linux-gnu__nightly": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "toolchain_repository_proxy", + "attributes": { + "toolchain": "@rust_linux_aarch64__aarch64-unknown-linux-gnu__nightly_tools//:rust_toolchain", + "target_settings": [ + "@rules_rust//rust/toolchain/channel:nightly" + ], + "toolchain_type": "@rules_rust//rust:toolchain", + "exec_compatible_with": [ + "@platforms//cpu:aarch64", + "@platforms//os:linux" + ], + "target_compatible_with": [ + "@platforms//cpu:aarch64", + "@platforms//os:linux" + ] + } + }, + "rust_linux_aarch64__wasm32-unknown-unknown__stable_tools": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "rust_toolchain_tools_repository", + "attributes": { + "exec_triple": "aarch64-unknown-linux-gnu", + "allocator_library": "@rules_rust//ffi/cc/allocator_library", + "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", + "target_triple": "wasm32-unknown-unknown", + "version": "1.81.0", + "rustfmt_version": "nightly/2024-09-05", + "edition": "2021", + "dev_components": false, + "extra_rustc_flags": [], + "extra_exec_rustc_flags": [], + "opt_level": {}, + "sha256s": {}, + "urls": [ + "https://static.rust-lang.org/dist/{}.tar.xz" + ], + "auth": {}, + "netrc": "", + "auth_patterns": [] + } + }, + "rust_linux_aarch64__wasm32-unknown-unknown__stable": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "toolchain_repository_proxy", + "attributes": { + "toolchain": "@rust_linux_aarch64__wasm32-unknown-unknown__stable_tools//:rust_toolchain", + "target_settings": [ + "@rules_rust//rust/toolchain/channel:stable" + ], + "toolchain_type": "@rules_rust//rust:toolchain", + "exec_compatible_with": [ + "@platforms//cpu:aarch64", + "@platforms//os:linux" + ], + "target_compatible_with": [ + "@platforms//cpu:wasm32", + "@platforms//os:none" + ] + } + }, + "rust_linux_aarch64__wasm32-unknown-unknown__nightly_tools": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "rust_toolchain_tools_repository", + "attributes": { + "exec_triple": "aarch64-unknown-linux-gnu", + "allocator_library": "@rules_rust//ffi/cc/allocator_library", + "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", + "target_triple": "wasm32-unknown-unknown", + "version": "nightly/2024-09-05", + "rustfmt_version": "nightly/2024-09-05", + "edition": "2021", + "dev_components": false, + "extra_rustc_flags": [], + "extra_exec_rustc_flags": [], + "opt_level": {}, + "sha256s": {}, + "urls": [ + "https://static.rust-lang.org/dist/{}.tar.xz" + ], + "auth": {}, + "netrc": "", + "auth_patterns": [] + } + }, + "rust_linux_aarch64__wasm32-unknown-unknown__nightly": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "toolchain_repository_proxy", + "attributes": { + "toolchain": "@rust_linux_aarch64__wasm32-unknown-unknown__nightly_tools//:rust_toolchain", + "target_settings": [ + "@rules_rust//rust/toolchain/channel:nightly" + ], + "toolchain_type": "@rules_rust//rust:toolchain", + "exec_compatible_with": [ + "@platforms//cpu:aarch64", + "@platforms//os:linux" + ], + "target_compatible_with": [ + "@platforms//cpu:wasm32", + "@platforms//os:none" + ] + } + }, + "rust_linux_aarch64__wasm32-wasi__stable_tools": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "rust_toolchain_tools_repository", + "attributes": { + "exec_triple": "aarch64-unknown-linux-gnu", + "allocator_library": "@rules_rust//ffi/cc/allocator_library", + "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", + "target_triple": "wasm32-wasi", + "version": "1.81.0", + "rustfmt_version": "nightly/2024-09-05", + "edition": "2021", + "dev_components": false, + "extra_rustc_flags": [], + "extra_exec_rustc_flags": [], + "opt_level": {}, + "sha256s": {}, + "urls": [ + "https://static.rust-lang.org/dist/{}.tar.xz" + ], + "auth": {}, + "netrc": "", + "auth_patterns": [] + } + }, + "rust_linux_aarch64__wasm32-wasi__stable": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "toolchain_repository_proxy", + "attributes": { + "toolchain": "@rust_linux_aarch64__wasm32-wasi__stable_tools//:rust_toolchain", + "target_settings": [ + "@rules_rust//rust/toolchain/channel:stable" + ], + "toolchain_type": "@rules_rust//rust:toolchain", + "exec_compatible_with": [ + "@platforms//cpu:aarch64", + "@platforms//os:linux" + ], + "target_compatible_with": [ + "@platforms//cpu:wasm32", + "@platforms//os:wasi" + ] + } + }, + "rust_linux_aarch64__wasm32-wasi__nightly_tools": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "rust_toolchain_tools_repository", + "attributes": { + "exec_triple": "aarch64-unknown-linux-gnu", + "allocator_library": "@rules_rust//ffi/cc/allocator_library", + "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", + "target_triple": "wasm32-wasi", + "version": "nightly/2024-09-05", + "rustfmt_version": "nightly/2024-09-05", + "edition": "2021", + "dev_components": false, + "extra_rustc_flags": [], + "extra_exec_rustc_flags": [], + "opt_level": {}, + "sha256s": {}, + "urls": [ + "https://static.rust-lang.org/dist/{}.tar.xz" + ], + "auth": {}, + "netrc": "", + "auth_patterns": [] + } + }, + "rust_linux_aarch64__wasm32-wasi__nightly": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "toolchain_repository_proxy", + "attributes": { + "toolchain": "@rust_linux_aarch64__wasm32-wasi__nightly_tools//:rust_toolchain", + "target_settings": [ + "@rules_rust//rust/toolchain/channel:nightly" + ], + "toolchain_type": "@rules_rust//rust:toolchain", + "exec_compatible_with": [ + "@platforms//cpu:aarch64", + "@platforms//os:linux" + ], + "target_compatible_with": [ + "@platforms//cpu:wasm32", + "@platforms//os:wasi" + ] + } + }, + "rust_linux_aarch64": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "rust_toolchain_set_repository", + "attributes": { + "toolchains": [ + "@rust_linux_aarch64__aarch64-unknown-linux-gnu__stable//:toolchain", + "@rust_linux_aarch64__aarch64-unknown-linux-gnu__nightly//:toolchain", + "@rust_linux_aarch64__wasm32-unknown-unknown__stable//:toolchain", + "@rust_linux_aarch64__wasm32-unknown-unknown__nightly//:toolchain", + "@rust_linux_aarch64__wasm32-wasi__stable//:toolchain", + "@rust_linux_aarch64__wasm32-wasi__nightly//:toolchain" + ] + } + }, + "rustfmt_nightly-2024-09-05__aarch64-unknown-linux-gnu_tools": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "rustfmt_toolchain_tools_repository", + "attributes": { + "version": "nightly/2024-09-05", + "sha256s": {}, + "urls": [ + "https://static.rust-lang.org/dist/{}.tar.xz" + ], + "auth": {}, + "netrc": "", + "auth_patterns": {}, + "exec_triple": "aarch64-unknown-linux-gnu" + } + }, + "rustfmt_nightly-2024-09-05__aarch64-unknown-linux-gnu": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "toolchain_repository_proxy", + "attributes": { + "toolchain": "@rustfmt_nightly-2024-09-05__aarch64-unknown-linux-gnu_tools//:rustfmt_toolchain", + "toolchain_type": "@rules_rust//rust/rustfmt:toolchain_type", + "target_settings": [], + "exec_compatible_with": [ + "@platforms//cpu:aarch64", + "@platforms//os:linux" + ], + "target_compatible_with": [] + } + }, + "rust_linux_s390x__s390x-unknown-linux-gnu__stable_tools": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "rust_toolchain_tools_repository", + "attributes": { + "exec_triple": "s390x-unknown-linux-gnu", + "allocator_library": "@rules_rust//ffi/cc/allocator_library", + "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", + "target_triple": "s390x-unknown-linux-gnu", + "version": "1.81.0", + "rustfmt_version": "nightly/2024-09-05", + "edition": "2021", + "dev_components": false, + "extra_rustc_flags": [], + "extra_exec_rustc_flags": [], + "opt_level": {}, + "sha256s": {}, + "urls": [ + "https://static.rust-lang.org/dist/{}.tar.xz" + ], + "auth": {}, + "netrc": "", + "auth_patterns": [] + } + }, + "rust_linux_s390x__s390x-unknown-linux-gnu__stable": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "toolchain_repository_proxy", + "attributes": { + "toolchain": "@rust_linux_s390x__s390x-unknown-linux-gnu__stable_tools//:rust_toolchain", + "target_settings": [ + "@rules_rust//rust/toolchain/channel:stable" + ], + "toolchain_type": "@rules_rust//rust:toolchain", + "exec_compatible_with": [ + "@platforms//cpu:s390x", + "@platforms//os:linux" + ], + "target_compatible_with": [ + "@platforms//cpu:s390x", + "@platforms//os:linux" + ] + } + }, + "rust_linux_s390x__s390x-unknown-linux-gnu__nightly_tools": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "rust_toolchain_tools_repository", + "attributes": { + "exec_triple": "s390x-unknown-linux-gnu", + "allocator_library": "@rules_rust//ffi/cc/allocator_library", + "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", + "target_triple": "s390x-unknown-linux-gnu", + "version": "nightly/2024-09-05", + "rustfmt_version": "nightly/2024-09-05", + "edition": "2021", + "dev_components": false, + "extra_rustc_flags": [], + "extra_exec_rustc_flags": [], + "opt_level": {}, + "sha256s": {}, + "urls": [ + "https://static.rust-lang.org/dist/{}.tar.xz" + ], + "auth": {}, + "netrc": "", + "auth_patterns": [] + } + }, + "rust_linux_s390x__s390x-unknown-linux-gnu__nightly": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "toolchain_repository_proxy", + "attributes": { + "toolchain": "@rust_linux_s390x__s390x-unknown-linux-gnu__nightly_tools//:rust_toolchain", + "target_settings": [ + "@rules_rust//rust/toolchain/channel:nightly" + ], + "toolchain_type": "@rules_rust//rust:toolchain", + "exec_compatible_with": [ + "@platforms//cpu:s390x", + "@platforms//os:linux" + ], + "target_compatible_with": [ + "@platforms//cpu:s390x", + "@platforms//os:linux" + ] + } + }, + "rust_linux_s390x__wasm32-unknown-unknown__stable_tools": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "rust_toolchain_tools_repository", + "attributes": { + "exec_triple": "s390x-unknown-linux-gnu", + "allocator_library": "@rules_rust//ffi/cc/allocator_library", + "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", + "target_triple": "wasm32-unknown-unknown", + "version": "1.81.0", + "rustfmt_version": "nightly/2024-09-05", + "edition": "2021", + "dev_components": false, + "extra_rustc_flags": [], + "extra_exec_rustc_flags": [], + "opt_level": {}, + "sha256s": {}, + "urls": [ + "https://static.rust-lang.org/dist/{}.tar.xz" + ], + "auth": {}, + "netrc": "", + "auth_patterns": [] + } + }, + "rust_linux_s390x__wasm32-unknown-unknown__stable": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "toolchain_repository_proxy", + "attributes": { + "toolchain": "@rust_linux_s390x__wasm32-unknown-unknown__stable_tools//:rust_toolchain", + "target_settings": [ + "@rules_rust//rust/toolchain/channel:stable" + ], + "toolchain_type": "@rules_rust//rust:toolchain", + "exec_compatible_with": [ + "@platforms//cpu:s390x", + "@platforms//os:linux" + ], + "target_compatible_with": [ + "@platforms//cpu:wasm32", + "@platforms//os:none" + ] + } + }, + "rust_linux_s390x__wasm32-unknown-unknown__nightly_tools": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "rust_toolchain_tools_repository", + "attributes": { + "exec_triple": "s390x-unknown-linux-gnu", + "allocator_library": "@rules_rust//ffi/cc/allocator_library", + "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", + "target_triple": "wasm32-unknown-unknown", + "version": "nightly/2024-09-05", + "rustfmt_version": "nightly/2024-09-05", + "edition": "2021", + "dev_components": false, + "extra_rustc_flags": [], + "extra_exec_rustc_flags": [], + "opt_level": {}, + "sha256s": {}, + "urls": [ + "https://static.rust-lang.org/dist/{}.tar.xz" + ], + "auth": {}, + "netrc": "", + "auth_patterns": [] + } + }, + "rust_linux_s390x__wasm32-unknown-unknown__nightly": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "toolchain_repository_proxy", + "attributes": { + "toolchain": "@rust_linux_s390x__wasm32-unknown-unknown__nightly_tools//:rust_toolchain", + "target_settings": [ + "@rules_rust//rust/toolchain/channel:nightly" + ], + "toolchain_type": "@rules_rust//rust:toolchain", + "exec_compatible_with": [ + "@platforms//cpu:s390x", + "@platforms//os:linux" + ], + "target_compatible_with": [ + "@platforms//cpu:wasm32", + "@platforms//os:none" + ] + } + }, + "rust_linux_s390x__wasm32-wasi__stable_tools": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "rust_toolchain_tools_repository", + "attributes": { + "exec_triple": "s390x-unknown-linux-gnu", + "allocator_library": "@rules_rust//ffi/cc/allocator_library", + "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", + "target_triple": "wasm32-wasi", + "version": "1.81.0", + "rustfmt_version": "nightly/2024-09-05", + "edition": "2021", + "dev_components": false, + "extra_rustc_flags": [], + "extra_exec_rustc_flags": [], + "opt_level": {}, + "sha256s": {}, + "urls": [ + "https://static.rust-lang.org/dist/{}.tar.xz" + ], + "auth": {}, + "netrc": "", + "auth_patterns": [] + } + }, + "rust_linux_s390x__wasm32-wasi__stable": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "toolchain_repository_proxy", + "attributes": { + "toolchain": "@rust_linux_s390x__wasm32-wasi__stable_tools//:rust_toolchain", + "target_settings": [ + "@rules_rust//rust/toolchain/channel:stable" + ], + "toolchain_type": "@rules_rust//rust:toolchain", + "exec_compatible_with": [ + "@platforms//cpu:s390x", + "@platforms//os:linux" + ], + "target_compatible_with": [ + "@platforms//cpu:wasm32", + "@platforms//os:wasi" + ] + } + }, + "rust_linux_s390x__wasm32-wasi__nightly_tools": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "rust_toolchain_tools_repository", + "attributes": { + "exec_triple": "s390x-unknown-linux-gnu", + "allocator_library": "@rules_rust//ffi/cc/allocator_library", + "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", + "target_triple": "wasm32-wasi", + "version": "nightly/2024-09-05", + "rustfmt_version": "nightly/2024-09-05", + "edition": "2021", + "dev_components": false, + "extra_rustc_flags": [], + "extra_exec_rustc_flags": [], + "opt_level": {}, + "sha256s": {}, + "urls": [ + "https://static.rust-lang.org/dist/{}.tar.xz" + ], + "auth": {}, + "netrc": "", + "auth_patterns": [] + } + }, + "rust_linux_s390x__wasm32-wasi__nightly": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "toolchain_repository_proxy", + "attributes": { + "toolchain": "@rust_linux_s390x__wasm32-wasi__nightly_tools//:rust_toolchain", + "target_settings": [ + "@rules_rust//rust/toolchain/channel:nightly" + ], + "toolchain_type": "@rules_rust//rust:toolchain", + "exec_compatible_with": [ + "@platforms//cpu:s390x", + "@platforms//os:linux" + ], + "target_compatible_with": [ + "@platforms//cpu:wasm32", + "@platforms//os:wasi" + ] + } + }, + "rust_linux_s390x": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "rust_toolchain_set_repository", + "attributes": { + "toolchains": [ + "@rust_linux_s390x__s390x-unknown-linux-gnu__stable//:toolchain", + "@rust_linux_s390x__s390x-unknown-linux-gnu__nightly//:toolchain", + "@rust_linux_s390x__wasm32-unknown-unknown__stable//:toolchain", + "@rust_linux_s390x__wasm32-unknown-unknown__nightly//:toolchain", + "@rust_linux_s390x__wasm32-wasi__stable//:toolchain", + "@rust_linux_s390x__wasm32-wasi__nightly//:toolchain" + ] + } + }, + "rustfmt_nightly-2024-09-05__s390x-unknown-linux-gnu_tools": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "rustfmt_toolchain_tools_repository", + "attributes": { + "version": "nightly/2024-09-05", + "sha256s": {}, + "urls": [ + "https://static.rust-lang.org/dist/{}.tar.xz" + ], + "auth": {}, + "netrc": "", + "auth_patterns": {}, + "exec_triple": "s390x-unknown-linux-gnu" + } + }, + "rustfmt_nightly-2024-09-05__s390x-unknown-linux-gnu": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "toolchain_repository_proxy", + "attributes": { + "toolchain": "@rustfmt_nightly-2024-09-05__s390x-unknown-linux-gnu_tools//:rustfmt_toolchain", + "toolchain_type": "@rules_rust//rust/rustfmt:toolchain_type", + "target_settings": [], + "exec_compatible_with": [ + "@platforms//cpu:s390x", + "@platforms//os:linux" + ], + "target_compatible_with": [] + } + }, + "rust_darwin_x86_64__x86_64-apple-darwin__stable_tools": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "rust_toolchain_tools_repository", + "attributes": { + "exec_triple": "x86_64-apple-darwin", + "allocator_library": "@rules_rust//ffi/cc/allocator_library", + "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", + "target_triple": "x86_64-apple-darwin", + "version": "1.81.0", + "rustfmt_version": "nightly/2024-09-05", + "edition": "2021", + "dev_components": false, + "extra_rustc_flags": [], + "extra_exec_rustc_flags": [], + "opt_level": {}, + "sha256s": {}, + "urls": [ + "https://static.rust-lang.org/dist/{}.tar.xz" + ], + "auth": {}, + "netrc": "", + "auth_patterns": [] + } + }, + "rust_darwin_x86_64__x86_64-apple-darwin__stable": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "toolchain_repository_proxy", + "attributes": { + "toolchain": "@rust_darwin_x86_64__x86_64-apple-darwin__stable_tools//:rust_toolchain", + "target_settings": [ + "@rules_rust//rust/toolchain/channel:stable" + ], + "toolchain_type": "@rules_rust//rust:toolchain", + "exec_compatible_with": [ + "@platforms//cpu:x86_64", + "@platforms//os:osx" + ], + "target_compatible_with": [ + "@platforms//cpu:x86_64", + "@platforms//os:osx" + ] + } + }, + "rust_darwin_x86_64__x86_64-apple-darwin__nightly_tools": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "rust_toolchain_tools_repository", + "attributes": { + "exec_triple": "x86_64-apple-darwin", + "allocator_library": "@rules_rust//ffi/cc/allocator_library", + "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", + "target_triple": "x86_64-apple-darwin", + "version": "nightly/2024-09-05", + "rustfmt_version": "nightly/2024-09-05", + "edition": "2021", + "dev_components": false, + "extra_rustc_flags": [], + "extra_exec_rustc_flags": [], + "opt_level": {}, + "sha256s": {}, + "urls": [ + "https://static.rust-lang.org/dist/{}.tar.xz" + ], + "auth": {}, + "netrc": "", + "auth_patterns": [] + } + }, + "rust_darwin_x86_64__x86_64-apple-darwin__nightly": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "toolchain_repository_proxy", + "attributes": { + "toolchain": "@rust_darwin_x86_64__x86_64-apple-darwin__nightly_tools//:rust_toolchain", + "target_settings": [ + "@rules_rust//rust/toolchain/channel:nightly" + ], + "toolchain_type": "@rules_rust//rust:toolchain", + "exec_compatible_with": [ + "@platforms//cpu:x86_64", + "@platforms//os:osx" + ], + "target_compatible_with": [ + "@platforms//cpu:x86_64", + "@platforms//os:osx" + ] + } + }, + "rust_darwin_x86_64__wasm32-unknown-unknown__stable_tools": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "rust_toolchain_tools_repository", + "attributes": { + "exec_triple": "x86_64-apple-darwin", + "allocator_library": "@rules_rust//ffi/cc/allocator_library", + "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", + "target_triple": "wasm32-unknown-unknown", + "version": "1.81.0", + "rustfmt_version": "nightly/2024-09-05", + "edition": "2021", + "dev_components": false, + "extra_rustc_flags": [], + "extra_exec_rustc_flags": [], + "opt_level": {}, + "sha256s": {}, + "urls": [ + "https://static.rust-lang.org/dist/{}.tar.xz" + ], + "auth": {}, + "netrc": "", + "auth_patterns": [] + } + }, + "rust_darwin_x86_64__wasm32-unknown-unknown__stable": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "toolchain_repository_proxy", + "attributes": { + "toolchain": "@rust_darwin_x86_64__wasm32-unknown-unknown__stable_tools//:rust_toolchain", + "target_settings": [ + "@rules_rust//rust/toolchain/channel:stable" + ], + "toolchain_type": "@rules_rust//rust:toolchain", + "exec_compatible_with": [ + "@platforms//cpu:x86_64", + "@platforms//os:osx" + ], + "target_compatible_with": [ + "@platforms//cpu:wasm32", + "@platforms//os:none" + ] + } + }, + "rust_darwin_x86_64__wasm32-unknown-unknown__nightly_tools": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "rust_toolchain_tools_repository", + "attributes": { + "exec_triple": "x86_64-apple-darwin", + "allocator_library": "@rules_rust//ffi/cc/allocator_library", + "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", + "target_triple": "wasm32-unknown-unknown", + "version": "nightly/2024-09-05", + "rustfmt_version": "nightly/2024-09-05", + "edition": "2021", + "dev_components": false, + "extra_rustc_flags": [], + "extra_exec_rustc_flags": [], + "opt_level": {}, + "sha256s": {}, + "urls": [ + "https://static.rust-lang.org/dist/{}.tar.xz" + ], + "auth": {}, + "netrc": "", + "auth_patterns": [] + } + }, + "rust_darwin_x86_64__wasm32-unknown-unknown__nightly": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "toolchain_repository_proxy", + "attributes": { + "toolchain": "@rust_darwin_x86_64__wasm32-unknown-unknown__nightly_tools//:rust_toolchain", + "target_settings": [ + "@rules_rust//rust/toolchain/channel:nightly" + ], + "toolchain_type": "@rules_rust//rust:toolchain", + "exec_compatible_with": [ + "@platforms//cpu:x86_64", + "@platforms//os:osx" + ], + "target_compatible_with": [ + "@platforms//cpu:wasm32", + "@platforms//os:none" + ] + } + }, + "rust_darwin_x86_64__wasm32-wasi__stable_tools": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "rust_toolchain_tools_repository", + "attributes": { + "exec_triple": "x86_64-apple-darwin", + "allocator_library": "@rules_rust//ffi/cc/allocator_library", + "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", + "target_triple": "wasm32-wasi", + "version": "1.81.0", + "rustfmt_version": "nightly/2024-09-05", + "edition": "2021", + "dev_components": false, + "extra_rustc_flags": [], + "extra_exec_rustc_flags": [], + "opt_level": {}, + "sha256s": {}, + "urls": [ + "https://static.rust-lang.org/dist/{}.tar.xz" + ], + "auth": {}, + "netrc": "", + "auth_patterns": [] + } + }, + "rust_darwin_x86_64__wasm32-wasi__stable": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "toolchain_repository_proxy", + "attributes": { + "toolchain": "@rust_darwin_x86_64__wasm32-wasi__stable_tools//:rust_toolchain", + "target_settings": [ + "@rules_rust//rust/toolchain/channel:stable" + ], + "toolchain_type": "@rules_rust//rust:toolchain", + "exec_compatible_with": [ + "@platforms//cpu:x86_64", + "@platforms//os:osx" + ], + "target_compatible_with": [ + "@platforms//cpu:wasm32", + "@platforms//os:wasi" + ] + } + }, + "rust_darwin_x86_64__wasm32-wasi__nightly_tools": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "rust_toolchain_tools_repository", + "attributes": { + "exec_triple": "x86_64-apple-darwin", + "allocator_library": "@rules_rust//ffi/cc/allocator_library", + "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", + "target_triple": "wasm32-wasi", + "version": "nightly/2024-09-05", + "rustfmt_version": "nightly/2024-09-05", + "edition": "2021", + "dev_components": false, + "extra_rustc_flags": [], + "extra_exec_rustc_flags": [], + "opt_level": {}, + "sha256s": {}, + "urls": [ + "https://static.rust-lang.org/dist/{}.tar.xz" + ], + "auth": {}, + "netrc": "", + "auth_patterns": [] + } + }, + "rust_darwin_x86_64__wasm32-wasi__nightly": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "toolchain_repository_proxy", + "attributes": { + "toolchain": "@rust_darwin_x86_64__wasm32-wasi__nightly_tools//:rust_toolchain", + "target_settings": [ + "@rules_rust//rust/toolchain/channel:nightly" + ], + "toolchain_type": "@rules_rust//rust:toolchain", + "exec_compatible_with": [ + "@platforms//cpu:x86_64", + "@platforms//os:osx" + ], + "target_compatible_with": [ + "@platforms//cpu:wasm32", + "@platforms//os:wasi" + ] + } + }, + "rust_darwin_x86_64": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "rust_toolchain_set_repository", + "attributes": { + "toolchains": [ + "@rust_darwin_x86_64__x86_64-apple-darwin__stable//:toolchain", + "@rust_darwin_x86_64__x86_64-apple-darwin__nightly//:toolchain", + "@rust_darwin_x86_64__wasm32-unknown-unknown__stable//:toolchain", + "@rust_darwin_x86_64__wasm32-unknown-unknown__nightly//:toolchain", + "@rust_darwin_x86_64__wasm32-wasi__stable//:toolchain", + "@rust_darwin_x86_64__wasm32-wasi__nightly//:toolchain" + ] + } + }, + "rustfmt_nightly-2024-09-05__x86_64-apple-darwin_tools": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "rustfmt_toolchain_tools_repository", + "attributes": { + "version": "nightly/2024-09-05", + "sha256s": {}, + "urls": [ + "https://static.rust-lang.org/dist/{}.tar.xz" + ], + "auth": {}, + "netrc": "", + "auth_patterns": {}, + "exec_triple": "x86_64-apple-darwin" + } + }, + "rustfmt_nightly-2024-09-05__x86_64-apple-darwin": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "toolchain_repository_proxy", + "attributes": { + "toolchain": "@rustfmt_nightly-2024-09-05__x86_64-apple-darwin_tools//:rustfmt_toolchain", + "toolchain_type": "@rules_rust//rust/rustfmt:toolchain_type", + "target_settings": [], + "exec_compatible_with": [ + "@platforms//cpu:x86_64", + "@platforms//os:osx" + ], + "target_compatible_with": [] + } + }, + "rust_windows_x86_64__x86_64-pc-windows-msvc__stable_tools": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "rust_toolchain_tools_repository", + "attributes": { + "exec_triple": "x86_64-pc-windows-msvc", + "allocator_library": "@rules_rust//ffi/cc/allocator_library", + "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", + "target_triple": "x86_64-pc-windows-msvc", + "version": "1.81.0", + "rustfmt_version": "nightly/2024-09-05", + "edition": "2021", + "dev_components": false, + "extra_rustc_flags": [], + "extra_exec_rustc_flags": [], + "opt_level": {}, + "sha256s": {}, + "urls": [ + "https://static.rust-lang.org/dist/{}.tar.xz" + ], + "auth": {}, + "netrc": "", + "auth_patterns": [] + } + }, + "rust_windows_x86_64__x86_64-pc-windows-msvc__stable": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "toolchain_repository_proxy", + "attributes": { + "toolchain": "@rust_windows_x86_64__x86_64-pc-windows-msvc__stable_tools//:rust_toolchain", + "target_settings": [ + "@rules_rust//rust/toolchain/channel:stable" + ], + "toolchain_type": "@rules_rust//rust:toolchain", + "exec_compatible_with": [ + "@platforms//cpu:x86_64", + "@platforms//os:windows" + ], + "target_compatible_with": [ + "@platforms//cpu:x86_64", + "@platforms//os:windows" + ] + } + }, + "rust_windows_x86_64__x86_64-pc-windows-msvc__nightly_tools": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "rust_toolchain_tools_repository", + "attributes": { + "exec_triple": "x86_64-pc-windows-msvc", + "allocator_library": "@rules_rust//ffi/cc/allocator_library", + "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", + "target_triple": "x86_64-pc-windows-msvc", + "version": "nightly/2024-09-05", + "rustfmt_version": "nightly/2024-09-05", + "edition": "2021", + "dev_components": false, + "extra_rustc_flags": [], + "extra_exec_rustc_flags": [], + "opt_level": {}, + "sha256s": {}, + "urls": [ + "https://static.rust-lang.org/dist/{}.tar.xz" + ], + "auth": {}, + "netrc": "", + "auth_patterns": [] + } + }, + "rust_windows_x86_64__x86_64-pc-windows-msvc__nightly": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "toolchain_repository_proxy", + "attributes": { + "toolchain": "@rust_windows_x86_64__x86_64-pc-windows-msvc__nightly_tools//:rust_toolchain", + "target_settings": [ + "@rules_rust//rust/toolchain/channel:nightly" + ], + "toolchain_type": "@rules_rust//rust:toolchain", + "exec_compatible_with": [ + "@platforms//cpu:x86_64", + "@platforms//os:windows" + ], + "target_compatible_with": [ + "@platforms//cpu:x86_64", + "@platforms//os:windows" + ] + } + }, + "rust_windows_x86_64__wasm32-unknown-unknown__stable_tools": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "rust_toolchain_tools_repository", + "attributes": { + "exec_triple": "x86_64-pc-windows-msvc", + "allocator_library": "@rules_rust//ffi/cc/allocator_library", + "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", + "target_triple": "wasm32-unknown-unknown", + "version": "1.81.0", + "rustfmt_version": "nightly/2024-09-05", + "edition": "2021", + "dev_components": false, + "extra_rustc_flags": [], + "extra_exec_rustc_flags": [], + "opt_level": {}, + "sha256s": {}, + "urls": [ + "https://static.rust-lang.org/dist/{}.tar.xz" + ], + "auth": {}, + "netrc": "", + "auth_patterns": [] + } + }, + "rust_windows_x86_64__wasm32-unknown-unknown__stable": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "toolchain_repository_proxy", + "attributes": { + "toolchain": "@rust_windows_x86_64__wasm32-unknown-unknown__stable_tools//:rust_toolchain", + "target_settings": [ + "@rules_rust//rust/toolchain/channel:stable" + ], + "toolchain_type": "@rules_rust//rust:toolchain", + "exec_compatible_with": [ + "@platforms//cpu:x86_64", + "@platforms//os:windows" + ], + "target_compatible_with": [ + "@platforms//cpu:wasm32", + "@platforms//os:none" + ] + } + }, + "rust_windows_x86_64__wasm32-unknown-unknown__nightly_tools": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "rust_toolchain_tools_repository", + "attributes": { + "exec_triple": "x86_64-pc-windows-msvc", + "allocator_library": "@rules_rust//ffi/cc/allocator_library", + "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", + "target_triple": "wasm32-unknown-unknown", + "version": "nightly/2024-09-05", + "rustfmt_version": "nightly/2024-09-05", + "edition": "2021", + "dev_components": false, + "extra_rustc_flags": [], + "extra_exec_rustc_flags": [], + "opt_level": {}, + "sha256s": {}, + "urls": [ + "https://static.rust-lang.org/dist/{}.tar.xz" + ], + "auth": {}, + "netrc": "", + "auth_patterns": [] + } + }, + "rust_windows_x86_64__wasm32-unknown-unknown__nightly": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "toolchain_repository_proxy", + "attributes": { + "toolchain": "@rust_windows_x86_64__wasm32-unknown-unknown__nightly_tools//:rust_toolchain", + "target_settings": [ + "@rules_rust//rust/toolchain/channel:nightly" + ], + "toolchain_type": "@rules_rust//rust:toolchain", + "exec_compatible_with": [ + "@platforms//cpu:x86_64", + "@platforms//os:windows" + ], + "target_compatible_with": [ + "@platforms//cpu:wasm32", + "@platforms//os:none" + ] + } + }, + "rust_windows_x86_64__wasm32-wasi__stable_tools": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "rust_toolchain_tools_repository", + "attributes": { + "exec_triple": "x86_64-pc-windows-msvc", + "allocator_library": "@rules_rust//ffi/cc/allocator_library", + "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", + "target_triple": "wasm32-wasi", + "version": "1.81.0", + "rustfmt_version": "nightly/2024-09-05", + "edition": "2021", + "dev_components": false, + "extra_rustc_flags": [], + "extra_exec_rustc_flags": [], + "opt_level": {}, + "sha256s": {}, + "urls": [ + "https://static.rust-lang.org/dist/{}.tar.xz" + ], + "auth": {}, + "netrc": "", + "auth_patterns": [] + } + }, + "rust_windows_x86_64__wasm32-wasi__stable": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "toolchain_repository_proxy", + "attributes": { + "toolchain": "@rust_windows_x86_64__wasm32-wasi__stable_tools//:rust_toolchain", + "target_settings": [ + "@rules_rust//rust/toolchain/channel:stable" + ], + "toolchain_type": "@rules_rust//rust:toolchain", + "exec_compatible_with": [ + "@platforms//cpu:x86_64", + "@platforms//os:windows" + ], + "target_compatible_with": [ + "@platforms//cpu:wasm32", + "@platforms//os:wasi" + ] + } + }, + "rust_windows_x86_64__wasm32-wasi__nightly_tools": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "rust_toolchain_tools_repository", + "attributes": { + "exec_triple": "x86_64-pc-windows-msvc", + "allocator_library": "@rules_rust//ffi/cc/allocator_library", + "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", + "target_triple": "wasm32-wasi", + "version": "nightly/2024-09-05", + "rustfmt_version": "nightly/2024-09-05", + "edition": "2021", + "dev_components": false, + "extra_rustc_flags": [], + "extra_exec_rustc_flags": [], + "opt_level": {}, + "sha256s": {}, + "urls": [ + "https://static.rust-lang.org/dist/{}.tar.xz" + ], + "auth": {}, + "netrc": "", + "auth_patterns": [] + } + }, + "rust_windows_x86_64__wasm32-wasi__nightly": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "toolchain_repository_proxy", + "attributes": { + "toolchain": "@rust_windows_x86_64__wasm32-wasi__nightly_tools//:rust_toolchain", + "target_settings": [ + "@rules_rust//rust/toolchain/channel:nightly" + ], + "toolchain_type": "@rules_rust//rust:toolchain", + "exec_compatible_with": [ + "@platforms//cpu:x86_64", + "@platforms//os:windows" + ], + "target_compatible_with": [ + "@platforms//cpu:wasm32", + "@platforms//os:wasi" + ] + } + }, + "rust_windows_x86_64": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "rust_toolchain_set_repository", + "attributes": { + "toolchains": [ + "@rust_windows_x86_64__x86_64-pc-windows-msvc__stable//:toolchain", + "@rust_windows_x86_64__x86_64-pc-windows-msvc__nightly//:toolchain", + "@rust_windows_x86_64__wasm32-unknown-unknown__stable//:toolchain", + "@rust_windows_x86_64__wasm32-unknown-unknown__nightly//:toolchain", + "@rust_windows_x86_64__wasm32-wasi__stable//:toolchain", + "@rust_windows_x86_64__wasm32-wasi__nightly//:toolchain" + ] + } + }, + "rustfmt_nightly-2024-09-05__x86_64-pc-windows-msvc_tools": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "rustfmt_toolchain_tools_repository", + "attributes": { + "version": "nightly/2024-09-05", + "sha256s": {}, + "urls": [ + "https://static.rust-lang.org/dist/{}.tar.xz" + ], + "auth": {}, + "netrc": "", + "auth_patterns": {}, + "exec_triple": "x86_64-pc-windows-msvc" + } + }, + "rustfmt_nightly-2024-09-05__x86_64-pc-windows-msvc": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "toolchain_repository_proxy", + "attributes": { + "toolchain": "@rustfmt_nightly-2024-09-05__x86_64-pc-windows-msvc_tools//:rustfmt_toolchain", + "toolchain_type": "@rules_rust//rust/rustfmt:toolchain_type", + "target_settings": [], + "exec_compatible_with": [ + "@platforms//cpu:x86_64", + "@platforms//os:windows" + ], + "target_compatible_with": [] + } + }, + "rust_freebsd_x86_64__x86_64-unknown-freebsd__stable_tools": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "rust_toolchain_tools_repository", + "attributes": { + "exec_triple": "x86_64-unknown-freebsd", + "allocator_library": "@rules_rust//ffi/cc/allocator_library", + "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", + "target_triple": "x86_64-unknown-freebsd", + "version": "1.81.0", + "rustfmt_version": "nightly/2024-09-05", + "edition": "2021", + "dev_components": false, + "extra_rustc_flags": [], + "extra_exec_rustc_flags": [], + "opt_level": {}, + "sha256s": {}, + "urls": [ + "https://static.rust-lang.org/dist/{}.tar.xz" + ], + "auth": {}, + "netrc": "", + "auth_patterns": [] + } + }, + "rust_freebsd_x86_64__x86_64-unknown-freebsd__stable": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "toolchain_repository_proxy", + "attributes": { + "toolchain": "@rust_freebsd_x86_64__x86_64-unknown-freebsd__stable_tools//:rust_toolchain", + "target_settings": [ + "@rules_rust//rust/toolchain/channel:stable" + ], + "toolchain_type": "@rules_rust//rust:toolchain", + "exec_compatible_with": [ + "@platforms//cpu:x86_64", + "@platforms//os:freebsd" + ], + "target_compatible_with": [ + "@platforms//cpu:x86_64", + "@platforms//os:freebsd" + ] + } + }, + "rust_freebsd_x86_64__x86_64-unknown-freebsd__nightly_tools": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "rust_toolchain_tools_repository", + "attributes": { + "exec_triple": "x86_64-unknown-freebsd", + "allocator_library": "@rules_rust//ffi/cc/allocator_library", + "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", + "target_triple": "x86_64-unknown-freebsd", + "version": "nightly/2024-09-05", + "rustfmt_version": "nightly/2024-09-05", + "edition": "2021", + "dev_components": false, + "extra_rustc_flags": [], + "extra_exec_rustc_flags": [], + "opt_level": {}, + "sha256s": {}, + "urls": [ + "https://static.rust-lang.org/dist/{}.tar.xz" + ], + "auth": {}, + "netrc": "", + "auth_patterns": [] + } + }, + "rust_freebsd_x86_64__x86_64-unknown-freebsd__nightly": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "toolchain_repository_proxy", + "attributes": { + "toolchain": "@rust_freebsd_x86_64__x86_64-unknown-freebsd__nightly_tools//:rust_toolchain", + "target_settings": [ + "@rules_rust//rust/toolchain/channel:nightly" + ], + "toolchain_type": "@rules_rust//rust:toolchain", + "exec_compatible_with": [ + "@platforms//cpu:x86_64", + "@platforms//os:freebsd" + ], + "target_compatible_with": [ + "@platforms//cpu:x86_64", + "@platforms//os:freebsd" + ] + } + }, + "rust_freebsd_x86_64__wasm32-unknown-unknown__stable_tools": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "rust_toolchain_tools_repository", + "attributes": { + "exec_triple": "x86_64-unknown-freebsd", + "allocator_library": "@rules_rust//ffi/cc/allocator_library", + "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", + "target_triple": "wasm32-unknown-unknown", + "version": "1.81.0", + "rustfmt_version": "nightly/2024-09-05", + "edition": "2021", + "dev_components": false, + "extra_rustc_flags": [], + "extra_exec_rustc_flags": [], + "opt_level": {}, + "sha256s": {}, + "urls": [ + "https://static.rust-lang.org/dist/{}.tar.xz" + ], + "auth": {}, + "netrc": "", + "auth_patterns": [] + } + }, + "rust_freebsd_x86_64__wasm32-unknown-unknown__stable": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "toolchain_repository_proxy", + "attributes": { + "toolchain": "@rust_freebsd_x86_64__wasm32-unknown-unknown__stable_tools//:rust_toolchain", + "target_settings": [ + "@rules_rust//rust/toolchain/channel:stable" + ], + "toolchain_type": "@rules_rust//rust:toolchain", + "exec_compatible_with": [ + "@platforms//cpu:x86_64", + "@platforms//os:freebsd" + ], + "target_compatible_with": [ + "@platforms//cpu:wasm32", + "@platforms//os:none" + ] + } + }, + "rust_freebsd_x86_64__wasm32-unknown-unknown__nightly_tools": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "rust_toolchain_tools_repository", + "attributes": { + "exec_triple": "x86_64-unknown-freebsd", + "allocator_library": "@rules_rust//ffi/cc/allocator_library", + "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", + "target_triple": "wasm32-unknown-unknown", + "version": "nightly/2024-09-05", + "rustfmt_version": "nightly/2024-09-05", + "edition": "2021", + "dev_components": false, + "extra_rustc_flags": [], + "extra_exec_rustc_flags": [], + "opt_level": {}, + "sha256s": {}, + "urls": [ + "https://static.rust-lang.org/dist/{}.tar.xz" + ], + "auth": {}, + "netrc": "", + "auth_patterns": [] + } + }, + "rust_freebsd_x86_64__wasm32-unknown-unknown__nightly": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "toolchain_repository_proxy", + "attributes": { + "toolchain": "@rust_freebsd_x86_64__wasm32-unknown-unknown__nightly_tools//:rust_toolchain", + "target_settings": [ + "@rules_rust//rust/toolchain/channel:nightly" + ], + "toolchain_type": "@rules_rust//rust:toolchain", + "exec_compatible_with": [ + "@platforms//cpu:x86_64", + "@platforms//os:freebsd" + ], + "target_compatible_with": [ + "@platforms//cpu:wasm32", + "@platforms//os:none" + ] + } + }, + "rust_freebsd_x86_64__wasm32-wasi__stable_tools": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "rust_toolchain_tools_repository", + "attributes": { + "exec_triple": "x86_64-unknown-freebsd", + "allocator_library": "@rules_rust//ffi/cc/allocator_library", + "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", + "target_triple": "wasm32-wasi", + "version": "1.81.0", + "rustfmt_version": "nightly/2024-09-05", + "edition": "2021", + "dev_components": false, + "extra_rustc_flags": [], + "extra_exec_rustc_flags": [], + "opt_level": {}, + "sha256s": {}, + "urls": [ + "https://static.rust-lang.org/dist/{}.tar.xz" + ], + "auth": {}, + "netrc": "", + "auth_patterns": [] + } + }, + "rust_freebsd_x86_64__wasm32-wasi__stable": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "toolchain_repository_proxy", + "attributes": { + "toolchain": "@rust_freebsd_x86_64__wasm32-wasi__stable_tools//:rust_toolchain", + "target_settings": [ + "@rules_rust//rust/toolchain/channel:stable" + ], + "toolchain_type": "@rules_rust//rust:toolchain", + "exec_compatible_with": [ + "@platforms//cpu:x86_64", + "@platforms//os:freebsd" + ], + "target_compatible_with": [ + "@platforms//cpu:wasm32", + "@platforms//os:wasi" + ] + } + }, + "rust_freebsd_x86_64__wasm32-wasi__nightly_tools": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "rust_toolchain_tools_repository", + "attributes": { + "exec_triple": "x86_64-unknown-freebsd", + "allocator_library": "@rules_rust//ffi/cc/allocator_library", + "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", + "target_triple": "wasm32-wasi", + "version": "nightly/2024-09-05", + "rustfmt_version": "nightly/2024-09-05", + "edition": "2021", + "dev_components": false, + "extra_rustc_flags": [], + "extra_exec_rustc_flags": [], + "opt_level": {}, + "sha256s": {}, + "urls": [ + "https://static.rust-lang.org/dist/{}.tar.xz" + ], + "auth": {}, + "netrc": "", + "auth_patterns": [] + } + }, + "rust_freebsd_x86_64__wasm32-wasi__nightly": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "toolchain_repository_proxy", + "attributes": { + "toolchain": "@rust_freebsd_x86_64__wasm32-wasi__nightly_tools//:rust_toolchain", + "target_settings": [ + "@rules_rust//rust/toolchain/channel:nightly" + ], + "toolchain_type": "@rules_rust//rust:toolchain", + "exec_compatible_with": [ + "@platforms//cpu:x86_64", + "@platforms//os:freebsd" + ], + "target_compatible_with": [ + "@platforms//cpu:wasm32", + "@platforms//os:wasi" + ] + } + }, + "rust_freebsd_x86_64": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "rust_toolchain_set_repository", + "attributes": { + "toolchains": [ + "@rust_freebsd_x86_64__x86_64-unknown-freebsd__stable//:toolchain", + "@rust_freebsd_x86_64__x86_64-unknown-freebsd__nightly//:toolchain", + "@rust_freebsd_x86_64__wasm32-unknown-unknown__stable//:toolchain", + "@rust_freebsd_x86_64__wasm32-unknown-unknown__nightly//:toolchain", + "@rust_freebsd_x86_64__wasm32-wasi__stable//:toolchain", + "@rust_freebsd_x86_64__wasm32-wasi__nightly//:toolchain" + ] + } + }, + "rustfmt_nightly-2024-09-05__x86_64-unknown-freebsd_tools": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "rustfmt_toolchain_tools_repository", + "attributes": { + "version": "nightly/2024-09-05", + "sha256s": {}, + "urls": [ + "https://static.rust-lang.org/dist/{}.tar.xz" + ], + "auth": {}, + "netrc": "", + "auth_patterns": {}, + "exec_triple": "x86_64-unknown-freebsd" + } + }, + "rustfmt_nightly-2024-09-05__x86_64-unknown-freebsd": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "toolchain_repository_proxy", + "attributes": { + "toolchain": "@rustfmt_nightly-2024-09-05__x86_64-unknown-freebsd_tools//:rustfmt_toolchain", + "toolchain_type": "@rules_rust//rust/rustfmt:toolchain_type", + "target_settings": [], + "exec_compatible_with": [ + "@platforms//cpu:x86_64", + "@platforms//os:freebsd" + ], + "target_compatible_with": [] + } + }, + "rust_linux_x86_64__x86_64-unknown-linux-gnu__stable_tools": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "rust_toolchain_tools_repository", + "attributes": { + "exec_triple": "x86_64-unknown-linux-gnu", + "allocator_library": "@rules_rust//ffi/cc/allocator_library", + "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", + "target_triple": "x86_64-unknown-linux-gnu", + "version": "1.81.0", + "rustfmt_version": "nightly/2024-09-05", + "edition": "2021", + "dev_components": false, + "extra_rustc_flags": [], + "extra_exec_rustc_flags": [], + "opt_level": {}, + "sha256s": {}, + "urls": [ + "https://static.rust-lang.org/dist/{}.tar.xz" + ], + "auth": {}, + "netrc": "", + "auth_patterns": [] + } + }, + "rust_linux_x86_64__x86_64-unknown-linux-gnu__stable": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "toolchain_repository_proxy", + "attributes": { + "toolchain": "@rust_linux_x86_64__x86_64-unknown-linux-gnu__stable_tools//:rust_toolchain", + "target_settings": [ + "@rules_rust//rust/toolchain/channel:stable" + ], + "toolchain_type": "@rules_rust//rust:toolchain", + "exec_compatible_with": [ + "@platforms//cpu:x86_64", + "@platforms//os:linux" + ], + "target_compatible_with": [ + "@platforms//cpu:x86_64", + "@platforms//os:linux" + ] + } + }, + "rust_linux_x86_64__x86_64-unknown-linux-gnu__nightly_tools": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "rust_toolchain_tools_repository", + "attributes": { + "exec_triple": "x86_64-unknown-linux-gnu", + "allocator_library": "@rules_rust//ffi/cc/allocator_library", + "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", + "target_triple": "x86_64-unknown-linux-gnu", + "version": "nightly/2024-09-05", + "rustfmt_version": "nightly/2024-09-05", + "edition": "2021", + "dev_components": false, + "extra_rustc_flags": [], + "extra_exec_rustc_flags": [], + "opt_level": {}, + "sha256s": {}, + "urls": [ + "https://static.rust-lang.org/dist/{}.tar.xz" + ], + "auth": {}, + "netrc": "", + "auth_patterns": [] + } + }, + "rust_linux_x86_64__x86_64-unknown-linux-gnu__nightly": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "toolchain_repository_proxy", + "attributes": { + "toolchain": "@rust_linux_x86_64__x86_64-unknown-linux-gnu__nightly_tools//:rust_toolchain", + "target_settings": [ + "@rules_rust//rust/toolchain/channel:nightly" + ], + "toolchain_type": "@rules_rust//rust:toolchain", + "exec_compatible_with": [ + "@platforms//cpu:x86_64", + "@platforms//os:linux" + ], + "target_compatible_with": [ + "@platforms//cpu:x86_64", + "@platforms//os:linux" + ] + } + }, + "rust_linux_x86_64__wasm32-unknown-unknown__stable_tools": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "rust_toolchain_tools_repository", + "attributes": { + "exec_triple": "x86_64-unknown-linux-gnu", + "allocator_library": "@rules_rust//ffi/cc/allocator_library", + "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", + "target_triple": "wasm32-unknown-unknown", + "version": "1.81.0", + "rustfmt_version": "nightly/2024-09-05", + "edition": "2021", + "dev_components": false, + "extra_rustc_flags": [], + "extra_exec_rustc_flags": [], + "opt_level": {}, + "sha256s": {}, + "urls": [ + "https://static.rust-lang.org/dist/{}.tar.xz" + ], + "auth": {}, + "netrc": "", + "auth_patterns": [] + } + }, + "rust_linux_x86_64__wasm32-unknown-unknown__stable": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "toolchain_repository_proxy", + "attributes": { + "toolchain": "@rust_linux_x86_64__wasm32-unknown-unknown__stable_tools//:rust_toolchain", + "target_settings": [ + "@rules_rust//rust/toolchain/channel:stable" + ], + "toolchain_type": "@rules_rust//rust:toolchain", + "exec_compatible_with": [ + "@platforms//cpu:x86_64", + "@platforms//os:linux" + ], + "target_compatible_with": [ + "@platforms//cpu:wasm32", + "@platforms//os:none" + ] + } + }, + "rust_linux_x86_64__wasm32-unknown-unknown__nightly_tools": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "rust_toolchain_tools_repository", + "attributes": { + "exec_triple": "x86_64-unknown-linux-gnu", + "allocator_library": "@rules_rust//ffi/cc/allocator_library", + "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", + "target_triple": "wasm32-unknown-unknown", + "version": "nightly/2024-09-05", + "rustfmt_version": "nightly/2024-09-05", + "edition": "2021", + "dev_components": false, + "extra_rustc_flags": [], + "extra_exec_rustc_flags": [], + "opt_level": {}, + "sha256s": {}, + "urls": [ + "https://static.rust-lang.org/dist/{}.tar.xz" + ], + "auth": {}, + "netrc": "", + "auth_patterns": [] + } + }, + "rust_linux_x86_64__wasm32-unknown-unknown__nightly": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "toolchain_repository_proxy", + "attributes": { + "toolchain": "@rust_linux_x86_64__wasm32-unknown-unknown__nightly_tools//:rust_toolchain", + "target_settings": [ + "@rules_rust//rust/toolchain/channel:nightly" + ], + "toolchain_type": "@rules_rust//rust:toolchain", + "exec_compatible_with": [ + "@platforms//cpu:x86_64", + "@platforms//os:linux" + ], + "target_compatible_with": [ + "@platforms//cpu:wasm32", + "@platforms//os:none" + ] + } + }, + "rust_linux_x86_64__wasm32-wasi__stable_tools": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "rust_toolchain_tools_repository", + "attributes": { + "exec_triple": "x86_64-unknown-linux-gnu", + "allocator_library": "@rules_rust//ffi/cc/allocator_library", + "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", + "target_triple": "wasm32-wasi", + "version": "1.81.0", + "rustfmt_version": "nightly/2024-09-05", + "edition": "2021", + "dev_components": false, + "extra_rustc_flags": [], + "extra_exec_rustc_flags": [], + "opt_level": {}, + "sha256s": {}, + "urls": [ + "https://static.rust-lang.org/dist/{}.tar.xz" + ], + "auth": {}, + "netrc": "", + "auth_patterns": [] + } + }, + "rust_linux_x86_64__wasm32-wasi__stable": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "toolchain_repository_proxy", + "attributes": { + "toolchain": "@rust_linux_x86_64__wasm32-wasi__stable_tools//:rust_toolchain", + "target_settings": [ + "@rules_rust//rust/toolchain/channel:stable" + ], + "toolchain_type": "@rules_rust//rust:toolchain", + "exec_compatible_with": [ + "@platforms//cpu:x86_64", + "@platforms//os:linux" + ], + "target_compatible_with": [ + "@platforms//cpu:wasm32", + "@platforms//os:wasi" + ] + } + }, + "rust_linux_x86_64__wasm32-wasi__nightly_tools": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "rust_toolchain_tools_repository", + "attributes": { + "exec_triple": "x86_64-unknown-linux-gnu", + "allocator_library": "@rules_rust//ffi/cc/allocator_library", + "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library", + "target_triple": "wasm32-wasi", + "version": "nightly/2024-09-05", + "rustfmt_version": "nightly/2024-09-05", + "edition": "2021", + "dev_components": false, + "extra_rustc_flags": [], + "extra_exec_rustc_flags": [], + "opt_level": {}, + "sha256s": {}, + "urls": [ + "https://static.rust-lang.org/dist/{}.tar.xz" + ], + "auth": {}, + "netrc": "", + "auth_patterns": [] + } + }, + "rust_linux_x86_64__wasm32-wasi__nightly": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "toolchain_repository_proxy", + "attributes": { + "toolchain": "@rust_linux_x86_64__wasm32-wasi__nightly_tools//:rust_toolchain", + "target_settings": [ + "@rules_rust//rust/toolchain/channel:nightly" + ], + "toolchain_type": "@rules_rust//rust:toolchain", + "exec_compatible_with": [ + "@platforms//cpu:x86_64", + "@platforms//os:linux" + ], + "target_compatible_with": [ + "@platforms//cpu:wasm32", + "@platforms//os:wasi" + ] + } + }, + "rust_linux_x86_64": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "rust_toolchain_set_repository", + "attributes": { + "toolchains": [ + "@rust_linux_x86_64__x86_64-unknown-linux-gnu__stable//:toolchain", + "@rust_linux_x86_64__x86_64-unknown-linux-gnu__nightly//:toolchain", + "@rust_linux_x86_64__wasm32-unknown-unknown__stable//:toolchain", + "@rust_linux_x86_64__wasm32-unknown-unknown__nightly//:toolchain", + "@rust_linux_x86_64__wasm32-wasi__stable//:toolchain", + "@rust_linux_x86_64__wasm32-wasi__nightly//:toolchain" + ] + } + }, + "rustfmt_nightly-2024-09-05__x86_64-unknown-linux-gnu_tools": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "rustfmt_toolchain_tools_repository", + "attributes": { + "version": "nightly/2024-09-05", + "sha256s": {}, + "urls": [ + "https://static.rust-lang.org/dist/{}.tar.xz" + ], + "auth": {}, + "netrc": "", + "auth_patterns": {}, + "exec_triple": "x86_64-unknown-linux-gnu" + } + }, + "rustfmt_nightly-2024-09-05__x86_64-unknown-linux-gnu": { + "bzlFile": "@@rules_rust~//rust:repositories.bzl", + "ruleClassName": "toolchain_repository_proxy", + "attributes": { + "toolchain": "@rustfmt_nightly-2024-09-05__x86_64-unknown-linux-gnu_tools//:rustfmt_toolchain", + "toolchain_type": "@rules_rust//rust/rustfmt:toolchain_type", + "target_settings": [], + "exec_compatible_with": [ + "@platforms//cpu:x86_64", + "@platforms//os:linux" + ], + "target_compatible_with": [] + } + }, + "rust_toolchains": { + "bzlFile": "@@rules_rust~//rust/private:repository_utils.bzl", + "ruleClassName": "toolchain_repository_hub", + "attributes": { + "toolchain_names": [ + "rust_analyzer_1.81.0", + "rust_darwin_aarch64__aarch64-apple-darwin__stable", + "rust_darwin_aarch64__aarch64-apple-darwin__nightly", + "rust_darwin_aarch64__wasm32-unknown-unknown__stable", + "rust_darwin_aarch64__wasm32-unknown-unknown__nightly", + "rust_darwin_aarch64__wasm32-wasi__stable", + "rust_darwin_aarch64__wasm32-wasi__nightly", + "rustfmt_nightly-2024-09-05__aarch64-apple-darwin", + "rust_windows_aarch64__aarch64-pc-windows-msvc__stable", + "rust_windows_aarch64__aarch64-pc-windows-msvc__nightly", + "rust_windows_aarch64__wasm32-unknown-unknown__stable", + "rust_windows_aarch64__wasm32-unknown-unknown__nightly", + "rust_windows_aarch64__wasm32-wasi__stable", + "rust_windows_aarch64__wasm32-wasi__nightly", + "rustfmt_nightly-2024-09-05__aarch64-pc-windows-msvc", + "rust_linux_aarch64__aarch64-unknown-linux-gnu__stable", + "rust_linux_aarch64__aarch64-unknown-linux-gnu__nightly", + "rust_linux_aarch64__wasm32-unknown-unknown__stable", + "rust_linux_aarch64__wasm32-unknown-unknown__nightly", + "rust_linux_aarch64__wasm32-wasi__stable", + "rust_linux_aarch64__wasm32-wasi__nightly", + "rustfmt_nightly-2024-09-05__aarch64-unknown-linux-gnu", + "rust_linux_s390x__s390x-unknown-linux-gnu__stable", + "rust_linux_s390x__s390x-unknown-linux-gnu__nightly", + "rust_linux_s390x__wasm32-unknown-unknown__stable", + "rust_linux_s390x__wasm32-unknown-unknown__nightly", + "rust_linux_s390x__wasm32-wasi__stable", + "rust_linux_s390x__wasm32-wasi__nightly", + "rustfmt_nightly-2024-09-05__s390x-unknown-linux-gnu", + "rust_darwin_x86_64__x86_64-apple-darwin__stable", + "rust_darwin_x86_64__x86_64-apple-darwin__nightly", + "rust_darwin_x86_64__wasm32-unknown-unknown__stable", + "rust_darwin_x86_64__wasm32-unknown-unknown__nightly", + "rust_darwin_x86_64__wasm32-wasi__stable", + "rust_darwin_x86_64__wasm32-wasi__nightly", + "rustfmt_nightly-2024-09-05__x86_64-apple-darwin", + "rust_windows_x86_64__x86_64-pc-windows-msvc__stable", + "rust_windows_x86_64__x86_64-pc-windows-msvc__nightly", + "rust_windows_x86_64__wasm32-unknown-unknown__stable", + "rust_windows_x86_64__wasm32-unknown-unknown__nightly", + "rust_windows_x86_64__wasm32-wasi__stable", + "rust_windows_x86_64__wasm32-wasi__nightly", + "rustfmt_nightly-2024-09-05__x86_64-pc-windows-msvc", + "rust_freebsd_x86_64__x86_64-unknown-freebsd__stable", + "rust_freebsd_x86_64__x86_64-unknown-freebsd__nightly", + "rust_freebsd_x86_64__wasm32-unknown-unknown__stable", + "rust_freebsd_x86_64__wasm32-unknown-unknown__nightly", + "rust_freebsd_x86_64__wasm32-wasi__stable", + "rust_freebsd_x86_64__wasm32-wasi__nightly", + "rustfmt_nightly-2024-09-05__x86_64-unknown-freebsd", + "rust_linux_x86_64__x86_64-unknown-linux-gnu__stable", + "rust_linux_x86_64__x86_64-unknown-linux-gnu__nightly", + "rust_linux_x86_64__wasm32-unknown-unknown__stable", + "rust_linux_x86_64__wasm32-unknown-unknown__nightly", + "rust_linux_x86_64__wasm32-wasi__stable", + "rust_linux_x86_64__wasm32-wasi__nightly", + "rustfmt_nightly-2024-09-05__x86_64-unknown-linux-gnu" + ], + "toolchain_labels": { + "rust_analyzer_1.81.0": "@rust_analyzer_1.81.0_tools//:rust_analyzer_toolchain", + "rust_darwin_aarch64__aarch64-apple-darwin__stable": "@rust_darwin_aarch64__aarch64-apple-darwin__stable_tools//:rust_toolchain", + "rust_darwin_aarch64__aarch64-apple-darwin__nightly": "@rust_darwin_aarch64__aarch64-apple-darwin__nightly_tools//:rust_toolchain", + "rust_darwin_aarch64__wasm32-unknown-unknown__stable": "@rust_darwin_aarch64__wasm32-unknown-unknown__stable_tools//:rust_toolchain", + "rust_darwin_aarch64__wasm32-unknown-unknown__nightly": "@rust_darwin_aarch64__wasm32-unknown-unknown__nightly_tools//:rust_toolchain", + "rust_darwin_aarch64__wasm32-wasi__stable": "@rust_darwin_aarch64__wasm32-wasi__stable_tools//:rust_toolchain", + "rust_darwin_aarch64__wasm32-wasi__nightly": "@rust_darwin_aarch64__wasm32-wasi__nightly_tools//:rust_toolchain", + "rustfmt_nightly-2024-09-05__aarch64-apple-darwin": "@rustfmt_nightly-2024-09-05__aarch64-apple-darwin_tools//:rustfmt_toolchain", + "rust_windows_aarch64__aarch64-pc-windows-msvc__stable": "@rust_windows_aarch64__aarch64-pc-windows-msvc__stable_tools//:rust_toolchain", + "rust_windows_aarch64__aarch64-pc-windows-msvc__nightly": "@rust_windows_aarch64__aarch64-pc-windows-msvc__nightly_tools//:rust_toolchain", + "rust_windows_aarch64__wasm32-unknown-unknown__stable": "@rust_windows_aarch64__wasm32-unknown-unknown__stable_tools//:rust_toolchain", + "rust_windows_aarch64__wasm32-unknown-unknown__nightly": "@rust_windows_aarch64__wasm32-unknown-unknown__nightly_tools//:rust_toolchain", + "rust_windows_aarch64__wasm32-wasi__stable": "@rust_windows_aarch64__wasm32-wasi__stable_tools//:rust_toolchain", + "rust_windows_aarch64__wasm32-wasi__nightly": "@rust_windows_aarch64__wasm32-wasi__nightly_tools//:rust_toolchain", + "rustfmt_nightly-2024-09-05__aarch64-pc-windows-msvc": "@rustfmt_nightly-2024-09-05__aarch64-pc-windows-msvc_tools//:rustfmt_toolchain", + "rust_linux_aarch64__aarch64-unknown-linux-gnu__stable": "@rust_linux_aarch64__aarch64-unknown-linux-gnu__stable_tools//:rust_toolchain", + "rust_linux_aarch64__aarch64-unknown-linux-gnu__nightly": "@rust_linux_aarch64__aarch64-unknown-linux-gnu__nightly_tools//:rust_toolchain", + "rust_linux_aarch64__wasm32-unknown-unknown__stable": "@rust_linux_aarch64__wasm32-unknown-unknown__stable_tools//:rust_toolchain", + "rust_linux_aarch64__wasm32-unknown-unknown__nightly": "@rust_linux_aarch64__wasm32-unknown-unknown__nightly_tools//:rust_toolchain", + "rust_linux_aarch64__wasm32-wasi__stable": "@rust_linux_aarch64__wasm32-wasi__stable_tools//:rust_toolchain", + "rust_linux_aarch64__wasm32-wasi__nightly": "@rust_linux_aarch64__wasm32-wasi__nightly_tools//:rust_toolchain", + "rustfmt_nightly-2024-09-05__aarch64-unknown-linux-gnu": "@rustfmt_nightly-2024-09-05__aarch64-unknown-linux-gnu_tools//:rustfmt_toolchain", + "rust_linux_s390x__s390x-unknown-linux-gnu__stable": "@rust_linux_s390x__s390x-unknown-linux-gnu__stable_tools//:rust_toolchain", + "rust_linux_s390x__s390x-unknown-linux-gnu__nightly": "@rust_linux_s390x__s390x-unknown-linux-gnu__nightly_tools//:rust_toolchain", + "rust_linux_s390x__wasm32-unknown-unknown__stable": "@rust_linux_s390x__wasm32-unknown-unknown__stable_tools//:rust_toolchain", + "rust_linux_s390x__wasm32-unknown-unknown__nightly": "@rust_linux_s390x__wasm32-unknown-unknown__nightly_tools//:rust_toolchain", + "rust_linux_s390x__wasm32-wasi__stable": "@rust_linux_s390x__wasm32-wasi__stable_tools//:rust_toolchain", + "rust_linux_s390x__wasm32-wasi__nightly": "@rust_linux_s390x__wasm32-wasi__nightly_tools//:rust_toolchain", + "rustfmt_nightly-2024-09-05__s390x-unknown-linux-gnu": "@rustfmt_nightly-2024-09-05__s390x-unknown-linux-gnu_tools//:rustfmt_toolchain", + "rust_darwin_x86_64__x86_64-apple-darwin__stable": "@rust_darwin_x86_64__x86_64-apple-darwin__stable_tools//:rust_toolchain", + "rust_darwin_x86_64__x86_64-apple-darwin__nightly": "@rust_darwin_x86_64__x86_64-apple-darwin__nightly_tools//:rust_toolchain", + "rust_darwin_x86_64__wasm32-unknown-unknown__stable": "@rust_darwin_x86_64__wasm32-unknown-unknown__stable_tools//:rust_toolchain", + "rust_darwin_x86_64__wasm32-unknown-unknown__nightly": "@rust_darwin_x86_64__wasm32-unknown-unknown__nightly_tools//:rust_toolchain", + "rust_darwin_x86_64__wasm32-wasi__stable": "@rust_darwin_x86_64__wasm32-wasi__stable_tools//:rust_toolchain", + "rust_darwin_x86_64__wasm32-wasi__nightly": "@rust_darwin_x86_64__wasm32-wasi__nightly_tools//:rust_toolchain", + "rustfmt_nightly-2024-09-05__x86_64-apple-darwin": "@rustfmt_nightly-2024-09-05__x86_64-apple-darwin_tools//:rustfmt_toolchain", + "rust_windows_x86_64__x86_64-pc-windows-msvc__stable": "@rust_windows_x86_64__x86_64-pc-windows-msvc__stable_tools//:rust_toolchain", + "rust_windows_x86_64__x86_64-pc-windows-msvc__nightly": "@rust_windows_x86_64__x86_64-pc-windows-msvc__nightly_tools//:rust_toolchain", + "rust_windows_x86_64__wasm32-unknown-unknown__stable": "@rust_windows_x86_64__wasm32-unknown-unknown__stable_tools//:rust_toolchain", + "rust_windows_x86_64__wasm32-unknown-unknown__nightly": "@rust_windows_x86_64__wasm32-unknown-unknown__nightly_tools//:rust_toolchain", + "rust_windows_x86_64__wasm32-wasi__stable": "@rust_windows_x86_64__wasm32-wasi__stable_tools//:rust_toolchain", + "rust_windows_x86_64__wasm32-wasi__nightly": "@rust_windows_x86_64__wasm32-wasi__nightly_tools//:rust_toolchain", + "rustfmt_nightly-2024-09-05__x86_64-pc-windows-msvc": "@rustfmt_nightly-2024-09-05__x86_64-pc-windows-msvc_tools//:rustfmt_toolchain", + "rust_freebsd_x86_64__x86_64-unknown-freebsd__stable": "@rust_freebsd_x86_64__x86_64-unknown-freebsd__stable_tools//:rust_toolchain", + "rust_freebsd_x86_64__x86_64-unknown-freebsd__nightly": "@rust_freebsd_x86_64__x86_64-unknown-freebsd__nightly_tools//:rust_toolchain", + "rust_freebsd_x86_64__wasm32-unknown-unknown__stable": "@rust_freebsd_x86_64__wasm32-unknown-unknown__stable_tools//:rust_toolchain", + "rust_freebsd_x86_64__wasm32-unknown-unknown__nightly": "@rust_freebsd_x86_64__wasm32-unknown-unknown__nightly_tools//:rust_toolchain", + "rust_freebsd_x86_64__wasm32-wasi__stable": "@rust_freebsd_x86_64__wasm32-wasi__stable_tools//:rust_toolchain", + "rust_freebsd_x86_64__wasm32-wasi__nightly": "@rust_freebsd_x86_64__wasm32-wasi__nightly_tools//:rust_toolchain", + "rustfmt_nightly-2024-09-05__x86_64-unknown-freebsd": "@rustfmt_nightly-2024-09-05__x86_64-unknown-freebsd_tools//:rustfmt_toolchain", + "rust_linux_x86_64__x86_64-unknown-linux-gnu__stable": "@rust_linux_x86_64__x86_64-unknown-linux-gnu__stable_tools//:rust_toolchain", + "rust_linux_x86_64__x86_64-unknown-linux-gnu__nightly": "@rust_linux_x86_64__x86_64-unknown-linux-gnu__nightly_tools//:rust_toolchain", + "rust_linux_x86_64__wasm32-unknown-unknown__stable": "@rust_linux_x86_64__wasm32-unknown-unknown__stable_tools//:rust_toolchain", + "rust_linux_x86_64__wasm32-unknown-unknown__nightly": "@rust_linux_x86_64__wasm32-unknown-unknown__nightly_tools//:rust_toolchain", + "rust_linux_x86_64__wasm32-wasi__stable": "@rust_linux_x86_64__wasm32-wasi__stable_tools//:rust_toolchain", + "rust_linux_x86_64__wasm32-wasi__nightly": "@rust_linux_x86_64__wasm32-wasi__nightly_tools//:rust_toolchain", + "rustfmt_nightly-2024-09-05__x86_64-unknown-linux-gnu": "@rustfmt_nightly-2024-09-05__x86_64-unknown-linux-gnu_tools//:rustfmt_toolchain" + }, + "toolchain_types": { + "rust_analyzer_1.81.0": "@rules_rust//rust/rust_analyzer:toolchain_type", + "rust_darwin_aarch64__aarch64-apple-darwin__stable": "@rules_rust//rust:toolchain", + "rust_darwin_aarch64__aarch64-apple-darwin__nightly": "@rules_rust//rust:toolchain", + "rust_darwin_aarch64__wasm32-unknown-unknown__stable": "@rules_rust//rust:toolchain", + "rust_darwin_aarch64__wasm32-unknown-unknown__nightly": "@rules_rust//rust:toolchain", + "rust_darwin_aarch64__wasm32-wasi__stable": "@rules_rust//rust:toolchain", + "rust_darwin_aarch64__wasm32-wasi__nightly": "@rules_rust//rust:toolchain", + "rustfmt_nightly-2024-09-05__aarch64-apple-darwin": "@rules_rust//rust/rustfmt:toolchain_type", + "rust_windows_aarch64__aarch64-pc-windows-msvc__stable": "@rules_rust//rust:toolchain", + "rust_windows_aarch64__aarch64-pc-windows-msvc__nightly": "@rules_rust//rust:toolchain", + "rust_windows_aarch64__wasm32-unknown-unknown__stable": "@rules_rust//rust:toolchain", + "rust_windows_aarch64__wasm32-unknown-unknown__nightly": "@rules_rust//rust:toolchain", + "rust_windows_aarch64__wasm32-wasi__stable": "@rules_rust//rust:toolchain", + "rust_windows_aarch64__wasm32-wasi__nightly": "@rules_rust//rust:toolchain", + "rustfmt_nightly-2024-09-05__aarch64-pc-windows-msvc": "@rules_rust//rust/rustfmt:toolchain_type", + "rust_linux_aarch64__aarch64-unknown-linux-gnu__stable": "@rules_rust//rust:toolchain", + "rust_linux_aarch64__aarch64-unknown-linux-gnu__nightly": "@rules_rust//rust:toolchain", + "rust_linux_aarch64__wasm32-unknown-unknown__stable": "@rules_rust//rust:toolchain", + "rust_linux_aarch64__wasm32-unknown-unknown__nightly": "@rules_rust//rust:toolchain", + "rust_linux_aarch64__wasm32-wasi__stable": "@rules_rust//rust:toolchain", + "rust_linux_aarch64__wasm32-wasi__nightly": "@rules_rust//rust:toolchain", + "rustfmt_nightly-2024-09-05__aarch64-unknown-linux-gnu": "@rules_rust//rust/rustfmt:toolchain_type", + "rust_linux_s390x__s390x-unknown-linux-gnu__stable": "@rules_rust//rust:toolchain", + "rust_linux_s390x__s390x-unknown-linux-gnu__nightly": "@rules_rust//rust:toolchain", + "rust_linux_s390x__wasm32-unknown-unknown__stable": "@rules_rust//rust:toolchain", + "rust_linux_s390x__wasm32-unknown-unknown__nightly": "@rules_rust//rust:toolchain", + "rust_linux_s390x__wasm32-wasi__stable": "@rules_rust//rust:toolchain", + "rust_linux_s390x__wasm32-wasi__nightly": "@rules_rust//rust:toolchain", + "rustfmt_nightly-2024-09-05__s390x-unknown-linux-gnu": "@rules_rust//rust/rustfmt:toolchain_type", + "rust_darwin_x86_64__x86_64-apple-darwin__stable": "@rules_rust//rust:toolchain", + "rust_darwin_x86_64__x86_64-apple-darwin__nightly": "@rules_rust//rust:toolchain", + "rust_darwin_x86_64__wasm32-unknown-unknown__stable": "@rules_rust//rust:toolchain", + "rust_darwin_x86_64__wasm32-unknown-unknown__nightly": "@rules_rust//rust:toolchain", + "rust_darwin_x86_64__wasm32-wasi__stable": "@rules_rust//rust:toolchain", + "rust_darwin_x86_64__wasm32-wasi__nightly": "@rules_rust//rust:toolchain", + "rustfmt_nightly-2024-09-05__x86_64-apple-darwin": "@rules_rust//rust/rustfmt:toolchain_type", + "rust_windows_x86_64__x86_64-pc-windows-msvc__stable": "@rules_rust//rust:toolchain", + "rust_windows_x86_64__x86_64-pc-windows-msvc__nightly": "@rules_rust//rust:toolchain", + "rust_windows_x86_64__wasm32-unknown-unknown__stable": "@rules_rust//rust:toolchain", + "rust_windows_x86_64__wasm32-unknown-unknown__nightly": "@rules_rust//rust:toolchain", + "rust_windows_x86_64__wasm32-wasi__stable": "@rules_rust//rust:toolchain", + "rust_windows_x86_64__wasm32-wasi__nightly": "@rules_rust//rust:toolchain", + "rustfmt_nightly-2024-09-05__x86_64-pc-windows-msvc": "@rules_rust//rust/rustfmt:toolchain_type", + "rust_freebsd_x86_64__x86_64-unknown-freebsd__stable": "@rules_rust//rust:toolchain", + "rust_freebsd_x86_64__x86_64-unknown-freebsd__nightly": "@rules_rust//rust:toolchain", + "rust_freebsd_x86_64__wasm32-unknown-unknown__stable": "@rules_rust//rust:toolchain", + "rust_freebsd_x86_64__wasm32-unknown-unknown__nightly": "@rules_rust//rust:toolchain", + "rust_freebsd_x86_64__wasm32-wasi__stable": "@rules_rust//rust:toolchain", + "rust_freebsd_x86_64__wasm32-wasi__nightly": "@rules_rust//rust:toolchain", + "rustfmt_nightly-2024-09-05__x86_64-unknown-freebsd": "@rules_rust//rust/rustfmt:toolchain_type", + "rust_linux_x86_64__x86_64-unknown-linux-gnu__stable": "@rules_rust//rust:toolchain", + "rust_linux_x86_64__x86_64-unknown-linux-gnu__nightly": "@rules_rust//rust:toolchain", + "rust_linux_x86_64__wasm32-unknown-unknown__stable": "@rules_rust//rust:toolchain", + "rust_linux_x86_64__wasm32-unknown-unknown__nightly": "@rules_rust//rust:toolchain", + "rust_linux_x86_64__wasm32-wasi__stable": "@rules_rust//rust:toolchain", + "rust_linux_x86_64__wasm32-wasi__nightly": "@rules_rust//rust:toolchain", + "rustfmt_nightly-2024-09-05__x86_64-unknown-linux-gnu": "@rules_rust//rust/rustfmt:toolchain_type" + }, + "exec_compatible_with": { + "rust_analyzer_1.81.0": [], + "rust_darwin_aarch64__aarch64-apple-darwin__stable": [ + "@platforms//cpu:aarch64", + "@platforms//os:osx" + ], + "rust_darwin_aarch64__aarch64-apple-darwin__nightly": [ + "@platforms//cpu:aarch64", + "@platforms//os:osx" + ], + "rust_darwin_aarch64__wasm32-unknown-unknown__stable": [ + "@platforms//cpu:aarch64", + "@platforms//os:osx" + ], + "rust_darwin_aarch64__wasm32-unknown-unknown__nightly": [ + "@platforms//cpu:aarch64", + "@platforms//os:osx" + ], + "rust_darwin_aarch64__wasm32-wasi__stable": [ + "@platforms//cpu:aarch64", + "@platforms//os:osx" + ], + "rust_darwin_aarch64__wasm32-wasi__nightly": [ + "@platforms//cpu:aarch64", + "@platforms//os:osx" + ], + "rustfmt_nightly-2024-09-05__aarch64-apple-darwin": [ + "@platforms//cpu:aarch64", + "@platforms//os:osx" + ], + "rust_windows_aarch64__aarch64-pc-windows-msvc__stable": [ + "@platforms//cpu:aarch64", + "@platforms//os:windows" + ], + "rust_windows_aarch64__aarch64-pc-windows-msvc__nightly": [ + "@platforms//cpu:aarch64", + "@platforms//os:windows" + ], + "rust_windows_aarch64__wasm32-unknown-unknown__stable": [ + "@platforms//cpu:aarch64", + "@platforms//os:windows" + ], + "rust_windows_aarch64__wasm32-unknown-unknown__nightly": [ + "@platforms//cpu:aarch64", + "@platforms//os:windows" + ], + "rust_windows_aarch64__wasm32-wasi__stable": [ + "@platforms//cpu:aarch64", + "@platforms//os:windows" + ], + "rust_windows_aarch64__wasm32-wasi__nightly": [ + "@platforms//cpu:aarch64", + "@platforms//os:windows" + ], + "rustfmt_nightly-2024-09-05__aarch64-pc-windows-msvc": [ + "@platforms//cpu:aarch64", + "@platforms//os:windows" + ], + "rust_linux_aarch64__aarch64-unknown-linux-gnu__stable": [ + "@platforms//cpu:aarch64", + "@platforms//os:linux" + ], + "rust_linux_aarch64__aarch64-unknown-linux-gnu__nightly": [ + "@platforms//cpu:aarch64", + "@platforms//os:linux" + ], + "rust_linux_aarch64__wasm32-unknown-unknown__stable": [ + "@platforms//cpu:aarch64", + "@platforms//os:linux" + ], + "rust_linux_aarch64__wasm32-unknown-unknown__nightly": [ + "@platforms//cpu:aarch64", + "@platforms//os:linux" + ], + "rust_linux_aarch64__wasm32-wasi__stable": [ + "@platforms//cpu:aarch64", + "@platforms//os:linux" + ], + "rust_linux_aarch64__wasm32-wasi__nightly": [ + "@platforms//cpu:aarch64", + "@platforms//os:linux" + ], + "rustfmt_nightly-2024-09-05__aarch64-unknown-linux-gnu": [ + "@platforms//cpu:aarch64", + "@platforms//os:linux" + ], + "rust_linux_s390x__s390x-unknown-linux-gnu__stable": [ + "@platforms//cpu:s390x", + "@platforms//os:linux" + ], + "rust_linux_s390x__s390x-unknown-linux-gnu__nightly": [ + "@platforms//cpu:s390x", + "@platforms//os:linux" + ], + "rust_linux_s390x__wasm32-unknown-unknown__stable": [ + "@platforms//cpu:s390x", + "@platforms//os:linux" + ], + "rust_linux_s390x__wasm32-unknown-unknown__nightly": [ + "@platforms//cpu:s390x", + "@platforms//os:linux" + ], + "rust_linux_s390x__wasm32-wasi__stable": [ + "@platforms//cpu:s390x", + "@platforms//os:linux" + ], + "rust_linux_s390x__wasm32-wasi__nightly": [ + "@platforms//cpu:s390x", + "@platforms//os:linux" + ], + "rustfmt_nightly-2024-09-05__s390x-unknown-linux-gnu": [ + "@platforms//cpu:s390x", + "@platforms//os:linux" + ], + "rust_darwin_x86_64__x86_64-apple-darwin__stable": [ + "@platforms//cpu:x86_64", + "@platforms//os:osx" + ], + "rust_darwin_x86_64__x86_64-apple-darwin__nightly": [ + "@platforms//cpu:x86_64", + "@platforms//os:osx" + ], + "rust_darwin_x86_64__wasm32-unknown-unknown__stable": [ + "@platforms//cpu:x86_64", + "@platforms//os:osx" + ], + "rust_darwin_x86_64__wasm32-unknown-unknown__nightly": [ + "@platforms//cpu:x86_64", + "@platforms//os:osx" + ], + "rust_darwin_x86_64__wasm32-wasi__stable": [ + "@platforms//cpu:x86_64", + "@platforms//os:osx" + ], + "rust_darwin_x86_64__wasm32-wasi__nightly": [ + "@platforms//cpu:x86_64", + "@platforms//os:osx" + ], + "rustfmt_nightly-2024-09-05__x86_64-apple-darwin": [ + "@platforms//cpu:x86_64", + "@platforms//os:osx" + ], + "rust_windows_x86_64__x86_64-pc-windows-msvc__stable": [ + "@platforms//cpu:x86_64", + "@platforms//os:windows" + ], + "rust_windows_x86_64__x86_64-pc-windows-msvc__nightly": [ + "@platforms//cpu:x86_64", + "@platforms//os:windows" + ], + "rust_windows_x86_64__wasm32-unknown-unknown__stable": [ + "@platforms//cpu:x86_64", + "@platforms//os:windows" + ], + "rust_windows_x86_64__wasm32-unknown-unknown__nightly": [ + "@platforms//cpu:x86_64", + "@platforms//os:windows" + ], + "rust_windows_x86_64__wasm32-wasi__stable": [ + "@platforms//cpu:x86_64", + "@platforms//os:windows" + ], + "rust_windows_x86_64__wasm32-wasi__nightly": [ + "@platforms//cpu:x86_64", + "@platforms//os:windows" + ], + "rustfmt_nightly-2024-09-05__x86_64-pc-windows-msvc": [ + "@platforms//cpu:x86_64", + "@platforms//os:windows" + ], + "rust_freebsd_x86_64__x86_64-unknown-freebsd__stable": [ + "@platforms//cpu:x86_64", + "@platforms//os:freebsd" + ], + "rust_freebsd_x86_64__x86_64-unknown-freebsd__nightly": [ + "@platforms//cpu:x86_64", + "@platforms//os:freebsd" + ], + "rust_freebsd_x86_64__wasm32-unknown-unknown__stable": [ + "@platforms//cpu:x86_64", + "@platforms//os:freebsd" + ], + "rust_freebsd_x86_64__wasm32-unknown-unknown__nightly": [ + "@platforms//cpu:x86_64", + "@platforms//os:freebsd" + ], + "rust_freebsd_x86_64__wasm32-wasi__stable": [ + "@platforms//cpu:x86_64", + "@platforms//os:freebsd" + ], + "rust_freebsd_x86_64__wasm32-wasi__nightly": [ + "@platforms//cpu:x86_64", + "@platforms//os:freebsd" + ], + "rustfmt_nightly-2024-09-05__x86_64-unknown-freebsd": [ + "@platforms//cpu:x86_64", + "@platforms//os:freebsd" + ], + "rust_linux_x86_64__x86_64-unknown-linux-gnu__stable": [ + "@platforms//cpu:x86_64", + "@platforms//os:linux" + ], + "rust_linux_x86_64__x86_64-unknown-linux-gnu__nightly": [ + "@platforms//cpu:x86_64", + "@platforms//os:linux" + ], + "rust_linux_x86_64__wasm32-unknown-unknown__stable": [ + "@platforms//cpu:x86_64", + "@platforms//os:linux" + ], + "rust_linux_x86_64__wasm32-unknown-unknown__nightly": [ + "@platforms//cpu:x86_64", + "@platforms//os:linux" + ], + "rust_linux_x86_64__wasm32-wasi__stable": [ + "@platforms//cpu:x86_64", + "@platforms//os:linux" + ], + "rust_linux_x86_64__wasm32-wasi__nightly": [ + "@platforms//cpu:x86_64", + "@platforms//os:linux" + ], + "rustfmt_nightly-2024-09-05__x86_64-unknown-linux-gnu": [ + "@platforms//cpu:x86_64", + "@platforms//os:linux" + ] + }, + "target_compatible_with": { + "rust_analyzer_1.81.0": [], + "rust_darwin_aarch64__aarch64-apple-darwin__stable": [ + "@platforms//cpu:aarch64", + "@platforms//os:osx" + ], + "rust_darwin_aarch64__aarch64-apple-darwin__nightly": [ + "@platforms//cpu:aarch64", + "@platforms//os:osx" + ], + "rust_darwin_aarch64__wasm32-unknown-unknown__stable": [ + "@platforms//cpu:wasm32", + "@platforms//os:none" + ], + "rust_darwin_aarch64__wasm32-unknown-unknown__nightly": [ + "@platforms//cpu:wasm32", + "@platforms//os:none" + ], + "rust_darwin_aarch64__wasm32-wasi__stable": [ + "@platforms//cpu:wasm32", + "@platforms//os:wasi" + ], + "rust_darwin_aarch64__wasm32-wasi__nightly": [ + "@platforms//cpu:wasm32", + "@platforms//os:wasi" + ], + "rustfmt_nightly-2024-09-05__aarch64-apple-darwin": [], + "rust_windows_aarch64__aarch64-pc-windows-msvc__stable": [ + "@platforms//cpu:aarch64", + "@platforms//os:windows" + ], + "rust_windows_aarch64__aarch64-pc-windows-msvc__nightly": [ + "@platforms//cpu:aarch64", + "@platforms//os:windows" + ], + "rust_windows_aarch64__wasm32-unknown-unknown__stable": [ + "@platforms//cpu:wasm32", + "@platforms//os:none" + ], + "rust_windows_aarch64__wasm32-unknown-unknown__nightly": [ + "@platforms//cpu:wasm32", + "@platforms//os:none" + ], + "rust_windows_aarch64__wasm32-wasi__stable": [ + "@platforms//cpu:wasm32", + "@platforms//os:wasi" + ], + "rust_windows_aarch64__wasm32-wasi__nightly": [ + "@platforms//cpu:wasm32", + "@platforms//os:wasi" + ], + "rustfmt_nightly-2024-09-05__aarch64-pc-windows-msvc": [], + "rust_linux_aarch64__aarch64-unknown-linux-gnu__stable": [ + "@platforms//cpu:aarch64", + "@platforms//os:linux" + ], + "rust_linux_aarch64__aarch64-unknown-linux-gnu__nightly": [ + "@platforms//cpu:aarch64", + "@platforms//os:linux" + ], + "rust_linux_aarch64__wasm32-unknown-unknown__stable": [ + "@platforms//cpu:wasm32", + "@platforms//os:none" + ], + "rust_linux_aarch64__wasm32-unknown-unknown__nightly": [ + "@platforms//cpu:wasm32", + "@platforms//os:none" + ], + "rust_linux_aarch64__wasm32-wasi__stable": [ + "@platforms//cpu:wasm32", + "@platforms//os:wasi" + ], + "rust_linux_aarch64__wasm32-wasi__nightly": [ + "@platforms//cpu:wasm32", + "@platforms//os:wasi" + ], + "rustfmt_nightly-2024-09-05__aarch64-unknown-linux-gnu": [], + "rust_linux_s390x__s390x-unknown-linux-gnu__stable": [ + "@platforms//cpu:s390x", + "@platforms//os:linux" + ], + "rust_linux_s390x__s390x-unknown-linux-gnu__nightly": [ + "@platforms//cpu:s390x", + "@platforms//os:linux" + ], + "rust_linux_s390x__wasm32-unknown-unknown__stable": [ + "@platforms//cpu:wasm32", + "@platforms//os:none" + ], + "rust_linux_s390x__wasm32-unknown-unknown__nightly": [ + "@platforms//cpu:wasm32", + "@platforms//os:none" + ], + "rust_linux_s390x__wasm32-wasi__stable": [ + "@platforms//cpu:wasm32", + "@platforms//os:wasi" + ], + "rust_linux_s390x__wasm32-wasi__nightly": [ + "@platforms//cpu:wasm32", + "@platforms//os:wasi" + ], + "rustfmt_nightly-2024-09-05__s390x-unknown-linux-gnu": [], + "rust_darwin_x86_64__x86_64-apple-darwin__stable": [ + "@platforms//cpu:x86_64", + "@platforms//os:osx" + ], + "rust_darwin_x86_64__x86_64-apple-darwin__nightly": [ + "@platforms//cpu:x86_64", + "@platforms//os:osx" + ], + "rust_darwin_x86_64__wasm32-unknown-unknown__stable": [ + "@platforms//cpu:wasm32", + "@platforms//os:none" + ], + "rust_darwin_x86_64__wasm32-unknown-unknown__nightly": [ + "@platforms//cpu:wasm32", + "@platforms//os:none" + ], + "rust_darwin_x86_64__wasm32-wasi__stable": [ + "@platforms//cpu:wasm32", + "@platforms//os:wasi" + ], + "rust_darwin_x86_64__wasm32-wasi__nightly": [ + "@platforms//cpu:wasm32", + "@platforms//os:wasi" + ], + "rustfmt_nightly-2024-09-05__x86_64-apple-darwin": [], + "rust_windows_x86_64__x86_64-pc-windows-msvc__stable": [ + "@platforms//cpu:x86_64", + "@platforms//os:windows" + ], + "rust_windows_x86_64__x86_64-pc-windows-msvc__nightly": [ + "@platforms//cpu:x86_64", + "@platforms//os:windows" + ], + "rust_windows_x86_64__wasm32-unknown-unknown__stable": [ + "@platforms//cpu:wasm32", + "@platforms//os:none" + ], + "rust_windows_x86_64__wasm32-unknown-unknown__nightly": [ + "@platforms//cpu:wasm32", + "@platforms//os:none" + ], + "rust_windows_x86_64__wasm32-wasi__stable": [ + "@platforms//cpu:wasm32", + "@platforms//os:wasi" + ], + "rust_windows_x86_64__wasm32-wasi__nightly": [ + "@platforms//cpu:wasm32", + "@platforms//os:wasi" + ], + "rustfmt_nightly-2024-09-05__x86_64-pc-windows-msvc": [], + "rust_freebsd_x86_64__x86_64-unknown-freebsd__stable": [ + "@platforms//cpu:x86_64", + "@platforms//os:freebsd" + ], + "rust_freebsd_x86_64__x86_64-unknown-freebsd__nightly": [ + "@platforms//cpu:x86_64", + "@platforms//os:freebsd" + ], + "rust_freebsd_x86_64__wasm32-unknown-unknown__stable": [ + "@platforms//cpu:wasm32", + "@platforms//os:none" + ], + "rust_freebsd_x86_64__wasm32-unknown-unknown__nightly": [ + "@platforms//cpu:wasm32", + "@platforms//os:none" + ], + "rust_freebsd_x86_64__wasm32-wasi__stable": [ + "@platforms//cpu:wasm32", + "@platforms//os:wasi" + ], + "rust_freebsd_x86_64__wasm32-wasi__nightly": [ + "@platforms//cpu:wasm32", + "@platforms//os:wasi" + ], + "rustfmt_nightly-2024-09-05__x86_64-unknown-freebsd": [], + "rust_linux_x86_64__x86_64-unknown-linux-gnu__stable": [ + "@platforms//cpu:x86_64", + "@platforms//os:linux" + ], + "rust_linux_x86_64__x86_64-unknown-linux-gnu__nightly": [ + "@platforms//cpu:x86_64", + "@platforms//os:linux" + ], + "rust_linux_x86_64__wasm32-unknown-unknown__stable": [ + "@platforms//cpu:wasm32", + "@platforms//os:none" + ], + "rust_linux_x86_64__wasm32-unknown-unknown__nightly": [ + "@platforms//cpu:wasm32", + "@platforms//os:none" + ], + "rust_linux_x86_64__wasm32-wasi__stable": [ + "@platforms//cpu:wasm32", + "@platforms//os:wasi" + ], + "rust_linux_x86_64__wasm32-wasi__nightly": [ + "@platforms//cpu:wasm32", + "@platforms//os:wasi" + ], + "rustfmt_nightly-2024-09-05__x86_64-unknown-linux-gnu": [] + } + } + } + }, + "recordedRepoMappingEntries": [ + [ + "bazel_features~", + "bazel_features_globals", + "bazel_features~~version_extension~bazel_features_globals" + ], + [ + "bazel_features~", + "bazel_features_version", + "bazel_features~~version_extension~bazel_features_version" + ], + [ + "rules_rust~", + "bazel_features", + "bazel_features~" + ], + [ + "rules_rust~", + "bazel_skylib", + "bazel_skylib~" + ], + [ + "rules_rust~", + "bazel_tools", + "bazel_tools" + ], + [ + "rules_rust~", + "rules_rust", + "rules_rust~" + ] + ] + } + } + } } diff --git a/psi/algorithm/ypir/legacy/util.cc b/psi/algorithm/ypir/legacy/util.cc index 7844dd47..c9c2bc1c 100644 --- a/psi/algorithm/ypir/legacy/util.cc +++ b/psi/algorithm/ypir/legacy/util.cc @@ -60,13 +60,8 @@ void matMulVecPacked8(uint32_t* out, const uint32_t* a, const uint32_t* b_full, // Wrapper function that matches the Rust signature void MatMulVecPacked(uint32_t* out, const uint32_t* a, const uint32_t* b, - size_t a_rows, size_t a_cols, size_t b_rows, - size_t b_cols) { - // Debug output (equivalent to Rust's debug! macro) - - // Assertions - assert(a_rows * a_cols == a_rows * a_cols); // a.len() == a_rows * a_cols - assert(b_rows * b_cols == b_rows * b_cols); // b.len() == b_rows * b_cols + size_t a_rows, size_t a_cols, + [[maybe_unused]] size_t b_rows, size_t b_cols) { assert(a_cols * 4 == b_rows); // Note: out.len() >= a_rows + 8 should be checked by caller From 62eecf9cdb3bec859bbb13b51a4d4a38a48ad342 Mon Sep 17 00:00:00 2001 From: sh1k4ku Date: Tue, 7 Apr 2026 22:16:31 +0800 Subject: [PATCH 10/12] fix macos --- .bazelrc | 1 + 1 file changed, 1 insertion(+) diff --git a/.bazelrc b/.bazelrc index 7f49c964..deeaa79f 100644 --- a/.bazelrc +++ b/.bazelrc @@ -46,6 +46,7 @@ build:linux-release --action_env=BAZEL_LINKLIBS=-l%:libstdc++.a:-l%:libgcc.a # platform specific config # Bazel will automatic pick platform config since we have enable_platform_specific_config set build:macos --copt=-Wno-unused-command-line-argument +build:macos --copt=-Wno-vla-cxx-extension build:macos --features=-supports_dynamic_linker build:macos --macos_minimum_os=12.0 build:macos --host_macos_minimum_os=12.0 From c796183d82a960b8df2ac3950e1196896304477f Mon Sep 17 00:00:00 2001 From: sh1k4ku Date: Wed, 8 Apr 2026 10:13:00 +0800 Subject: [PATCH 11/12] fix macos yacl --- .bazelrc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.bazelrc b/.bazelrc index deeaa79f..747e7cb4 100644 --- a/.bazelrc +++ b/.bazelrc @@ -51,6 +51,9 @@ build:macos --features=-supports_dynamic_linker build:macos --macos_minimum_os=12.0 build:macos --host_macos_minimum_os=12.0 +# Fix yacl VLA warning on macOS Clang (Xcode 16.4+) +build --per_file_copt=external/yacl.*openssl.*@-Wno-vla-cxx-extension + # NOTE: fix build on linux_aarch64, since `build:linux_aarch64` works only if `--config linux_aarch64` option included. build:linux --cxxopt=-Wno-mismatched-new-delete From 7fa2ab915cb72fd979dcfd0872f0271c00e68c92 Mon Sep 17 00:00:00 2001 From: sh1k4ku Date: Wed, 8 Apr 2026 12:02:10 +0800 Subject: [PATCH 12/12] fix macos brpc --- .bazelrc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.bazelrc b/.bazelrc index 747e7cb4..56efa6ae 100644 --- a/.bazelrc +++ b/.bazelrc @@ -53,6 +53,9 @@ build:macos --host_macos_minimum_os=12.0 # Fix yacl VLA warning on macOS Clang (Xcode 16.4+) build --per_file_copt=external/yacl.*openssl.*@-Wno-vla-cxx-extension +# Fix brpc deprecated protobuf API warning +build --per_file_copt=external/yacl.*brpc.*@-Wno-deprecated-declarations +build --per_file_copt=external/brpc.*@-Wno-deprecated-declarations # NOTE: fix build on linux_aarch64, since `build:linux_aarch64` works only if `--config linux_aarch64` option included. build:linux --cxxopt=-Wno-mismatched-new-delete