Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
ae9515c
feat(experimental): add threshold_ecdsa module (core + tests)
jjllzhang Mar 4, 2026
8f0aa0e
tecdsa: add MPInt bigint utility layer
jjllzhang Mar 5, 2026
1161cb3
tecdsa: migrate scalar and encoding to MPInt
jjllzhang Mar 5, 2026
fb19cd7
tecdsa: migrate paillier provider to MPInt
jjllzhang Mar 5, 2026
7bdf7e9
tecdsa: migrate strict proof bigint math to MPInt
jjllzhang Mar 5, 2026
65eb344
tecdsa: finish strict proof build/verify migration to MPInt
jjllzhang Mar 5, 2026
8c28459
tecdsa: migrate keygen session bigint path to MPInt
jjllzhang Mar 5, 2026
d260300
tecdsa: migrate sign session proof structs and mpint serialization
jjllzhang Mar 5, 2026
feebe3b
tecdsa: migrate sign session MTA/proof arithmetic to MPInt
jjllzhang Mar 5, 2026
d33f41b
tecdsa: remove gmpxx usage from tests
jjllzhang Mar 5, 2026
8724cfe
tecdsa: drop gmp/gmpxx linkopts and update docs for MPInt
jjllzhang Mar 5, 2026
dab0310
refactor: Refactor threshold ECDSA implementation to replace mpz_clas…
jjllzhang Mar 5, 2026
7be78f6
fix: Validate size in RandomBytes to prevent exceeding INT_MAX
jjllzhang Mar 5, 2026
e7d2de0
refactor: Implement strict proofs codec and math for threshold ECDSA
jjllzhang Mar 5, 2026
1083e40
refactor: Implement threshold ECDSA key generation protocol
jjllzhang Mar 5, 2026
ce192e6
refactor: Add shared test utilities for threshold ECDSA signing flow
jjllzhang Mar 5, 2026
057aa0a
docs: Update README and BUILD.bazel for clarity and dependencies
jjllzhang Mar 5, 2026
1af3d0b
fix: Remove unused link options for tecdsa_core library
jjllzhang Mar 6, 2026
8885e4e
style(threshold_ecdsa): fix lint and license issues
jjllzhang Mar 6, 2026
48bd007
Merge branch 'main' into integration/threshold_ecdsa
jjllzhang Mar 12, 2026
47c50a7
feat: add round-driven tecdsa prototype layer
jjllzhang Mar 26, 2026
db193f7
feat: complete round-driven tecdsa signing flow
jjllzhang Mar 26, 2026
886df18
refactor: remove tecdsa session framework
jjllzhang Mar 26, 2026
f37ecda
refactor: narrow tecdsa proof surface
jjllzhang Mar 26, 2026
87a336e
refactor: drop tecdsa cleanup leftovers
jjllzhang Mar 26, 2026
6964552
fix: localize CLA workflow
jjllzhang Mar 26, 2026
d6c6a3c
fix: localize CLA workflow
jjllzhang Mar 26, 2026
8eb05b6
fix: allowlist repo owner in CLA
jjllzhang Mar 26, 2026
9f5237d
fix: allowlist repo owner in CLA
jjllzhang Mar 26, 2026
4814668
Merge pull request #1 from jjllzhang/tecdsa-proto-rewrite
jjllzhang Mar 26, 2026
ea222c3
Merge branch 'secretflow:main' into integration/threshold_ecdsa
jjllzhang Mar 26, 2026
bb7da7f
fix: stabilize macOS unittest for tecdsa PR
jjllzhang Mar 26, 2026
9696019
refactor: shrink threshold ecdsa review surface
jjllzhang Mar 27, 2026
47890b9
refactor: add threshold_ecdsa stage 0/1 groundwork
jjllzhang Apr 20, 2026
bc15254
refactor: extract threshold_ecdsa stage 2 core helpers
jjllzhang Apr 20, 2026
5a1c6e5
refactor: extract threshold_ecdsa stage 3 crypto core
jjllzhang Apr 20, 2026
d3e2c66
refactor: extract threshold_ecdsa stage 4 mta helpers
jjllzhang Apr 20, 2026
e41b708
refactor: extract threshold_ecdsa stage 5 keygen orchestration
jjllzhang Apr 20, 2026
4d5c4bd
refactor: extract threshold_ecdsa stage 6 sign orchestration
jjllzhang Apr 20, 2026
64d31c0
refactor: split threshold_ecdsa stage 7 build graph
jjllzhang Apr 20, 2026
bbb05a1
refactor: add threshold_ecdsa stage 8 sm2 flow
jjllzhang Apr 20, 2026
c93b424
refactor: extract threshold_ecdsa stage 9 ids
jjllzhang Apr 21, 2026
4145b57
refactor: extract threshold_ecdsa stage 10 schema owners
jjllzhang Apr 21, 2026
faabdfc
refactor: extract threshold_ecdsa stage 11 helper owners
jjllzhang Apr 21, 2026
d23a3f7
refactor: extract threshold_ecdsa stage 12 transcript context
jjllzhang Apr 21, 2026
ca4374a
refactor: extract threshold_ecdsa stage 13 mta context
jjllzhang Apr 21, 2026
9a8f06c
refactor: extract threshold_ecdsa stage 14 shared proof context
jjllzhang Apr 21, 2026
fe908cf
refactor: finalize threshold_ecdsa shared core contexts
jjllzhang Apr 21, 2026
49d6cc3
refactor: add threshold paper auxiliary setup owner
jjllzhang Apr 22, 2026
0fb8a1a
refactor: add threshold paper stage 2 correct-form proofs
jjllzhang Apr 22, 2026
9e61507
refactor: add threshold paper stage 3 ecdsa proofs
jjllzhang Apr 22, 2026
4ff897d
refactor: add threshold paper stage 4 sm2 proof owners
jjllzhang Apr 22, 2026
f186d36
refactor: add threshold paper stage 5 sm2 abort reports
jjllzhang Apr 22, 2026
9ac56fe
refactor: add threshold paper stage 6 strict signer model
jjllzhang Apr 22, 2026
0fc01fa
refactor: add threshold paper stage 7 sm2 public proofs
jjllzhang Apr 22, 2026
6e5b3bb
refactor: finalize threshold paper proof cleanup
jjllzhang Apr 22, 2026
0d24aa7
refactor: own threshold exact proof types
jjllzhang Apr 22, 2026
1673ba2
refactor: adapt threshold proofs to core transport
jjllzhang Apr 22, 2026
becac93
refactor: restore threshold proto proof compatibility
jjllzhang Apr 22, 2026
3f94767
refactor: own sm2 mta message types
jjllzhang Apr 22, 2026
d6c3d57
refactor: mark threshold core transport boundaries
jjllzhang Apr 22, 2026
f736869
test: finalize threshold exact proof ownership coverage
jjllzhang Apr 22, 2026
184bd46
refactor: finalize threshold proof message boundaries
jjllzhang Apr 23, 2026
8b5e7e8
refactor: isolate threshold core owners
jjllzhang Apr 23, 2026
3ace45a
refactor: dedup threshold mta proof types
jjllzhang Apr 23, 2026
35407c1
refactor: dedup threshold mta proof kernels
jjllzhang Apr 23, 2026
2dc57d3
refactor: share threshold keygen round12 helpers
jjllzhang Apr 24, 2026
4aada94
refactor: share threshold mta envelope checks
jjllzhang Apr 24, 2026
7b2eb5c
refactor: isolate threshold protocol compat target
jjllzhang Apr 24, 2026
31e30c3
refactor(crypto): rename threshold signatures module
jjllzhang Apr 24, 2026
e03813e
Merge branch 'main' into integration/threshold_ecdsa
jjllzhang Apr 24, 2026
37c14db
refactor(crypto): streamline threshold signatures implementation
jjllzhang May 18, 2026
882d76b
Merge branch 'main' into integration/threshold_ecdsa
jjllzhang Jun 17, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 86 additions & 0 deletions yacl/crypto/experimental/threshold_ecdsa/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# Copyright 2026 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.

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

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

