[experimental][threshold_ecdsa] Add threshold ECDSA module with native Paillier and YACL-style cleanup#634
Conversation
- add experimental threshold ECDSA module under yacl/crypto/experimental/threshold_ecdsa with: common/, crypto/, net/, protocol/, tests/ - add build integration: - BUILD.bazel (tecdsa_core + 4 test binaries) - CMakeLists.txt (tecdsa_core + 4 test executables) - implement ECC path with yacl EcGroup (OpenSSL backend) and math-based ECDSA verify flow - add native Paillier provider (keygen/encrypt/decrypt/homomorphic ops, Z*_N checks) - align module error handling with YACL exception style via common/errors.h (TECDSA_THROW*) - include protocol/session infrastructure for keygen/sign and strict-proof validation - add regression/E2E targets: crypto_primitives_tests, protocol_infrastructure_tests, keygen_flow_tests, sign_flow_tests - intentionally exclude bench and docs artifacts from this commit
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request adds an experimental threshold ECDSA module to YACL, enhancing its cryptographic capabilities. It focuses on improving maintainability and reducing external dependencies by replacing Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a new experimental module for threshold ECDSA, which is a substantial and well-structured contribution. The implementation aligns with the GG2019 paper and includes a native Paillier implementation, replacing previous dependencies. The code quality is high, with strong error handling, good security practices like secure zeroization of sensitive data, and a comprehensive test suite covering happy paths and adversarial scenarios. My main feedback concerns the maintainability of several very large files. Splitting them into smaller, more focused modules would significantly improve readability and future development. I've also identified a minor potential integer overflow issue in the random number generation utility.
Note: Security Review did not run due to the size of the PR.
…s with BigInt - Removed dependencies on GMP's mpz_class in favor of a custom BigInt type for better integration and performance. - Updated function signatures and internal logic to accommodate BigInt, including conversions and validations. - Adjusted tests to ensure compatibility with the new BigInt type, ensuring that all instances of mpz_class are replaced. - Enhanced readability and maintainability of the code by streamlining type usage across key generation and signing sessions.
- Added strict_proofs_codec.cc to handle encoding and decoding of strict proof metadata and payloads. - Introduced strict_proofs_internal.h for internal structures and functions related to strict proofs. - Created strict_proofs_math.cc for mathematical operations and challenge generation related to strict proofs. - Implemented functions for encoding/decoding square-free strict payloads and auxiliary parameter strict payloads. - Added utility functions for handling modular arithmetic and random number generation in the context of strict proofs.
- Added keygen_session_codec.cc and keygen_session_internal.h to handle key generation logic. - Implemented phase 1, phase 2, and phase 3 of the key generation process in separate source files. - Introduced functions for validating participants, building peer sets, and handling payloads for each phase. - Added support for Schnorr proofs and square-free proofs in the key generation process. - Ensured strict proof verification and compatibility checks for enhanced security.
- Introduced `sign_flow_test_shared.h` to define common structures and functions for testing the signing flow in threshold ECDSA. - Implemented `sign_flow_test_support.cc` to provide utility functions for managing key generation and signing sessions, including envelope delivery and message collection for various phases. - Added helper functions for constructing sign fixtures, verifying session states, and handling envelope tampering scenarios.
- add missing Apache license headers to threshold_ecdsa sources - run clang-format on the threshold_ecdsa module - reformat BUILD.bazel with buildifier - keep changes limited to style and CI cleanup
Summary
This PR adds
yacl/crypto/experimental/threshold_ecdsaand finalizes the staged integration work.common/,crypto/,net/,protocol/,tests/EcGroup, OpenSSL backend)libhcsdependency with native Paillier implementationcommon/errors.h(TECDSA_THROW*)yacl_cc_library/yacl_cc_binary)bench/,docs/)Motivation
Main Changes
yacl/crypto/experimental/threshold_ecdsa/BUILD.bazelyacl/crypto/experimental/threshold_ecdsa/CMakeLists.txtcrypto_primitives_testsprotocol_infrastructure_testskeygen_flow_testssign_flow_testsREADME.mdto match current module scope (no bench/docs section)Compatibility
Validation
Commands executed: