Skip to content

Commit

Permalink
repo-sync-2023-11-22T16:15:37+0800
Browse files Browse the repository at this point in the history
  • Loading branch information
6fj committed Nov 22, 2023
1 parent d8ca8a7 commit 6c582fb
Show file tree
Hide file tree
Showing 341 changed files with 61,944 additions and 0 deletions.
76 changes: 76 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Copyright 2023 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

# Required by OpenXLA
build --nocheck_visibility

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

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


test --keep_going
test --test_output=errors

build:benchmark --copt -O3
build:benchmark --copt -march=native

# static link runtime libraries on Linux
build:linux-release --action_env=BAZEL_LINKOPTS=-static-libstdc++:-static-libgcc
build:linux-release --action_env=BAZEL_LINKLIBS=-l%:libstdc++.a:-l%:libgcc.a

# platform specific config
# Bazel will automatic pick platform config since we have enable_platform_specific_config set
build:macos --copt="-Xpreprocessor -fopenmp"
build:macos --copt=-Wno-unused-command-line-argument
build:macos --features=-supports_dynamic_linker
build:macos --cxxopt -Wno-deprecated-enum-enum-conversion
build:macos --cxxopt -Wno-deprecated-anon-enum-enum-conversion
build:macos --macos_minimum_os=11.0
build:macos --host_macos_minimum_os=11.0

build:linux --copt=-fopenmp
build:linux --linkopt=-fopenmp

build:asan --strip=never
build:asan --copt -fno-sanitize-recover=all
build:asan --copt -fsanitize=address
build:asan --copt -Og
build:asan --copt -g
build:asan --copt -fno-omit-frame-pointer
build:asan --linkopt -fsanitize=address
build:asan --linkopt -static-libasan

build:ubsan --strip=never
build:ubsan --copt -fno-sanitize-recover=all
build:ubsan --copt -fsanitize=undefined
build:ubsan --copt -Og
build:ubsan --copt -g
build:ubsan --copt -fno-omit-frame-pointer
build:ubsan --linkopt -fsanitize=undefined
build:ubsan --linkopt -static-libubsan

build:macos-asan --features=asan
build:macos-ubsan --features=ubsan
1 change: 1 addition & 0 deletions .bazelversion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
6.2.1
15 changes: 15 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Use the Google style in this project.
BasedOnStyle: Google

IncludeBlocks: Regroup
IncludeCategories:
- Regex: '^<.*\.h>'
Priority: 1
- Regex: "^<.*"
Priority: 2
- Regex: '.*\.pb\.h"$'
Priority: 5
- Regex: '^"psi.*'
Priority: 4
- Regex: '^".*'
Priority: 3
78 changes: 78 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
Checks: "abseil-cleanup-ctad,
abseil-faster-strsplit-delimiter,
abseil-duration-*,
abseil-no-namespace,
abseil-redundant-strcat-calls,
abseil-str-cat-append,
abseil-string-find-startswith,
abseil-upgrade-duration-conversions
bugprone-*,
-bugprone-easily-swappable-parameters,
-bugprone-implicit-widening-of-multiplication-result,
-bugprone-narrowing-conversions, # too many false positives around `std::size_t` vs. `*::difference_type`.
google-build-using-namespace,
google-explicit-constructor,
google-global-names-in-headers,
google-readability-casting,
google-runtime-int,
google-runtime-operator,
misc-unused-using-decls,
modernize-*,
-modernize-use-trailing-return-type,
-modernize-avoid-c-arrays,
-modernize-return-braced-init-list, # can hurt readability
-modernize-use-nodiscard,
performance-*,
readability-*,
-readability-else-after-return,
-readability-identifier-length,
-readability-function-cognitive-complexity,
-readability-magic-numbers,
-readability-named-parameter"

CheckOptions:
- key: bugprone-argument-comment.StrictMode
value: 1

- key: bugprone-dangling-handle.HandleClasses
value: "std::basic_string_view;std::experimental::basic_string_view;absl::string_view"

- key: misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic
value: 1

# Ignore GoogleTest function macros.
- key: readability-identifier-naming.FunctionIgnoredRegexp
value: "(TEST|TEST_F|TEST_P|INSTANTIATE_TEST_SUITE_P|MOCK_METHOD|TYPED_TEST)"

- key: readability-identifier-naming.ClassCase
value: "CamelCase"

- key: readability-identifier-naming.EnumCase
value: "CamelCase"

- key: readability-identifier-naming.EnumConstantCase
value: "CamelCase"

- key: readability-identifier-naming.ParameterCase
value: "lower_case"

- key: readability-identifier-naming.PrivateMemberCase
value: "lower_case"

- key: readability-identifier-naming.PrivateMemberSuffix
value: "_"

- key: readability-identifier-naming.StructCase
value: "CamelCase"

- key: readability-identifier-naming.TypeAliasCase
value: "CamelCase"

- key: readability-identifier-naming.UnionCase
value: "CamelCase"

- key: readability-identifier-naming.FunctionCase
value: "CamelBack"

- key: performance-unnecessary-value-param.AllowedTypes
value: PtBufferView
47 changes: 47 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# devtools
.idea/
*.plist
clion/
*.swp
tags
sftp-config.json
build_cmakelist.py
.akconfig
.cloudide/
*.code-workspace
vipclient-*
*.pb.h
*.pb.cc
compile_commands.json
.clangd
Pipfile

# bazel
bazel-*