TECDSA_COPTS = ["-std=gnu++20"]

TECDSA_CORE_SRCS = glob([
"crypto/*.cc",
"net/*.cc",
"protocol/*.cc",
])

TECDSA_CORE_HDRS = glob([
"common/*.h",
"crypto/*.h",
"net/*.h",
"protocol/*.h",
])

TECDSA_CORE_DEPS = [
"//yacl/crypto/ecc/openssl:openssl",
]

TECDSA_CORE_LINKOPTS = [
"-lcrypto",
"-lgmpxx",
"-lgmp",
]

yacl_cc_library(
name = "tecdsa_core",
srcs = TECDSA_CORE_SRCS,
hdrs = TECDSA_CORE_HDRS,
copts = TECDSA_COPTS,
deps = TECDSA_CORE_DEPS + [
"//yacl/base:exception",
],
linkopts = TECDSA_CORE_LINKOPTS,
)

alias(
name = "tecdsa_m0",
actual = ":tecdsa_core",
)

yacl_cc_binary(
name = "crypto_primitives_tests",
srcs = ["tests/crypto_primitives_test.cc"],
copts = TECDSA_COPTS,
deps = [":tecdsa_core"],
)

yacl_cc_binary(
name = "protocol_infrastructure_tests",
srcs = ["tests/protocol_infrastructure_test.cc"],
copts = TECDSA_COPTS,
deps = [":tecdsa_core"],
)

