Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Milestone 3 #1

Merged
merged 77 commits into from
Dec 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
ebbe669
feat(zk+ sign): add enc-elg and elog zk proof + refactor threshold si…
NhoxxKienn Oct 24, 2024
3ee7346
fix(documentation) : update README.md and code documentation + sugges…
NhoxxKienn Oct 24, 2024
82d2306
merge: with origin head
NhoxxKienn Oct 24, 2024
f352d3c
Create LICENSE
cryptphil Oct 29, 2024
6aa0cc0
Update README.md
cryptphil Oct 29, 2024
7021b84
fix: refactor + fix missing PR requests
NhoxxKienn Oct 29, 2024
e115202
fix: add private modifiers to functions
NhoxxKienn Oct 29, 2024
a2af95e
feat(keygen): add keygen protocol
NhoxxKienn Nov 16, 2024
cedea07
feat(keygen): add auxilary protocol
NhoxxKienn Nov 21, 2024
a29bd43
feat(main, test): add keygen and aux to main and add test for new zk-…
NhoxxKienn Nov 24, 2024
edd9af3
fix(aux): add missing schnorr proofs for aux-info
NhoxxKienn Nov 25, 2024
daef208
Merge pull request #2 from perun-network/canetti
NhoxxKienn Nov 27, 2024
af4c349
refactor(zk): refactor the zk packages + add logger
NhoxxKienn Dec 5, 2024
0cc5a98
refactor(code): remove redundant empty lines and fix exceptions' desc…
NhoxxKienn Dec 5, 2024
ae37d9e
Update README.md
cryptphil Oct 19, 2024
a542f6f
Create LICENSE
cryptphil Oct 29, 2024
b646ec1
Update README.md
cryptphil Oct 29, 2024
0d41233
fix: refactor + fix missing PR requests
NhoxxKienn Oct 29, 2024
1a4e59d
fix: add private modifiers to functions
NhoxxKienn Oct 29, 2024
2cfc5b4
feat(keygen): add keygen protocol
NhoxxKienn Nov 16, 2024
6e75bde
feat(keygen): add auxilary protocol
NhoxxKienn Nov 21, 2024
2e415b2
feat(main, test): add keygen and aux to main and add test for new zk-…
NhoxxKienn Nov 24, 2024
5a85b98
fix(aux): add missing schnorr proofs for aux-info
NhoxxKienn Nov 25, 2024
9209361
feat(readme): add coverage badge to readme.
NhoxxKienn Nov 26, 2024
1c1b7f9
Update README.md
NhoxxKienn Nov 27, 2024
2118da8
Update README.md
NhoxxKienn Nov 27, 2024
d9d5b28
feat(readme): update readme
NhoxxKienn Nov 27, 2024
d00afe2
feat(doc): add documentation for aux, keygen, signer.
NhoxxKienn Nov 27, 2024
43039df
feat(doc): add missing doc for zk proofs.
NhoxxKienn Nov 28, 2024
0efe75b
Merge branch 'master' into update_doc
NhoxxKienn Dec 5, 2024
ca9d92b
Merge branch 'feature/keygen_aux' into update_doc
NhoxxKienn Dec 5, 2024
3017378
merge with keygen_aux changes
NhoxxKienn Dec 5, 2024
9839689
Update README.md
cryptphil Oct 19, 2024
1ddc302
Create LICENSE
cryptphil Oct 29, 2024
ac97aba
Update README.md
cryptphil Oct 29, 2024
8ba70c0
fix: refactor + fix missing PR requests
NhoxxKienn Oct 29, 2024
43ac8c4
fix: add private modifiers to functions
NhoxxKienn Oct 29, 2024
12180a9
feat(keygen): add keygen protocol
NhoxxKienn Nov 16, 2024
c04fe7f
feat(keygen): add auxilary protocol
NhoxxKienn Nov 21, 2024
b32a1a6
feat(main, test): add keygen and aux to main and add test for new zk-…
NhoxxKienn Nov 24, 2024
084e579
fix(aux): add missing schnorr proofs for aux-info
NhoxxKienn Nov 25, 2024
80880fb
feat(ci/cd, test): add zk tests and ci/cd workflow.
NhoxxKienn Nov 25, 2024
e21c8dd
feat(ci/cd, test): add zk tests and ci/cd workflow.
NhoxxKienn Nov 25, 2024
93cdde5
fix(ci/cd): add ci/cd trigger.
NhoxxKienn Nov 25, 2024
da665f7
fix(ci/cd): change code coverage to jacoco.
NhoxxKienn Nov 26, 2024
86d7772
fix(ci/cd): fix workflow coverage badge.
NhoxxKienn Nov 26, 2024
8802547
fix(ci/cd): fix workflow coverage badge csv file.
NhoxxKienn Nov 26, 2024
4e52294
feat(test): add test for presign, aux, keygen.
NhoxxKienn Nov 26, 2024
79a39c6
feat(test): add tests for precomps, ecdsa packages.
NhoxxKienn Nov 26, 2024
dd55cd7
feat(test): add tests for signer, paillier.
NhoxxKienn Nov 27, 2024
a31edd4
feat(test): add fail test cases for aux, keygen, presign.
NhoxxKienn Nov 28, 2024
998f826
feat(test): add fail test cases for aux, keygen, presign.
NhoxxKienn Nov 28, 2024
16b8719
fix(test): fix incorrect test cases for aux, keygen, presign.
NhoxxKienn Nov 28, 2024
a35228e
code: clean up code.
NhoxxKienn Nov 28, 2024
347a179
feat(test): improve branch coverage.
NhoxxKienn Nov 28, 2024
108c95d
Merge branch 'master' into test
NhoxxKienn Dec 5, 2024
ae45b5c
Merge branch 'feature/keygen_aux' into test
NhoxxKienn Dec 5, 2024
5027814
fix(code):fix problems regarding merge
NhoxxKienn Dec 5, 2024
9714eae
refactor(style): remove redundant newlines and "\n" characters.
NhoxxKienn Dec 7, 2024
374f755
refactor(style): fix style analysis problems and move jacobi to Helpe…
NhoxxKienn Dec 7, 2024
e461d57
fix(doc): remove redundant documentation of exceptions and remove the…
NhoxxKienn Dec 7, 2024
f499aeb
Merge branch 'feature/keygen_aux' into update_doc
NhoxxKienn Dec 7, 2024
6e503a4
Merge branch 'feature/keygen_aux' into test
NhoxxKienn Dec 7, 2024
529d1a2
feat(readme): add code testplan section
NhoxxKienn Dec 7, 2024
1cb4486
fix(zero_knowledge): refactor package name for zk after refactored.
NhoxxKienn Dec 7, 2024
a60b982
Merge branch 'feature/keygen_aux' into update_doc
NhoxxKienn Dec 7, 2024
7c8c8a6
Merge branch 'feature/keygen_aux' into test
NhoxxKienn Dec 7, 2024
79b6167
fix(ci/cd); fix CI naming and allowed the process to run on PR to fea…
NhoxxKienn Dec 7, 2024
715499a
fix(Main): fix merge problems with feature/keygen_aux
NhoxxKienn Dec 7, 2024
2757f51
fix(zk) remove redundant zk packages after merge.
NhoxxKienn Dec 7, 2024
fb0f6ec
Merge pull request #6 from perun-network/feature/keygen_aux
NhoxxKienn Dec 11, 2024
dfec719
fix(doc): fix incorrect documentation.
NhoxxKienn Dec 12, 2024
7bb1d24
Merge pull request #8 from perun-network/update_doc
cryptphil Dec 13, 2024
5c344c8
fix(test): clean up test documentation.
NhoxxKienn Dec 13, 2024
e394eea
Merge branch 'master' into test
NhoxxKienn Dec 13, 2024
bd49201
Merge pull request #7 from perun-network/test
NhoxxKienn Dec 14, 2024
4b519b8
Merge branch 'main' into master
NhoxxKienn Dec 14, 2024
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
62 changes: 62 additions & 0 deletions .github/workflows/ci_cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: CI
on:
workflow_dispatch:

