Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
17 changes: 15 additions & 2 deletions .github/workflows/cla.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,21 @@ on:
pull_request_target:
types: [opened, closed, synchronize]
permissions:
contents: write
issues: write
pull-requests: write
jobs:
CLAssistant:
uses: secretflow/.github/.github/workflows/cla.yml@main
secrets: inherit
runs-on: ubuntu-latest
steps:
- name: CLA Assistant
if: github.event_name == 'pull_request_target' || github.event.comment.body == 'recheck' || github.event.comment.body == 'I have read the CLA Document and I hereby sign the CLA'
uses: contributor-assistant/github-action@ca4a40a7d1004f18d9960b404b97e5f30a505a08
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
path-to-document: https://github.com/secretflow/.github/blob/main/CLA.md
path-to-signatures: signatures/version1/cla.json
branch: main
allowlist: jjllzhang,test,renovate[bot],dependabot[bot],pre-commit-ci[bot],github-actions[bot],snyk-bot,Copilot
lock-pullrequest-aftermerge: true
98 changes: 98 additions & 0 deletions yacl/crypto/experimental/threshold_signatures/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# 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"]

TSIG_CORE_SRCS = glob([
"core/**/*.cc",
])

TSIG_CORE_HDRS = glob([
"common/*.h",
"core/**/*.h",
])

TSIG_ECDSA_SRCS = glob([
"ecdsa/**/*.cc",
])

TSIG_ECDSA_HDRS = glob([
"ecdsa/**/*.h",
])

TSIG_COMMON_DEPS = [
"//yacl/crypto/ecc/openssl:openssl",
# Big integer backend used across scalar/paillier/proof/protocol code paths.
"//yacl/math/mpint",
]

yacl_cc_library(
name = "tsig_core",
srcs = TSIG_CORE_SRCS,
hdrs = TSIG_CORE_HDRS,
copts = TECDSA_COPTS,
deps = TSIG_COMMON_DEPS + [
"//yacl/base:exception",
"//yacl/crypto/hash:ssl_hash",
"//yacl/crypto/rand",
],
)

yacl_cc_library(
name = "tsig_ecdsa",
srcs = TSIG_ECDSA_SRCS,
hdrs = TSIG_ECDSA_HDRS,
copts = TECDSA_COPTS,
deps = [
":tsig_core",
],
)

yacl_cc_library(
name = "tsig_sm2",
srcs = glob([
"sm2/**/*.cc",
]),
hdrs = glob([
"sm2/**/*.h",
]),
copts = TECDSA_COPTS,
deps = [
":tsig_core",
],
)

yacl_cc_binary(
name = "sign_flow_tests",
srcs = [
"tests/ecdsa_flow_test.cc",
"tests/test_helpers.h",
],
copts = TECDSA_COPTS,
deps = [":tsig_ecdsa"],
)

yacl_cc_binary(
name = "sm2_sign_flow_tests",
srcs = [
"tests/sm2_flow_test.cc",
"tests/test_helpers.h",
],
copts = TECDSA_COPTS,
deps = [":tsig_sm2"],
)
98 changes: 98 additions & 0 deletions yacl/crypto/experimental/threshold_signatures/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# Threshold Signatures

## Introduction

This directory contains experimental C++20 implementations of threshold ECDSA
and threshold SM2. The two schemes have independent protocol flows and share
common cryptographic building blocks through `core/`.

The code is intended for protocol review and integration experiments. It does
not include transport, persistent storage, wallet integration, or production
hardening.

## Implementation

### Code Structure

