Skip to content

Commit

Permalink
repo-sync-2024-03-12T17:55:36+0800 (#285)
Browse files Browse the repository at this point in the history
* repo-sync-2024-03-12T17:55:36+0800

* Update brpc.patch

* Update README.md

* Update continue-config.yml
  • Loading branch information
Jamie-Cui authored Mar 12, 2024
1 parent cfe90e6 commit 8a47205
Show file tree
Hide file tree
Showing 49 changed files with 1,269 additions and 339 deletions.
3 changes: 3 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ build --cxxopt=-std=c++17
build --host_cxxopt=-std=c++17
build --linkopt -lm

# HACK
build:linux --cxxopt -Wno-error=mismatched-new-delete

# Binary safety flags
build --host_copt=-fPIE
build --host_copt=-fstack-protector-strong
Expand Down
14 changes: 14 additions & 0 deletions .github/workflows/buildifier.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# 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.

---
name: Bazel files linter
on:
Expand Down
14 changes: 14 additions & 0 deletions .github/workflows/cla.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# 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.

---
name: CLA Assistant
on:
Expand Down
14 changes: 14 additions & 0 deletions .github/workflows/clang-format-linter.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# 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.

---
name: Run clang-format Linter
on:
Expand Down
14 changes: 14 additions & 0 deletions .github/workflows/scorecard.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# 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.

# This workflow uses actions that are not certified by GitHub. They are provided
# by a third-party and are governed by separate terms of service, privacy
# policy, and support documentation.
Expand Down
14 changes: 14 additions & 0 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# 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.

---
name: Mark stale issues and pull requests
on:
Expand Down
14 changes: 14 additions & 0 deletions .github/workflows/yaml-lint.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# 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.

---
name: Yaml Lint
on:
Expand Down
130 changes: 104 additions & 26 deletions ALGORITHMS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,117 @@

## Primitives

- OT
- Simplest OT : https://eprint.iacr.org/2015/267.pdf
- INKP OT Extension : https://www.iacr.org/archive/crypto2003/27290145/27290145.pdf
- KOS OT Extension : https://eprint.iacr.org/2015/546.pdf
- KKRT OT Extension : https://eprint.iacr.org/2016/799.pdf
- SGRR OT Extension: https://eprint.iacr.org/2019/1084.pdf
- GYWZ OT Extension : https://eprint.iacr.org/2022/1431.pdf
- Ferret OT Extension : https://eprint.iacr.org/2020/924.pdf
- Softspoken OT Extension : https://eprint.iacr.org/2022/192.pdf
- VOLE(over f2k)
- base VOLE : https://eprint.iacr.org/2016/505.pdf
- Silent VOLE : https://eprint.iacr.org/2019/1159.pdf, https://eprint.iacr.org/2021/1150.pdf https://eprint.iacr.org/2022/1014.pdf

- CODE
- Local Linear Code : https://eprint.iacr.org/2020/924.pdf
- Low Density Parity Check Code (Silver Code) : https://eprint.iacr.org/2021/1150.pdf
- Expanding Accumulation Code : https://eprint.iacr.org/2022/1014.pdf
### Oblivious Transfer and Extensions

- The Simplest Protocol for Oblivious Transfer\
*Tung Chou, Claudio Orlandi*\
LatinCrypt 2015, [eprint](https://eprint.iacr.org/2015/267), CO15

- Extending Oblivious Transfers Efficiently\
*Yuval Ishai, Joe Kilian, Kobbi Nissim, Erez Petrank*\
Crypto 2003, [eprint](https://www.iacr.org/archive/crypto2003/27290145/27290145.pdf), IKNP03

- Actively Secure OT Extension with Optimal Overhead\
*Marcel Keller, Emmanuela Orsini, Peter Scholl*\
Crypto 2015, [eprint](https://eprint.iacr.org/2015/546), KOS15

- Efficient Batched Oblivious PRF with Applications to Private Set Intersection\
*Vladimir Kolesnikov, Ranjit Kumaresan, Mike Rosulek, Ni Trieu*\
CCS 2016, [eprint](https://eprint.iacr.org/2016/799), KKRT16

- Distributed vector-OLE: Improved constructions and implementation\
*Phillipp Schoppmann, Adrià Gascón, Leonie Reichert, Mariana Raykova*\
CCS 2019, [eprint](https://eprint.iacr.org/2019/1084), SGRR19

- Half-Tree: Halving the Cost of Tree Expansion in COT and DPF\
*Xiaojie Guo, Kang Yang, Xiao Wang, Wenhao Zhang, Xiang Xie, Jiang Zhang, Zheli Liu*\
EUROCRYPT 2023, [eprint](https://eprint.iacr.org/2022/1431), GYWZ+23

- Ferret: Fast Extension for coRRElated oT with small communication\
*Kang Yang, Chenkai Weng, Xiao Lan, Jiang Zhang, Xiao Wang*\
CCS'20, [eprint](https://eprint.iacr.org/2020/924), YWLZ+20

- SoftSpokenOT: Quieter OT Extension from Small-Field Silent VOLE in the Minicrypt Model\
*Lawrence Roy*\
Crypto 2022, [publisher](https://www.iacr.org/cryptodb//data/paper.php?pubkey=32258), Roy22

### Vector Oblivious Linear Evaluation (over Field 2k)

Base VOLE:

- MASCOT: Faster Malicious Arithmetic Secure Computation with Oblivious Transfer\
*Marcel Keller, Emmanuela Orsini*\
CCS 2016, [eprint](https://eprint.iacr.org/2016/505), KO16

Silent VOLE:

- Efficient Two-Round OT Extension and Silent Non-Interactive Secure Computation\
*Elette Boyle, Geoffroy Couteau, Niv Gilboa, Yuval Ishai, Lisa Kohl, Peter Rindal, Peter Scholl*\
CCS 2019, [eprint](https://eprint.iacr.org/2019/1159), BCGI+19 (with Peter Rindal)

- Efficient Two-Round OT Extension and Silent Non-Interactive Secure Computation\
*Elette Boyle, Geoffroy Couteau, Niv Gilboa, Yuval Ishai, Lisa Kohl, Peter Rindal, Peter Scholl*\
CCS 2019, [eprint](https://eprint.iacr.org/2019/1159), BCGI+19

- Correlated Pseudorandomness from Expand-Accumulate Codes\
*Elette Boyle, Geoffroy Couteau, Niv Gilboa, Yuval Ishai, Lisa Kohl, Nicolas Resch, Peter Scholl*\
Crypto 2022, [eprint](https://eprint.iacr.org/2022/1014), BCG+22


### Codes

Local Linear Code

- Ferret: Fast Extension for coRRElated oT with small communication\
*Kang Yang, Chenkai Weng, Xiao Lan, Jiang Zhang, Xiao Wang*\
CCS'20, [eprint](https://eprint.iacr.org/2020/924), YWLZ+20

Low Density Parity Check Code (Silver Code)

- Silver: Silent VOLE and Oblivious Transfer from Hardness of Decoding Structured LDPC Codes\
*Geoffroy Couteau, Peter Rindal, Srinivasan Raghuraman*\
Crypto 2021, [eprint](https://eprint.iacr.org/2021/1150), CRR21

Expanding Accumulation Code : https://eprint.iacr.org/2022/1014.pdf

- Correlated Pseudorandomness from Expand-Accumulate Codes\
*Elette Boyle, Geoffroy Couteau, Niv Gilboa, Yuval Ishai, Lisa Kohl, Nicolas Resch, Peter Scholl*\
Crypto 2022, [eprint](https://eprint.iacr.org/2022/1014), BCG+22


## Theoretical Tools

- Random Oracle (RO)
- Random Permutation (RP)
- Pseudorandom Generator (PRG)
- Correlation-Robust Hash (CrHash) : https://eprint.iacr.org/2019/074.pdf
- Circular Correlation-Robust Hash (CcrHash) : https://eprint.iacr.org/2019/074.pdf
Random Oracle (RO)

- TBD

Random Permutation (RP)

- TBD

Pseudorandom Generator (PRG)

- TBD

Correlation-Robust Hash (CrHash)

- Efficient and Secure Multiparty Computation from Fixed-Key Block Ciphers\
*Chun Guo, Jonathan Katz, Xiao Wang, Yu Yu*\
Preprint 2019, [eprint](https://eprint.iacr.org/2019/074), GKWY19

Circular Correlation-Robust Hash (CCR Hash)

- Efficient and Secure Multiparty Computation from Fixed-Key Block Ciphers\
*Chun Guo, Jonathan Katz, Xiao Wang, Yu Yu*\
Preprint 2019, [eprint](https://eprint.iacr.org/2019/074), GKWY19

## Basic (Traditional) algorithms
## Basic (Traditional) algorithms (TBD)

- AEAD
- AES
- Block Cipher
- ECC (TODO)
- ECC
- Hash
- HMAC
- PKE: RSA, SM2
- Signature: RSA, SM2
- Public-Key Encryption: RSA, SM2
- Digital Signature: RSA, SM2
18 changes: 0 additions & 18 deletions yacl/crypto/primitives/dpf/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
# limitations under the License.

load("//bazel:yacl.bzl", "AES_COPT_FLAGS", "yacl_cc_library", "yacl_cc_test")
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@rules_cc//cc:defs.bzl", "cc_proto_library")

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

Expand All @@ -23,7 +21,6 @@ yacl_cc_library(
srcs = ["dpf.cc"],
hdrs = ["dpf.h"],
deps = [
":serializable_cc_proto",
"//yacl/base:int128",
"//yacl/crypto/tools:prg",
"//yacl/link",
Expand All @@ -38,21 +35,6 @@ yacl_cc_test(
],
)

proto_library(
name = "serializable_proto",
srcs = [
"serializable.proto",
],
deps = [
"//yacl/utils:serializable_proto",
],
)

cc_proto_library(
name = "serializable_cc_proto",
deps = [":serializable_proto"],
)

yacl_cc_library(
name = "mpfss",
srcs = ["mpfss.cc"],
Expand Down
68 changes: 19 additions & 49 deletions yacl/crypto/primitives/dpf/dpf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@
#include "yacl/crypto/primitives/dpf/dpf.h"

#include <future>
#include <sstream>

#include "spdlog/spdlog.h"

#include "yacl/crypto/primitives/dpf/serializable.pb.h"
#include "yacl/utils/serializer.h"
#include "yacl/utils/serializer_adapter.h"

namespace yacl::crypto {

Expand Down Expand Up @@ -290,59 +288,31 @@ std::vector<DpfOutStore> DpfContext::EvalAll(DpfKey& key) {
return result;
}

std::string DpfKey::Serialize() const {
DpfKeyProto proto;
// Set properties
proto.set_enable_evalall(enable_evalall);
Buffer DpfKey::Serialize() const {
// var "cws_vec" 's type 'std::vector<DpfCW>' not supported, convert to STL
// type
std::vector<std::pair<uint128_t, uint8_t>> dpf_cws;
dpf_cws.reserve(cws_vec.size());
for (const auto& cws : cws_vec) {
auto* cws_proto = proto.add_cws_vec();
auto i128_parts = DecomposeUInt128(cws.GetSeed());
cws_proto->mutable_seed()->set_hi(i128_parts.first);
cws_proto->mutable_seed()->set_lo(i128_parts.second);
cws_proto->set_t_store(cws.GetTStore());
}
for (const auto& last_cw : last_cw_vec) {
auto* last_cw_proto = proto.add_last_cw_vec();
auto i128_parts = DecomposeUInt128(last_cw);
last_cw_proto->set_hi(i128_parts.first);
last_cw_proto->set_lo(i128_parts.second);
dpf_cws.emplace_back(cws.GetSeed(), cws.GetTStore());
}
proto.set_rank(rank_);
proto.set_in_bitnum(in_bitnum_);
proto.set_ss_bitnum(ss_bitnum_);
proto.set_sec_param(sec_param_);

auto i128_parts = DecomposeUInt128(mseed_);
proto.mutable_mseed()->set_hi(i128_parts.first);
proto.mutable_mseed()->set_lo(i128_parts.second);

return proto.SerializeAsString();
// do serialize
return SerializeVars(enable_evalall, dpf_cws, last_cw_vec, rank_, in_bitnum_,
ss_bitnum_, sec_param_, mseed_);
}

void DpfKey::Deserialize(const std::string& s) {
DpfKeyProto proto;
proto.ParseFromString(s);
void DpfKey::Deserialize(ByteContainerView in) {
std::vector<std::pair<uint128_t, uint8_t>> dpf_cws;
DeserializeVarsTo(in, &enable_evalall, &dpf_cws, &last_cw_vec, &rank_,
&in_bitnum_, &ss_bitnum_, &sec_param_, &mseed_);

enable_evalall = proto.enable_evalall();
// recover "cws_vec" with type std::vector<DpfCW>
cws_vec.clear();
for (const auto& cws_proto : proto.cws_vec()) {
cws_vec.emplace_back(
MakeUint128(cws_proto.seed().hi(), cws_proto.seed().lo()),
cws_proto.t_store());
cws_vec.reserve(dpf_cws.size());
for (const auto& cws : dpf_cws) {
cws_vec.emplace_back(cws.first, cws.second);
}

last_cw_vec.clear();
for (const auto& last_cw_proto : proto.last_cw_vec()) {
last_cw_vec.emplace_back(
MakeUint128(last_cw_proto.hi(), last_cw_proto.lo()));
}

rank_ = proto.rank();
in_bitnum_ = proto.in_bitnum();
ss_bitnum_ = proto.ss_bitnum();
sec_param_ = proto.sec_param();

mseed_ = MakeUint128(proto.mseed().hi(), proto.mseed().lo());
}

} // namespace yacl::crypto
Loading

0 comments on commit 8a47205

Please sign in to comment.