yacl_cc_binary(
name = "keygen_flow_tests",
srcs = ["tests/keygen_flow_test.cc"],
copts = TECDSA_COPTS,
deps = [":tecdsa_core"],
)

yacl_cc_binary(
name = "sign_flow_tests",
srcs = ["tests/sign_flow_test.cc"],
copts = TECDSA_COPTS,
deps = [":tecdsa_core"],
)
61 changes: 61 additions & 0 deletions yacl/crypto/experimental/threshold_ecdsa/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
cmake_minimum_required(VERSION 3.22)
project(threshold_ecdsa LANGUAGES C CXX)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

find_package(OpenSSL QUIET)

set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE)

add_library(tecdsa_core
crypto/scalar.cc
crypto/ec_point.cc
crypto/ecdsa_verify.cc
crypto/hash.cc
crypto/random.cc
crypto/commitment.cc
crypto/encoding.cc
crypto/paillier.cc
crypto/strict_proofs.cc
crypto/transcript.cc
net/envelope.cc
net/in_memory_transport.cc
protocol/session.cc
protocol/session_router.cc
protocol/keygen_session.cc
protocol/sign_session.cc
)

target_include_directories(tecdsa_core PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/../../../../
${CMAKE_CURRENT_SOURCE_DIR}
)

target_link_libraries(tecdsa_core PUBLIC gmpxx gmp)
if(OpenSSL_FOUND)
target_link_libraries(tecdsa_core PUBLIC OpenSSL::Crypto)
else()
target_link_libraries(tecdsa_core PUBLIC crypto)
endif()

add_library(tecdsa_m0 ALIAS tecdsa_core)

add_executable(crypto_primitives_tests tests/crypto_primitives_test.cc)
target_link_libraries(crypto_primitives_tests PRIVATE tecdsa_core)

add_executable(protocol_infrastructure_tests tests/protocol_infrastructure_test.cc)
target_link_libraries(protocol_infrastructure_tests PRIVATE tecdsa_core)

add_executable(keygen_flow_tests tests/keygen_flow_test.cc)
target_link_libraries(keygen_flow_tests PRIVATE tecdsa_core)

add_executable(sign_flow_tests tests/sign_flow_test.cc)
target_link_libraries(sign_flow_tests PRIVATE tecdsa_core)

enable_testing()
add_test(NAME crypto_primitives_tests COMMAND crypto_primitives_tests)
add_test(NAME protocol_infrastructure_tests COMMAND protocol_infrastructure_tests)
add_test(NAME keygen_flow_tests COMMAND keygen_flow_tests)
add_test(NAME sign_flow_tests COMMAND sign_flow_tests)
130 changes: 130 additions & 0 deletions yacl/crypto/experimental/threshold_ecdsa/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
# threshold_ecdsa

Research artifact for a C++20 implementation of the GG2019 threshold ECDSA protocol.

## Paper Reference

- Rosario Gennaro, Steven Goldfeder.
*Fast Multiparty Threshold ECDSA with Fast Trustless Setup* (CCS 2019).

This repository implements protocol components as executable state machines and emphasizes:

- protocol-correct message flow,
- strict input validation and abort behavior,
- reproducible tests.

It is not a production-ready wallet/signing service.

## Scope of This Artifact

### Implemented Components

- Elliptic-curve scalar/point operations (`yacl::crypto::EcGroup` with openssl backend).
- Native Paillier encryption implementation (`yacl-native`).
- Hashing, commitments, transcript/challenge utilities, wire encoding.
- Session model with lifecycle management (`running/completed/aborted/timed-out`).
- In-memory transport and session routing.
- Threshold key generation (`KeygenSession`, 3 phases).
- Threshold signing (`SignSession`, Phase1 to Phase5E).
- Strict/dev gating for square-free and auxiliary-parameter proof artifacts.