1. `common/` defines shared aliases, participant ids, peer maps, and error
helpers.
2. `core/` contains the shared primitives used by both schemes:
- `algebra/`: curve point and scalar wrappers over YACL ECC.
- `bigint/`: protocol-facing `MPInt` encoding and validation helpers.
- `commitment/`, `transcript/`, `proof/`, `vss/`: commitment,
Fiat-Shamir transcript, Schnorr proof, and Feldman VSS helpers.
- `mta/`: semantic MtA/MtAwc session API and the corresponding proof
primitives.
- `paillier/`: Paillier provider, auxiliary RSA setup, and paper proof
helpers.
- `protocol/`: peer-message checks and a simple linear round driver.
- `random/`, `suite/`: threshold-signature random helpers, suite
descriptors, group contexts, and hash dispatch.
3. `ecdsa/` implements threshold ECDSA key generation, signing, relation
proofs, and signature verification.
4. `sm2/` implements threshold SM2 key generation, offline presigning, online
signing, identifiable-abort data types, SM2-specific proofs, ZID binding,
and signature verification.
5. `tests/` contains executable ECDSA and SM2 flow tests.

### Threshold ECDSA

1. Key generation uses dealerless Feldman VSS, Paillier parameters, auxiliary
RSA parameters, square-free/auxiliary proofs, and public-share checks.
2. `VerifiedPublicKeygenData` validates and owns the public keygen data consumed
by signing.
3. Signing is exposed as explicit round methods on `SignParty`. The large
signing flow is split by round, and `SigningMtaExchange` hides pairwise
MtA/MtAwc message and proof details from the scheme-level round code.
4. Finalization verifies the produced ECDSA signature before returning it.

### Threshold SM2

1. Key generation derives SM2 public-key material from distributed `z_i` shares,
pairwise MtA sigma shares, group relation proofs, square-free proofs, and
Paillier auxiliary proof artifacts.
2. Offline presigning computes nonce/product state with MtAwc and validates the
aggregate product relation.
3. Online signing binds the SM2 ZID digest, computes partial signatures, and
returns identifiable-abort evidence for invalid partials when possible.

## Build / Test

Build all threshold-signature targets:

```bash
bazel build //yacl/crypto/experimental/threshold_signatures:all
```

Build individual libraries:

```bash
bazel build //yacl/crypto/experimental/threshold_signatures:tsig_core
bazel build //yacl/crypto/experimental/threshold_signatures:tsig_ecdsa
bazel build //yacl/crypto/experimental/threshold_signatures:tsig_sm2
```

Run the executable flow tests:

```bash
bazel run //yacl/crypto/experimental/threshold_signatures:sign_flow_tests
bazel run //yacl/crypto/experimental/threshold_signatures:sm2_sign_flow_tests
```

## Dependencies

- Elliptic-curve operations use YACL ECC support.
- Big integer operations use YACL `MPInt`.
- Random bytes are sourced through `yacl::crypto::SecureRandBytes`.
- Hashing is routed through YACL hash abstractions such as `SslHash` and
`HashAlgorithm`.

## Notes

- The module keeps ECDSA and SM2 protocol messages separate and shares only
primitives that are common to both schemes.
- Scheme-level code calls semantic MtA APIs such as `InitiatorInit`,
`ResponderMid`, and `InitiatorEnd`; low-level proof construction and
verification remain inside `core/mta`.
- `core/bigint` is a protocol adapter for encoding and validation. It should
not be expanded into a mirror of the full `MPInt` API.
24 changes: 24 additions & 0 deletions yacl/crypto/experimental/threshold_signatures/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))
31 changes: 31 additions & 0 deletions yacl/crypto/experimental/threshold_signatures/common/ids.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// 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 <cstdint>
#include <string>
#include <vector>

namespace tecdsa {

using Bytes = std::vector<uint8_t>;
using PartyIndex = uint32_t;

struct PartyInfo {
PartyIndex id;
std::string endpoint;
};

} // namespace tecdsa
30 changes: 30 additions & 0 deletions yacl/crypto/experimental/threshold_signatures/common/types.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// 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/crypto/experimental/threshold_signatures/core/algebra/point.h"
#include "yacl/crypto/experimental/threshold_signatures/core/algebra/scalar.h"
#include "yacl/crypto/experimental/threshold_signatures/core/paillier/paillier.h"

namespace tecdsa {

using BigInt = core::paillier::BigInt;
using ECPoint = core::Point;
using Scalar = core::Scalar;

using PaillierProvider = core::paillier::PaillierProvider;
using PaillierPublicKey = core::paillier::PaillierPublicKey;

} // namespace tecdsa
Loading
Loading