push:
branches:
- master
pull_request:
branches:
- master
- feature/keygen_aux

jobs:
build:
name: Build and Test
runs-on: ubuntu-latest

steps:
# Step 1: Checkout the repository
- name: Checkout code
uses: actions/checkout@v3

# Step 2: Set up JDK for Kotlin
- name: Set up JDK
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: 11

# Step 3: Cache Gradle dependencies
- name: Cache Gradle dependencies
uses: actions/cache@v3
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-

# Step 4: Build the project
- name: Build project
run: ./gradlew build

# Step 5: Run tests with code coverage verification
- name: Run tests and verify coverage
run: ./gradlew test

# Step 6: Generate code coverage report
- name: Generate code coverage report
run: ./gradlew jacocoTestReport

# Step 7: Upload code coverage report as artifact
- name: Generate Coverage Badge
uses: cicirello/jacoco-badge-generator@v2
with:
jacoco-csv-file: build/reports/jacoco/test/jacocoTestReport.csv
badges-directory: build/reports/jacoco/test/html/badges

- name: Publish coverage report to GitHub Pages
# if: ${{ github.ref == 'refs/heads/master' }}
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: build/reports/jacoco/test/html
76 changes: 65 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
# Threshold ECDSA Signature

[![Test Coverage](https://github.com/perun-network/ecdsa-threshold/blob/gh-pages/badges/jacoco.svg?raw=true)](https://perun-network.github.io/ecdsa-threshold/)
[![CI](https://github.com/perun-network/ecdsa-threshold/actions/workflows/ci_cd.yml/badge.svg?branch=keygen)](https://github.com/perun-network/ecdsa-threshold/actions/workflows/ci_cd.yml)
[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)

This project implements the threshold ECDSA protocol by [Canetti et al.](https://eprint.iacr.org/2021/060) (2021) that achieves non-interactive signing using 3 preprocessing rounds.
It further provides malicious security and identifiable aborts.

We provide an implementation of the protocol in Kotlin using the secp256k1 elliptic curve.

The report on threshold ECDSA signatures for Atala PRISM and the project timeline can be found in the [Wiki](https://github.com/perun-network/atala-prism-threshold/wiki/Threshold-ECDSA-Signatures-for-Atala-PRISM-Report).
Expand All @@ -13,6 +18,7 @@ The report on threshold ECDSA signatures for Atala PRISM and the project timelin
- [Requirements](#requirements)
- [Installation](#installation)
- [Usage](#usage)
- [Test](#test)
- [Code Structure](#code-structure)
- [Limitations](#limitations)
- [Copyright](#copyright)
Expand All @@ -21,38 +27,40 @@ The report on threshold ECDSA signatures for Atala PRISM and the project timelin

- Threshold ECDSA signing with preprocessing, where subsets of t signers can create signatures in one round.
- Implementation of the Paillier encryption scheme and Pedersen commitments.
- Zero-knowledge proofs for Paillier encryptions, which are during the signing process.
- Zero-knowledge proofs to prove the validity of computations along the execution of the protocol.
- The protocol can be integrated to [Apollo](https://github.com/hyperledger/identus-apollo) to be used in crypto services and the threshold Signature can be translated to Apollo's ECDSA Secp256k1 implementation.

## Architecture

The project is structured into several packages:

- **`ecdsa`**: Core ECDSA functionalities and mathematical operations.
- **`keygen`**: Key generation and precomputation.
- **`precomp`**: Centralized key generation and precomputation.
- **`math`**: Mathematical operations and utilities used throughout the signing process.
- **`paillier`**: Implementation of the Paillier cryptosystem for encryption.
- **`pedersen`**: Pedersen commitment scheme with parameter generation.
- **`presign`**: Management of the presigning process, including rounds of communication and computations between signers.
- **`sign`**: Signing process management and partial signature combination.
- **`keygen`**: 3-round Key generation protocol.
- **`aux`**: 3-round key refresh/auxiliary-info protocol.
- **`presign`**: 3-round presigning protocol.
- **`zero_knowledge`**: Zero-knowledge proof implementations.

## Requirements

- Kotlin 1.5 or higher
- Java Development Kit (JDK) 8 or higher
- Java Development Kit (JDK) 11 or higher
- Dependencies for cryptographic operations (included in the project)

## Installation

1. **Clone the Repository**:
```bash
git clone https://github.com/yourusername/ecdsa-threshold-signing.git
git clone https://github.com/perun-network/atala-prism-threshold.git
```

2. **Navigate to the Project Directory**:
```bash
cd ecdsa-threshold-signing
cd ecdsa-threshold
```

3. **Build the Project**:
Expand All @@ -73,29 +81,75 @@ The main entry point for the threshold signing process is located in the `main`

The application will output the execution time and confirm if the ECDSA signature was generated and verified successfully.

## Test
This section describes the testing strategy and tools used to maintain code quality and reliability.

### Testing Frameworks and Tools
- **Framework**: The project uses [JUnit 5](https://junit.org/junit5/) for unit and integration testing.
- **Build Tool Integration**: Tests are executed using Gradle's test task.

### Unit Tests and Integration Tests.
- Test individual components (e.g., classes, functions) in isolation.
- Validate interactions between components.
- Located in `src/test/kotlin`.

### Running Tests
To execute tests locally:

- **Run all tests**:
```bash
./gradlew test
```
- **Run a specific test class:
```bash
./gradlew test --tests <class_name>
```
### Test Coverage Report
The project uses [JaCoCo](https://www.eclemma.org/jacoco/) to measure test coverage.

1. Generate Coverage Report: Run the following command to generate the coverage report:
```bash
./gradlew jacocoTestReport
```
2. View the Report: The HTML report is available at:
```bash
build/reports/jacoco/test/html/index.html
```
or online at
[Test Report](https://perun-network.github.io/ecdsa-threshold/)

3. Coverage Standards:
- Instruction coverage: 90% or higher.
- Branches coverage: 80% or higher
- Critical areas must be thoroughly covered.

## Code Structure
- **`src`**: Contains all source code.
- **`main`**: Contains main functionality.
- **`ecdsa`**: Core functionalities.
- **`keygen`**: Key generation and precomputation.
- **`precomp`**: Centralized key generation and precomputation.
- **`math`**: Mathematical operations and utilities.
- **`paillier`**: Paillier cryptosystem implementation.
- **`pedersen`**: Pedersen commitment management.
- **`presign`**: Presigning process management.
- **`sign`**: Signing process management.
- **`zkproof`**: Zero-knowledge proof implementations.
- **`keygen`**: Keygen process management.
- **`aux`**: Aux-Info process management.
- **`presign`**: Presigning process management.
- **`zero_knowledge`**: Zero-knowledge proof implementations.

- **`test`**: Contains functionality test.
- **`ecdsa`**: Contains unit test for the Secp256k1 ECDSA signatures.
- **`math`**: Contains unit test for the `math` classes.
- **`paillier`**: Contains unit test for the Paillier encryption scheme.
- **`precomp`**: Contains unit test for the `precomputation` classes.
- **`sign`**: Contains unit test for the signing of Threshold ECDSA.
- **`zk`**: Contains unit test for zero-knowledge implementations.

## Limitations
The current implementation is currently lacking some intended features:

- Distributed key generation protocol by [Canetti et al.](https://eprint.iacr.org/2021/060) have not been fully implemented. (Currently centralized)
- Missing key refresh and adversary identification protocols.
- Main currently using precomputed secret primes to generate precomputations. This is to speed up the process. It is expected to have an accelerated prime generator incorporated in the precomputation phase.
- Parallelization of Broadcast communication.

---
## Copyright
Expand Down
34 changes: 31 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
plugins {
kotlin("jvm") version "2.0.0"
id("org.jetbrains.kotlin.plugin.serialization") version "2.0.20-RC2"
id("jacoco")
}

group = "perun_network.ecdsa_threshold"
Expand All @@ -11,9 +12,11 @@ repositories {
maven("https://jitpack.io")
}


dependencies {
// define the BOM and its version
// define the BOM and its version
implementation(platform("org.kotlincrypto.hash:bom:0.5.3"))
implementation("org.kotlincrypto.hash:sha2")
testImplementation(kotlin("test"))
implementation(kotlin("stdlib"))
implementation("org.jetbrains.kotlinx:kotlinx-serialization-cbor:1.7.1")
Expand All @@ -22,13 +25,38 @@ dependencies {
implementation("org.jetbrains.kotlin:kotlin-reflect:1.5.0")
implementation("fr.acinq.secp256k1:secp256k1-kmp:0.15.0")
implementation("fr.acinq.secp256k1:secp256k1-kmp-jni-jvm:0.15.0")
implementation("org.kotlincrypto.hash:sha2")

implementation("com.ionspin.kotlin:bignum:0.3.8")
// Add Kotlin Logging
implementation("io.github.microutils:kotlin-logging:3.0.5")
implementation("ch.qos.logback:logback-classic:1.4.11")

}

tasks.test {
useJUnitPlatform()
}
kotlin {
jvmToolchain(11)
}
}


jacoco {
toolVersion = "0.8.10" // Adjust to the latest JaCoCo version
}

tasks.jacocoTestReport {
reports {
csv.required.set(true)
xml.required.set(true) // Generate XML report
html.required.set(true) // Generate HTML report
}
classDirectories.setFrom(files(classDirectories.files.map {
fileTree(it) {
setExcludes(listOf(
"**/MainKt.class",
"perun_network/ecdsa_threshold/tuple/*",
))
}
}))
}
Loading
Loading