# cmake related
abseil-cpp
bld
bld.install
CMakeCache.txt
cmake_install.cmake
CTestTestfile.cmake

# mixed
.DS_Store
.ipynb_checkpoints
trace.*log

dump/

# clangd cache
.cache
external

#brpc
rpc_data

coverity*/
idir/

ossutil_output/
59 changes: 59 additions & 0 deletions .markdownlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Copyright 2023 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.

# Enable all markdownlint rules by default
default: true

# List formatting:
#
# 1. Lists must have a blank line before AND after the list.
# 2. Lists start aligned to the left (do not indent the top level list items).
# NOTE: markdownlint currently checks indentation for unordered lists only.
# Please manually verify that your ordered lists are not indented.
# See https://github.com/DavidAnson/markdownlint/issues/138.
# 3. You may use one or zero blank lines between list items.
# 4. Nested list items should be indented to align with the first character of
# the first line. For bullet lists, that means 2 spaces. For numbered
# lists, that's 3 spaces (but 4 spaces is okay if that's easier).
# 5. In multiline list items, subsequent lines are indented by 2 spaces.
# This is not checked automatically, so we're documenting this convention
# to make sure the codebase stays consistent.
#
# Examples:
#
# * This is a list item that has multiple
# lines and each line aligns with the text from the first line.
# * This is a nested list, also aligned with the first line.
#
# For ordered lists, that means three spaces for wrapped lines:
#
# 1. This is an ordered list item.
# 1. The nested list aligns with the first line.
ul-indent:
indent: 2

line-length:
line_length: 150
tables: false
code_blocks: false

# Allow inline HTML
no-inline-html: false

# Allow dupe heading names only if they're not siblings
no-duplicate-heading:
siblings_only: true

# Allow images w/o alt-text
no-alt-text: false
7 changes: 7 additions & 0 deletions LEGAL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Legal Disclaimer

Within this source code, the comments in Chinese shall be the original, governing version. Any comment in other languages are for reference only. In the event of any conflict between the Chinese language version comments and other language version comments, the Chinese language version shall prevail.

法律免责声明

关于代码注释部分,中文注释为官方版本,其它语言注释仅做参考。中文注释可能与其它语言注释存在不一致,当中文注释与其它语言注释存在不一致时,请以中文注释为准。
75 changes: 75 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# SecretFlow PSI Library

The repo of Private Set Intersection(PSI) and Private Information Retrieval(PIR) from SecretFlow.

This repo is formerly psi/pir part from secretflow/spu repo.

## Quick Start

<!-- todo -->

## Building SecretFlow PSI Library

### System Setup


#### Docker

We use the same dev docker from secretflow/spu.

```sh
## start container
docker run -d -it --name spu-dev-$(whoami) \
--mount type=bind,source="$(pwd)",target=/home/admin/dev/ \
-w /home/admin/dev \
--cap-add=SYS_PTRACE --security-opt seccomp=unconfined \
--cap-add=NET_ADMIN \
--privileged=true \
secretflow/spu-ci:latest

# attach to build container
docker exec -it spu-dev-$(whoami) bash
```

#### Linux

```sh
Install gcc>=11.2, cmake>=3.26, ninja, nasm>=2.15, python>=3.8, bazel==6.2.1, golang, xxd, lld
```

### Build & UnitTest




``` sh
# build as debug
bazel build //... -c dbg

# build as release
bazel build //... -c opt

# test
bazel test //...
```


### Trace

We use [Perfetto](https://perfetto.dev/) from Google for tracing.

Please use debug_options.trace_path field in PsiConfig to modify trace file path. The default path is /tmp/psi.trace.

After running psi binaries, please check trace by using [Trace Viewer](https://ui.perfetto.dev/). If this is not applicable, please check [this link](https://github.com/google/perfetto/issues/170) to deploy your own website.

The alternate way to visualize trace is to use **chrome://tracing**:
1. Download perfetto assets from https://github.com/google/perfetto/releases/tag/v37.0
2. You should find traceconv binary in assets folder.
3. Transfer trace file to JSON format:

```bash
chmod +x traceconv

./traceconv json [trace file path] [json file path]
```
4. Open chrome://tracing in your chrome and load JSON file.
31 changes: 31 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Security

If you believe you have found a security vulnerability in any SecretFlow repository that meets
[SecretFlow's definition of a security vulnerability](https://security.alipay.com/announcement.htm?id=1), please report it to us as described below.

## Reporting Security Issues

**Please do not report security vulnerabilities through public GitHub issues.**

Instead, please report them to the ANT GROUP SECURITY Response Center at [https://security.alipay.com/](https://security.alipay.com/).

If you prefer to submit without logging in, send email to [[email protected]](mailto:[email protected]).

You should receive a response within 48 hours. If for some reason you do not, please follow up via email to ensure we received your original message.
Additional information can be found at [https://security.alipay.com/](https://security.alipay.com/).

Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue:

* Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.)
* Full paths of source file(s) related to the manifestation of the issue
* The location of the affected source code (tag/branch/commit or direct URL)
* Any special configuration required to reproduce the issue
* Step-by-step instructions to reproduce the issue
* Proof-of-concept or exploit code (if possible)
* Impact of the issue, including how an attacker might exploit the issue

This information will help us triage your report more quickly.

## Preferred Languages

We prefer all communications to be in Chinese or English.
Loading

0 comments on commit 6c582fb

Please sign in to comment.