### Current Engineering Goal

The repository targets protocol engineering reproducibility, not hardened deployment.

## Repository Layout

```text
common/ # bytes/secure_zeroize/thread_pool
crypto/ # Scalar/ECPoint/Paillier/hash/commitment/encoding/transcript/proofs
net/ # Envelope, transport interfaces, in-memory network
protocol/ # Session base, router, keygen/sign state machines
tests/
crypto_primitives_test.cc
protocol_infrastructure_test.cc
keygen_flow_test.cc
sign_flow_test.cc
```

## Reproducibility

### Requirements

- CMake >= 3.22
- C++20 compiler (`clang++`/`g++`)
- GMP / gmpxx
- OpenSSL `libcrypto`

### Build

```bash
cmake -S . -B build
cmake --build build -j
```

### Bazel

```bash
bazelisk build //yacl/crypto/experimental/threshold_ecdsa:tecdsa_core
bazelisk build //yacl/crypto/experimental/threshold_ecdsa:all
```

If your environment resolves `rules_foreign_cc` to `built_make` and fails on
`BootstrapGNUMake`, run with one-off toolchain flags:

```bash
bazelisk build //yacl/crypto/experimental/threshold_ecdsa:tecdsa_core \
--extra_toolchains=@rules_foreign_cc//toolchains:preinstalled_make_toolchain,@rules_foreign_cc//toolchains:preinstalled_pkgconfig_toolchain
```

### Test Suite

Run all tests:

```bash
ctest --test-dir build --output-on-failure
```

Run individual executables:

```bash
./build/crypto_primitives_tests
./build/protocol_infrastructure_tests
./build/keygen_flow_tests
./build/sign_flow_tests
```

### Test Coverage Summary

- `crypto_primitives_tests`: basic crypto primitives and wire format checks.
- `protocol_infrastructure_tests`: transport/router/session skeleton behavior.
- `keygen_flow_tests`: end-to-end keygen, strict gating, and adversarial tampering.
- `sign_flow_tests`: end-to-end signing, proof checks, and adversarial failure paths.

## Error Handling Style

- Runtime argument/logic/runtime failures in module code are normalized through
`common/errors.h` (`TECDSA_THROW*`) and map to YACL exception macros.

## Protocol Flow (Implemented)

### Keygen (`KeygenSession`)

1. Phase1: broadcast commitment + Paillier public parameters.
2. Phase2: broadcast opens/commitments and send shares point-to-point.
3. Phase3: broadcast `X_i = g^{x_i}` with Schnorr proof.
4. Finalization: aggregate `x_i`, `y`, all `X_i`, and Paillier/public proof artifacts.

### Sign (`SignSession`)

1. Phase1: commit to `Gamma_i`.
2. Phase2: MtA/MtAwc interaction with Appendix-A style proof checks.
3. Phase3: broadcast `delta_i` and aggregate inversion path.
4. Phase4: open `Gamma_i`, verify proof, derive `R` and `r`.
5. Phase5A~5E: commit/open rounds with relation proofs, then finalize `(r, s)`.

## Limitations

- Network layer is in-memory only (no real transport security/retransmission/persistence).
- No claim of production security hardening.
- Intended for protocol implementation study and testing.
10 changes: 10 additions & 0 deletions yacl/crypto/experimental/threshold_ecdsa/common/bytes.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#pragma once

#include <cstdint>
#include <vector>

namespace tecdsa {

using Bytes = std::vector<uint8_t>;

} // namespace tecdsa
24 changes: 24 additions & 0 deletions yacl/crypto/experimental/threshold_ecdsa/common/errors.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright 2026 Ant Group Co., Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#pragma once

#include "yacl/base/exception.h"

// Use YACL-style exceptions with a safe "{}" wrapper so dynamic messages are
// treated as plain text instead of runtime format strings.
#define TECDSA_THROW(msg) YACL_THROW("{}", (msg))
#define TECDSA_THROW_ARGUMENT(msg) YACL_THROW_ARGUMENT_ERROR("{}", (msg))
#define TECDSA_THROW_LOGIC(msg) YACL_THROW_LOGIC_ERROR("{}", (msg))
#define TECDSA_ENFORCE(cond, msg) YACL_ENFORCE((cond), "{}", (msg))
Loading