Skip to content

Commit

Permalink
repo-sync-2024-10-18T16:46:31+0800 (#408)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamie authored Oct 19, 2024
1 parent a8df061 commit 18a346f
Show file tree
Hide file tree
Showing 39 changed files with 303 additions and 148 deletions.
1 change: 1 addition & 0 deletions .bazelignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
examples
1 change: 1 addition & 0 deletions .licenserc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ header: # <1>
- 'LICENSE'
- 'NOTICE'
- '.bazelversion'
- '.bazelignore'
- '.clang-format'
- '.clang-tidy'
- '.gitattributes'
Expand Down
13 changes: 2 additions & 11 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

workspace(name = "yacl")

# yacl's dependencies

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

yacl_deps()
Expand All @@ -22,13 +24,6 @@ load("@rules_python//python:repositories.bzl", "py_repositories")

py_repositories()

load("@pybind11_bazel//:python_configure.bzl", "python_configure")

python_configure(
name = "local_config_python",
python_version = "3",
)

load(
"@rules_foreign_cc//foreign_cc:repositories.bzl",
"rules_foreign_cc_dependencies",
Expand All @@ -47,7 +42,3 @@ bazel_features_deps()
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")

protobuf_deps()

load("@rules_jni//jni:repositories.bzl", "rules_jni_dependencies")

rules_jni_dependencies()
38 changes: 0 additions & 38 deletions bazel/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ def yacl_deps():
_rule_proto()
_rule_python()
_rules_foreign_cc()
_rules_jni()
_com_github_madler_zlib()
_com_google_protobuf()
_com_github_gflags_gflags()
Expand All @@ -35,9 +34,6 @@ def yacl_deps():
_com_github_msgpack_msgpack()
_com_github_greendow_hash_drbg()

_com_github_pybind11_bazel()
_com_github_pybind11()

# ssl
_com_github_tongsuo_tongsuo()
_com_github_openssl_openssl()
Expand Down Expand Up @@ -88,29 +84,6 @@ def _org_interconnection():
path = "/opt/homebrew/opt/libomp/",
)

def _com_github_pybind11_bazel():
maybe(
http_archive,
name = "pybind11_bazel",
sha256 = "dc4882b23a617575d0fd822aba88aa4a14133c3d428b5a8fb83d81d03444a475",
strip_prefix = "pybind11_bazel-8889d39b2b925b2a47519ae09402a96f00ccf2b4",
urls = [
"https://github.com/pybind/pybind11_bazel/archive/8889d39b2b925b2a47519ae09402a96f00ccf2b4.zip",
],
)

def _com_github_pybind11():
maybe(
http_archive,
name = "pybind11",
build_file = "@pybind11_bazel//:pybind11.BUILD",
sha256 = "bf8f242abd1abcd375d516a7067490fb71abd79519a282d22b6e4d19282185a7",
strip_prefix = "pybind11-2.12.0",
urls = [
"https://github.com/pybind/pybind11/archive/refs/tags/v2.12.0.tar.gz",
],
)

def _com_github_brpc_brpc():
maybe(
http_archive,
Expand Down Expand Up @@ -314,17 +287,6 @@ def _rules_foreign_cc():
url = "https://github.com/bazelbuild/rules_foreign_cc/releases/download/0.12.0/rules_foreign_cc-0.12.0.tar.gz",
)

def _rules_jni():
maybe(
http_archive,
name = "rules_jni",
sha256 = "a84863992f425220e1b5e7dfd4663ef1f7c69d63aff6e09a154880744ce0bab0",
strip_prefix = "rules_jni-0.10.1",
urls = [
"https://github.com/fmeum/rules_jni/archive/refs/tags/v0.10.1.tar.gz",
],
)

def _com_github_libsodium():
maybe(
http_archive,
Expand Down
41 changes: 41 additions & 0 deletions examples/.bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Copyright 2024 Ant Group Co., Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

common --experimental_repo_remote_exec
common --experimental_cc_shared_library

build --incompatible_new_actions_api=false
build --copt=-fdiagnostics-color=always
build --enable_platform_specific_config

build --cxxopt=-std=c++17
build --host_cxxopt=-std=c++17
build --linkopt -lm

# Binary safety flags
build --host_copt=-fPIE
build --host_copt=-fstack-protector-strong
build:linux --host_copt=-Wl,-z,noexecstack
build:macos --host_copt=-Wa,--noexecstack

# platform specific config
# Bazel will automatic pick platform config since we have enable_platform_specific_config set
build:macos --features=-supports_dynamic_linker
build:macos --copt=-Wno-unused-command-line-argument
build:macos --macos_minimum_os=13.0
build:macos --host_macos_minimum_os=13.0
build:macos --action_env MACOSX_DEPLOYMENT_TARGET=13.0

test --keep_going
test --test_output=errors
1 change: 1 addition & 0 deletions examples/.bazelversion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
6.5.0
13 changes: 13 additions & 0 deletions examples/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2024 Ant Group Co., Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
63 changes: 63 additions & 0 deletions examples/WORKSPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Copyright 2024 Ant Group Co., Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

workspace(name = "yacl-examples")

new_local_repository(
name = "yacl",
build_file = "BUILD.bazel",
path = "..",
)

load("//repositories.bzl", "example_deps")

example_deps()

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

yacl_deps()

load("@rules_python//python:repositories.bzl", "py_repositories")

py_repositories()

load("@pybind11_bazel//:python_configure.bzl", "python_configure")

python_configure(
name = "local_config_python",
python_version = "3",
)

load(
"@rules_foreign_cc//foreign_cc:repositories.bzl",
"rules_foreign_cc_dependencies",
)

rules_foreign_cc_dependencies(
register_built_tools = False,
register_default_tools = False,
register_preinstalled_tools = True,
)

load("@bazel_features//:deps.bzl", "bazel_features_deps")

bazel_features_deps()

load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")

protobuf_deps()

load("@rules_jni//jni:repositories.bzl", "rules_jni_dependencies")

rules_jni_dependencies()
12 changes: 6 additions & 6 deletions examples/hesm2/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

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

package(default_visibility = ["//visibility:public"])

Expand All @@ -31,10 +31,10 @@ yacl_cc_binary(
"t2.h",
],
deps = [
"//yacl/crypto/ecc:spi",
"//yacl/crypto/ecc/openssl",
"//yacl/math/mpint",
"//yacl/utils:cuckoo_index", # 添加 cuckoo_index 依赖
"//yacl/utils/spi",
"@yacl//yacl/crypto/ecc:spi",
"@yacl//yacl/crypto/ecc/openssl",
"@yacl//yacl/math/mpint",
"@yacl//yacl/utils:cuckoo_index", # 添加 cuckoo_index 依赖
"@yacl//yacl/utils/spi",
],
)
6 changes: 3 additions & 3 deletions examples/hesm2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ cd bazel-bin/examples/hesm2
```cpp
#include <iostream>

#include "examples/hesm2/ahesm2.h"
#include "examples/hesm2/config.h"
#include "examples/hesm2/private_key.h"
#include "hesm2/ahesm2.h"
#include "hesm2/config.h"
#include "hesm2/private_key.h"

#include "yacl/crypto/ecc/ecc_spi.h"
#include "yacl/math/mpint/mp_int.h"
Expand Down
14 changes: 7 additions & 7 deletions examples/hesm2/ahesm2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "examples/hesm2/ahesm2.h"
#include "hesm2/ahesm2.h"

#include <atomic>

#include "examples/hesm2/ciphertext.h"
#include "examples/hesm2/config.h"
#include "examples/hesm2/private_key.h"
#include "examples/hesm2/t1.h"
#include "examples/hesm2/t2.h"
#include "hesm2/ciphertext.h"
#include "hesm2/config.h"
#include "hesm2/private_key.h"
#include "hesm2/t1.h"
#include "hesm2/t2.h"

#include "yacl/crypto/ecc/ec_point.h"
#include "yacl/math/mpint/mp_int.h"
Expand Down Expand Up @@ -371,4 +371,4 @@ Ciphertext HMul(const Ciphertext& ciphertext1, const yacl::math::MPInt& scalar,
auto c2 = ec_group->Mul(ciphertext1.GetC2(), scalar);
return Ciphertext{c1, c2};
}
} // namespace examples::hesm2
} // namespace examples::hesm2
4 changes: 2 additions & 2 deletions examples/hesm2/ahesm2.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

#pragma once

#include "examples/hesm2/ciphertext.h"
#include "examples/hesm2/private_key.h"
#include "hesm2/ciphertext.h"
#include "hesm2/private_key.h"

namespace examples::hesm2 {

Expand Down
6 changes: 3 additions & 3 deletions examples/hesm2/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "examples/hesm2/config.h"
#include "hesm2/config.h"

#include "examples/hesm2/t1.h"
#include "examples/hesm2/t2.h"
#include "hesm2/t1.h"
#include "hesm2/t2.h"

namespace examples::hesm2 {

Expand Down
6 changes: 3 additions & 3 deletions examples/hesm2/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@

#include <iostream>

#include "examples/hesm2/ahesm2.h"
#include "examples/hesm2/config.h"
#include "examples/hesm2/private_key.h"
#include "hesm2/ahesm2.h"
#include "hesm2/config.h"
#include "hesm2/private_key.h"

#include "yacl/crypto/ecc/ecc_spi.h"
#include "yacl/math/mpint/mp_int.h"
Expand Down
2 changes: 1 addition & 1 deletion examples/hesm2/private_key.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

#pragma once

#include "examples/hesm2/public_key.h"
#include "hesm2/public_key.h"

#include "yacl/crypto/ecc/ecc_spi.h"
#include "yacl/math/mpint/mp_int.h"
Expand Down
2 changes: 1 addition & 1 deletion examples/hesm2/t1.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include <shared_mutex>
#include <unordered_map>

#include "examples/hesm2/config.h"
#include "hesm2/config.h"

#include "yacl/crypto/ecc/ecc_spi.h"
#include "yacl/math/mpint/mp_int.h"
Expand Down
2 changes: 1 addition & 1 deletion examples/hesm2/t2.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include <utility>
#include <vector>

#include "examples/hesm2/config.h"
#include "hesm2/config.h"

#include "yacl/crypto/ecc/ecc_spi.h"
#include "yacl/math/mpint/mp_int.h"
Expand Down
10 changes: 5 additions & 5 deletions examples/psi/cpp/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

load("//bazel:yacl.bzl", "yacl_cc_binary", "yacl_cc_library", "yacl_cc_test")
load("@yacl//bazel:yacl.bzl", "yacl_cc_binary", "yacl_cc_library", "yacl_cc_test")

package(default_visibility = ["//visibility:public"])

Expand All @@ -25,8 +25,8 @@ yacl_cc_library(
"ecdh_psi.h",
],
deps = [
"//yacl/crypto/ecc",
"//yacl/link",
"@yacl//yacl/crypto/ecc",
"@yacl//yacl/link",
],
)

Expand All @@ -43,10 +43,10 @@ yacl_cc_binary(
"main_utils.h",
],
data = [
"//examples/psi:psi_data",
"//psi:psi_data",
],
deps = [
":ecdh_psi",
"//yacl/io/rw:csv_reader",
"@yacl//yacl/io/rw:csv_reader",
],
)
Loading

0 comments on commit 18a346f

Please sign in to comment.