From fa343ef17094027d0005822bec23bf36cbbb9aa0 Mon Sep 17 00:00:00 2001
From: Jun FENG <99384777+6fj@users.noreply.github.com>
Date: Mon, 19 Feb 2024 16:57:06 +0800
Subject: [PATCH] repo-sync-2024-02-19T16:30:32+0800 (#78)
---
.github/workflows/scorecard.yml | 2 +-
README.md | 9 +-
RELEASE.md | 5 +
bazel/patches/apsi.patch | 173 ++++----
bazel/patches/grpc.patch | 1 -
bazel/patches/ippcp.patch | 1 -
bazel/patches/perfetto.patch | 2 +-
bazel/sparsehash.BUILD | 2 +-
docs/conf.py | 2 +-
docs/getting_started.rst | 11 +-
docs/reference/launch_config.md | 6 +-
docs/reference/psi_v2_config.md | 2 +-
docs/requirements.txt | 6 +-
docs/user_guide/faq.md | 90 +++++
docs/user_guide/index.rst | 1 +
docs/user_guide/psi.rst | 12 +-
docs/user_guide/psi_v2.rst | 30 +-
examples/pir/BUILD.bazel | 18 +-
examples/pir/keyword_pir_client.cc | 16 +-
examples/pir/keyword_pir_mem_server.cc | 21 +-
examples/pir/keyword_pir_server.cc | 20 +-
examples/pir/keyword_pir_setup.cc | 18 +-
psi/BUILD.bazel | 81 +++-
.../core/labeled_psi => apsi}/BUILD.bazel | 170 ++++++--
psi/{psi/core/labeled_psi => apsi}/README.md | 0
.../apsi_bench.cc => apsi/apsi_benchmark.cc} | 31 +-
.../labeled_psi => apsi}/apsi_label_test.cc | 33 +-
.../core/labeled_psi => apsi}/apsi_test.cc | 33 +-
psi/{psi/core/labeled_psi => apsi}/kv_test.cc | 54 +--
psi/{psi/core/labeled_psi => apsi}/package.cc | 8 +-
psi/{psi/core/labeled_psi => apsi}/package.h | 10 +-
psi/{psi/core/labeled_psi => apsi}/padding.cc | 6 +-
psi/{psi/core/labeled_psi => apsi}/padding.h | 4 +-
psi/{pir => apsi}/pir.cc | 201 +++++----
psi/{pir => apsi}/pir.h | 6 +-
psi/{pir => apsi}/pir_test.cc | 74 ++--
.../core/labeled_psi => apsi}/psi_params.cc | 40 +-
.../core/labeled_psi => apsi}/psi_params.h | 26 +-
.../core/labeled_psi => apsi}/receiver.cc | 77 ++--
psi/{psi/core/labeled_psi => apsi}/receiver.h | 41 +-
psi/{psi/core/labeled_psi => apsi}/sender.cc | 84 ++--
psi/{psi/core/labeled_psi => apsi}/sender.h | 16 +-
.../core/labeled_psi => apsi}/sender_db.cc | 49 +--
.../core/labeled_psi => apsi}/sender_db.h | 48 +--
.../core/labeled_psi => apsi}/sender_kvdb.cc | 133 +++---
.../core/labeled_psi => apsi}/sender_kvdb.h | 16 +-
.../core/labeled_psi => apsi}/sender_memdb.cc | 169 ++++----
.../core/labeled_psi => apsi}/sender_memdb.h | 28 +-
.../labeled_psi => apsi}/serializable.proto | 2 +-
.../core/labeled_psi => apsi}/serialize.h | 48 +--
psi/{psi/core/bc22_psi => bc22}/BUILD.bazel | 16 +-
psi/{psi/core/bc22_psi => bc22}/bc22_psi.cc | 12 +-
psi/{psi/core/bc22_psi => bc22}/bc22_psi.h | 10 +-
.../bc22_psi_benchmark.cc} | 6 +-
.../core/bc22_psi => bc22}/bc22_psi_test.cc | 6 +-
psi/{psi/core/bc22_psi => bc22}/emp_vole.cc | 6 +-
psi/{psi/core/bc22_psi => bc22}/emp_vole.h | 10 +-
.../core/bc22_psi => bc22}/emp_vole_test.cc | 8 +-
.../generalized_cuckoo_hash.cc | 6 +-
.../generalized_cuckoo_hash.h | 6 +-
.../generalized_cuckoo_hash_test.cc | 6 +-
psi/{psi => }/cryptor/BUILD.bazel | 2 +-
psi/{psi => }/cryptor/cryptor_selector.cc | 16 +-
psi/{psi => }/cryptor/cryptor_selector.h | 6 +-
psi/{psi => }/cryptor/ecc_cryptor.cc | 6 +-
psi/{psi => }/cryptor/ecc_cryptor.h | 4 +-
psi/{psi => }/cryptor/ecc_utils.h | 4 +-
psi/{psi => }/cryptor/ecc_utils_test.cc | 6 +-
psi/{psi => }/cryptor/fourq_cryptor.cc | 6 +-
psi/{psi => }/cryptor/fourq_cryptor.h | 6 +-
psi/{psi => }/cryptor/fpga_ecc_cryptor.h | 6 +-
.../cryptor/hash_to_curve_elligator2.cc | 6 +-
.../cryptor/hash_to_curve_elligator2.h | 4 +-
.../cryptor/hash_to_curve_elligator2_test.cc | 6 +-
psi/{psi => }/cryptor/ipp_ecc_cryptor.cc | 8 +-
psi/{psi => }/cryptor/ipp_ecc_cryptor.h | 6 +-
psi/{psi => }/cryptor/sm2_cryptor.cc | 8 +-
psi/{psi => }/cryptor/sm2_cryptor.h | 6 +-
psi/{psi => }/cryptor/sm2_cryptor_test.cc | 6 +-
.../cryptor/sodium_curve25519_cryptor.cc | 8 +-
.../cryptor/sodium_curve25519_cryptor.h | 6 +-
psi/ecdh/BUILD.bazel | 237 +++++++++++
.../ecdh_oprf => ecdh}/basic_ecdh_oprf.cc | 8 +-
.../core/ecdh_oprf => ecdh}/basic_ecdh_oprf.h | 10 +-
.../basic_ecdh_oprf_test.cc | 8 +-
psi/{psi => }/ecdh/client.cc | 12 +-
psi/{psi => }/ecdh/client.h | 8 +-
psi/{psi => }/ecdh/common.h | 4 +-
psi/{psi/core => ecdh}/ecdh_3pc_psi.cc | 8 +-
psi/{psi/core => ecdh}/ecdh_3pc_psi.h | 8 +-
.../ecdh_3pc_psi_benchmark.cc} | 24 +-
psi/{psi/core => ecdh}/ecdh_3pc_psi_test.cc | 77 ++--
psi/ecdh/ecdh_logger.h | 41 ++
psi/{psi/core/ecdh_oprf => ecdh}/ecdh_oprf.cc | 6 +-
psi/{psi/core/ecdh_oprf => ecdh}/ecdh_oprf.h | 6 +-
psi/{psi/core => ecdh}/ecdh_oprf_psi.cc | 13 +-
psi/{psi/core => ecdh}/ecdh_oprf_psi.h | 14 +-
psi/{psi/core => ecdh}/ecdh_oprf_psi_test.cc | 16 +-
.../ecdh_oprf => ecdh}/ecdh_oprf_selector.cc | 10 +-
.../ecdh_oprf => ecdh}/ecdh_oprf_selector.h | 6 +-
psi/{psi/core => ecdh}/ecdh_psi.cc | 37 +-
psi/{psi/core => ecdh}/ecdh_psi.h | 20 +-
.../ecdh_psi_benchmark.cc} | 20 +-
psi/{psi/core => ecdh}/ecdh_psi_test.cc | 10 +-
psi/{psi => }/ecdh/receiver.cc | 14 +-
psi/{psi => }/ecdh/receiver.h | 10 +-
psi/{psi => }/ecdh/sender.cc | 14 +-
psi/{psi => }/ecdh/sender.h | 10 +-
psi/{psi => }/ecdh/server.cc | 12 +-
psi/{psi => }/ecdh/server.h | 8 +-
psi/{psi => }/factory.cc | 22 +-
psi/{psi => }/factory.h | 6 +-
psi/{psi => }/interface.cc | 20 +-
psi/{psi => }/interface.h | 10 +-
psi/kkrt/BUILD.bazel | 88 ++++
psi/{psi => }/kkrt/common.cc | 8 +-
psi/{psi => }/kkrt/common.h | 6 +-
psi/{psi/core => kkrt}/kkrt_psi.cc | 12 +-
psi/{psi/core => kkrt}/kkrt_psi.h | 4 +-
.../kkrt_psi_benchmark.cc} | 10 +-
psi/{psi/core => kkrt}/kkrt_psi_test.cc | 6 +-
psi/{psi => }/kkrt/receiver.cc | 22 +-
psi/{psi => }/kkrt/receiver.h | 8 +-
psi/{psi => }/kkrt/sender.cc | 22 +-
psi/{psi => }/kkrt/sender.h | 8 +-
psi/{psi => }/launch.cc | 14 +-
psi/{psi => }/launch.h | 6 +-
psi/{psi/operator => legacy}/BUILD.bazel | 101 ++++-
psi/{psi/operator => legacy}/base_operator.cc | 10 +-
psi/{psi/operator => legacy}/base_operator.h | 4 +-
.../operator => legacy}/bc22_2party_psi.cc | 12 +-
.../operator => legacy}/bc22_2party_psi.h | 6 +-
psi/{psi => legacy}/bucket_psi.cc | 33 +-
psi/{psi => legacy}/bucket_psi.h | 16 +-
psi/{psi => legacy}/bucket_psi_test.cc | 8 +-
psi/{psi => legacy}/bucket_ub_psi.cc | 74 ++--
psi/{psi => legacy}/bucket_ub_psi.h | 24 +-
psi/{psi => legacy}/bucket_ub_psi_test.cc | 10 +-
psi/{psi/operator => legacy}/dp_2party_psi.cc | 23 +-
psi/{psi/operator => legacy}/dp_2party_psi.h | 12 +-
psi/{psi/core => legacy}/dp_psi/BUILD.bazel | 33 +-
psi/{psi/core => legacy}/dp_psi/dp_psi.cc | 30 +-
psi/{psi/core => legacy}/dp_psi/dp_psi.h | 6 +-
.../dp_psi/dp_psi_benchmark.cc} | 6 +-
.../dp_psi/dp_psi_payload_benchmark.cc} | 8 +-
.../core => legacy}/dp_psi/dp_psi_test.cc | 6 +-
.../core => legacy}/dp_psi/dp_psi_utils.cc | 6 +-
.../core => legacy}/dp_psi/dp_psi_utils.h | 4 +-
.../operator => legacy}/ecdh_3party_psi.cc | 14 +-
.../operator => legacy}/ecdh_3party_psi.h | 10 +-
psi/{psi/operator => legacy}/factory.h | 6 +-
.../operator => legacy}/kkrt_2party_psi.cc | 19 +-
.../operator => legacy}/kkrt_2party_psi.h | 7 +-
psi/{psi => legacy}/memory_psi.cc | 18 +-
psi/{psi => legacy}/memory_psi.h | 4 +-
psi/{psi => legacy}/memory_psi_test.cc | 8 +-
.../mini_psi}/BUILD.bazel | 43 +-
psi/{psi/core => legacy/mini_psi}/mini_psi.cc | 20 +-
psi/{psi/core => legacy/mini_psi}/mini_psi.h | 5 +-
.../core => legacy/mini_psi}/mini_psi_demo.cc | 18 +-
.../core => legacy/mini_psi}/mini_psi_test.cc | 8 +-
.../mini_psi}/polynomial.cc | 6 +-
.../mini_psi}/polynomial.h | 4 +-
.../mini_psi}/polynomial_test.cc | 6 +-
psi/{psi/operator => legacy}/nparty_psi.cc | 24 +-
psi/{psi/operator => legacy}/nparty_psi.h | 8 +-
.../operator => legacy}/nparty_psi_test.cc | 8 +-
.../operator => legacy}/rr22_2party_psi.cc | 21 +-
.../operator => legacy}/rr22_2party_psi.h | 10 +-
psi/main.cc | 13 +-
psi/{psi => }/prelude.h | 16 +-
psi/proto/entry.proto | 6 +-
psi/proto/pir.proto | 2 +-
psi/proto/psi.proto | 2 +-
psi/proto/psi_v2.proto | 4 +-
psi/psi/BUILD.bazel | 181 ---------
psi/psi/benchmark/BUILD.bazel | 64 ---
psi/psi/benchmark/mparty_bench.cc | 102 -----
psi/psi/benchmark/mparty_bench.h | 310 --------------
psi/psi/benchmark/standalone_bench.cc | 45 ---
psi/psi/benchmark/standalone_bench.h | 380 ------------------
psi/psi/core/BUILD.bazel | 224 -----------
psi/psi/core/ecdh_oprf/BUILD.bazel | 84 ----
psi/psi/core/generate_psi.py | 75 ----
psi/psi/ecdh/BUILD.bazel | 67 ---
psi/psi/kkrt/BUILD.bazel | 52 ---
psi/psi/rr22/BUILD.bazel | 51 ---
psi/{psi => }/psi_test.cc | 10 +-
psi/{psi/core/vole_psi => rr22}/BUILD.bazel | 76 +++-
psi/{psi => }/rr22/common.cc | 8 +-
psi/{psi => }/rr22/common.h | 10 +-
.../vole_psi => rr22}/davis_meyer_hash.cc | 8 +-
.../core/vole_psi => rr22}/davis_meyer_hash.h | 4 +-
.../davis_meyer_hash_test.cc | 6 +-
.../core/vole_psi => rr22}/okvs/BUILD.bazel | 0
.../core/vole_psi => rr22}/okvs/aes_crhash.cc | 6 +-
.../core/vole_psi => rr22}/okvs/aes_crhash.h | 4 +-
.../vole_psi => rr22}/okvs/aes_crhash_test.cc | 8 +-
psi/{psi/core/vole_psi => rr22}/okvs/baxos.cc | 8 +-
psi/{psi/core/vole_psi => rr22}/okvs/baxos.h | 12 +-
.../core/vole_psi => rr22}/okvs/baxos_test.cc | 6 +-
.../core/vole_psi => rr22}/okvs/dense_mtx.cc | 6 +-
.../core/vole_psi => rr22}/okvs/dense_mtx.h | 6 +-
.../core/vole_psi => rr22}/okvs/galois128.cc | 8 +-
.../core/vole_psi => rr22}/okvs/galois128.h | 6 +-
.../vole_psi => rr22}/okvs/galois128_test.cc | 6 +-
psi/{psi/core/vole_psi => rr22}/okvs/paxos.cc | 6 +-
psi/{psi/core/vole_psi => rr22}/okvs/paxos.h | 12 +-
.../core/vole_psi => rr22}/okvs/paxos_hash.cc | 6 +-
.../core/vole_psi => rr22}/okvs/paxos_hash.h | 8 +-
.../vole_psi => rr22}/okvs/paxos_hash_test.cc | 6 +-
.../core/vole_psi => rr22}/okvs/paxos_test.cc | 6 +-
.../vole_psi => rr22}/okvs/paxos_utils.cc | 4 +-
.../core/vole_psi => rr22}/okvs/paxos_utils.h | 6 +-
.../vole_psi => rr22}/okvs/simple_index.cc | 6 +-
.../vole_psi => rr22}/okvs/simple_index.h | 4 +-
psi/{psi => }/rr22/receiver.cc | 22 +-
psi/{psi => }/rr22/receiver.h | 8 +-
psi/{psi/core/vole_psi => rr22}/rr22_oprf.cc | 10 +-
psi/{psi/core/vole_psi => rr22}/rr22_oprf.h | 6 +-
.../core/vole_psi => rr22}/rr22_oprf_test.cc | 8 +-
psi/{psi/core/vole_psi => rr22}/rr22_psi.cc | 22 +-
psi/{psi/core/vole_psi => rr22}/rr22_psi.h | 14 +-
.../rr22_psi_benchmark.cc} | 16 +-
.../core/vole_psi => rr22}/rr22_psi_test.cc | 12 +-
psi/{psi/core/vole_psi => rr22}/rr22_utils.cc | 10 +-
psi/{psi/core/vole_psi => rr22}/rr22_utils.h | 2 +-
psi/{psi => }/rr22/sender.cc | 20 +-
psi/{psi => }/rr22/sender.h | 8 +-
.../core/vole_psi => rr22}/sparseconfig.h | 0
psi/{pir => seal_pir}/BUILD.bazel | 30 +-
psi/{pir => seal_pir}/seal_mpir.cc | 16 +-
psi/{pir => seal_pir}/seal_mpir.h | 14 +-
psi/{pir => seal_pir}/seal_mpir_test.cc | 19 +-
psi/{pir => seal_pir}/seal_pir.cc | 12 +-
psi/{pir => seal_pir}/seal_pir.h | 8 +-
psi/{pir => seal_pir}/seal_pir_test.cc | 16 +-
psi/{pir => seal_pir}/seal_pir_utils.cc | 6 +-
psi/{pir => seal_pir}/seal_pir_utils.h | 4 +-
psi/{pir => seal_pir}/serializable.proto | 2 +-
psi/{psi => }/trace_categories.cc | 2 +-
psi/{psi => }/trace_categories.h | 0
psi/{psi => }/utils/BUILD.bazel | 48 ++-
psi/{psi => }/utils/advanced_join.cc | 10 +-
psi/{psi => }/utils/advanced_join.h | 4 +-
psi/{psi => }/utils/advanced_join_test.cc | 6 +-
.../utils/arrow_csv_batch_provider.cc | 8 +-
.../utils/arrow_csv_batch_provider.h | 6 +-
.../utils/arrow_csv_batch_provider_test.cc | 6 +-
psi/{psi => }/utils/batch_provider.cc | 8 +-
psi/{psi => }/utils/batch_provider.h | 8 +-
psi/{psi => }/utils/bucket.cc | 10 +-
psi/{psi => }/utils/bucket.h | 10 +-
psi/{psi/core => utils}/communication.cc | 6 +-
psi/{psi/core => utils}/communication.h | 6 +-
psi/{psi => }/utils/csv_checker.cc | 10 +-
psi/{psi => }/utils/csv_checker.h | 4 +-
psi/{psi => }/utils/csv_checker_test.cc | 8 +-
psi/{psi => }/utils/csv_header_analyzer.h | 4 +-
psi/{psi => }/utils/csv_header_parser.cc | 6 +-
psi/{psi => }/utils/csv_header_parser.h | 4 +-
psi/{psi => }/utils/csv_header_parser_test.cc | 6 +-
psi/{psi/core => utils}/cuckoo_index.cc | 6 +-
psi/{psi/core => utils}/cuckoo_index.h | 4 +-
psi/{psi/core => utils}/cuckoo_index_test.cc | 6 +-
psi/{psi => }/utils/ec.cc | 10 +-
psi/{psi => }/utils/ec.h | 4 +-
psi/{psi => }/utils/ec_point_store.cc | 8 +-
psi/{psi => }/utils/ec_point_store.h | 8 +-
psi/{psi => }/utils/emp_io_adapter.cc | 2 +-
psi/{psi => }/utils/emp_io_adapter.h | 0
psi/{psi => }/utils/emp_io_adapter_test.cc | 2 +-
psi/{psi => }/utils/hash_bucket_cache.cc | 8 +-
psi/{psi => }/utils/hash_bucket_cache.h | 8 +-
psi/{psi => }/utils/index_store.cc | 6 +-
psi/{psi => }/utils/index_store.h | 4 +-
psi/{psi => }/utils/index_store_test.cc | 6 +-
psi/{psi => }/utils/io.cc | 6 +-
psi/{psi => }/utils/io.h | 4 +-
psi/{psi => }/utils/key.cc | 10 +-
psi/{psi => }/utils/key.h | 4 +-
psi/{psi => }/utils/multiplex_disk_cache.cc | 6 +-
psi/{psi => }/utils/multiplex_disk_cache.h | 6 +-
.../utils/multiplex_disk_cache_test.cc | 8 +-
psi/{psi => }/utils/progress.cc | 6 +-
psi/{psi => }/utils/progress.h | 4 +-
psi/{psi => }/utils/progress_test.cc | 6 +-
psi/{psi => }/utils/recovery.cc | 8 +-
psi/{psi => }/utils/recovery.h | 6 +-
psi/{psi => }/utils/recovery_test.cc | 8 +-
psi/{psi => }/utils/resource.cc | 6 +-
psi/{psi => }/utils/resource.h | 4 +-
psi/{psi => }/utils/serializable.proto | 2 +-
psi/{psi => }/utils/serialize.h | 6 +-
psi/{psi => }/utils/sync.cc | 8 +-
psi/{psi => }/utils/sync.h | 6 +-
psi/{psi => }/utils/test_utils.h | 4 +-
psi/{psi => }/utils/ub_psi_cache.cc | 8 +-
psi/{psi => }/utils/ub_psi_cache.h | 8 +-
psi/{psi => }/utils/ub_psi_cache_test.cc | 6 +-
psi/version.h | 2 +-
301 files changed, 2808 insertions(+), 3617 deletions(-)
create mode 100644 docs/user_guide/faq.md
rename psi/{psi/core/labeled_psi => apsi}/BUILD.bazel (52%)
rename psi/{psi/core/labeled_psi => apsi}/README.md (100%)
rename psi/{psi/core/labeled_psi/apsi_bench.cc => apsi/apsi_benchmark.cc} (91%)
rename psi/{psi/core/labeled_psi => apsi}/apsi_label_test.cc (90%)
rename psi/{psi/core/labeled_psi => apsi}/apsi_test.cc (90%)
rename psi/{psi/core/labeled_psi => apsi}/kv_test.cc (90%)
rename psi/{psi/core/labeled_psi => apsi}/package.cc (93%)
rename psi/{psi/core/labeled_psi => apsi}/package.h (83%)
rename psi/{psi/core/labeled_psi => apsi}/padding.cc (94%)
rename psi/{psi/core/labeled_psi => apsi}/padding.h (94%)
rename psi/{pir => apsi}/pir.cc (77%)
rename psi/{pir => apsi}/pir.h (94%)
rename psi/{pir => apsi}/pir_test.cc (80%)
rename psi/{psi/core/labeled_psi => apsi}/psi_params.cc (91%)
rename psi/{psi/core/labeled_psi => apsi}/psi_params.h (73%)
rename psi/{psi/core/labeled_psi => apsi}/receiver.cc (90%)
rename psi/{psi/core/labeled_psi => apsi}/receiver.h (76%)
rename psi/{psi/core/labeled_psi => apsi}/sender.cc (89%)
rename psi/{psi/core/labeled_psi => apsi}/sender.h (83%)
rename psi/{psi/core/labeled_psi => apsi}/sender_db.cc (87%)
rename psi/{psi/core/labeled_psi => apsi}/sender_db.h (88%)
rename psi/{psi/core/labeled_psi => apsi}/sender_kvdb.cc (87%)
rename psi/{psi/core/labeled_psi => apsi}/sender_kvdb.h (93%)
rename psi/{psi/core/labeled_psi => apsi}/sender_memdb.cc (86%)
rename psi/{psi/core/labeled_psi => apsi}/sender_memdb.h (89%)
rename psi/{psi/core/labeled_psi => apsi}/serializable.proto (98%)
rename psi/{psi/core/labeled_psi => apsi}/serialize.h (75%)
rename psi/{psi/core/bc22_psi => bc22}/BUILD.bazel (90%)
rename psi/{psi/core/bc22_psi => bc22}/bc22_psi.cc (98%)
rename psi/{psi/core/bc22_psi => bc22}/bc22_psi.h (93%)
rename psi/{psi/core/bc22_psi/bc22_psi_bench.cc => bc22/bc22_psi_benchmark.cc} (97%)
rename psi/{psi/core/bc22_psi => bc22}/bc22_psi_test.cc (97%)
rename psi/{psi/core/bc22_psi => bc22}/emp_vole.cc (97%)
rename psi/{psi/core/bc22_psi => bc22}/emp_vole.h (93%)
rename psi/{psi/core/bc22_psi => bc22}/emp_vole_test.cc (96%)
rename psi/{psi/core/bc22_psi => bc22}/generalized_cuckoo_hash.cc (98%)
rename psi/{psi/core/bc22_psi => bc22}/generalized_cuckoo_hash.h (97%)
rename psi/{psi/core/bc22_psi => bc22}/generalized_cuckoo_hash_test.cc (97%)
rename psi/{psi => }/cryptor/BUILD.bazel (99%)
rename psi/{psi => }/cryptor/cryptor_selector.cc (90%)
rename psi/{psi => }/cryptor/cryptor_selector.h (88%)
rename psi/{psi => }/cryptor/ecc_cryptor.cc (97%)
rename psi/{psi => }/cryptor/ecc_cryptor.h (98%)
rename psi/{psi => }/cryptor/ecc_utils.h (99%)
rename psi/{psi => }/cryptor/ecc_utils_test.cc (92%)
rename psi/{psi => }/cryptor/fourq_cryptor.cc (96%)
rename psi/{psi => }/cryptor/fourq_cryptor.h (92%)
rename psi/{psi => }/cryptor/fpga_ecc_cryptor.h (90%)
rename psi/{psi => }/cryptor/hash_to_curve_elligator2.cc (99%)
rename psi/{psi => }/cryptor/hash_to_curve_elligator2.h (96%)
rename psi/{psi => }/cryptor/hash_to_curve_elligator2_test.cc (95%)
rename psi/{psi => }/cryptor/ipp_ecc_cryptor.cc (94%)
rename psi/{psi => }/cryptor/ipp_ecc_cryptor.h (93%)
rename psi/{psi => }/cryptor/sm2_cryptor.cc (95%)
rename psi/{psi => }/cryptor/sm2_cryptor.h (95%)
rename psi/{psi => }/cryptor/sm2_cryptor_test.cc (97%)
rename psi/{psi => }/cryptor/sodium_curve25519_cryptor.cc (94%)
rename psi/{psi => }/cryptor/sodium_curve25519_cryptor.h (95%)
create mode 100644 psi/ecdh/BUILD.bazel
rename psi/{psi/core/ecdh_oprf => ecdh}/basic_ecdh_oprf.cc (99%)
rename psi/{psi/core/ecdh_oprf => ecdh}/basic_ecdh_oprf.h (96%)
rename psi/{psi/core/ecdh_oprf => ecdh}/basic_ecdh_oprf_test.cc (94%)
rename psi/{psi => }/ecdh/client.cc (95%)
rename psi/{psi => }/ecdh/client.h (89%)
rename psi/{psi => }/ecdh/common.h (92%)
rename psi/{psi/core => ecdh}/ecdh_3pc_psi.cc (98%)
rename psi/{psi/core => ecdh}/ecdh_3pc_psi.h (97%)
rename psi/{psi/core/ecdh_3pc_psi_bench.cc => ecdh/ecdh_3pc_psi_benchmark.cc} (78%)
rename psi/{psi/core => ecdh}/ecdh_3pc_psi_test.cc (78%)
create mode 100644 psi/ecdh/ecdh_logger.h
rename psi/{psi/core/ecdh_oprf => ecdh}/ecdh_oprf.cc (96%)
rename psi/{psi/core/ecdh_oprf => ecdh}/ecdh_oprf.h (98%)
rename psi/{psi/core => ecdh}/ecdh_oprf_psi.cc (98%)
rename psi/{psi/core => ecdh}/ecdh_oprf_psi.h (96%)
rename psi/{psi/core => ecdh}/ecdh_oprf_psi_test.cc (97%)
rename psi/{psi/core/ecdh_oprf => ecdh}/ecdh_oprf_selector.cc (96%)
rename psi/{psi/core/ecdh_oprf => ecdh}/ecdh_oprf_selector.h (92%)
rename psi/{psi/core => ecdh}/ecdh_psi.cc (92%)
rename psi/{psi/core => ecdh}/ecdh_psi.h (92%)
rename psi/{psi/core/ecdh_psi_bench.cc => ecdh/ecdh_psi_benchmark.cc} (82%)
rename psi/{psi/core => ecdh}/ecdh_psi_test.cc (97%)
rename psi/{psi => }/ecdh/receiver.cc (94%)
rename psi/{psi => }/ecdh/receiver.h (87%)
rename psi/{psi => }/ecdh/sender.cc (94%)
rename psi/{psi => }/ecdh/sender.h (87%)
rename psi/{psi => }/ecdh/server.cc (96%)
rename psi/{psi => }/ecdh/server.h (89%)
rename psi/{psi => }/factory.cc (87%)
rename psi/{psi => }/factory.h (92%)
rename psi/{psi => }/interface.cc (97%)
rename psi/{psi => }/interface.h (96%)
create mode 100644 psi/kkrt/BUILD.bazel
rename psi/{psi => }/kkrt/common.cc (88%)
rename psi/{psi => }/kkrt/common.h (89%)
rename psi/{psi/core => kkrt}/kkrt_psi.cc (98%)
rename psi/{psi/core => kkrt}/kkrt_psi.h (98%)
rename psi/{psi/core/kkrt_psi_bench.cc => kkrt/kkrt_psi_benchmark.cc} (88%)
rename psi/{psi/core => kkrt}/kkrt_psi_test.cc (98%)
rename psi/{psi => }/kkrt/receiver.cc (93%)
rename psi/{psi => }/kkrt/receiver.h (90%)
rename psi/{psi => }/kkrt/sender.cc (92%)
rename psi/{psi => }/kkrt/sender.h (89%)
rename psi/{psi => }/launch.cc (96%)
rename psi/{psi => }/launch.h (94%)
rename psi/{psi/operator => legacy}/BUILD.bazel (57%)
rename psi/{psi/operator => legacy}/base_operator.cc (87%)
rename psi/{psi/operator => legacy}/base_operator.h (96%)
rename psi/{psi/operator => legacy}/bc22_2party_psi.cc (88%)
rename psi/{psi/operator => legacy}/bc22_2party_psi.h (92%)
rename psi/{psi => legacy}/bucket_psi.cc (96%)
rename psi/{psi => legacy}/bucket_psi.h (95%)
rename psi/{psi => legacy}/bucket_psi_test.cc (99%)
rename psi/{psi => legacy}/bucket_ub_psi.cc (87%)
rename psi/{psi => legacy}/bucket_ub_psi.h (76%)
rename psi/{psi => legacy}/bucket_ub_psi_test.cc (98%)
rename psi/{psi/operator => legacy}/dp_2party_psi.cc (78%)
rename psi/{psi/operator => legacy}/dp_2party_psi.h (81%)
rename psi/{psi/core => legacy}/dp_psi/BUILD.bazel (77%)
rename psi/{psi/core => legacy}/dp_psi/dp_psi.cc (94%)
rename psi/{psi/core => legacy}/dp_psi/dp_psi.h (96%)
rename psi/{psi/core/dp_psi/dp_psi_bench.cc => legacy/dp_psi/dp_psi_benchmark.cc} (98%)
rename psi/{psi/core/dp_psi/dp_psi_payload_bench.cc => legacy/dp_psi/dp_psi_payload_benchmark.cc} (98%)
rename psi/{psi/core => legacy}/dp_psi/dp_psi_test.cc (97%)
rename psi/{psi/core => legacy}/dp_psi/dp_psi_utils.cc (98%)
rename psi/{psi/core => legacy}/dp_psi/dp_psi_utils.h (95%)
rename psi/{psi/operator => legacy}/ecdh_3party_psi.cc (91%)
rename psi/{psi/operator => legacy}/ecdh_3party_psi.h (95%)
rename psi/{psi/operator => legacy}/factory.h (96%)
rename psi/{psi/operator => legacy}/kkrt_2party_psi.cc (80%)
rename psi/{psi/operator => legacy}/kkrt_2party_psi.h (90%)
rename psi/{psi => legacy}/memory_psi.cc (90%)
rename psi/{psi => legacy}/memory_psi.h (96%)
rename psi/{psi => legacy}/memory_psi_test.cc (98%)
rename psi/{psi/core/polynomial => legacy/mini_psi}/BUILD.bazel (50%)
rename psi/{psi/core => legacy/mini_psi}/mini_psi.cc (97%)
rename psi/{psi/core => legacy/mini_psi}/mini_psi.h (96%)
rename psi/{psi/core => legacy/mini_psi}/mini_psi_demo.cc (91%)
rename psi/{psi/core => legacy/mini_psi}/mini_psi_test.cc (95%)
rename psi/{psi/core/polynomial => legacy/mini_psi}/polynomial.cc (98%)
rename psi/{psi/core/polynomial => legacy/mini_psi}/polynomial.h (96%)
rename psi/{psi/core/polynomial => legacy/mini_psi}/polynomial_test.cc (96%)
rename psi/{psi/operator => legacy}/nparty_psi.cc (94%)
rename psi/{psi/operator => legacy}/nparty_psi.h (95%)
rename psi/{psi/operator => legacy}/nparty_psi_test.cc (97%)
rename psi/{psi/operator => legacy}/rr22_2party_psi.cc (89%)
rename psi/{psi/operator => legacy}/rr22_2party_psi.h (85%)
rename psi/{psi => }/prelude.h (63%)
delete mode 100644 psi/psi/BUILD.bazel
delete mode 100644 psi/psi/benchmark/BUILD.bazel
delete mode 100644 psi/psi/benchmark/mparty_bench.cc
delete mode 100644 psi/psi/benchmark/mparty_bench.h
delete mode 100644 psi/psi/benchmark/standalone_bench.cc
delete mode 100644 psi/psi/benchmark/standalone_bench.h
delete mode 100644 psi/psi/core/BUILD.bazel
delete mode 100644 psi/psi/core/ecdh_oprf/BUILD.bazel
delete mode 100644 psi/psi/core/generate_psi.py
delete mode 100644 psi/psi/ecdh/BUILD.bazel
delete mode 100644 psi/psi/kkrt/BUILD.bazel
delete mode 100644 psi/psi/rr22/BUILD.bazel
rename psi/{psi => }/psi_test.cc (99%)
rename psi/{psi/core/vole_psi => rr22}/BUILD.bazel (74%)
rename psi/{psi => }/rr22/common.cc (91%)
rename psi/{psi => }/rr22/common.h (84%)
rename psi/{psi/core/vole_psi => rr22}/davis_meyer_hash.cc (94%)
rename psi/{psi/core/vole_psi => rr22}/davis_meyer_hash.h (96%)
rename psi/{psi/core/vole_psi => rr22}/davis_meyer_hash_test.cc (93%)
rename psi/{psi/core/vole_psi => rr22}/okvs/BUILD.bazel (100%)
rename psi/{psi/core/vole_psi => rr22}/okvs/aes_crhash.cc (96%)
rename psi/{psi/core/vole_psi => rr22}/okvs/aes_crhash.h (96%)
rename psi/{psi/core/vole_psi => rr22}/okvs/aes_crhash_test.cc (92%)
rename psi/{psi/core/vole_psi => rr22}/okvs/baxos.cc (99%)
rename psi/{psi/core/vole_psi => rr22}/okvs/baxos.h (95%)
rename psi/{psi/core/vole_psi => rr22}/okvs/baxos_test.cc (95%)
rename psi/{psi/core/vole_psi => rr22}/okvs/dense_mtx.cc (96%)
rename psi/{psi/core/vole_psi => rr22}/okvs/dense_mtx.h (98%)
rename psi/{psi/core/vole_psi => rr22}/okvs/galois128.cc (96%)
rename psi/{psi/core/vole_psi => rr22}/okvs/galois128.h (95%)
rename psi/{psi/core/vole_psi => rr22}/okvs/galois128_test.cc (95%)
rename psi/{psi/core/vole_psi => rr22}/okvs/paxos.cc (99%)
rename psi/{psi/core/vole_psi => rr22}/okvs/paxos.h (96%)
rename psi/{psi/core/vole_psi => rr22}/okvs/paxos_hash.cc (99%)
rename psi/{psi/core/vole_psi => rr22}/okvs/paxos_hash.h (97%)
rename psi/{psi/core/vole_psi => rr22}/okvs/paxos_hash_test.cc (93%)
rename psi/{psi/core/vole_psi => rr22}/okvs/paxos_test.cc (96%)
rename psi/{psi/core/vole_psi => rr22}/okvs/paxos_utils.cc (88%)
rename psi/{psi/core/vole_psi => rr22}/okvs/paxos_utils.h (98%)
rename psi/{psi/core/vole_psi => rr22}/okvs/simple_index.cc (99%)
rename psi/{psi/core/vole_psi => rr22}/okvs/simple_index.h (93%)
rename psi/{psi => }/rr22/receiver.cc (93%)
rename psi/{psi => }/rr22/receiver.h (89%)
rename psi/{psi/core/vole_psi => rr22}/rr22_oprf.cc (99%)
rename psi/{psi/core/vole_psi => rr22}/rr22_oprf.h (98%)
rename psi/{psi/core/vole_psi => rr22}/rr22_oprf_test.cc (96%)
rename psi/{psi/core/vole_psi => rr22}/rr22_psi.cc (91%)
rename psi/{psi/core/vole_psi => rr22}/rr22_psi.h (86%)
rename psi/{psi/core/vole_psi/rr22_psi_bench.cc => rr22/rr22_psi_benchmark.cc} (90%)
rename psi/{psi/core/vole_psi => rr22}/rr22_psi_test.cc (91%)
rename psi/{psi/core/vole_psi => rr22}/rr22_utils.cc (96%)
rename psi/{psi/core/vole_psi => rr22}/rr22_utils.h (97%)
rename psi/{psi => }/rr22/sender.cc (92%)
rename psi/{psi => }/rr22/sender.h (89%)
rename psi/{psi/core/vole_psi => rr22}/sparseconfig.h (100%)
rename psi/{pir => seal_pir}/BUILD.bazel (75%)
rename psi/{pir => seal_pir}/seal_mpir.cc (96%)
rename psi/{pir => seal_pir}/seal_mpir.h (94%)
rename psi/{pir => seal_pir}/seal_mpir_test.cc (91%)
rename psi/{pir => seal_pir}/seal_pir.cc (99%)
rename psi/{pir => seal_pir}/seal_pir.h (98%)
rename psi/{pir => seal_pir}/seal_pir_test.cc (90%)
rename psi/{pir => seal_pir}/seal_pir_utils.cc (95%)
rename psi/{pir => seal_pir}/seal_pir_utils.h (98%)
rename psi/{pir => seal_pir}/serializable.proto (98%)
rename psi/{psi => }/trace_categories.cc (94%)
rename psi/{psi => }/trace_categories.h (100%)
rename psi/{psi => }/utils/BUILD.bazel (88%)
rename psi/{psi => }/utils/advanced_join.cc (99%)
rename psi/{psi => }/utils/advanced_join.h (98%)
rename psi/{psi => }/utils/advanced_join_test.cc (99%)
rename psi/{psi => }/utils/arrow_csv_batch_provider.cc (95%)
rename psi/{psi => }/utils/arrow_csv_batch_provider.h (94%)
rename psi/{psi => }/utils/arrow_csv_batch_provider_test.cc (96%)
rename psi/{psi => }/utils/batch_provider.cc (99%)
rename psi/{psi => }/utils/batch_provider.h (97%)
rename psi/{psi => }/utils/bucket.cc (95%)
rename psi/{psi => }/utils/bucket.h (89%)
rename psi/{psi/core => utils}/communication.cc (96%)
rename psi/{psi/core => utils}/communication.h (97%)
rename psi/{psi => }/utils/csv_checker.cc (98%)
rename psi/{psi => }/utils/csv_checker.h (96%)
rename psi/{psi => }/utils/csv_checker_test.cc (98%)
rename psi/{psi => }/utils/csv_header_analyzer.h (99%)
rename psi/{psi => }/utils/csv_header_parser.cc (96%)
rename psi/{psi => }/utils/csv_header_parser.h (96%)
rename psi/{psi => }/utils/csv_header_parser_test.cc (94%)
rename psi/{psi/core => utils}/cuckoo_index.cc (98%)
rename psi/{psi/core => utils}/cuckoo_index.h (99%)
rename psi/{psi/core => utils}/cuckoo_index_test.cc (97%)
rename psi/{psi => }/utils/ec.cc (89%)
rename psi/{psi => }/utils/ec.h (93%)
rename psi/{psi => }/utils/ec_point_store.cc (98%)
rename psi/{psi => }/utils/ec_point_store.h (96%)
rename psi/{psi => }/utils/emp_io_adapter.cc (99%)
rename psi/{psi => }/utils/emp_io_adapter.h (100%)
rename psi/{psi => }/utils/emp_io_adapter_test.cc (98%)
rename psi/{psi => }/utils/hash_bucket_cache.cc (95%)
rename psi/{psi => }/utils/hash_bucket_cache.h (94%)
rename psi/{psi => }/utils/index_store.cc (98%)
rename psi/{psi => }/utils/index_store.h (97%)
rename psi/{psi => }/utils/index_store_test.cc (97%)
rename psi/{psi => }/utils/io.cc (97%)
rename psi/{psi => }/utils/io.h (98%)
rename psi/{psi => }/utils/key.cc (95%)
rename psi/{psi => }/utils/key.h (97%)
rename psi/{psi => }/utils/multiplex_disk_cache.cc (96%)
rename psi/{psi => }/utils/multiplex_disk_cache.h (96%)
rename psi/{psi => }/utils/multiplex_disk_cache_test.cc (95%)
rename psi/{psi => }/utils/progress.cc (97%)
rename psi/{psi => }/utils/progress.h (97%)
rename psi/{psi => }/utils/progress_test.cc (96%)
rename psi/{psi => }/utils/recovery.cc (98%)
rename psi/{psi => }/utils/recovery.h (97%)
rename psi/{psi => }/utils/recovery_test.cc (96%)
rename psi/{psi => }/utils/resource.cc (95%)
rename psi/{psi => }/utils/resource.h (94%)
rename psi/{psi => }/utils/serializable.proto (97%)
rename psi/{psi => }/utils/serialize.h (94%)
rename psi/{psi => }/utils/sync.cc (94%)
rename psi/{psi => }/utils/sync.h (97%)
rename psi/{psi => }/utils/test_utils.h (96%)
rename psi/{psi => }/utils/ub_psi_cache.cc (97%)
rename psi/{psi => }/utils/ub_psi_cache.h (95%)
rename psi/{psi => }/utils/ub_psi_cache_test.cc (96%)
diff --git a/.github/workflows/scorecard.yml b/.github/workflows/scorecard.yml
index f84f2f1f..188012c1 100644
--- a/.github/workflows/scorecard.yml
+++ b/.github/workflows/scorecard.yml
@@ -67,6 +67,6 @@ jobs:
# Upload the results to GitHub's code scanning dashboard.
- name: "Upload to code-scanning"
- uses: github/codeql-action/upload-sarif@379614612a29c9e28f31f39a59013eb8012a51f0 # v3.24.3
+ uses: github/codeql-action/upload-sarif@0b21cf2492b6b02c465a3e5d7c473717ad7721ba # v3.23.1
with:
sarif_file: results.sarif
diff --git a/README.md b/README.md
index 7ada0339..9cd9a228 100644
--- a/README.md
+++ b/README.md
@@ -119,13 +119,13 @@ sender.config:
In the first terminal, run the following command
```bash
-docker run -it --rm --network host --mount type=bind,source=/tmp/receiver,target=/root/receiver -w /root --cap-add=SYS_PTRACE --security-opt seccomp=unconfined --cap-add=NET_ADMIN --privileged=true secretflow-registry.cn-hangzhou.cr.aliyuncs.com/secretflow/psi-anolis8:latest bash -c "./main --config receiver/receiver.config"
+docker run -it --rm --network host --mount type=bind,source=/tmp/receiver,target=/root/receiver --cap-add=SYS_PTRACE --security-opt seccomp=unconfined --cap-add=NET_ADMIN --privileged=true secretflow-registry.cn-hangzhou.cr.aliyuncs.com/secretflow/psi-anolis8:latest bash -c "./main --config receiver/receiver.config"
```
In the other terminal, run the following command simultaneously.
```bash
-docker run -it --rm --network host --mount type=bind,source=/tmp/sender,target=/root/sender -w /root --cap-add=SYS_PTRACE --security-opt seccomp=unconfined --cap-add=NET_ADMIN --privileged=true secretflow-registry.cn-hangzhou.cr.aliyuncs.com/secretflow/psi-anolis8:latest bash -c "./main --config sender/sender.config"
+docker run -it --rm --network host --mount type=bind,source=/tmp/sender,target=/root/sender --cap-add=SYS_PTRACE --security-opt seccomp=unconfined --cap-add=NET_ADMIN --privileged=true secretflow-registry.cn-hangzhou.cr.aliyuncs.com/secretflow/psi-anolis8:latest bash -c "./main --config sender/sender.config"
```
## Building SecretFlow PSI Library
@@ -155,9 +155,12 @@ docker exec -it psi-dev-$(whoami) bash
#### Linux
```sh
-Install gcc>=11.2, cmake>=3.26, ninja, nasm>=2.15, python>=3.8, bazel==6.4.0, golang, xxd, lld
+Install gcc>=11.2, cmake>=3.26, ninja, nasm>=2.15, python>=3.8, bazel, golang, xxd, lld
```
+> **Note**
+Please install bazel with version in .bazelversion or use bazelisk.
+
### Build & UnitTest
diff --git a/RELEASE.md b/RELEASE.md
index 23b10952..819569a2 100644
--- a/RELEASE.md
+++ b/RELEASE.md
@@ -5,6 +5,11 @@
> - `[API]` prefix for API changes.
> - `[Improvement]` prefix for implementation improvement.
+## v0.2.0.dev240219
+
+- [Feature] add ecdh logger for debug purposes.
+- [API] modify repo structure.
+
## v0.2.0.dev240123
- [Feature] add RFC9380 25519 elligator2 hash_to_curve.
diff --git a/bazel/patches/apsi.patch b/bazel/patches/apsi.patch
index 34bd1d09..13eb7e79 100644
--- a/bazel/patches/apsi.patch
+++ b/bazel/patches/apsi.patch
@@ -95,9 +95,88 @@ index 3b15780..5085038 100644
if(APSI_FOURQ_AMD64)
add_subdirectory(amd64)
+diff --git a/common/apsi/fourq/FourQ_internal.h b/common/apsi/fourq/FourQ_internal.h
+index 009bb1d..5aa9886 100644
+--- a/common/apsi/fourq/FourQ_internal.h
++++ b/common/apsi/fourq/FourQ_internal.h
+@@ -143,7 +143,7 @@ static __inline unsigned int is_digit_lessthan_ct(digit_t x, digit_t y)
+
+ // 64x64-bit multiplication
+ #define MUL128(multiplier, multiplicand, product) \
+- mp_mul( \
++ fq_mp_mul( \
+ (digit_t *)&(multiplier), \
+ (digit_t *)&(multiplicand), \
+ (digit_t *)&(product), \
+@@ -151,12 +151,12 @@ static __inline unsigned int is_digit_lessthan_ct(digit_t x, digit_t y)
+
+ // 128-bit addition, inputs < 2^127
+ #define ADD128(addend1, addend2, addition) \
+- mp_add((digit_t *)(addend1), (digit_t *)(addend2), (digit_t *)(addition), NWORDS_FIELD);
++ fq_mp_add((digit_t *)(addend1), (digit_t *)(addend2), (digit_t *)(addition), NWORDS_FIELD);
+
+ // 128-bit addition with output carry
+ #define ADC128(addend1, addend2, carry, addition) \
+ (carry) = \
+- mp_add((digit_t *)(addend1), (digit_t *)(addend2), (digit_t *)(addition), NWORDS_FIELD);
++ fq_mp_add((digit_t *)(addend1), (digit_t *)(addend2), (digit_t *)(addition), NWORDS_FIELD);
+
+ #elif (TARGET == TARGET_AMD64 && OS_TARGET == OS_WIN)
+
+@@ -257,10 +257,10 @@ static __inline unsigned int is_digit_lessthan_ct(digit_t x, digit_t y)
+ bool is_zero_ct(digit_t *a, unsigned int nwords);
+
+ // Multiprecision addition, c = a+b. Returns the carry bit
+-unsigned int mp_add(digit_t *a, digit_t *b, digit_t *c, unsigned int nwords);
++unsigned int fq_mp_add(digit_t *a, digit_t *b, digit_t *c, unsigned int nwords);
+
+ // Schoolbook multiprecision multiply, c = a*b
+-void mp_mul(const digit_t *a, const digit_t *b, digit_t *c, const unsigned int nwords);
++void fq_mp_mul(const digit_t *a, const digit_t *b, digit_t *c, const unsigned int nwords);
+
+ // Multiprecision subtraction, c = a-b. Returns the borrow bit
+ #if defined(GENERIC_IMPLEMENTATION)
+diff --git a/common/apsi/fourq/generic/fp.h b/common/apsi/fourq/generic/fp.h
+index f475de1..e24a26a 100644
+--- a/common/apsi/fourq/generic/fp.h
++++ b/common/apsi/fourq/generic/fp.h
+@@ -172,7 +172,7 @@ void mod1271(felm_t a)
+ ADDC(borrow, a[NWORDS_FIELD - 1], (mask >> 1), borrow, a[NWORDS_FIELD - 1]);
+ }
+
+-void mp_mul(const digit_t *a, const digit_t *b, digit_t *c, const unsigned int nwords)
++void fq_mp_mul(const digit_t *a, const digit_t *b, digit_t *c, const unsigned int nwords)
+ { // Schoolbook multiprecision multiply, c = a*b
+ unsigned int i, j;
+ digit_t u, v, UV[2];
+@@ -195,7 +195,7 @@ void mp_mul(const digit_t *a, const digit_t *b, digit_t *c, const unsigned int n
+ }
+ }
+
+-unsigned int mp_add(digit_t *a, digit_t *b, digit_t *c, unsigned int nwords)
++unsigned int fq_mp_add(digit_t *a, digit_t *b, digit_t *c, unsigned int nwords)
+ { // Multiprecision addition, c = a+b, where lng(a) = lng(b) = nwords. Returns the carry bit
+ unsigned int i, carry = 0;
+
+@@ -263,13 +263,13 @@ void fpinv1271(felm_t a)
+ static void multiply(const digit_t *a, const digit_t *b, digit_t *c)
+ { // Schoolbook multiprecision multiply, c = a*b
+
+- mp_mul(a, b, c, NWORDS_ORDER);
++ fq_mp_mul(a, b, c, NWORDS_ORDER);
+ }
+
+ static unsigned int add(const digit_t *a, const digit_t *b, digit_t *c, const unsigned int nwords)
+ { // Multiprecision addition, c = a+b, where lng(a) = lng(b) = nwords. Returns the carry bit
+
+- return mp_add((digit_t *)a, (digit_t *)b, c, (unsigned int)nwords);
++ return fq_mp_add((digit_t *)a, (digit_t *)b, c, (unsigned int)nwords);
+ }
+
+ unsigned int subtract(const digit_t *a, const digit_t *b, digit_t *c, const unsigned int nwords)
diff --git a/common/apsi/fourq/kex.c b/common/apsi/fourq/kex.c
new file mode 100644
-index 0000000..5c37c60
+index 0000000..d59af6d
--- /dev/null
+++ b/common/apsi/fourq/kex.c
@@ -0,0 +1,181 @@
@@ -282,6 +361,19 @@ index 0000000..5c37c60
+
+ return Status;
+}
+diff --git a/common/apsi/util/stopwatch.h b/common/apsi/util/stopwatch.h
+index e09a53b..c5e4bab 100644
+--- a/common/apsi/util/stopwatch.h
++++ b/common/apsi/util/stopwatch.h
+@@ -22,7 +22,7 @@
+
+ // Measure a block
+ #define STOPWATCH(stopwatch, name) \
+- apsi::util::StopwatchScope UNIQUE_STOPWATCH_NAME(stopwatchscope)(stopwatch, name);
++ ::apsi::util::StopwatchScope UNIQUE_STOPWATCH_NAME(stopwatchscope)(stopwatch, name);
+
+ namespace apsi {
+ namespace util {
diff --git a/receiver/apsi/CMakeLists.txt b/receiver/apsi/CMakeLists.txt
index afce298..7757b68 100644
--- a/receiver/apsi/CMakeLists.txt
@@ -355,82 +447,3 @@ index fd245d7..99e4228 100644
DESTINATION
${APSI_INCLUDES_INSTALL_DIR}/apsi
)
- diff --git a/common/apsi/fourq/FourQ_internal.h b/common/apsi/fourq/FourQ_internal.h
-index 009bb1d..5aa9886 100644
---- a/common/apsi/fourq/FourQ_internal.h
-+++ b/common/apsi/fourq/FourQ_internal.h
-@@ -143,7 +143,7 @@ static __inline unsigned int is_digit_lessthan_ct(digit_t x, digit_t y)
-
- // 64x64-bit multiplication
- #define MUL128(multiplier, multiplicand, product) \
-- mp_mul( \
-+ fq_mp_mul( \
- (digit_t *)&(multiplier), \
- (digit_t *)&(multiplicand), \
- (digit_t *)&(product), \
-@@ -151,12 +151,12 @@ static __inline unsigned int is_digit_lessthan_ct(digit_t x, digit_t y)
-
- // 128-bit addition, inputs < 2^127
- #define ADD128(addend1, addend2, addition) \
-- mp_add((digit_t *)(addend1), (digit_t *)(addend2), (digit_t *)(addition), NWORDS_FIELD);
-+ fq_mp_add((digit_t *)(addend1), (digit_t *)(addend2), (digit_t *)(addition), NWORDS_FIELD);
-
- // 128-bit addition with output carry
- #define ADC128(addend1, addend2, carry, addition) \
- (carry) = \
-- mp_add((digit_t *)(addend1), (digit_t *)(addend2), (digit_t *)(addition), NWORDS_FIELD);
-+ fq_mp_add((digit_t *)(addend1), (digit_t *)(addend2), (digit_t *)(addition), NWORDS_FIELD);
-
- #elif (TARGET == TARGET_AMD64 && OS_TARGET == OS_WIN)
-
-@@ -257,10 +257,10 @@ static __inline unsigned int is_digit_lessthan_ct(digit_t x, digit_t y)
- bool is_zero_ct(digit_t *a, unsigned int nwords);
-
- // Multiprecision addition, c = a+b. Returns the carry bit
--unsigned int mp_add(digit_t *a, digit_t *b, digit_t *c, unsigned int nwords);
-+unsigned int fq_mp_add(digit_t *a, digit_t *b, digit_t *c, unsigned int nwords);
-
- // Schoolbook multiprecision multiply, c = a*b
--void mp_mul(const digit_t *a, const digit_t *b, digit_t *c, const unsigned int nwords);
-+void fq_mp_mul(const digit_t *a, const digit_t *b, digit_t *c, const unsigned int nwords);
-
- // Multiprecision subtraction, c = a-b. Returns the borrow bit
- #if defined(GENERIC_IMPLEMENTATION)
-diff --git a/common/apsi/fourq/generic/fp.h b/common/apsi/fourq/generic/fp.h
-index f475de1..e24a26a 100644
---- a/common/apsi/fourq/generic/fp.h
-+++ b/common/apsi/fourq/generic/fp.h
-@@ -172,7 +172,7 @@ void mod1271(felm_t a)
- ADDC(borrow, a[NWORDS_FIELD - 1], (mask >> 1), borrow, a[NWORDS_FIELD - 1]);
- }
-
--void mp_mul(const digit_t *a, const digit_t *b, digit_t *c, const unsigned int nwords)
-+void fq_mp_mul(const digit_t *a, const digit_t *b, digit_t *c, const unsigned int nwords)
- { // Schoolbook multiprecision multiply, c = a*b
- unsigned int i, j;
- digit_t u, v, UV[2];
-@@ -195,7 +195,7 @@ void mp_mul(const digit_t *a, const digit_t *b, digit_t *c, const unsigned int n
- }
- }
-
--unsigned int mp_add(digit_t *a, digit_t *b, digit_t *c, unsigned int nwords)
-+unsigned int fq_mp_add(digit_t *a, digit_t *b, digit_t *c, unsigned int nwords)
- { // Multiprecision addition, c = a+b, where lng(a) = lng(b) = nwords. Returns the carry bit
- unsigned int i, carry = 0;
-
-@@ -263,13 +263,13 @@ void fpinv1271(felm_t a)
- static void multiply(const digit_t *a, const digit_t *b, digit_t *c)
- { // Schoolbook multiprecision multiply, c = a*b
-
-- mp_mul(a, b, c, NWORDS_ORDER);
-+ fq_mp_mul(a, b, c, NWORDS_ORDER);
- }
-
- static unsigned int add(const digit_t *a, const digit_t *b, digit_t *c, const unsigned int nwords)
- { // Multiprecision addition, c = a+b, where lng(a) = lng(b) = nwords. Returns the carry bit
-
-- return mp_add((digit_t *)a, (digit_t *)b, c, (unsigned int)nwords);
-+ return fq_mp_add((digit_t *)a, (digit_t *)b, c, (unsigned int)nwords);
- }
-
- unsigned int subtract(const digit_t *a, const digit_t *b, digit_t *c, const unsigned int nwords)
diff --git a/bazel/patches/grpc.patch b/bazel/patches/grpc.patch
index 08bde547..fd8e09fb 100644
--- a/bazel/patches/grpc.patch
+++ b/bazel/patches/grpc.patch
@@ -30,4 +30,3 @@ index 72e1b6609e..aded52d0db 100644
#include
#include
#include
-
diff --git a/bazel/patches/ippcp.patch b/bazel/patches/ippcp.patch
index ad5a909c..0af05b25 100644
--- a/bazel/patches/ippcp.patch
+++ b/bazel/patches/ippcp.patch
@@ -248,4 +248,3 @@ index 315d1a3..8b11c7a 100644
endif(${ARCH} MATCHES "ia32")
endif(APPLE)
endif(UNIX)
-
diff --git a/bazel/patches/perfetto.patch b/bazel/patches/perfetto.patch
index 70ecb72e..99254d1b 100644
--- a/bazel/patches/perfetto.patch
+++ b/bazel/patches/perfetto.patch
@@ -13,4 +13,4 @@ index 4ebb0576b..6322273b8 100644
+
#include
#include
- #include
+ #include
\ No newline at end of file
diff --git a/bazel/sparsehash.BUILD b/bazel/sparsehash.BUILD
index baa8d805..d53da1fb 100644
--- a/bazel/sparsehash.BUILD
+++ b/bazel/sparsehash.BUILD
@@ -19,6 +19,6 @@ cc_library(
includes = ["src"],
visibility = ["//visibility:public"],
deps = [
- "@psi//psi/psi/core/vole_psi:sparsehash_config",
+ "@psi//psi/rr22:sparsehash_config",
],
)
diff --git a/docs/conf.py b/docs/conf.py
index e89f2a53..e132f2f7 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -39,7 +39,7 @@
# global variables
extlinks = {
"psi_doc_host": ("https://www.secretflow.org.cn/docs/psi/en/", "doc "),
- "psi_code_host": ("https://github.com/secretflow", "code "),
+ "psi_code_host": ("https://github.com/secretflow/psi/", "code "),
}
html_theme = "pydata_sphinx_theme"
diff --git a/docs/getting_started.rst b/docs/getting_started.rst
index 91cdcb66..7073f8f8 100644
--- a/docs/getting_started.rst
+++ b/docs/getting_started.rst
@@ -7,7 +7,7 @@ Welcome to SecretFlow PSI Library. There are multiple methods to use PSI/PIR.
* Python packages
* `SPU `_ warps the library as Python bindings. You could call PSI/PIR with spu.
- * `SecretFlow `_ warps SPU further.
+ * `SecretFlow `_ warps SPU further with user-friendly APIs.
* Applications
@@ -147,11 +147,13 @@ You need to install:
* ninja
* nasm>=2.15
* python>=3.8
-* bazel==6.4.0
+* bazel
* golang
* xxd
* lld
+For bazel, please check version in `.bazelversion `_ or use bazelisk instead.
+
Build & UnitTest
^^^^^^^^^^^^^^^^
@@ -172,8 +174,3 @@ Reporting an Issue
Please create an issue at `Github Issues `_.
We will look into issues and get back to you soon.
-
-Frequently Asked Questions (FAQ)
---------------------------------
-
-We will collect some popular questions from users and update this part promptly.
diff --git a/docs/reference/launch_config.md b/docs/reference/launch_config.md
index 1c1aa1ba..bd6622f1 100644
--- a/docs/reference/launch_config.md
+++ b/docs/reference/launch_config.md
@@ -41,9 +41,9 @@ Please check psi.v2.PsiConfig and psi.v2.UbPsiConfig at **PSI v2 Configuration**
| ----- | ---- | ----------- |
| link_config | [ yacl.link.ContextDescProto](#yacllinkcontextdescproto) | Configs for network. |
| self_link_party | [ string](#string) | With link_config. |
-| [**oneof**](https://developers.google.com/protocol-buffers/docs/proto3#oneof) runtime_config.legacy_psi_config | [ psi.BucketPsiConfig](#psibucketpsiconfig) | Please check at psi.proto. |
-| [**oneof**](https://developers.google.com/protocol-buffers/docs/proto3#oneof) runtime_config.psi_config | [ psi.v2.PsiConfig](#psiv2psiconfig) | Please check at psi_v2.proto. |
-| [**oneof**](https://developers.google.com/protocol-buffers/docs/proto3#oneof) runtime_config.ub_psi_config | [ psi.v2.UbPsiConfig](#psiv2ubpsiconfig) | Please check at psi_v2.proto. |
+| [**oneof**](https://developers.google.com/protocol-buffers/docs/proto3#oneof) runtime_config.legacy_psi_config | [ BucketPsiConfig](#bucketpsiconfig) | Please check at psi.proto. |
+| [**oneof**](https://developers.google.com/protocol-buffers/docs/proto3#oneof) runtime_config.psi_config | [ v2.PsiConfig](#v2psiconfig) | Please check at psi_v2.proto. |
+| [**oneof**](https://developers.google.com/protocol-buffers/docs/proto3#oneof) runtime_config.ub_psi_config | [ v2.UbPsiConfig](#v2ubpsiconfig) | Please check at psi_v2.proto. |
diff --git a/docs/reference/psi_v2_config.md b/docs/reference/psi_v2_config.md
index a7cffa61..aaa67bc6 100644
--- a/docs/reference/psi_v2_config.md
+++ b/docs/reference/psi_v2_config.md
@@ -66,7 +66,7 @@ Configs for ECDH protocol.
| Field | Type | Description |
| ----- | ---- | ----------- |
-| curve | [ psi.psi.CurveType](#psipsicurvetype) | none |
+| curve | [ psi.CurveType](#psicurvetype) | none |
diff --git a/docs/requirements.txt b/docs/requirements.txt
index d2ff723c..673bb04c 100644
--- a/docs/requirements.txt
+++ b/docs/requirements.txt
@@ -1,5 +1,5 @@
-nbsphinx==0.9.3
-sphinx==7.2.6
-myst-parser==2.0.0
+nbsphinx==0.8.9
+sphinx==5.3.0
+myst-parser==0.18.1
sphinx-intl==2.1.0
pydata-sphinx-theme
diff --git a/docs/user_guide/faq.md b/docs/user_guide/faq.md
new file mode 100644
index 00000000..8e92122f
--- /dev/null
+++ b/docs/user_guide/faq.md
@@ -0,0 +1,90 @@
+# Frequently Asked Questions (FAQ)
+
+We will collect some popular questions from users and update this part promptly.
+
+## Config Issues
+
+1. In PSI config, what is difference of **broadcast_result** and **receiver**? Is it safe to turn on **broadcast_result**?
+
+In PSI protocols, the parties who are promised to receive the intersection are called **receiver**s, the other parties are called **sender**s.
+When **broadcast_result** is turn on, **sender**s also receive the intersection. Both parties must agree on the value of **broadcast_result**, otherwise the program will stop.
+
+If **broadcast_result** is turn on, only **receiver**s and **sender**s could receive the result while any third parties could not see. So it is safe to set **broadcast_result** to true, if both **receiver**s and **sender**s wish to get the result.
+
+2. What is **IO_TYPE_UNSPECIFIED**?
+
+You must select a type as IoType. **IO_TYPE_UNSPECIFIED** is the default value of **IoType**, which is meaningless. At this moment, we only support **IO_TYPE_FILE_CSV**.
+
+3. What is **ADVANCED_JOIN_TYPE_UNSPECIFIED**?
+
+PSI protocols doesnât allow duplicates in ids of inputs. However, sometimes we may intend to have duplicates in ids and perform LEFT / RIGHT / FULL join following rules of SQL. This is called **AdvancedJoinType**.
+
+**ADVANCED_JOIN_TYPE_UNSPECIFIED** is default value of AdvancedJoinType, which means default implementation of PSI configs and duplicates is disallowed. If ids of inputs contains duplicates at this moment, the behavior is undefined.
+
+4. What is the recommendation value of bucket size?
+
+The default value is 2^20. You shouldn't set this value unless you have very limited computation resource.
+
+5. What is **disable_alignment**?
+
+If **disable_alignment** turns on, the intersection received by **receiver**s and **sender**s are not promised to be aligned(the order doesn't match) and save time.
+
+If any **AdvancedJoinType** is specified, aligement is promised due to implementation, **disable_alignment** is ignored.
+
+6. What is **RetryOptionsProto** in **ContextDescProto**?
+
+We have proper default values for all fields. You shouldn't set any values unless the network is pretty bad.
+
+## Feature Issues
+
+1. How to enable SSL?
+
+We support mTLS and you should provide proper **ContextDescProto**:
+
+- **enable_ssl** is enabled.
+- In **client_ssl_opts**, set **verify_depth** and provide peer CA file with **ca_file_path**
+- In **server_ssl_opts**, provide self certificate and private key file with **certificate_path** and **private_key_path**
+- You must provide these settings at both sides.
+
+```
+{
+ "psi_config": {},
+ "link_config": {
+ "parties": [
+ {
+ "id": "receiver",
+ "host": "127.0.0.1:5300"
+ },
+ {
+ "id": "sender",
+ "host": "127.0.0.1:5400"
+ }
+ ],
+ "enable_ssl": true,
+ "client_ssl_opts": {
+ "verify_depth": 1,
+ "ca_file_path": "/path/to/peer/CA/file"
+ },
+ "server_ssl_opts": {
+ "certificate_path": "/path/to/self/certificate/file",
+ "private_key_path": "/path/to/self/private/key/file"
+ }
+ },
+ "self_link_party": "sender"
+}
+```
+
+2. How to use recovery?
+
+We provide recovery feature in PSI v2.
+
+You have to provide a proper **RecoveryConfig**:
+
+- **enabled** set to true.
+- **folder** is provided to store checkpoints.
+
+If a PSI task fails, just restart the task with the same config, the progress will resume.
+
+3. What is **Easy PSI**? Why and when to use **Easy PSI**?
+
+[Easy PSI](https://www.secretflow.org.cn/docs/quickstart/easy-psi) is a standalone PSI product powered by this library. It provides a simple User Interface and utilize [Kuscia](https://www.secretflow.org.cn/docs/kuscia) to launch PSI binaries between both parties.
diff --git a/docs/user_guide/index.rst b/docs/user_guide/index.rst
index ee78d35f..dad825f4 100644
--- a/docs/user_guide/index.rst
+++ b/docs/user_guide/index.rst
@@ -9,3 +9,4 @@ PSI v2 is recommended to use. We are still working on PIR code refactoring.
psi
psi_v2
pir
+ faq
\ No newline at end of file
diff --git a/docs/user_guide/psi.rst b/docs/user_guide/psi.rst
index 5e63e564..d03fc3d1 100644
--- a/docs/user_guide/psi.rst
+++ b/docs/user_guide/psi.rst
@@ -7,9 +7,9 @@ Quick start with Private Set Intersection (PSI) V1 APIs.
Supported Protocols
----------------------
-.. The :psi_code_host:`ECDH-PSI ` is favorable if the bandwidth is the bottleneck.
-.. If the computing is the bottleneck, you should try the BaRK-OPRF based
-.. PSI :psi_code_host:`KKRT-PSI API `.
+The :psi_code_host:`ECDH-PSI ` is favorable if the bandwidth is the bottleneck.
+If the computing is the bottleneck, you should try the BaRK-OPRF based
+PSI :psi_code_host:`KKRT-PSI `.
+---------------+--------------+--------------+--------------+
| PSI protocols | Threat Model | Party Number | PsiTypeCode |
@@ -69,12 +69,12 @@ Run PSI
In the first terminal, run the following command::
- docker run -it --rm --network host --mount type=bind,source=/tmp/receiver,target=/root/receiver -w /root --cap-add=SYS_PTRACE --security-opt seccomp=unconfined --cap-add=NET_ADMIN --privileged=true secretflow-registry.cn-hangzhou.cr.aliyuncs.com/secretflow/psi-anolis8:0.1.0beta bash -c "./main --config receiver/receiver.config"
+ docker run -it --rm --network host --mount type=bind,source=/tmp/receiver,target=/root/receiver --cap-add=SYS_PTRACE --security-opt seccomp=unconfined --cap-add=NET_ADMIN --privileged=true secretflow-registry.cn-hangzhou.cr.aliyuncs.com/secretflow/psi-anolis8:latest bash -c "./main --config receiver/receiver.config"
In the other terminal, run the following command simultaneously::
- docker run -it --rm --network host --mount type=bind,source=/tmp/sender,target=/root/sender -w /root --cap-add=SYS_PTRACE --security-opt seccomp=unconfined --cap-add=NET_ADMIN --privileged=true secretflow-registry.cn-hangzhou.cr.aliyuncs.com/secretflow/psi-anolis8:0.1.0beta bash -c "./main --config sender/sender.config"
+ docker run -it --rm --network host --mount type=bind,source=/tmp/sender,target=/root/sender --cap-add=SYS_PTRACE --security-opt seccomp=unconfined --cap-add=NET_ADMIN --privileged=true secretflow-registry.cn-hangzhou.cr.aliyuncs.com/secretflow/psi-anolis8:latest bash -c "./main --config sender/sender.config"
Building from source
@@ -97,7 +97,7 @@ benchmark result without data load time
ecdh-psi Benchmark
>>>>>>>>>>>>>>>>>>
-:psi_code_host:`DH-PSI benchmark code `
+:psi_code_host:`DH-PSI benchmark code `
cpu limited by docker(--cpu)
diff --git a/docs/user_guide/psi_v2.rst b/docs/user_guide/psi_v2.rst
index b0dda180..eff234d3 100644
--- a/docs/user_guide/psi_v2.rst
+++ b/docs/user_guide/psi_v2.rst
@@ -96,20 +96,20 @@ To launch PSI, please check LaunchConfig at :doc:`/reference/launch_config` and
"check_hash_digest": false,
"recovery_config": {
"enabled": false
- },
- "link_config": {
- "parties": [
- {
- "id": "receiver",
- "host": "127.0.0.1:5300"
- },
- {
- "id": "sender",
- "host": "127.0.0.1:5400"
- }
- ]
}
},
+ "link_config": {
+ "parties": [
+ {
+ "id": "receiver",
+ "host": "127.0.0.1:5300"
+ },
+ {
+ "id": "sender",
+ "host": "127.0.0.1:5400"
+ }
+ ]
+ },
"self_link_party": "sender"
}
@@ -123,7 +123,7 @@ You need to prepare following files:
+------------------------+------------------------------------------------+-------------------------------------------------------------------------------+
| sender.config | /tmp/sender/sender.config | Config for sender. |
+------------------------+------------------------------------------------+-------------------------------------------------------------------------------+
-| receiver_input.csv | /tmp/receiver/receiver_input.config | SupInput for receiver. Make sure the file contains two id keys - id0 and id1. |
+| receiver_input.csv | /tmp/receiver/receiver_input.config | Input for receiver. Make sure the file contains two id keys - id0 and id1. |
+------------------------+------------------------------------------------+-------------------------------------------------------------------------------+
| sender_input.csv | /tmp/sender/sender_input.config | Input for sender. Make sure the file contains two id keys - id0 and id1. |
+------------------------+------------------------------------------------+-------------------------------------------------------------------------------+
@@ -134,12 +134,12 @@ Run PSI
In the first terminal, run the following command::
- docker run -it --rm --network host --mount type=bind,source=/tmp/receiver,target=/root/receiver -w /root --cap-add=SYS_PTRACE --security-opt seccomp=unconfined --cap-add=NET_ADMIN --privileged=true secretflow-registry.cn-hangzhou.cr.aliyuncs.com/secretflow/psi-anolis8:0.1.0beta bash -c "./main --config receiver/receiver.config"
+ docker run -it --rm --network host --mount type=bind,source=/tmp/receiver,target=/root/receiver --cap-add=SYS_PTRACE --security-opt seccomp=unconfined --cap-add=NET_ADMIN --privileged=true secretflow-registry.cn-hangzhou.cr.aliyuncs.com/secretflow/psi-anolis8:0.1.0beta bash -c "./main --config receiver/receiver.config"
In the other terminal, run the following command simultaneously::
- docker run -it --rm --network host --mount type=bind,source=/tmp/sender,target=/root/sender -w /root --cap-add=SYS_PTRACE --security-opt seccomp=unconfined --cap-add=NET_ADMIN --privileged=true secretflow-registry.cn-hangzhou.cr.aliyuncs.com/secretflow/psi-anolis8:0.1.0beta bash -c "./main --config sender/sender.config"
+ docker run -it --rm --network host --mount type=bind,source=/tmp/sender,target=/root/sender --cap-add=SYS_PTRACE --security-opt seccomp=unconfined --cap-add=NET_ADMIN --privileged=true secretflow-registry.cn-hangzhou.cr.aliyuncs.com/secretflow/psi-anolis8:0.1.0beta bash -c "./main --config sender/sender.config"
Building from source
diff --git a/examples/pir/BUILD.bazel b/examples/pir/BUILD.bazel
index 56bfe1c8..20cf9d12 100644
--- a/examples/pir/BUILD.bazel
+++ b/examples/pir/BUILD.bazel
@@ -35,8 +35,7 @@ psi_cc_binary(
],
deps = [
":utils",
- "//psi/pir",
- "//psi/psi/core/labeled_psi",
+ "//psi/apsi:pir",
"@com_google_absl//absl/strings",
"@yacl//yacl/crypto/utils:rand",
],
@@ -50,9 +49,8 @@ psi_cc_binary(
],
deps = [
":utils",
- "//psi/pir",
- "//psi/psi/core/labeled_psi",
- "//psi/psi/utils:serialize",
+ "//psi/apsi:pir",
+ "//psi/utils:serialize",
"@com_google_absl//absl/strings",
"@yacl//yacl/crypto/utils:rand",
],
@@ -66,9 +64,8 @@ psi_cc_binary(
],
deps = [
":utils",
- "//psi/pir",
- "//psi/psi/core/labeled_psi",
- "//psi/psi/utils:serialize",
+ "//psi/apsi:pir",
+ "//psi/utils:serialize",
"@com_google_absl//absl/strings",
"@yacl//yacl/crypto/utils:rand",
],
@@ -82,9 +79,8 @@ psi_cc_binary(
],
deps = [
":utils",
- "//psi/pir",
- "//psi/psi/core/labeled_psi",
- "//psi/psi/utils:serialize",
+ "//psi/apsi:pir",
+ "//psi/utils:serialize",
"@com_google_absl//absl/strings",
"@yacl//yacl/crypto/utils:rand",
"@yacl//yacl/io/rw:csv_writer",
diff --git a/examples/pir/keyword_pir_client.cc b/examples/pir/keyword_pir_client.cc
index 6a87112e..533849ee 100644
--- a/examples/pir/keyword_pir_client.cc
+++ b/examples/pir/keyword_pir_client.cc
@@ -25,11 +25,11 @@
#include "examples/pir/utils.h"
#include "yacl/io/rw/csv_writer.h"
-#include "psi/pir/pir.h"
-#include "psi/psi/core/labeled_psi/psi_params.h"
-#include "psi/psi/core/labeled_psi/receiver.h"
-#include "psi/psi/utils/batch_provider.h"
-#include "psi/psi/utils/serialize.h"
+#include "psi/apsi/pir.h"
+#include "psi/apsi/psi_params.h"
+#include "psi/apsi/receiver.h"
+#include "psi/utils/batch_provider.h"
+#include "psi/utils/serialize.h"
#include "psi/proto/pir.pb.h"
@@ -56,15 +56,15 @@ int main(int argc, char **argv) {
std::vector ids = absl::StrSplit(FLAGS_key_columns, ',');
- psi::pir::PirClientConfig config;
+ psi::PirClientConfig config;
- config.set_pir_protocol(psi::pir::PirProtocol::KEYWORD_PIR_LABELED_PSI);
+ config.set_pir_protocol(psi::PirProtocol::KEYWORD_PIR_LABELED_PSI);
config.set_input_path(FLAGS_in_path);
config.mutable_key_columns()->Add(ids.begin(), ids.end());
config.set_output_path(FLAGS_out_path);
- psi::pir::PirResultReport report = psi::pir::PirClient(link_ctx, config);
+ psi::PirResultReport report = psi::apsi::PirClient(link_ctx, config);
SPDLOG_INFO("data count:{}", report.data_count());
diff --git a/examples/pir/keyword_pir_mem_server.cc b/examples/pir/keyword_pir_mem_server.cc
index 2ff6eb3f..10372954 100644
--- a/examples/pir/keyword_pir_mem_server.cc
+++ b/examples/pir/keyword_pir_mem_server.cc
@@ -26,12 +26,12 @@
#include "spdlog/spdlog.h"
#include "yacl/link/test_util.h"
-#include "psi/pir/pir.h"
-#include "psi/psi/core/ecdh_oprf/ecdh_oprf_selector.h"
-#include "psi/psi/core/labeled_psi/psi_params.h"
-#include "psi/psi/core/labeled_psi/receiver.h"
-#include "psi/psi/core/labeled_psi/sender.h"
-#include "psi/psi/utils/serialize.h"
+#include "psi/apsi/pir.h"
+#include "psi/apsi/psi_params.h"
+#include "psi/apsi/receiver.h"
+#include "psi/apsi/sender.h"
+#include "psi/ecdh//ecdh_oprf_selector.h"
+#include "psi/utils/serialize.h"
#include "psi/proto/pir.pb.h"
@@ -72,10 +72,10 @@ int main(int argc, char **argv) {
std::vector ids = absl::StrSplit(FLAGS_key_columns, ',');
std::vector labels = absl::StrSplit(FLAGS_label_columns, ',');
- psi::pir::PirSetupConfig config;
+ psi::PirSetupConfig config;
- config.set_pir_protocol(psi::pir::PirProtocol::KEYWORD_PIR_LABELED_PSI);
- config.set_store_type(psi::pir::KvStoreType::LEVELDB_KV_STORE);
+ config.set_pir_protocol(psi::PirProtocol::KEYWORD_PIR_LABELED_PSI);
+ config.set_store_type(psi::KvStoreType::LEVELDB_KV_STORE);
config.set_input_path(FLAGS_in_path);
config.mutable_key_columns()->Add(ids.begin(), ids.end());
@@ -89,8 +89,7 @@ int main(int argc, char **argv) {
config.set_bucket_size(FLAGS_bucket);
config.set_max_items_per_bin(FLAGS_max_items_per_bin);
- psi::pir::PirResultReport report =
- psi::pir::PirMemoryServer(link_ctx, config);
+ psi::PirResultReport report = psi::apsi::PirMemoryServer(link_ctx, config);
SPDLOG_INFO("data count:{}", report.data_count());
diff --git a/examples/pir/keyword_pir_server.cc b/examples/pir/keyword_pir_server.cc
index c969e466..2d9d49c2 100644
--- a/examples/pir/keyword_pir_server.cc
+++ b/examples/pir/keyword_pir_server.cc
@@ -26,12 +26,12 @@
#include "spdlog/spdlog.h"
#include "yacl/link/test_util.h"
-#include "psi/pir/pir.h"
-#include "psi/psi/core/ecdh_oprf/ecdh_oprf_selector.h"
-#include "psi/psi/core/labeled_psi/psi_params.h"
-#include "psi/psi/core/labeled_psi/receiver.h"
-#include "psi/psi/core/labeled_psi/sender.h"
-#include "psi/psi/utils/serialize.h"
+#include "psi/apsi/pir.h"
+#include "psi/apsi/psi_params.h"
+#include "psi/apsi/receiver.h"
+#include "psi/apsi/sender.h"
+#include "psi/ecdh//ecdh_oprf_selector.h"
+#include "psi/utils/serialize.h"
#include "psi/proto/pir.pb.h"
@@ -57,15 +57,15 @@ int main(int argc, char **argv) {
link_ctx->SetRecvTimeout(kLinkRecvTimeout);
- psi::pir::PirServerConfig config;
+ psi::PirServerConfig config;
- config.set_pir_protocol(psi::pir::PirProtocol::KEYWORD_PIR_LABELED_PSI);
- config.set_store_type(psi::pir::KvStoreType::LEVELDB_KV_STORE);
+ config.set_pir_protocol(psi::PirProtocol::KEYWORD_PIR_LABELED_PSI);
+ config.set_store_type(psi::KvStoreType::LEVELDB_KV_STORE);
config.set_oprf_key_path(FLAGS_oprf_key_path);
config.set_setup_path(FLAGS_setup_path);
- psi::pir::PirResultReport report = psi::pir::PirServer(link_ctx, config);
+ psi::PirResultReport report = psi::apsi::PirServer(link_ctx, config);
SPDLOG_INFO("data count:{}", report.data_count());
diff --git a/examples/pir/keyword_pir_setup.cc b/examples/pir/keyword_pir_setup.cc
index 8aecc0a9..f9f82dce 100644
--- a/examples/pir/keyword_pir_setup.cc
+++ b/examples/pir/keyword_pir_setup.cc
@@ -30,11 +30,11 @@
#include "spdlog/spdlog.h"
#include "yacl/link/test_util.h"
-#include "psi/pir/pir.h"
-#include "psi/psi/core/ecdh_oprf/ecdh_oprf_selector.h"
-#include "psi/psi/core/labeled_psi/psi_params.h"
-#include "psi/psi/core/labeled_psi/receiver.h"
-#include "psi/psi/core/labeled_psi/sender.h"
+#include "psi/apsi/pir.h"
+#include "psi/apsi/psi_params.h"
+#include "psi/apsi/receiver.h"
+#include "psi/apsi/sender.h"
+#include "psi/ecdh//ecdh_oprf_selector.h"
#include "psi/proto/pir.pb.h"
@@ -74,10 +74,10 @@ int main(int argc, char **argv) {
SPDLOG_INFO("key columns: {}", FLAGS_key_columns);
SPDLOG_INFO("label columns: {}", FLAGS_label_columns);
- psi::pir::PirSetupConfig config;
+ psi::PirSetupConfig config;
- config.set_pir_protocol(psi::pir::PirProtocol::KEYWORD_PIR_LABELED_PSI);
- config.set_store_type(psi::pir::KvStoreType::LEVELDB_KV_STORE);
+ config.set_pir_protocol(psi::PirProtocol::KEYWORD_PIR_LABELED_PSI);
+ config.set_store_type(psi::KvStoreType::LEVELDB_KV_STORE);
config.set_input_path(FLAGS_in_path);
config.mutable_key_columns()->Add(ids.begin(), ids.end());
@@ -91,7 +91,7 @@ int main(int argc, char **argv) {
config.set_bucket_size(FLAGS_bucket);
config.set_max_items_per_bin(FLAGS_max_items_per_bin);
- psi::pir::PirResultReport report = psi::pir::PirSetup(config);
+ psi::PirResultReport report = psi::apsi::PirSetup(config);
SPDLOG_INFO("data count:{}", report.data_count());
diff --git a/psi/BUILD.bazel b/psi/BUILD.bazel
index 6b26509f..fda9b50f 100644
--- a/psi/BUILD.bazel
+++ b/psi/BUILD.bazel
@@ -16,6 +16,85 @@ load("//bazel:psi.bzl", "psi_cc_binary", "psi_cc_library", "psi_cc_test")
package(default_visibility = ["//visibility:public"])
+psi_cc_library(
+ name = "prelude",
+ hdrs = [
+ "prelude.h",
+ ],
+ deps = [
+ "//psi/proto:psi_cc_proto",
+ "//psi/proto:psi_v2_cc_proto",
+ ],
+)
+
+psi_cc_library(
+ name = "interface",
+ srcs = ["interface.cc"],
+ hdrs = ["interface.h"],
+ deps = [
+ ":trace_categories",
+ "//psi/legacy:bucket_psi",
+ "//psi/proto:psi_v2_cc_proto",
+ "//psi/utils:advanced_join",
+ "//psi/utils:index_store",
+ "//psi/utils:recovery",
+ "@boost//:uuid",
+ "@com_github_google_perfetto//:perfetto",
+ "@com_google_absl//absl/status",
+ "@yacl//yacl/link",
+ ],
+)
+
+psi_cc_library(
+ name = "factory",
+ srcs = ["factory.cc"],
+ hdrs = ["factory.h"],
+ deps = [
+ "//psi/ecdh:client",
+ "//psi/ecdh:receiver",
+ "//psi/ecdh:sender",
+ "//psi/ecdh:server",
+ "//psi/kkrt:receiver",
+ "//psi/kkrt:sender",
+ "//psi/rr22:receiver",
+ "//psi/rr22:sender",
+ "@yacl//yacl/base:exception",
+ ],
+)
+
+psi_cc_library(
+ name = "launch",
+ srcs = ["launch.cc"],
+ hdrs = ["launch.h"],
+ deps = [
+ ":factory",
+ ":trace_categories",
+ "//psi/legacy:bucket_psi",
+ "@boost//:algorithm",
+ "@boost//:uuid",
+ ],
+)
+
+psi_cc_library(
+ name = "trace_categories",
+ srcs = ["trace_categories.cc"],
+ hdrs = ["trace_categories.h"],
+ deps = [
+ "@com_github_google_perfetto//:perfetto",
+ ],
+)
+
+psi_cc_test(
+ name = "psi_test",
+ srcs = ["psi_test.cc"],
+ deps = [
+ ":factory",
+ "//psi/utils:arrow_csv_batch_provider",
+ "@boost//:uuid",
+ "@yacl//yacl/utils:scope_guard",
+ ],
+)
+
psi_cc_library(
name = "version",
hdrs = ["version.h"],
@@ -51,8 +130,8 @@ psi_cc_binary(
deps = [
":kuscia_adapter",
":version",
+ "//psi:launch",
"//psi/proto:entry_cc_proto",
- "//psi/psi:launch",
"@com_github_gflags_gflags//:gflags",
],
)
diff --git a/psi/psi/core/labeled_psi/BUILD.bazel b/psi/apsi/BUILD.bazel
similarity index 52%
rename from psi/psi/core/labeled_psi/BUILD.bazel
rename to psi/apsi/BUILD.bazel
index d0ada59f..7ef4e026 100644
--- a/psi/psi/core/labeled_psi/BUILD.bazel
+++ b/psi/apsi/BUILD.bazel
@@ -18,51 +18,115 @@ load("@rules_cc//cc:defs.bzl", "cc_proto_library")
package(default_visibility = ["//visibility:public"])
+proto_library(
+ name = "serializable_proto",
+ srcs = ["serializable.proto"],
+)
+
+cc_proto_library(
+ name = "serializable_cc_proto",
+ deps = [":serializable_proto"],
+)
+
psi_cc_library(
- name = "labeled_psi",
- srcs = [
- "package.cc",
- "psi_params.cc",
- "receiver.cc",
- "sender.cc",
- "sender_db.cc",
- "sender_kvdb.cc",
- "sender_memdb.cc",
- ],
- hdrs = [
- "package.h",
- "psi_params.h",
- "receiver.h",
- "sender.h",
- "sender_db.h",
- "sender_kvdb.h",
- "sender_memdb.h",
- "serialize.h",
+ name = "padding",
+ srcs = ["padding.cc"],
+ hdrs = ["padding.h"],
+ deps = [
+ "@yacl//yacl/base:byte_container_view",
+ "@yacl//yacl/base:exception",
],
+)
+
+psi_cc_library(
+ name = "package",
+ srcs = ["package.cc"],
+ hdrs = ["package.h"],
+ deps = [
+ "@com_github_microsoft_apsi//:apsi",
+ "@yacl//yacl/base:exception",
+ ],
+)
+
+psi_cc_library(
+ name = "psi_params",
+ srcs = ["psi_params.cc"],
+ hdrs = ["psi_params.h"],
deps = [
- ":padding",
":serializable_cc_proto",
- "//psi/psi/core/ecdh_oprf:ecdh_oprf_selector",
- "//psi/psi/utils:batch_provider",
"@com_github_microsoft_apsi//:apsi",
- "@com_google_absl//absl/strings",
"@yacl//yacl/base:exception",
- "@yacl//yacl/crypto/tools:prg",
+ "@yacl//yacl/link",
+ ],
+)
+
+psi_cc_library(
+ name = "serialize",
+ hdrs = ["serialize.h"],
+ deps = [
+ ":serializable_cc_proto",
+ "@com_github_microsoft_apsi//:apsi",
+ ],
+)
+
+psi_cc_library(
+ name = "sender_db",
+ srcs = ["sender_db.cc"],
+ hdrs = ["sender_db.h"],
+ deps = [
+ ":serialize",
+ "//psi/ecdh:ecdh_oprf_selector",
+ "//psi/utils:batch_provider",
+ "@yacl//yacl/base:byte_container_view",
+ "@yacl//yacl/base:exception",
"@yacl//yacl/io/kv:leveldb_kvstore",
"@yacl//yacl/io/kv:memory_kvstore",
- "@yacl//yacl/link",
- "@yacl//yacl/utils:parallel",
],
)
-proto_library(
- name = "serializable_proto",
- srcs = ["serializable.proto"],
+psi_cc_library(
+ name = "sender_kvdb",
+ srcs = ["sender_kvdb.cc"],
+ hdrs = ["sender_kvdb.h"],
+ deps = [
+ ":padding",
+ ":sender_db",
+ ],
)
-cc_proto_library(
- name = "serializable_cc_proto",
- deps = [":serializable_proto"],
+psi_cc_library(
+ name = "sender_memdb",
+ srcs = ["sender_memdb.cc"],
+ hdrs = ["sender_memdb.h"],
+ deps = [
+ ":padding",
+ ":sender_db",
+ ],
+)
+
+psi_cc_library(
+ name = "receiver",
+ srcs = ["receiver.cc"],
+ hdrs = ["receiver.h"],
+ deps = [
+ ":package",
+ ":padding",
+ ":psi_params",
+ "//psi/ecdh:ecdh_oprf_selector",
+ ],
+)
+
+psi_cc_library(
+ name = "sender",
+ srcs = ["sender.cc"],
+ hdrs = ["sender.h"],
+ deps = [
+ ":package",
+ ":psi_params",
+ ":sender_kvdb",
+ ":sender_memdb",
+ "@yacl//yacl/link",
+ ],
)
psi_cc_test(
@@ -71,7 +135,8 @@ psi_cc_test(
"apsi_test.cc",
],
deps = [
- ":labeled_psi",
+ ":receiver",
+ ":sender",
"@com_google_absl//absl/strings",
"@yacl//yacl/crypto/tools:prg",
"@yacl//yacl/utils:scope_guard",
@@ -84,7 +149,8 @@ psi_cc_test(
"apsi_label_test.cc",
],
deps = [
- ":labeled_psi",
+ ":receiver",
+ ":sender",
"@com_google_absl//absl/strings",
"@yacl//yacl/crypto/tools:prg",
"@yacl//yacl/utils:scope_guard",
@@ -97,8 +163,9 @@ psi_cc_test(
"kv_test.cc",
],
deps = [
- ":labeled_psi",
- "//psi/psi/utils:sync",
+ ":receiver",
+ ":sender",
+ "//psi/utils:sync",
"@com_google_absl//absl/strings",
"@yacl//yacl/crypto/tools:prg",
"@yacl//yacl/utils:scope_guard",
@@ -106,12 +173,13 @@ psi_cc_test(
)
psi_cc_binary(
- name = "apsi_bench",
+ name = "apsi_benchmark",
srcs = [
- "apsi_bench.cc",
+ "apsi_benchmark.cc",
],
deps = [
- ":labeled_psi",
+ ":receiver",
+ ":sender",
"@com_github_google_benchmark//:benchmark_main",
"@com_google_absl//absl/strings",
"@com_google_googletest//:gtest",
@@ -120,11 +188,25 @@ psi_cc_binary(
)
psi_cc_library(
- name = "padding",
- srcs = ["padding.cc"],
- hdrs = ["padding.h"],
+ name = "pir",
+ srcs = ["pir.cc"],
+ hdrs = ["pir.h"],
deps = [
- "@yacl//yacl/base:byte_container_view",
- "@yacl//yacl/base:exception",
+ ":receiver",
+ ":sender",
+ "//psi/proto:pir_cc_proto",
+ "//psi/utils:serialize",
+ "//psi/utils:sync",
+ "@yacl//yacl/crypto/base/block_cipher:symmetric_crypto",
+ ],
+)
+
+psi_cc_test(
+ name = "pir_test",
+ srcs = ["pir_test.cc"],
+ deps = [
+ ":pir",
+ "//psi/utils:io",
+ "@yacl//yacl/utils:scope_guard",
],
)
diff --git a/psi/psi/core/labeled_psi/README.md b/psi/apsi/README.md
similarity index 100%
rename from psi/psi/core/labeled_psi/README.md
rename to psi/apsi/README.md
diff --git a/psi/psi/core/labeled_psi/apsi_bench.cc b/psi/apsi/apsi_benchmark.cc
similarity index 91%
rename from psi/psi/core/labeled_psi/apsi_bench.cc
rename to psi/apsi/apsi_benchmark.cc
index 91199925..c24d33bd 100644
--- a/psi/psi/core/labeled_psi/apsi_bench.cc
+++ b/psi/apsi/apsi_benchmark.cc
@@ -26,13 +26,13 @@
#include "yacl/crypto/tools/prg.h"
#include "yacl/link/test_util.h"
-#include "psi/psi/core/ecdh_oprf/ecdh_oprf_selector.h"
-#include "psi/psi/core/labeled_psi/psi_params.h"
-#include "psi/psi/core/labeled_psi/receiver.h"
-#include "psi/psi/core/labeled_psi/sender.h"
-#include "psi/psi/core/labeled_psi/sender_kvdb.h"
+#include "psi/apsi/psi_params.h"
+#include "psi/apsi/receiver.h"
+#include "psi/apsi/sender.h"
+#include "psi/apsi/sender_kvdb.h"
+#include "psi/ecdh//ecdh_oprf_selector.h"
-namespace psi::psi {
+namespace psi::apsi {
namespace {
@@ -140,17 +140,17 @@ static void BM_LabeledPsi(benchmark::State& state) {
state.ResumeTiming();
- apsi::PSIParams psi_params = GetPsiParams(nr, ns);
+ ::apsi::PSIParams psi_params = GetPsiParams(nr, ns);
// step 1: PsiParams Request and Response
std::future f_sender_params =
std::async([&] { return LabelPsiSender::RunPsiParams(ns, ctxs[0]); });
- std::future f_receiver_params = std::async(
+ std::future<::apsi::PSIParams> f_receiver_params = std::async(
[&] { return LabelPsiReceiver::RequestPsiParams(nr, ctxs[1]); });
f_sender_params.get();
- apsi::PSIParams psi_params2 = f_receiver_params.get();
+ ::apsi::PSIParams psi_params2 = f_receiver_params.get();
EXPECT_EQ(psi_params.table_params().table_size,
psi_params2.table_params().table_size);
@@ -194,8 +194,9 @@ static void BM_LabeledPsi(benchmark::State& state) {
SPDLOG_INFO("after set db, bin_bundle_count:{}, packing_rate:{}",
sender_db->GetBinBundleCount(), sender_db->GetPackingRate());
- std::unique_ptr oprf_server =
- CreateEcdhOprfServer(oprf_key, OprfType::Basic, CurveType::CURVE_FOURQ);
+ std::unique_ptr oprf_server =
+ ecdh::CreateEcdhOprfServer(oprf_key, ecdh::OprfType::Basic,
+ CurveType::CURVE_FOURQ);
LabelPsiSender sender(sender_db);
@@ -208,13 +209,13 @@ static void BM_LabeledPsi(benchmark::State& state) {
std::future f_sender_oprf = std::async(
[&] { return sender.RunOPRF(std::move(oprf_server), ctxs[0]); });
- std::future<
- std::pair, std::vector>>
+ std::future,
+ std::vector<::apsi::LabelKey>>>
f_receiver_oprf = std::async(
[&] { return receiver.RequestOPRF(receiver_items, ctxs[1]); });
f_sender_oprf.get();
- std::pair, std::vector>
+ std::pair, std::vector<::apsi::LabelKey>>
oprf_pair = f_receiver_oprf.get();
const auto oprf_end = std::chrono::system_clock::now();
@@ -275,4 +276,4 @@ BENCHMARK(BM_LabeledPsi)
BENCHMARK_MAIN();
-} // namespace psi::psi
+} // namespace psi::apsi
diff --git a/psi/psi/core/labeled_psi/apsi_label_test.cc b/psi/apsi/apsi_label_test.cc
similarity index 90%
rename from psi/psi/core/labeled_psi/apsi_label_test.cc
rename to psi/apsi/apsi_label_test.cc
index 4088f860..2c8b4b7c 100644
--- a/psi/psi/core/labeled_psi/apsi_label_test.cc
+++ b/psi/apsi/apsi_label_test.cc
@@ -28,14 +28,14 @@
#include "yacl/link/test_util.h"
#include "yacl/utils/scope_guard.h"
-#include "psi/psi/core/ecdh_oprf/ecdh_oprf_selector.h"
-#include "psi/psi/core/labeled_psi/psi_params.h"
-#include "psi/psi/core/labeled_psi/receiver.h"
-#include "psi/psi/core/labeled_psi/sender.h"
-#include "psi/psi/core/labeled_psi/sender_kvdb.h"
-#include "psi/psi/core/labeled_psi/sender_memdb.h"
+#include "psi/apsi/psi_params.h"
+#include "psi/apsi/receiver.h"
+#include "psi/apsi/sender.h"
+#include "psi/apsi/sender_kvdb.h"
+#include "psi/apsi/sender_memdb.h"
+#include "psi/ecdh//ecdh_oprf_selector.h"
-namespace psi::psi {
+namespace psi::apsi {
namespace {
@@ -103,17 +103,17 @@ class LabelPsiTest : public testing::TestWithParam {};
TEST_P(LabelPsiTest, Works) {
auto params = GetParam();
auto ctxs = yacl::link::test::SetupWorld(2);
- apsi::PSIParams psi_params = GetPsiParams(params.nr, params.ns);
+ ::apsi::PSIParams psi_params = GetPsiParams(params.nr, params.ns);
// step 1: PsiParams Request and Response
std::future f_sender_params = std::async(
[&] { return LabelPsiSender::RunPsiParams(params.ns, ctxs[0]); });
- std::future f_receiver_params = std::async(
+ std::future<::apsi::PSIParams> f_receiver_params = std::async(
[&] { return LabelPsiReceiver::RequestPsiParams(params.nr, ctxs[1]); });
f_sender_params.get();
- apsi::PSIParams psi_params2 = f_receiver_params.get();
+ ::apsi::PSIParams psi_params2 = f_receiver_params.get();
EXPECT_EQ(psi_params.table_params().table_size,
psi_params2.table_params().table_size);
@@ -183,7 +183,7 @@ TEST_P(LabelPsiTest, Works) {
SPDLOG_INFO("after set db, bin_bundle_count:{}, packing_rate:{}",
sender_db->GetBinBundleCount(), sender_db->GetPackingRate());
- const apsi::PSIParams apsi_params = sender_db->GetParams();
+ const ::apsi::PSIParams apsi_params = sender_db->GetParams();
SPDLOG_INFO("params.bundle_idx_count={}", apsi_params.bundle_idx_count());
LabelPsiSender sender(sender_db);
@@ -195,19 +195,20 @@ TEST_P(LabelPsiTest, Works) {
const auto oprf_start = std::chrono::system_clock::now();
std::future f_sender_oprf = std::async([&] {
- std::unique_ptr oprf_server =
- CreateEcdhOprfServer(oprf_key, OprfType::Basic, CurveType::CURVE_FOURQ);
+ std::unique_ptr oprf_server =
+ ecdh::CreateEcdhOprfServer(oprf_key, ecdh::OprfType::Basic,
+ CurveType::CURVE_FOURQ);
return sender.RunOPRF(std::move(oprf_server), ctxs[0]);
});
std::future<
- std::pair, std::vector>>
+ std::pair, std::vector<::apsi::LabelKey>>>
f_receiver_oprf = std::async(
[&] { return receiver.RequestOPRF(receiver_items, ctxs[1]); });
f_sender_oprf.get();
- std::pair, std::vector>
+ std::pair, std::vector<::apsi::LabelKey>>
oprf_pair = f_receiver_oprf.get();
const auto oprf_end = std::chrono::system_clock::now();
@@ -266,4 +267,4 @@ INSTANTIATE_TEST_SUITE_P(Works_Instances, LabelPsiTest,
#endif
);
-} // namespace psi::psi
+} // namespace psi::apsi
diff --git a/psi/psi/core/labeled_psi/apsi_test.cc b/psi/apsi/apsi_test.cc
similarity index 90%
rename from psi/psi/core/labeled_psi/apsi_test.cc
rename to psi/apsi/apsi_test.cc
index 1cb5c5bb..4666189e 100644
--- a/psi/psi/core/labeled_psi/apsi_test.cc
+++ b/psi/apsi/apsi_test.cc
@@ -28,14 +28,14 @@
#include "yacl/link/test_util.h"
#include "yacl/utils/scope_guard.h"
-#include "psi/psi/core/ecdh_oprf/ecdh_oprf_selector.h"
-#include "psi/psi/core/labeled_psi/psi_params.h"
-#include "psi/psi/core/labeled_psi/receiver.h"
-#include "psi/psi/core/labeled_psi/sender.h"
-#include "psi/psi/core/labeled_psi/sender_kvdb.h"
-#include "psi/psi/core/labeled_psi/sender_memdb.h"
+#include "psi/apsi/psi_params.h"
+#include "psi/apsi/receiver.h"
+#include "psi/apsi/sender.h"
+#include "psi/apsi/sender_kvdb.h"
+#include "psi/apsi/sender_memdb.h"
+#include "psi/ecdh//ecdh_oprf_selector.h"
-namespace psi::psi {
+namespace psi::apsi {
namespace {
@@ -94,17 +94,17 @@ class LabelPsiTest : public testing::TestWithParam {};
TEST_P(LabelPsiTest, Works) {
auto params = GetParam();
auto ctxs = yacl::link::test::SetupWorld(2);
- apsi::PSIParams psi_params = GetPsiParams(params.nr, params.ns);
+ ::apsi::PSIParams psi_params = GetPsiParams(params.nr, params.ns);
// step 1: PsiParams Request and Response
std::future f_sender_params = std::async(
[&] { return LabelPsiSender::RunPsiParams(params.ns, ctxs[0]); });
- std::future f_receiver_params = std::async(
+ std::future<::apsi::PSIParams> f_receiver_params = std::async(
[&] { return LabelPsiReceiver::RequestPsiParams(params.nr, ctxs[1]); });
f_sender_params.get();
- apsi::PSIParams psi_params2 = f_receiver_params.get();
+ ::apsi::PSIParams psi_params2 = f_receiver_params.get();
EXPECT_EQ(psi_params.table_params().table_size,
psi_params2.table_params().table_size);
@@ -168,14 +168,15 @@ TEST_P(LabelPsiTest, Works) {
SPDLOG_INFO("after set db, bin_bundle_count:{}, packing_rate:{}",
sender_db->GetBinBundleCount(), sender_db->GetPackingRate());
- const apsi::PSIParams apsi_params = sender_db->GetParams();
+ const ::apsi::PSIParams apsi_params = sender_db->GetParams();
SPDLOG_INFO("params.bundle_idx_count={}", apsi_params.bundle_idx_count());
for (size_t i = 0; i < apsi_params.bundle_idx_count(); ++i) {
SPDLOG_INFO("i={},count={}", i, sender_db->GetBinBundleCount(i));
}
- std::unique_ptr oprf_server =
- CreateEcdhOprfServer(oprf_key, OprfType::Basic, CurveType::CURVE_FOURQ);
+ std::unique_ptr oprf_server =
+ ecdh::CreateEcdhOprfServer(oprf_key, ecdh::OprfType::Basic,
+ CurveType::CURVE_FOURQ);
LabelPsiSender sender(sender_db);
@@ -189,12 +190,12 @@ TEST_P(LabelPsiTest, Works) {
[&] { return sender.RunOPRF(std::move(oprf_server), ctxs[0]); });
std::future<
- std::pair, std::vector>>
+ std::pair, std::vector<::apsi::LabelKey>>>
f_receiver_oprf = std::async(
[&] { return receiver.RequestOPRF(receiver_items, ctxs[1]); });
f_sender_oprf.get();
- std::pair, std::vector>
+ std::pair, std::vector<::apsi::LabelKey>>
oprf_pair = f_receiver_oprf.get();
const auto oprf_end = std::chrono::system_clock::now();
@@ -253,4 +254,4 @@ INSTANTIATE_TEST_SUITE_P(Works_Instances, LabelPsiTest,
#endif
);
-} // namespace psi::psi
+} // namespace psi::apsi
diff --git a/psi/psi/core/labeled_psi/kv_test.cc b/psi/apsi/kv_test.cc
similarity index 90%
rename from psi/psi/core/labeled_psi/kv_test.cc
rename to psi/apsi/kv_test.cc
index 680798b9..dae6ba3e 100644
--- a/psi/psi/core/labeled_psi/kv_test.cc
+++ b/psi/apsi/kv_test.cc
@@ -28,15 +28,15 @@
#include "yacl/link/test_util.h"
#include "yacl/utils/scope_guard.h"
-#include "psi/psi/core/ecdh_oprf/ecdh_oprf_selector.h"
-#include "psi/psi/core/labeled_psi/padding.h"
-#include "psi/psi/core/labeled_psi/psi_params.h"
-#include "psi/psi/core/labeled_psi/receiver.h"
-#include "psi/psi/core/labeled_psi/sender.h"
-#include "psi/psi/core/labeled_psi/sender_kvdb.h"
-#include "psi/psi/utils/sync.h"
+#include "psi/apsi/padding.h"
+#include "psi/apsi/psi_params.h"
+#include "psi/apsi/receiver.h"
+#include "psi/apsi/sender.h"
+#include "psi/apsi/sender_kvdb.h"
+#include "psi/ecdh//ecdh_oprf_selector.h"
+#include "psi/utils/sync.h"
-namespace psi::psi {
+namespace psi::apsi {
namespace {
@@ -63,25 +63,25 @@ std::vector GenerateData(size_t seed, size_t item_count) {
return items;
}
-std::vector GenerateSenderData(
+std::vector<::apsi::Item> GenerateSenderData(
size_t seed, size_t item_count,
const absl::Span &receiver_items,
std::vector *intersection_idx) {
- std::vector sender_items;
+ std::vector<::apsi::Item> sender_items;
yacl::crypto::Prg prg(seed);
for (size_t i = 0; i < item_count; ++i) {
- apsi::Item::value_type value{};
+ ::apsi::Item::value_type value{};
prg.Fill(absl::MakeSpan(value));
sender_items.emplace_back(value);
}
for (size_t i = 0; i < receiver_items.size(); i += 3) {
- apsi::Item::value_type value{};
+ ::apsi::Item::value_type value{};
std::memcpy(value.data(), receiver_items[i].data(),
receiver_items[i].length());
- apsi::Item item(value);
+ ::apsi::Item item(value);
sender_items[kPsiStartPos + i * 5] = item;
(*intersection_idx).emplace_back(i);
}
@@ -89,18 +89,18 @@ std::vector GenerateSenderData(
return sender_items;
}
-std::vector> GenerateSenderData(
+std::vector> GenerateSenderData(
size_t seed, size_t item_count, size_t label_byte_count,
const absl::Span &receiver_items,
std::vector *intersection_idx,
std::vector *intersection_label) {
- std::vector> sender_items;
+ std::vector> sender_items;
yacl::crypto::Prg prg(seed);
for (size_t i = 0; i < item_count; ++i) {
- apsi::Item item;
- apsi::Label label;
+ ::apsi::Item item;
+ ::apsi::Label label;
label.resize(label_byte_count);
prg.Fill(absl::MakeSpan(item.value()));
prg.Fill(absl::MakeSpan(label));
@@ -108,7 +108,7 @@ std::vector> GenerateSenderData(
}
for (size_t i = 0; i < receiver_items.size(); i += 3) {
- apsi::Item item;
+ ::apsi::Item item;
std::memcpy(item.value().data(), receiver_items[i].data(),
receiver_items[i].length());
@@ -149,17 +149,17 @@ TEST_P(LabelPsiTest, Works) {
SPDLOG_INFO("d1 len:{} d2 len:{}", d1.size(), d2.length());
}
- apsi::PSIParams psi_params = GetPsiParams(params.nr, params.ns);
+ ::apsi::PSIParams psi_params = GetPsiParams(params.nr, params.ns);
// step 1: PsiParams Request and Response
std::future f_sender_params = std::async(
[&] { return LabelPsiSender::RunPsiParams(params.ns, ctxs[0]); });
- std::future f_receiver_params = std::async(
+ std::future<::apsi::PSIParams> f_receiver_params = std::async(
[&] { return LabelPsiReceiver::RequestPsiParams(params.nr, ctxs[1]); });
f_sender_params.get();
- apsi::PSIParams psi_params2 = f_receiver_params.get();
+ ::apsi::PSIParams psi_params2 = f_receiver_params.get();
EXPECT_EQ(psi_params.table_params().table_size,
psi_params2.table_params().table_size);
@@ -203,7 +203,7 @@ TEST_P(LabelPsiTest, Works) {
const auto setdb_start = std::chrono::system_clock::now();
if (params.label_bytes == 0) {
- std::vector sender_items = GenerateSenderData(
+ std::vector<::apsi::Item> sender_items = GenerateSenderData(
rd(), item_count, absl::MakeSpan(receiver_items), &intersection_idx);
// sender_db->SetData(sender_items);
@@ -222,7 +222,7 @@ TEST_P(LabelPsiTest, Works) {
sender_db->SetData(batch_provider);
} else {
- std::vector> sender_items =
+ std::vector> sender_items =
GenerateSenderData(rd(), item_count, label_byte_count - 6,
absl::MakeSpan(receiver_items), &intersection_idx,
&intersection_label);
@@ -258,7 +258,7 @@ TEST_P(LabelPsiTest, Works) {
SPDLOG_INFO("after set db, bin_bundle_count:{}, packing_rate:{}",
sender_db->GetBinBundleCount(), sender_db->GetPackingRate());
- const apsi::PSIParams &apsi_params = sender_db->GetParams();
+ const ::apsi::PSIParams &apsi_params = sender_db->GetParams();
SPDLOG_INFO("bundle_idx_count:{}", apsi_params.bundle_idx_count());
SPDLOG_INFO("BinBundleCount:{}", sender_db->GetBinBundleCount());
for (size_t i = 0; i < apsi_params.bundle_idx_count(); ++i) {
@@ -281,12 +281,12 @@ TEST_P(LabelPsiTest, Works) {
[&] { return sender.RunOPRF(std::move(oprf_server), ctxs[0]); });
std::future<
- std::pair, std::vector>>
+ std::pair, std::vector<::apsi::LabelKey>>>
f_receiver_oprf = std::async(
[&] { return receiver.RequestOPRF(receiver_items, ctxs[1]); });
f_sender_oprf.get();
- std::pair, std::vector>
+ std::pair, std::vector<::apsi::LabelKey>>
oprf_pair = f_receiver_oprf.get();
const auto oprf_end = std::chrono::system_clock::now();
@@ -360,4 +360,4 @@ INSTANTIATE_TEST_SUITE_P(
#endif
);
-} // namespace psi::psi
+} // namespace psi::apsi
diff --git a/psi/psi/core/labeled_psi/package.cc b/psi/apsi/package.cc
similarity index 93%
rename from psi/psi/core/labeled_psi/package.cc
rename to psi/apsi/package.cc
index 55d262ae..47e7daf8 100644
--- a/psi/psi/core/labeled_psi/package.cc
+++ b/psi/apsi/package.cc
@@ -12,17 +12,17 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "psi/psi/core/labeled_psi/package.h"
+#include "psi/apsi/package.h"
#include
#include "spdlog/spdlog.h"
#include "yacl/base/exception.h"
-namespace psi::psi {
+namespace psi::apsi {
PlainResultPackage ResultPackage::extract(
- const apsi::CryptoContext &crypto_context) {
+ const ::apsi::CryptoContext &crypto_context) {
YACL_ENFORCE(crypto_context.decryptor(),
"decryptor is not configured in CryptoContext");
@@ -60,4 +60,4 @@ PlainResultPackage ResultPackage::extract(
return plain_rp;
}
-} // namespace psi::psi
+} // namespace psi::apsi
diff --git a/psi/psi/core/labeled_psi/package.h b/psi/apsi/package.h
similarity index 83%
rename from psi/psi/core/labeled_psi/package.h
rename to psi/apsi/package.h
index 6139e8fd..f1ec893c 100644
--- a/psi/psi/core/labeled_psi/package.h
+++ b/psi/apsi/package.h
@@ -21,7 +21,7 @@
#include "gsl/span"
#include "seal/seal.h"
-namespace psi::psi {
+namespace psi::apsi {
struct PlainResultPackage {
std::uint32_t bundle_idx;
@@ -37,19 +37,19 @@ struct PlainResultPackage {
class ResultPackage {
public:
- PlainResultPackage extract(const apsi::CryptoContext& crypto_context);
+ PlainResultPackage extract(const ::apsi::CryptoContext& crypto_context);
std::uint32_t bundle_idx;
seal::compr_mode_type compr_mode = seal::Serialization::compr_mode_default;
- apsi::SEALObject psi_result;
+ ::apsi::SEALObject psi_result;
std::uint32_t label_byte_count;
std::uint32_t nonce_byte_count;
- std::vector> label_result;
+ std::vector<::apsi::SEALObject> label_result;
}; // struct ResultPackage
-} // namespace psi::psi
+} // namespace psi::apsi
diff --git a/psi/psi/core/labeled_psi/padding.cc b/psi/apsi/padding.cc
similarity index 94%
rename from psi/psi/core/labeled_psi/padding.cc
rename to psi/apsi/padding.cc
index d2f1fcba..e17c0138 100644
--- a/psi/psi/core/labeled_psi/padding.cc
+++ b/psi/apsi/padding.cc
@@ -12,11 +12,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "psi/psi/core/labeled_psi/padding.h"
+#include "psi/apsi/padding.h"
#include "yacl/base/exception.h"
-namespace psi::psi {
+namespace psi::apsi {
// pad data to max_len bytes
// format len(32bit)||data||00..00
@@ -45,4 +45,4 @@ std::string UnPaddingData(yacl::ByteContainerView data) {
return ret;
}
-} // namespace psi::psi
+} // namespace psi::apsi
diff --git a/psi/psi/core/labeled_psi/padding.h b/psi/apsi/padding.h
similarity index 94%
rename from psi/psi/core/labeled_psi/padding.h
rename to psi/apsi/padding.h
index a81750bf..d596cbf5 100644
--- a/psi/psi/core/labeled_psi/padding.h
+++ b/psi/apsi/padding.h
@@ -16,10 +16,10 @@
#include "yacl/base/byte_container_view.h"
-namespace psi::psi {
+namespace psi::apsi {
std::vector PaddingData(yacl::ByteContainerView data, size_t max_len);
std::string UnPaddingData(yacl::ByteContainerView data);
-} // namespace psi::psi
\ No newline at end of file
+} // namespace psi::apsi
diff --git a/psi/pir/pir.cc b/psi/apsi/pir.cc
similarity index 77%
rename from psi/pir/pir.cc
rename to psi/apsi/pir.cc
index 48389a87..6db91d54 100644
--- a/psi/pir/pir.cc
+++ b/psi/apsi/pir.cc
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "psi/pir/pir.h"
+#include "psi/apsi/pir.h"
#include
#include
@@ -26,19 +26,19 @@
#include "yacl/io/kv/leveldb_kvstore.h"
#include "yacl/io/rw/csv_writer.h"
-#include "psi/psi/core/ecdh_oprf/ecdh_oprf_selector.h"
-#include "psi/psi/core/labeled_psi/receiver.h"
-#include "psi/psi/core/labeled_psi/sender.h"
-#include "psi/psi/core/labeled_psi/sender_db.h"
-#include "psi/psi/core/labeled_psi/sender_kvdb.h"
-#include "psi/psi/core/labeled_psi/sender_memdb.h"
-#include "psi/psi/cryptor/ecc_cryptor.h"
-#include "psi/psi/utils/batch_provider.h"
-#include "psi/psi/utils/io.h"
-#include "psi/psi/utils/serialize.h"
-#include "psi/psi/utils/sync.h"
+#include "psi/apsi/receiver.h"
+#include "psi/apsi/sender.h"
+#include "psi/apsi/sender_db.h"
+#include "psi/apsi/sender_kvdb.h"
+#include "psi/apsi/sender_memdb.h"
+#include "psi/cryptor/ecc_cryptor.h"
+#include "psi/ecdh//ecdh_oprf_selector.h"
+#include "psi/utils/batch_provider.h"
+#include "psi/utils/io.h"
+#include "psi/utils/serialize.h"
+#include "psi/utils/sync.h"
-namespace psi::pir {
+namespace psi::apsi {
namespace {
@@ -49,15 +49,13 @@ std::vector ReadEcSecretKeyFile(const std::string &file_path) {
} catch (std::filesystem::filesystem_error &e) {
YACL_THROW("ReadEcSecretKeyFile {} Error: {}", file_path, e.what());
}
- YACL_ENFORCE(file_byte_size == ::psi::psi::kEccKeySize,
- "error format: key file bytes is not {}",
- ::psi::psi::kEccKeySize);
+ YACL_ENFORCE(file_byte_size == ::psi::kEccKeySize,
+ "error format: key file bytes is not {}", ::psi::kEccKeySize);
- std::vector secret_key(::psi::psi::kEccKeySize);
+ std::vector secret_key(::psi::kEccKeySize);
- auto in = ::psi::psi::io::BuildInputStream(
- ::psi::psi::io::FileIoOptions(file_path));
- in->Read(secret_key.data(), ::psi::psi::kEccKeySize);
+ auto in = ::psi::io::BuildInputStream(::psi::io::FileIoOptions(file_path));
+ in->Read(secret_key.data(), ::psi::kEccKeySize);
in->Close();
return secret_key;
@@ -67,8 +65,8 @@ size_t CsvFileDataCount(const std::string &file_path,
const std::vector &ids) {
size_t data_count = 0;
- std::shared_ptr<::psi::psi::IBasicBatchProvider> batch_provider =
- std::make_shared<::psi::psi::CsvBatchProvider>(file_path, ids, 4096);
+ std::shared_ptr<::psi::IBasicBatchProvider> batch_provider =
+ std::make_shared<::psi::CsvBatchProvider>(file_path, ids, 4096);
while (true) {
auto batch = batch_provider->ReadNextBatch();
@@ -96,7 +94,7 @@ constexpr size_t kNonceByteCount = 16;
void WriteMetaInfo(const std::string &setup_path, size_t server_data_count,
size_t count_per_query, size_t label_byte_count,
const std::vector &label_cloumns,
- const apsi::PSIParams &psi_params, size_t bucket_count,
+ const ::apsi::PSIParams &psi_params, size_t bucket_count,
size_t bucket_size = 1000000, bool compressed = false) {
std::string meta_store_name =
fmt::format("{}/{}", setup_path, kMetaInfoStoreName);
@@ -110,7 +108,7 @@ void WriteMetaInfo(const std::string &setup_path, size_t server_data_count,
meta_info_store->Put(kBucketSize, fmt::format("{}", bucket_size));
meta_info_store->Put(kCompressed, fmt::format("{}", compressed ? 1 : 0));
- ::psi::psi::proto::StrItemsProto proto;
+ ::psi::proto::StrItemsProto proto;
for (const auto &label_cloumn : label_cloumns) {
proto.add_items(label_cloumn);
}
@@ -119,7 +117,7 @@ void WriteMetaInfo(const std::string &setup_path, size_t server_data_count,
meta_info_store->Put(kLabelColumns, buf);
- yacl::Buffer params_buffer = ::psi::psi::PsiParamsToBuffer(psi_params);
+ yacl::Buffer params_buffer = PsiParamsToBuffer(psi_params);
meta_info_store->Put(kPsiParams, params_buffer);
meta_info_store->Put(kBucketCount, fmt::format("{}", bucket_count));
@@ -136,12 +134,13 @@ size_t GetSizeFromStore(
return key_value;
}
-apsi::PSIParams ReadMetaInfo(const std::string &setup_path,
- size_t *server_data_count, size_t *count_per_query,
- size_t *label_byte_count,
- std::vector *label_cloumns,
- size_t *bucket_count, size_t *bucket_size,
- bool *compressed) {
+::apsi::PSIParams ReadMetaInfo(const std::string &setup_path,
+ size_t *server_data_count,
+ size_t *count_per_query,
+ size_t *label_byte_count,
+ std::vector *label_cloumns,
+ size_t *bucket_count, size_t *bucket_size,
+ bool *compressed) {
std::string meta_store_name =
fmt::format("{}/{}", setup_path, kMetaInfoStoreName);
std::shared_ptr meta_info_store =
@@ -153,7 +152,7 @@ apsi::PSIParams ReadMetaInfo(const std::string &setup_path,
yacl::Buffer label_columns_buf;
meta_info_store->Get(kLabelColumns, &label_columns_buf);
- ::psi::psi::proto::StrItemsProto proto;
+ ::psi::proto::StrItemsProto proto;
proto.ParseFromArray(label_columns_buf.data(), label_columns_buf.size());
(*label_cloumns).reserve(proto.items_size());
for (auto item : proto.items()) {
@@ -162,7 +161,7 @@ apsi::PSIParams ReadMetaInfo(const std::string &setup_path,
yacl::Buffer params_buffer;
meta_info_store->Get(kPsiParams, ¶ms_buffer);
- apsi::PSIParams psi_params = ::psi::psi::ParsePsiParamsProto(params_buffer);
+ ::apsi::PSIParams psi_params = ParsePsiParamsProto(params_buffer);
*bucket_count = GetSizeFromStore(meta_info_store, kBucketCount);
*bucket_size = GetSizeFromStore(meta_info_store, kBucketSize);
@@ -214,8 +213,8 @@ PirResultReport LabeledPirSetup(const PirSetupConfig &config) {
}
std::filesystem::create_directory(kv_store_path);
- apsi::PSIParams psi_params = ::psi::psi::GetPsiParams(
- count_per_query, bucket_size, config.max_items_per_bin());
+ ::apsi::PSIParams psi_params =
+ GetPsiParams(count_per_query, bucket_size, config.max_items_per_bin());
SPDLOG_INFO("table_params hash_func_count:{}",
psi_params.table_params().hash_func_count);
@@ -231,8 +230,8 @@ PirResultReport LabeledPirSetup(const PirSetupConfig &config) {
label_byte_count, label_columns, psi_params, bucket_count,
config.bucket_size(), config.compressed());
- std::shared_ptr<::psi::psi::ILabeledBatchProvider> batch_provider =
- std::make_shared<::psi::psi::CsvBatchProvider>(
+ std::shared_ptr<::psi::ILabeledBatchProvider> batch_provider =
+ std::make_shared<::psi::CsvBatchProvider>(
config.input_path(), key_columns, bucket_size, label_columns);
for (size_t i = 0; i < bucket_count; i++) {
std::string bucket_setup_path =
@@ -251,18 +250,17 @@ PirResultReport LabeledPirSetup(const PirSetupConfig &config) {
std::filesystem::create_directory(bucket_setup_path);
- apsi::PSIParams bucket_psi_params = ::psi::psi::GetPsiParams(
+ ::apsi::PSIParams bucket_psi_params = GetPsiParams(
count_per_query, std::min(bucket_size, batch_ids.size()),
config.max_items_per_bin());
- std::shared_ptr<::psi::psi::ISenderDB> sender_db =
- std::make_shared<::psi::psi::SenderKvDB>(
- bucket_psi_params, oprf_key, bucket_setup_path, label_byte_count,
- nonce_byte_count, config.compressed());
+ std::shared_ptr sender_db = std::make_shared(
+ bucket_psi_params, oprf_key, bucket_setup_path, label_byte_count,
+ nonce_byte_count, config.compressed());
- std::shared_ptr<::psi::psi::IBatchProvider> bucket_batch_provider =
- std::make_shared<::psi::psi::MemoryBatchProvider>(
- batch_ids, bucket_size, batch_labels);
+ std::shared_ptr<::psi::IBatchProvider> bucket_batch_provider =
+ std::make_shared<::psi::MemoryBatchProvider>(batch_ids, bucket_size,
+ batch_labels);
sender_db->SetData(bucket_batch_provider);
SPDLOG_INFO("finish bucket:{}", i);
@@ -276,30 +274,29 @@ PirResultReport LabeledPirSetup(const PirSetupConfig &config) {
PirResultReport LabeledPirServer(
const std::shared_ptr &link_ctx,
- const std::shared_ptr<::psi::psi::ISenderDB> &sender_db,
- const std::vector &oprf_key, const apsi::PSIParams &psi_params,
+ const std::shared_ptr &sender_db,
+ const std::vector &oprf_key, const ::apsi::PSIParams &psi_params,
const std::vector &label_columns, size_t bucket_count,
size_t /*server_data_count*/, size_t count_per_query,
size_t /*label_byte_count*/, uint32_t /*bucket_size*/) {
// send count_per_query
link_ctx->SendAsync(link_ctx->NextRank(),
- ::psi::psi::utils::SerializeSize(count_per_query),
+ ::psi::utils::SerializeSize(count_per_query),
fmt::format("count_per_query:{}", count_per_query));
- yacl::Buffer labels_buffer =
- ::psi::psi::utils::SerializeStrItems(label_columns);
+ yacl::Buffer labels_buffer = ::psi::utils::SerializeStrItems(label_columns);
// send labels column name
link_ctx->SendAsync(link_ctx->NextRank(), labels_buffer,
fmt::format("send label columns name"));
// send psi params
- yacl::Buffer params_buffer = ::psi::psi::PsiParamsToBuffer(psi_params);
+ yacl::Buffer params_buffer = PsiParamsToBuffer(psi_params);
link_ctx->SendAsync(link_ctx->NextRank(), params_buffer,
fmt::format("send psi params"));
// bucket_count
link_ctx->SendAsync(link_ctx->NextRank(),
- ::psi::psi::utils::SerializeSize(bucket_count),
+ ::psi::utils::SerializeSize(bucket_count),
fmt::format("bucket_count:{}", bucket_count));
// const auto total_query_start = std::chrono::system_clock::now();
@@ -307,11 +304,11 @@ PirResultReport LabeledPirServer(
size_t query_count = 0;
size_t data_count = 0;
- ::psi::psi::LabelPsiSender sender(sender_db);
+ LabelPsiSender sender(sender_db);
while (true) {
// recv current batch_size
- size_t batch_data_size = ::psi::psi::utils::DeserializeSize(
+ size_t batch_data_size = ::psi::utils::DeserializeSize(
link_ctx->Recv(link_ctx->NextRank(), fmt::format("batch_data_size")));
SPDLOG_INFO("client data size: {}", batch_data_size);
@@ -321,9 +318,9 @@ PirResultReport LabeledPirServer(
data_count += batch_data_size;
// oprf
- std::unique_ptr<::psi::psi::IEcdhOprfServer> oprf_server =
- ::psi::psi::CreateEcdhOprfServer(oprf_key, ::psi::psi::OprfType::Basic,
- ::psi::psi::CurveType::CURVE_FOURQ);
+ std::unique_ptr oprf_server =
+ ecdh::CreateEcdhOprfServer(oprf_key, ecdh::OprfType::Basic,
+ ::psi::CurveType::CURVE_FOURQ);
// const auto oprf_start = std::chrono::system_clock::now();
sender.RunOPRF(std::move(oprf_server), link_ctx);
@@ -362,7 +359,7 @@ PirResultReport LabeledPirServer(
size_t bucket_size;
bool compressed;
- apsi::PSIParams psi_params =
+ ::apsi::PSIParams psi_params =
ReadMetaInfo(config.setup_path(), &server_data_count, &count_per_query,
&label_byte_count, &label_columns, &bucket_count,
&bucket_size, &compressed);
@@ -373,52 +370,51 @@ PirResultReport LabeledPirServer(
// server and client sync
auto run_f = std::async([&] { return 0; });
- ::psi::psi::SyncWait(link_ctx, &run_f);
+ ::psi::SyncWait(link_ctx, &run_f);
SPDLOG_INFO("table_params hash_func_count:{}",
psi_params.table_params().hash_func_count);
size_t nonce_byte_count = kNonceByteCount;
- std::vector> sender_db(bucket_count);
- std::vector> sender(bucket_count);
+ std::vector> sender_db(bucket_count);
+ std::vector> sender(bucket_count);
- std::unique_ptr<::psi::psi::IEcdhOprfServer> oprf_server =
- ::psi::psi::CreateEcdhOprfServer(oprf_key, ::psi::psi::OprfType::Basic,
- ::psi::psi::CurveType::CURVE_FOURQ);
+ std::unique_ptr oprf_server =
+ ecdh::CreateEcdhOprfServer(oprf_key, ecdh::OprfType::Basic,
+ ::psi::CurveType::CURVE_FOURQ);
for (size_t bucket_idx = 0; bucket_idx < bucket_count; ++bucket_idx) {
std::string bucket_setup_path =
fmt::format("{}/bucket_{}", config.setup_path(), bucket_idx);
- sender_db[bucket_idx] = std::make_shared<::psi::psi::SenderKvDB>(
+ sender_db[bucket_idx] = std::make_shared(
psi_params, oprf_key, bucket_setup_path, label_byte_count,
nonce_byte_count, compressed);
sender[bucket_idx] =
- std::make_shared<::psi::psi::LabelPsiSender>(sender_db[bucket_idx]);
+ std::make_shared(sender_db[bucket_idx]);
}
SPDLOG_INFO("db GetItemCount:{}", sender_db[0]->GetItemCount());
// send count_per_query
link_ctx->SendAsync(link_ctx->NextRank(),
- ::psi::psi::utils::SerializeSize(count_per_query),
+ ::psi::utils::SerializeSize(count_per_query),
fmt::format("count_per_query:{}", count_per_query));
- yacl::Buffer labels_buffer =
- ::psi::psi::utils::SerializeStrItems(label_columns);
+ yacl::Buffer labels_buffer = ::psi::utils::SerializeStrItems(label_columns);
// send labels column name
link_ctx->SendAsync(link_ctx->NextRank(), labels_buffer,
fmt::format("send label columns name"));
// send psi params
- yacl::Buffer params_buffer = ::psi::psi::PsiParamsToBuffer(psi_params);
+ yacl::Buffer params_buffer = PsiParamsToBuffer(psi_params);
link_ctx->SendAsync(link_ctx->NextRank(), params_buffer,
fmt::format("send psi params"));
// send bucket_count
link_ctx->SendAsync(link_ctx->NextRank(),
- ::psi::psi::utils::SerializeSize(bucket_count),
+ ::psi::utils::SerializeSize(bucket_count),
fmt::format("bucket_count:{}", bucket_count));
// const auto total_query_start = std::chrono::system_clock::now();
@@ -428,7 +424,7 @@ PirResultReport LabeledPirServer(
while (true) {
// recv current batch_size
- size_t batch_data_size = ::psi::psi::utils::DeserializeSize(
+ size_t batch_data_size = ::psi::utils::DeserializeSize(
link_ctx->Recv(link_ctx->NextRank(), fmt::format("batch_data_size")));
SPDLOG_INFO("client data size: {}", batch_data_size);
@@ -438,9 +434,9 @@ PirResultReport LabeledPirServer(
data_count += batch_data_size;
// oprf
- std::unique_ptr<::psi::psi::IEcdhOprfServer> oprf_server =
- ::psi::psi::CreateEcdhOprfServer(oprf_key, ::psi::psi::OprfType::Basic,
- ::psi::psi::CurveType::CURVE_FOURQ);
+ std::unique_ptr oprf_server =
+ ecdh::CreateEcdhOprfServer(oprf_key, ecdh::OprfType::Basic,
+ ::psi::CurveType::CURVE_FOURQ);
// const auto oprf_start = std::chrono::system_clock::now();
sender[0]->RunOPRF(std::move(oprf_server), link_ctx);
@@ -487,31 +483,29 @@ PirResultReport LabeledPirMemoryServer(
YACL_ENFORCE(server_data_count <= config.bucket_size(),
"data_count:{} bucket_size:{}", config.bucket_size());
- apsi::PSIParams psi_params = ::psi::psi::GetPsiParams(
+ ::apsi::PSIParams psi_params = GetPsiParams(
count_per_query, server_data_count, config.max_items_per_bin());
- std::vector oprf_key =
- yacl::crypto::RandBytes(::psi::psi::kEccKeySize);
+ std::vector oprf_key = yacl::crypto::RandBytes(::psi::kEccKeySize);
size_t label_byte_count = config.label_max_len();
size_t nonce_byte_count = kNonceByteCount;
- std::shared_ptr<::psi::psi::ISenderDB> sender_db =
- std::make_shared<::psi::psi::SenderMemDB>(
- psi_params, oprf_key, label_byte_count, nonce_byte_count,
- config.compressed());
+ std::shared_ptr sender_db =
+ std::make_shared(psi_params, oprf_key, label_byte_count,
+ nonce_byte_count, config.compressed());
// server and client sync
auto run_f = std::async([&] {
- std::shared_ptr<::psi::psi::IBatchProvider> batch_provider =
- std::make_shared<::psi::psi::CsvBatchProvider>(
+ std::shared_ptr<::psi::IBatchProvider> batch_provider =
+ std::make_shared<::psi::CsvBatchProvider>(
config.input_path(), key_columns, 500000, label_columns);
sender_db->SetData(batch_provider);
return 0;
});
- ::psi::psi::SyncWait(link_ctx, &run_f);
+ ::psi::SyncWait(link_ctx, &run_f);
SPDLOG_INFO("sender_db->GetItemCount:{}", sender_db->GetItemCount());
@@ -534,10 +528,10 @@ PirResultReport LabeledPirClient(
// server and client sync
auto run_f = std::async([&] { return 0; });
- ::psi::psi::SyncWait(link_ctx, &run_f);
+ ::psi::SyncWait(link_ctx, &run_f);
// recv count_per_query
- size_t count_per_query = ::psi::psi::utils::DeserializeSize(
+ size_t count_per_query = ::psi::utils::DeserializeSize(
link_ctx->Recv(link_ctx->NextRank(), fmt::format("count_per_query")));
YACL_ENFORCE(count_per_query > 0, "Invalid nr:{}", count_per_query);
@@ -547,8 +541,7 @@ PirResultReport LabeledPirClient(
link_ctx->NextRank(), fmt::format("recv label columns name"));
std::vector label_columns_name;
- ::psi::psi::utils::DeserializeStrItems(label_columns_buffer,
- &label_columns_name);
+ ::psi::utils::DeserializeStrItems(label_columns_buffer, &label_columns_name);
yacl::io::Schema s;
for (size_t i = 0; i < key_columns.size(); ++i) {
@@ -565,8 +558,8 @@ PirResultReport LabeledPirClient(
yacl::io::WriterOptions w_op;
w_op.file_schema = s;
- auto out = ::psi::psi::io::BuildOutputStream(
- ::psi::psi::io::FileIoOptions(config.output_path()));
+ auto out = ::psi::io::BuildOutputStream(
+ ::psi::io::FileIoOptions(config.output_path()));
yacl::io::CsvWriter writer(w_op, std::move(out));
writer.Init();
@@ -574,7 +567,7 @@ PirResultReport LabeledPirClient(
yacl::Buffer params_buffer =
link_ctx->Recv(link_ctx->NextRank(), fmt::format("recv psi params"));
- apsi::PSIParams psi_params = ::psi::psi::ParsePsiParamsProto(params_buffer);
+ ::apsi::PSIParams psi_params = ParsePsiParamsProto(params_buffer);
SPDLOG_INFO("table_params hash_func_count:{}",
psi_params.table_params().hash_func_count);
@@ -586,11 +579,11 @@ PirResultReport LabeledPirClient(
SPDLOG_INFO("query_params query_powers size:{}",
psi_params.query_params().query_powers.size());
- size_t bucket_count = ::psi::psi::utils::DeserializeSize(
+ size_t bucket_count = ::psi::utils::DeserializeSize(
link_ctx->Recv(link_ctx->NextRank(), fmt::format("bucket_count")));
SPDLOG_INFO("bucket_count:{}", bucket_count);
- ::psi::psi::LabelPsiReceiver receiver(psi_params, true);
+ LabelPsiReceiver receiver(psi_params, true);
// const auto total_query_start = std::chrono::system_clock::now();
@@ -604,9 +597,9 @@ PirResultReport LabeledPirClient(
size_t batch_read_count = std::max(table_items, count_per_query);
SPDLOG_INFO("batch_read_count:{}", batch_read_count);
- std::shared_ptr<::psi::psi::IBasicBatchProvider> query_batch_provider =
- std::make_shared<::psi::psi::CsvBatchProvider>(
- config.input_path(), key_columns, batch_read_count);
+ std::shared_ptr<::psi::IBasicBatchProvider> query_batch_provider =
+ std::make_shared<::psi::CsvBatchProvider>(config.input_path(),
+ key_columns, batch_read_count);
while (true) {
auto query_batch_items = query_batch_provider->ReadNextBatch();
@@ -614,7 +607,7 @@ PirResultReport LabeledPirClient(
// send count_batch_size
link_ctx->SendAsync(
link_ctx->NextRank(),
- ::psi::psi::utils::SerializeSize(query_batch_items.size()),
+ ::psi::utils::SerializeSize(query_batch_items.size()),
fmt::format("count_batch_size:{}", query_batch_items.size()));
if (query_batch_items.empty()) {
@@ -623,7 +616,7 @@ PirResultReport LabeledPirClient(
data_count += query_batch_items.size();
// const auto oprf_start = std::chrono::system_clock::now();
- std::pair, std::vector>
+ std::pair, std::vector<::apsi::LabelKey>>
items_oprf = receiver.RequestOPRF(query_batch_items, link_ctx);
// const auto oprf_end = std::chrono::system_clock::now();
@@ -700,7 +693,7 @@ PirResultReport LabeledPirClient(
}
PirResultReport PirSetup(const PirSetupConfig &config) {
- if (config.pir_protocol() != KEYWORD_PIR_LABELED_PSI) {
+ if (config.pir_protocol() != ::psi::KEYWORD_PIR_LABELED_PSI) {
YACL_THROW("Unsupported pir protocol {}",
PirProtocol_Name(config.pir_protocol()));
}
@@ -710,7 +703,7 @@ PirResultReport PirSetup(const PirSetupConfig &config) {
PirResultReport PirServer(const std::shared_ptr &link_ctx,
const PirServerConfig &config) {
- if (config.pir_protocol() != KEYWORD_PIR_LABELED_PSI) {
+ if (config.pir_protocol() != ::psi::KEYWORD_PIR_LABELED_PSI) {
YACL_THROW("Unsupported pir protocol {}",
PirProtocol_Name(config.pir_protocol()));
}
@@ -721,7 +714,7 @@ PirResultReport PirServer(const std::shared_ptr &link_ctx,
PirResultReport PirMemoryServer(
const std::shared_ptr &link_ctx,
const PirSetupConfig &config) {
- if (config.pir_protocol() != KEYWORD_PIR_LABELED_PSI) {
+ if (config.pir_protocol() != ::psi::KEYWORD_PIR_LABELED_PSI) {
YACL_THROW("Unsupported pir protocol {}",
PirProtocol_Name(config.pir_protocol()));
}
@@ -731,7 +724,7 @@ PirResultReport PirMemoryServer(
PirResultReport PirClient(const std::shared_ptr &link_ctx,
const PirClientConfig &config) {
- if (config.pir_protocol() != KEYWORD_PIR_LABELED_PSI) {
+ if (config.pir_protocol() != ::psi::KEYWORD_PIR_LABELED_PSI) {
YACL_THROW("Unsupported pir protocol {}",
PirProtocol_Name(config.pir_protocol()));
}
@@ -739,4 +732,4 @@ PirResultReport PirClient(const std::shared_ptr &link_ctx,
return LabeledPirClient(link_ctx, config);
}
-} // namespace psi::pir
+} // namespace psi::apsi
diff --git a/psi/pir/pir.h b/psi/apsi/pir.h
similarity index 94%
rename from psi/pir/pir.h
rename to psi/apsi/pir.h
index 6f70b7e6..e12fc081 100644
--- a/psi/pir/pir.h
+++ b/psi/apsi/pir.h
@@ -18,11 +18,11 @@
#include "yacl/link/link.h"
-#include "psi/psi/core/labeled_psi/sender_db.h"
+#include "psi/apsi/sender_db.h"
#include "psi/proto/pir.pb.h"
-namespace psi::pir {
+namespace psi::apsi {
PirResultReport PirSetup(const PirSetupConfig &config);
@@ -51,4 +51,4 @@ PirResultReport LabeledPirClient(
const std::shared_ptr &link_ctx,
const PirClientConfig &config);
-} // namespace psi::pir
+} // namespace psi::apsi
diff --git a/psi/pir/pir_test.cc b/psi/apsi/pir_test.cc
similarity index 80%
rename from psi/pir/pir_test.cc
rename to psi/apsi/pir_test.cc
index b65c66c9..d6d7e1c9 100644
--- a/psi/pir/pir_test.cc
+++ b/psi/apsi/pir_test.cc
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "psi/pir/pir.h"
+#include "psi/apsi/pir.h"
#include
#include
@@ -27,8 +27,8 @@
#include "yacl/link/test_util.h"
#include "yacl/utils/scope_guard.h"
-#include "psi/psi/core/labeled_psi/psi_params.h"
-#include "psi/psi/utils/io.h"
+#include "psi/apsi/psi_params.h"
+#include "psi/utils/io.h"
namespace {
@@ -46,8 +46,7 @@ struct TestParams {
void WriteCsvFile(const std::string &file_name, const std::string &id_name,
const std::vector &items) {
- auto out =
- psi::psi::io::BuildOutputStream(psi::psi::io::FileIoOptions(file_name));
+ auto out = psi::io::BuildOutputStream(psi::io::FileIoOptions(file_name));
out->Write(fmt::format("{}\n", id_name));
for (size_t i = 0; i < items.size(); ++i) {
out->Write(fmt::format("{}\n", items[i]));
@@ -59,8 +58,7 @@ void WriteCsvFile(const std::string &file_name, const std::string &id_name,
const std::string &label_name,
const std::vector &items,
const std::vector &labels) {
- auto out =
- psi::psi::io::BuildOutputStream(psi::psi::io::FileIoOptions(file_name));
+ auto out = psi::io::BuildOutputStream(psi::io::FileIoOptions(file_name));
out->Write(fmt::format("{},{}\n", id_name, label_name));
for (size_t i = 0; i < items.size(); ++i) {
out->Write(fmt::format("{},{}\n", items[i], labels[i]));
@@ -126,14 +124,14 @@ GenerateSenderData(size_t seed, size_t item_count, size_t label_byte_count,
} // namespace
-namespace psi::pir {
+namespace psi::apsi {
class PirTest : public testing::TestWithParam {};
TEST_P(PirTest, Works) {
auto params = GetParam();
auto ctxs = yacl::link::test::SetupWorld(2);
- apsi::PSIParams psi_params = ::psi::psi::GetPsiParams(params.nr, params.ns);
+ ::apsi::PSIParams psi_params = GetPsiParams(params.nr, params.ns);
std::string tmp_store_path =
fmt::format("data_{}_{}", yacl::crypto::FastRandU64(), params.ns);
@@ -189,10 +187,10 @@ TEST_P(PirTest, Works) {
std::vector labels = {label_cloumn_name};
if (params.use_filedb) {
- PirSetupConfig config;
+ ::psi::PirSetupConfig config;
- config.set_pir_protocol(PirProtocol::KEYWORD_PIR_LABELED_PSI);
- config.set_store_type(KvStoreType::LEVELDB_KV_STORE);
+ config.set_pir_protocol(::psi::PirProtocol::KEYWORD_PIR_LABELED_PSI);
+ config.set_store_type(::psi::KvStoreType::LEVELDB_KV_STORE);
config.set_input_path(server_csv_path);
config.mutable_key_columns()->Add(ids.begin(), ids.end());
@@ -205,48 +203,48 @@ TEST_P(PirTest, Works) {
config.set_compressed(params.compressed);
config.set_bucket_size(params.bucket_size);
- PirResultReport setup_report = PirSetup(config);
+ ::psi::PirResultReport setup_report = PirSetup(config);
EXPECT_EQ(setup_report.data_count(), params.ns);
- std::future f_server = std::async([&] {
- PirServerConfig config;
+ std::future<::psi::PirResultReport> f_server = std::async([&] {
+ ::psi::PirServerConfig config;
- config.set_pir_protocol(PirProtocol::KEYWORD_PIR_LABELED_PSI);
- config.set_store_type(KvStoreType::LEVELDB_KV_STORE);
+ config.set_pir_protocol(::psi::PirProtocol::KEYWORD_PIR_LABELED_PSI);
+ config.set_store_type(::psi::KvStoreType::LEVELDB_KV_STORE);
config.set_oprf_key_path(oprf_key_path);
config.set_setup_path(setup_path);
- PirResultReport report = PirServer(ctxs[0], config);
+ ::psi::PirResultReport report = PirServer(ctxs[0], config);
return report;
});
- std::future f_client = std::async([&] {
- PirClientConfig config;
+ std::future<::psi::PirResultReport> f_client = std::async([&] {
+ ::psi::PirClientConfig config;
- config.set_pir_protocol(PirProtocol::KEYWORD_PIR_LABELED_PSI);
+ config.set_pir_protocol(::psi::PirProtocol::KEYWORD_PIR_LABELED_PSI);
config.set_input_path(client_csv_path);
config.mutable_key_columns()->Add(ids.begin(), ids.end());
config.set_output_path(pir_result_path);
- PirResultReport report = PirClient(ctxs[1], config);
+ ::psi::PirResultReport report = PirClient(ctxs[1], config);
return report;
});
- PirResultReport server_report = f_server.get();
- PirResultReport client_report = f_client.get();
+ ::psi::PirResultReport server_report = f_server.get();
+ ::psi::PirResultReport client_report = f_client.get();
EXPECT_EQ(server_report.data_count(), params.nr);
EXPECT_EQ(client_report.data_count(), params.nr);
} else {
- std::future f_server = std::async([&] {
- PirSetupConfig config;
+ std::future<::psi::PirResultReport> f_server = std::async([&] {
+ ::psi::PirSetupConfig config;
- config.set_pir_protocol(PirProtocol::KEYWORD_PIR_LABELED_PSI);
- config.set_store_type(KvStoreType::LEVELDB_KV_STORE);
+ config.set_pir_protocol(::psi::PirProtocol::KEYWORD_PIR_LABELED_PSI);
+ config.set_store_type(::psi::KvStoreType::LEVELDB_KV_STORE);
config.set_input_path(server_csv_path);
config.mutable_key_columns()->Add(ids.begin(), ids.end());
@@ -259,32 +257,32 @@ TEST_P(PirTest, Works) {
config.set_compressed(params.compressed);
config.set_bucket_size(params.bucket_size);
- PirResultReport report = PirMemoryServer(ctxs[0], config);
+ ::psi::PirResultReport report = PirMemoryServer(ctxs[0], config);
return report;
});
- std::future f_client = std::async([&] {
- PirClientConfig config;
+ std::future<::psi::PirResultReport> f_client = std::async([&] {
+ ::psi::PirClientConfig config;
- config.set_pir_protocol(PirProtocol::KEYWORD_PIR_LABELED_PSI);
+ config.set_pir_protocol(::psi::PirProtocol::KEYWORD_PIR_LABELED_PSI);
config.set_input_path(client_csv_path);
config.mutable_key_columns()->Add(ids.begin(), ids.end());
config.set_output_path(pir_result_path);
- PirResultReport report = PirClient(ctxs[1], config);
+ ::psi::PirResultReport report = PirClient(ctxs[1], config);
return report;
});
- PirResultReport server_report = f_server.get();
- PirResultReport client_report = f_client.get();
+ ::psi::PirResultReport server_report = f_server.get();
+ ::psi::PirResultReport client_report = f_client.get();
EXPECT_EQ(server_report.data_count(), params.nr);
EXPECT_EQ(client_report.data_count(), params.nr);
}
- std::shared_ptr<::psi::psi::ILabeledBatchProvider> pir_result_provider =
- std::make_shared<::psi::psi::CsvBatchProvider>(
+ std::shared_ptr<::psi::ILabeledBatchProvider> pir_result_provider =
+ std::make_shared<::psi::CsvBatchProvider>(
pir_result_path, ids, intersection_idx.size(), labels);
// read pir_result from csv
@@ -307,4 +305,4 @@ INSTANTIATE_TEST_SUITE_P(Works_Instances, PirTest,
);
-} // namespace psi::pir
+} // namespace psi::apsi
diff --git a/psi/psi/core/labeled_psi/psi_params.cc b/psi/apsi/psi_params.cc
similarity index 91%
rename from psi/psi/core/labeled_psi/psi_params.cc
rename to psi/apsi/psi_params.cc
index eb80e6b5..4624a65a 100644
--- a/psi/psi/core/labeled_psi/psi_params.cc
+++ b/psi/apsi/psi_params.cc
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "psi/psi/core/labeled_psi/psi_params.h"
+#include "psi/apsi/psi_params.h"
#include
#include
@@ -21,7 +21,7 @@
#include "spdlog/spdlog.h"
-namespace psi::psi {
+namespace psi::apsi {
namespace {
@@ -46,7 +46,7 @@ std::vector kSealParams = {
{8192, 65537, 0, {56, 56, 30}}, // 14
};
-std::map kPolynomialParams = {
+std::map kPolynomialParams = {
{20, {0, {1, 2, 5, 8, 9, 10}}},
{35, {5, {1, 2, 3, 4, 5, 6, 18, 30, 42, 54, 60}}},
{36, {0, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
@@ -94,7 +94,7 @@ std::map kPolynomialParams = {
};
} // namespace
-yacl::Buffer PsiParamsToBuffer(const apsi::PSIParams &psi_params) {
+yacl::Buffer PsiParamsToBuffer(const ::apsi::PSIParams &psi_params) {
proto::LabelPsiParamsProto psi_params_proto;
psi_params_proto.set_hash_func_count(
@@ -132,7 +132,7 @@ yacl::Buffer PsiParamsToBuffer(const apsi::PSIParams &psi_params) {
return buffer;
}
-apsi::PSIParams ParsePsiParamsProto(const yacl::Buffer &buffer) {
+::apsi::PSIParams ParsePsiParamsProto(const yacl::Buffer &buffer) {
proto::LabelPsiParamsProto psi_params_proto;
YACL_ENFORCE(psi_params_proto.ParseFromArray(buffer.data(), buffer.size()));
@@ -140,12 +140,12 @@ apsi::PSIParams ParsePsiParamsProto(const yacl::Buffer &buffer) {
return ParsePsiParamsProto(psi_params_proto);
}
-apsi::PSIParams ParsePsiParamsProto(
+::apsi::PSIParams ParsePsiParamsProto(
const proto::LabelPsiParamsProto &psi_params_proto) {
- apsi::PSIParams::ItemParams item_params;
- apsi::PSIParams::TableParams table_params;
- apsi::PSIParams::QueryParams query_params;
- apsi::PSIParams::SEALParams seal_params;
+ ::apsi::PSIParams::ItemParams item_params;
+ ::apsi::PSIParams::TableParams table_params;
+ ::apsi::PSIParams::QueryParams query_params;
+ ::apsi::PSIParams::SEALParams seal_params;
item_params.felts_per_item = psi_params_proto.felts_per_item();
@@ -182,8 +182,8 @@ apsi::PSIParams ParsePsiParamsProto(
seal_params.set_coeff_modulus(coeff_modulus);
- apsi::PSIParams psi_params(item_params, table_params, query_params,
- seal_params);
+ ::apsi::PSIParams psi_params(item_params, table_params, query_params,
+ seal_params);
return psi_params;
}
@@ -217,13 +217,13 @@ SEALParams GetSealParams(size_t nr, size_t ns) {
return kSealParams[12];
}
-apsi::PSIParams GetPsiParams(size_t nr, size_t ns, size_t max_items_per_bin) {
+::apsi::PSIParams GetPsiParams(size_t nr, size_t ns, size_t max_items_per_bin) {
SEALParams seal_params = GetSealParams(nr, ns);
- apsi::PSIParams::ItemParams item_params;
- apsi::PSIParams::TableParams table_params;
- apsi::PSIParams::QueryParams query_params;
- apsi::PSIParams::SEALParams apsi_seal_params;
+ ::apsi::PSIParams::ItemParams item_params;
+ ::apsi::PSIParams::TableParams table_params;
+ ::apsi::PSIParams::QueryParams query_params;
+ ::apsi::PSIParams::SEALParams apsi_seal_params;
size_t hash_size = GetHashTruncateSize(nr, ns);
item_params.felts_per_item = std::ceil(
@@ -304,10 +304,10 @@ apsi::PSIParams GetPsiParams(size_t nr, size_t ns, size_t max_items_per_bin) {
query_params = kPolynomialParams[max_items_per_bin];
}
- apsi::PSIParams psi_params(item_params, table_params, query_params,
- apsi_seal_params);
+ ::apsi::PSIParams psi_params(item_params, table_params, query_params,
+ apsi_seal_params);
return psi_params;
}
-} // namespace psi::psi
+} // namespace psi::apsi
diff --git a/psi/psi/core/labeled_psi/psi_params.h b/psi/apsi/psi_params.h
similarity index 73%
rename from psi/psi/core/labeled_psi/psi_params.h
rename to psi/apsi/psi_params.h
index 1742edcb..103489ed 100644
--- a/psi/psi/core/labeled_psi/psi_params.h
+++ b/psi/apsi/psi_params.h
@@ -23,9 +23,9 @@
#include "yacl/base/exception.h"
#include "yacl/link/link.h"
-#include "psi/psi/core/labeled_psi/serializable.pb.h"
+#include "psi/apsi/serializable.pb.h"
-namespace psi::psi {
+namespace psi::apsi {
struct SEALParams {
size_t poly_modulus_degree;
@@ -53,27 +53,27 @@ struct SEALParams {
*
* @param nr receiver's items size
* @param ns sender's items size
- * @return apsi::PSIParams
+ * @return ::apsi::PSIParams
*/
-apsi::PSIParams GetPsiParams(size_t nr, size_t ns,
- size_t max_items_per_bin = 0);
+::apsi::PSIParams GetPsiParams(size_t nr, size_t ns,
+ size_t max_items_per_bin = 0);
/**
- * @brief Serialize apsi::PSIParams to yacl::Buffer
+ * @brief Serialize ::apsi::PSIParams to yacl::Buffer
*
- * @param psi_params apsi::PSIParams
+ * @param psi_params ::apsi::PSIParams
* @return yacl::Buffer
*/
-yacl::Buffer PsiParamsToBuffer(const apsi::PSIParams &psi_params);
+yacl::Buffer PsiParamsToBuffer(const ::apsi::PSIParams &psi_params);
/**
- * @brief DeSerialize yacl::Buffer to apsi::PSIParams
+ * @brief DeSerialize yacl::Buffer to ::apsi::PSIParams
*
* @param buffer PSIParams bytes buffer
- * @return apsi::PSIParams
+ * @return ::apsi::PSIParams
*/
-apsi::PSIParams ParsePsiParamsProto(const yacl::Buffer &buffer);
-apsi::PSIParams ParsePsiParamsProto(
+::apsi::PSIParams ParsePsiParamsProto(const yacl::Buffer &buffer);
+::apsi::PSIParams ParsePsiParamsProto(
const proto::LabelPsiParamsProto &psi_params_proto);
-} // namespace psi::psi
+} // namespace psi::apsi
diff --git a/psi/psi/core/labeled_psi/receiver.cc b/psi/apsi/receiver.cc
similarity index 90%
rename from psi/psi/core/labeled_psi/receiver.cc
rename to psi/apsi/receiver.cc
index 505c3850..1816c8b2 100644
--- a/psi/psi/core/labeled_psi/receiver.cc
+++ b/psi/apsi/receiver.cc
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "psi/psi/core/labeled_psi/receiver.h"
+#include "psi/apsi/receiver.h"
#include
#include
@@ -32,12 +32,12 @@
#include "spdlog/spdlog.h"
#include "yacl/utils/parallel.h"
-#include "psi/psi/core/ecdh_oprf/ecdh_oprf_selector.h"
-#include "psi/psi/core/labeled_psi/package.h"
-#include "psi/psi/core/labeled_psi/padding.h"
-#include "psi/psi/core/labeled_psi/psi_params.h"
+#include "psi/apsi/package.h"
+#include "psi/apsi/padding.h"
+#include "psi/apsi/psi_params.h"
+#include "psi/ecdh//ecdh_oprf_selector.h"
-namespace psi::psi {
+namespace psi::apsi {
namespace {
@@ -50,7 +50,7 @@ bool HasNZeros(T *ptr, size_t count) {
}
} // namespace
-LabelPsiReceiver::LabelPsiReceiver(const apsi::PSIParams ¶ms,
+LabelPsiReceiver::LabelPsiReceiver(const ::apsi::PSIParams ¶ms,
bool has_label)
: psi_params_(params), has_label_(has_label) {
Initialize();
@@ -65,7 +65,7 @@ void LabelPsiReceiver::Initialize() {
psi_params_.bins_per_bundle(), psi_params_.bundle_idx_count());
// Initialize the CryptoContext with a new SEALContext
- crypto_context_ = apsi::CryptoContext(psi_params_);
+ crypto_context_ = ::apsi::CryptoContext(psi_params_);
// Set up the PowersDag
ResetPowersDag(psi_params_.query_params().query_powers);
@@ -93,7 +93,7 @@ void LabelPsiReceiver::ResetKeys() {
std::uint32_t LabelPsiReceiver::ResetPowersDag(
const std::set &source_powers) {
// First compute the target powers
- std::set target_powers = apsi::util::create_powers_set(
+ std::set target_powers = ::apsi::util::create_powers_set(
psi_params_.query_params().ps_low_degree,
psi_params_.table_params().max_items_per_bin);
@@ -104,8 +104,8 @@ std::uint32_t LabelPsiReceiver::ResetPowersDag(
if (!pd_.is_configured()) {
SPDLOG_ERROR(
"Failed to configure PowersDag (source_powers:{} target_powers:{})",
- apsi::util::to_string(source_powers),
- apsi::util::to_string(target_powers));
+ ::apsi::util::to_string(source_powers),
+ ::apsi::util::to_string(target_powers));
YACL_THROW("failed to configure PowersDag");
}
@@ -114,7 +114,7 @@ std::uint32_t LabelPsiReceiver::ResetPowersDag(
return pd_.depth();
}
-apsi::PSIParams LabelPsiReceiver::RequestPsiParams(
+::apsi::PSIParams LabelPsiReceiver::RequestPsiParams(
size_t items_size, const std::shared_ptr &link_ctx) {
yacl::Buffer buffer(&items_size, sizeof(items_size));
@@ -128,17 +128,18 @@ apsi::PSIParams LabelPsiReceiver::RequestPsiParams(
return ParsePsiParamsProto(psi_params_buffer);
}
-std::pair, std::vector>
+std::pair, std::vector<::apsi::LabelKey>>
LabelPsiReceiver::RequestOPRF(
const std::vector &items,
const std::shared_ptr &link_ctx) {
std::vector blind_items(items.size());
- std::vector> oprf_clients(items.size());
+ std::vector> oprf_clients(
+ items.size());
yacl::parallel_for(0, items.size(), [&](int64_t begin, int64_t end) {
for (int idx = begin; idx < end; ++idx) {
- oprf_clients[idx] =
- CreateEcdhOprfClient(OprfType::Basic, CurveType::CURVE_FOURQ);
+ oprf_clients[idx] = ecdh::CreateEcdhOprfClient(ecdh::OprfType::Basic,
+ CurveType::CURVE_FOURQ);
oprf_clients[idx]->SetCompareLength(kEccKeySize);
blind_items[idx] = oprf_clients[idx]->Blind(items[idx]);
@@ -173,8 +174,8 @@ LabelPsiReceiver::RequestOPRF(
}
});
- std::vector hashed_items(items_oprf.size());
- std::vector label_keys(items_oprf.size());
+ std::vector<::apsi::HashedItem> hashed_items(items_oprf.size());
+ std::vector<::apsi::LabelKey> label_keys(items_oprf.size());
for (size_t idx = 0; idx < items_oprf.size(); ++idx) {
std::memcpy(hashed_items[idx].value().data(), items_oprf[idx].data(),
@@ -190,8 +191,8 @@ LabelPsiReceiver::RequestOPRF(
std::pair, std::vector>
LabelPsiReceiver::RequestQuery(
- const std::vector &hashed_items,
- const std::vector &label_keys,
+ const std::vector<::apsi::HashedItem> &hashed_items,
+ const std::vector<::apsi::LabelKey> &label_keys,
const std::shared_ptr &link_ctx) {
kuku::KukuTable cuckoo(
psi_params_.table_params().table_size, // Size of the hash table
@@ -231,7 +232,7 @@ LabelPsiReceiver::RequestQuery(
"fill-rate: {}",
cuckoo.loc_func_count(), cuckoo.fill_rate());
- apsi::receiver::IndexTranslationTable itt;
+ ::apsi::receiver::IndexTranslationTable itt;
itt.item_count_ = hashed_items.size();
for (size_t item_idx = 0; item_idx < hashed_items.size(); item_idx++) {
@@ -241,11 +242,11 @@ LabelPsiReceiver::RequestQuery(
}
// Set up unencrypted query data
- std::vector plain_powers;
+ std::vector<::apsi::receiver::PlaintextPowers> plain_powers;
// prepare_data
{
- STOPWATCH(apsi::util::recv_stopwatch,
+ STOPWATCH(::apsi::util::recv_stopwatch,
"Receiver::create_query::prepare_data");
for (uint32_t bundle_idx = 0; bundle_idx < psi_params_.bundle_idx_count();
bundle_idx++) {
@@ -262,12 +263,12 @@ LabelPsiReceiver::RequestQuery(
// Now set up a BitstringView to this item
gsl::span item_bytes(
reinterpret_cast(item.data()), sizeof(item));
- apsi::BitstringView item_bits(
+ ::apsi::BitstringView item_bits(
item_bytes, psi_params_.item_bit_count());
// Create an algebraic item by breaking up the item into modulo
// plain_modulus parts
- std::vector alg_item = apsi::util::bits_to_field_elts(
+ std::vector alg_item = ::apsi::util::bits_to_field_elts(
item_bits, psi_params_.seal_params().plain_modulus());
std::copy(alg_item.cbegin(), alg_item.cend(), back_inserter(alg_items));
}
@@ -283,7 +284,8 @@ LabelPsiReceiver::RequestQuery(
// The very last thing to do is encrypt the plain_powers and consolidate the
// matching powers for different bundle indices
- std::unordered_map>>
+ std::unordered_map>>
encrypted_powers;
// encrypt_data
@@ -383,8 +385,8 @@ LabelPsiReceiver::RequestQuery(
std::vector>
LabelPsiReceiver::ProcessQueryResult(
const proto::QueryResultProto &query_result_proto,
- const apsi::receiver::IndexTranslationTable &itt,
- const std::vector &label_keys) {
+ const ::apsi::receiver::IndexTranslationTable &itt,
+ const std::vector<::apsi::LabelKey> &label_keys) {
auto seal_context = GetSealContext();
ResultPackage result_package;
@@ -404,7 +406,7 @@ LabelPsiReceiver::ProcessQueryResult(
gsl::span label_data_span(
reinterpret_cast(label_data.data()),
label_data.length());
- apsi::SEALObject temp;
+ ::apsi::SEALObject temp;
temp.load(seal_context, label_data_span);
result_package.label_result.emplace_back(std::move(temp));
}
@@ -521,34 +523,35 @@ LabelPsiReceiver::ProcessQueryResult(
SPDLOG_DEBUG("Match found for items[{}] at cuckoo table index {}",
item_idx, table_idx);
- apsi::Label label;
+ ::apsi::Label label;
if (label_byte_count) {
SPDLOG_DEBUG(
"Found {} label parts for items[{}]; expecting {}-byte label ",
plain_rp.label_result.size(), item_idx, label_byte_count);
// Collect the entire label into this vector
- apsi::util::AlgLabel alg_label;
+ ::apsi::util::AlgLabel alg_label;
size_t label_offset =
seal::util::mul_safe(std::get<1>(i), felts_per_item);
for (auto &label_parts : plain_rp.label_result) {
- gsl::span label_part(
+ gsl::span<::apsi::util::felt_t> label_part(
label_parts.data() + label_offset, felts_per_item);
std::copy(label_part.begin(), label_part.end(),
back_inserter(alg_label));
}
// Create the label
- apsi::EncryptedLabel encrypted_label = apsi::util::dealgebraize_label(
- alg_label, received_label_bit_count,
- psi_params_.seal_params().plain_modulus());
+ ::apsi::EncryptedLabel encrypted_label =
+ ::apsi::util::dealgebraize_label(
+ alg_label, received_label_bit_count,
+ psi_params_.seal_params().plain_modulus());
// Resize down to the effective byte count
encrypted_label.resize(effective_label_byte_count);
// Decrypt the label
- label = apsi::util::decrypt_label(
+ label = ::apsi::util::decrypt_label(
encrypted_label, label_keys[item_idx], nonce_byte_count);
}
@@ -569,4 +572,4 @@ LabelPsiReceiver::ProcessQueryResult(
return match_ids;
}
-} // namespace psi::psi
+} // namespace psi::apsi
diff --git a/psi/psi/core/labeled_psi/receiver.h b/psi/apsi/receiver.h
similarity index 76%
rename from psi/psi/core/labeled_psi/receiver.h
rename to psi/apsi/receiver.h
index 42023485..a6718b2c 100644
--- a/psi/psi/core/labeled_psi/receiver.h
+++ b/psi/apsi/receiver.h
@@ -29,15 +29,15 @@
#include "seal/seal.h"
#include "yacl/link/link.h"
-#include "psi/psi/core/ecdh_oprf/ecdh_oprf.h"
+#include "psi/ecdh//ecdh_oprf.h"
-#include "psi/psi/core/labeled_psi/serializable.pb.h"
+#include "psi/apsi/serializable.pb.h"
-namespace psi::psi {
+namespace psi::apsi {
class LabelPsiReceiver {
public:
- explicit LabelPsiReceiver(const apsi::PSIParams ¶ms,
+ explicit LabelPsiReceiver(const ::apsi::PSIParams ¶ms,
bool has_label = false);
/**
@@ -45,9 +45,9 @@ class LabelPsiReceiver {
*
* @param items_size receiver's items size
* @param link_ctx link context
- * @return apsi::PSIParams
+ * @return ::apsi::PSIParams
*/
- static apsi::PSIParams RequestPsiParams(
+ static ::apsi::PSIParams RequestPsiParams(
size_t items_size, const std::shared_ptr &link_ctx);
/**
@@ -55,12 +55,13 @@ class LabelPsiReceiver {
*
* @param items receiver's items
* @param link_ctx link context
- * @return std::pair,
- * std::vector>
+ * @return std::pair,
+ * std::vector<::apsi::LabelKey>>
*
* split items's oprf(32B) to HashedItem(16B) and LabelKey(16B)
*/
- static std::pair, std::vector>
+ static std::pair,
+ std::vector<::apsi::LabelKey>>
RequestOPRF(const std::vector &items,
const std::shared_ptr &link_ctx);
@@ -76,8 +77,8 @@ class LabelPsiReceiver {
*
*/
std::pair, std::vector> RequestQuery(
- const std::vector &hashed_items,
- const std::vector &label_keys,
+ const std::vector<::apsi::HashedItem> &hashed_items,
+ const std::vector<::apsi::LabelKey> &label_keys,
const std::shared_ptr &link_ctx);
/**
@@ -88,12 +89,12 @@ class LabelPsiReceiver {
/**
Returns a reference to the PowersDag configured for this Receiver.
*/
- const apsi::PowersDag &GetPowersDag() const { return pd_; }
+ const ::apsi::PowersDag &GetPowersDag() const { return pd_; }
/**
Returns a reference to the CryptoContext for this Receiver.
*/
- const apsi::CryptoContext &GetCryptoContext() const {
+ const ::apsi::CryptoContext &GetCryptoContext() const {
return crypto_context_;
}
@@ -117,20 +118,20 @@ class LabelPsiReceiver {
std::vector> ProcessQueryResult(
const proto::QueryResultProto &query_result_proto,
- const apsi::receiver::IndexTranslationTable &itt,
- const std::vector &label_keys);
+ const ::apsi::receiver::IndexTranslationTable &itt,
+ const std::vector<::apsi::LabelKey> &label_keys);
- apsi::PSIParams psi_params_;
+ ::apsi::PSIParams psi_params_;
- apsi::CryptoContext crypto_context_;
+ ::apsi::CryptoContext crypto_context_;
- apsi::PowersDag pd_;
+ ::apsi::PowersDag pd_;
- apsi::SEALObject relin_keys_;
+ ::apsi::SEALObject relin_keys_;
// NOTE(juhou): we now support zstd compression by default
seal::compr_mode_type compr_mode_ = seal::Serialization::compr_mode_default;
bool has_label_;
};
-} // namespace psi::psi
+} // namespace psi::apsi
diff --git a/psi/psi/core/labeled_psi/sender.cc b/psi/apsi/sender.cc
similarity index 89%
rename from psi/psi/core/labeled_psi/sender.cc
rename to psi/apsi/sender.cc
index dd7f9349..09a6c4b6 100644
--- a/psi/psi/core/labeled_psi/sender.cc
+++ b/psi/apsi/sender.cc
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "psi/psi/core/labeled_psi/sender.h"
+#include "psi/apsi/sender.h"
#include
#include
@@ -29,21 +29,21 @@
#include "gsl/span"
#include "yacl/utils/parallel.h"
-#include "psi/psi/core/labeled_psi/package.h"
-#include "psi/psi/core/labeled_psi/sender_db.h"
-#include "psi/psi/core/labeled_psi/sender_kvdb.h"
+#include "psi/apsi/package.h"
+#include "psi/apsi/sender_db.h"
+#include "psi/apsi/sender_kvdb.h"
-#include "psi/psi/core/labeled_psi/serializable.pb.h"
+#include "psi/apsi/serializable.pb.h"
-namespace psi::psi {
+namespace psi::apsi {
namespace {
class QueryRequest {
public:
- QueryRequest(apsi::SEALObject *relin_keys,
+ QueryRequest(::apsi::SEALObject *relin_keys,
std::unordered_map<
- uint32_t, std::vector>>
+ uint32_t, std::vector<::apsi::SEALObject>>
&encrypted_powers,
const std::shared_ptr &sender_db) {
auto seal_context = sender_db->GetSealContext();
@@ -93,12 +93,13 @@ class QueryRequest {
using CiphertextPowers = std::vector;
-uint32_t reset_powers_dag(apsi::PowersDag *pd, const apsi::PSIParams ¶ms,
+uint32_t reset_powers_dag(::apsi::PowersDag *pd,
+ const ::apsi::PSIParams ¶ms,
const std::set &source_powers) {
// First compute the target powers
std::set target_powers =
- apsi::util::create_powers_set(params.query_params().ps_low_degree,
- params.table_params().max_items_per_bin);
+ ::apsi::util::create_powers_set(params.query_params().ps_low_degree,
+ params.table_params().max_items_per_bin);
SPDLOG_DEBUG("target_powers size:{}", target_powers.size());
// Configure the PowersDag
@@ -109,8 +110,8 @@ uint32_t reset_powers_dag(apsi::PowersDag *pd, const apsi::PSIParams ¶ms,
SPDLOG_INFO(
"Failed to configure PowersDag ("
"source_powers: {}, target_powers: {}",
- apsi::util::to_string(source_powers),
- apsi::util::to_string(target_powers));
+ ::apsi::util::to_string(source_powers),
+ ::apsi::util::to_string(target_powers));
YACL_THROW("failed to configure PowersDag");
}
SPDLOG_INFO("Configured PowersDag with depth {}", pd->depth());
@@ -122,9 +123,9 @@ uint32_t reset_powers_dag(apsi::PowersDag *pd, const apsi::PSIParams ¶ms,
LabelPsiSender::LabelPsiSender(std::shared_ptr sender_db)
: sender_db_(std::move(sender_db)) {
- apsi::PSIParams params(sender_db_->GetParams());
+ ::apsi::PSIParams params(sender_db_->GetParams());
- crypto_context_ = apsi::CryptoContext(sender_db_->GetParams());
+ crypto_context_ = ::apsi::CryptoContext(sender_db_->GetParams());
SPDLOG_INFO("begin set PowersDag");
reset_powers_dag(&pd_, params, params.query_params().query_powers);
@@ -141,7 +142,7 @@ void LabelPsiSender::RunPsiParams(
YACL_ENFORCE(sizeof(nr) == nr_buffer.size());
std::memcpy(&nr, nr_buffer.data(), nr_buffer.size());
- apsi::PSIParams psi_params = GetPsiParams(nr, items_size);
+ ::apsi::PSIParams psi_params = GetPsiParams(nr, items_size);
yacl::Buffer params_buffer = PsiParamsToBuffer(psi_params);
@@ -151,7 +152,7 @@ void LabelPsiSender::RunPsiParams(
}
void LabelPsiSender::RunOPRF(
- const std::shared_ptr &oprf_server,
+ const std::shared_ptr &oprf_server,
const std::shared_ptr &link_ctx) {
oprf_server->SetCompareLength(kEccKeySize);
@@ -188,7 +189,7 @@ void LabelPsiSender::RunOPRF(
std::vector> SenderRunQuery(
const QueryRequest &query, const std::shared_ptr &sender_db,
- const apsi::PowersDag &pd);
+ const ::apsi::PowersDag &pd);
void LabelPsiSender::RunQuery(
const std::shared_ptr &link_ctx) {
@@ -201,7 +202,7 @@ void LabelPsiSender::RunQuery(
auto seal_context = sender_db_->GetSealContext();
- apsi::SEALObject relin_keys;
+ ::apsi::SEALObject relin_keys;
if (seal_context->using_keyswitching()) {
auto relin_keys_data = query_proto.relin_keys();
gsl::span relin_keys_data_span(
@@ -211,13 +212,14 @@ void LabelPsiSender::RunQuery(
relin_keys.load(seal_context, relin_keys_data_span);
}
- std::unordered_map>>
+ std::unordered_map>>
encrypted_powers;
for (int idx = 0; idx < query_proto.encrypted_powers_size(); ++idx) {
const proto::EncryptedPowersProto &encrypted_powers_proto =
query_proto.encrypted_powers(idx);
- std::vector> ciphertexts;
+ std::vector<::apsi::SEALObject> ciphertexts;
ciphertexts.reserve(encrypted_powers_proto.ciphertexts_size());
for (int cipher_idx = 0;
@@ -225,7 +227,7 @@ void LabelPsiSender::RunQuery(
auto ct = encrypted_powers_proto.ciphertexts(cipher_idx);
gsl::span ct_span(
reinterpret_cast(ct.data()), ct.length());
- apsi::SEALObject temp;
+ ::apsi::SEALObject temp;
temp.load(seal_context, ct_span);
ciphertexts.emplace_back(std::move(temp));
}
@@ -241,7 +243,7 @@ void LabelPsiSender::RunQuery(
proto::QueryResponseProto response_proto;
std::vector> futures;
- apsi::ThreadPoolMgr tpm;
+ ::apsi::ThreadPoolMgr tpm;
for (auto &result : query_result) {
proto::QueryResultProto *result_proto = response_proto.add_results();
@@ -277,26 +279,26 @@ void LabelPsiSender::RunQuery(
}
void ComputePowers(const std::shared_ptr &sender_db,
- const apsi::CryptoContext &crypto_context,
+ const ::apsi::CryptoContext &crypto_context,
std::vector *all_powers,
- const apsi::PowersDag &pd, uint32_t bundle_idx,
+ const ::apsi::PowersDag &pd, uint32_t bundle_idx,
seal::MemoryPoolHandle *pool);
void ProcessBinBundleCache(
const std::shared_ptr &sender_db,
- const apsi::CryptoContext &crypto_context,
- const std::shared_ptr &bundle,
+ const ::apsi::CryptoContext &crypto_context,
+ const std::shared_ptr<::apsi::sender::BinBundle> &bundle,
std::vector *all_powers, uint32_t bundle_idx,
seal::compr_mode_type compr_mode, seal::MemoryPoolHandle *pool,
const std::shared_ptr &result);
std::vector> SenderRunQuery(
const QueryRequest &query, const std::shared_ptr &sender_db,
- const apsi::PowersDag &pd) {
+ const ::apsi::PowersDag &pd) {
// We use a custom SEAL memory that is freed after the query is done
auto pool = seal::MemoryManager::GetPool(seal::mm_force_new);
- apsi::ThreadPoolMgr tpm;
+ ::apsi::ThreadPoolMgr tpm;
// Acquire read lock on SenderDB
// auto sender_db = sender_db;
@@ -310,11 +312,11 @@ std::vector> SenderRunQuery(
// that case query.relin_keys() simply holds an empty seal::RelinKeys
// instance. There is no problem with the below call to
// CryptoContext::set_evaluator.
- apsi::CryptoContext crypto_context(sender_db->GetCryptoContext());
+ ::apsi::CryptoContext crypto_context(sender_db->GetCryptoContext());
crypto_context.set_evaluator(query.relin_keys());
// Get the PSIParams
- apsi::PSIParams params(sender_db->GetParams());
+ ::apsi::PSIParams params(sender_db->GetParams());
uint32_t bundle_idx_count = params.bundle_idx_count();
@@ -371,7 +373,7 @@ std::vector> SenderRunQuery(
std::vector> futures;
for (size_t cache_idx = 0; cache_idx < cache_count; ++cache_idx) {
- std::shared_ptr bundle =
+ std::shared_ptr<::apsi::sender::BinBundle> bundle =
sender_db->GetBinBundleAt(static_cast(bundle_idx),
cache_idx);
@@ -398,9 +400,9 @@ std::vector> SenderRunQuery(
}
void ComputePowers(const std::shared_ptr &sender_db,
- const apsi::CryptoContext &crypto_context,
+ const ::apsi::CryptoContext &crypto_context,
std::vector *all_powers,
- const apsi::PowersDag &pd, uint32_t bundle_idx,
+ const ::apsi::PowersDag &pd, uint32_t bundle_idx,
seal::MemoryPoolHandle *pool) {
SPDLOG_DEBUG("Sender::ComputePowers");
@@ -413,7 +415,7 @@ void ComputePowers(const std::shared_ptr &sender_db,
CiphertextPowers &powers_at_this_bundle_idx = (*all_powers)[bundle_idx];
bool relinearize = crypto_context.seal_context()->using_keyswitching();
- pd.parallel_apply([&](const apsi::PowersDag::PowersNode &node) {
+ pd.parallel_apply([&](const ::apsi::PowersDag::PowersNode &node) {
if (!node.is_source()) {
auto parents = node.parents;
seal::Ciphertext prod(*pool);
@@ -443,7 +445,7 @@ void ComputePowers(const std::shared_ptr &sender_db,
// only for convenience of the indexing; the ciphertext is actually not set or
// valid for use.
- apsi::ThreadPoolMgr tpm;
+ ::apsi::ThreadPoolMgr tpm;
// After computing all powers we will modulus switch down to parameters that
// one more level for low powers than for high powers; same choice must be
@@ -489,14 +491,14 @@ void ComputePowers(const std::shared_ptr &sender_db,
void ProcessBinBundleCache(
const std::shared_ptr &sender_db,
- const apsi::CryptoContext &crypto_context,
- const std::shared_ptr &bundle,
+ const ::apsi::CryptoContext &crypto_context,
+ const std::shared_ptr<::apsi::sender::BinBundle> &bundle,
std::vector *all_powers, uint32_t bundle_idx,
seal::compr_mode_type compr_mode, seal::MemoryPoolHandle *pool,
const std::shared_ptr &result) {
SPDLOG_DEBUG("Sender::ProcessBinBundleCache");
- std::reference_wrapper cache =
+ std::reference_wrapper cache =
std::cref(bundle->get_cache());
// Package for the result data
@@ -509,7 +511,7 @@ void ProcessBinBundleCache(
seal::util::safe_cast(sender_db->GetLabelByteCount());
// Compute the matching result and move to rp
- const apsi::sender::BatchedPlaintextPolyn &matching_polyn =
+ const ::apsi::sender::BatchedPlaintextPolyn &matching_polyn =
cache.get().batched_matching_polyn;
// Determine if we use Paterson-Stockmeyer or not
@@ -541,4 +543,4 @@ void ProcessBinBundleCache(
}
}
-} // namespace psi::psi
+} // namespace psi::apsi
diff --git a/psi/psi/core/labeled_psi/sender.h b/psi/apsi/sender.h
similarity index 83%
rename from psi/psi/core/labeled_psi/sender.h
rename to psi/apsi/sender.h
index 792eb657..c81da652 100644
--- a/psi/psi/core/labeled_psi/sender.h
+++ b/psi/apsi/sender.h
@@ -24,11 +24,11 @@
#include "yacl/base/exception.h"
#include "yacl/link/link.h"
-#include "psi/psi/core/ecdh_oprf/ecdh_oprf.h"
-#include "psi/psi/core/labeled_psi/psi_params.h"
-#include "psi/psi/core/labeled_psi/sender_db.h"
+#include "psi/apsi/psi_params.h"
+#include "psi/apsi/sender_db.h"
+#include "psi/ecdh//ecdh_oprf.h"
-namespace psi::psi {
+namespace psi::apsi {
class LabelPsiSender {
public:
@@ -49,7 +49,7 @@ class LabelPsiSender {
* @param oprf_server
* @param link_ctx
*/
- static void RunOPRF(const std::shared_ptr& oprf_server,
+ static void RunOPRF(const std::shared_ptr& oprf_server,
const std::shared_ptr& link_ctx);
/**
@@ -62,10 +62,10 @@ class LabelPsiSender {
private:
std::shared_ptr sender_db_;
- apsi::CryptoContext crypto_context_;
+ ::apsi::CryptoContext crypto_context_;
seal::compr_mode_type compr_mode_ = seal::Serialization::compr_mode_default;
- apsi::PowersDag pd_;
+ ::apsi::PowersDag pd_;
};
-} // namespace psi::psi
+} // namespace psi::apsi
diff --git a/psi/psi/core/labeled_psi/sender_db.cc b/psi/apsi/sender_db.cc
similarity index 87%
rename from psi/psi/core/labeled_psi/sender_db.cc
rename to psi/apsi/sender_db.cc
index 9214b99c..b84fe90e 100644
--- a/psi/psi/core/labeled_psi/sender_db.cc
+++ b/psi/apsi/sender_db.cc
@@ -19,7 +19,8 @@
// we are using our own OPRF, the reason is we wanna make the oprf
// switchable between secp256k1, sm2 or other types
-// STD
+#include "psi/apsi/sender_db.h"
+
#include
#include
#include