Skip to content

Commit 4b00e86

Browse files
authored
Merge pull request #135 from LFDT-Lockness/update-cggmp24
Update cggmp24
2 parents a3d33e6 + aaa1b2c commit 4b00e86

22 files changed

+214
-45
lines changed

.github/workflows/deps.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ jobs:
1919
contents: read
2020
pull-requests: write
2121
steps:
22-
- uses: actions/checkout@v3
22+
- uses: actions/checkout@v4
2323
with:
2424
path: base_branch
2525
ref: ${{ github.base_ref }}
26-
- uses: actions/checkout@v3
26+
- uses: actions/checkout@v4
2727
with:
2828
path: pr_branch
2929
- name: Retrieve base branch deps

.github/workflows/docs.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
contents: read
1818
pull-requests: write
1919
steps:
20-
- uses: actions/checkout@v3
20+
- uses: actions/checkout@v4
2121
- name: Compile LaTeX document
2222
uses: xu-cheng/latex-action@v3
2323
with:
@@ -40,7 +40,7 @@ jobs:
4040
build_docs:
4141
runs-on: ubuntu-latest
4242
steps:
43-
- uses: actions/checkout@v3
43+
- uses: actions/checkout@v4
4444
- uses: dtolnay/rust-toolchain@nightly
4545
- uses: Swatinem/rust-cache@v2
4646
with:

.github/workflows/publish.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
github.ref_type == 'tag'
2323
&& startsWith(github.ref_name, 'v')
2424
steps:
25-
- uses: actions/checkout@v3
25+
- uses: actions/checkout@v4
2626
- run: cargo publish -p cggmp21
2727
env:
2828
CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_TOKEN }}
@@ -35,7 +35,7 @@ jobs:
3535
github.ref_type == 'tag'
3636
&& startsWith(github.ref_name, 'key-share-v')
3737
steps:
38-
- uses: actions/checkout@v3
38+
- uses: actions/checkout@v4
3939
- run: cargo publish -p key-share
4040
env:
4141
CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_TOKEN }}
@@ -48,7 +48,7 @@ jobs:
4848
github.ref_type == 'tag'
4949
&& startsWith(github.ref_name, 'cggmp21-keygen-v')
5050
steps:
51-
- uses: actions/checkout@v3
51+
- uses: actions/checkout@v4
5252
- run: cargo publish -p cggmp21-keygen
5353
env:
5454
CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_TOKEN }}
@@ -61,7 +61,7 @@ jobs:
6161
github.ref_type == 'tag'
6262
&& startsWith(github.ref_name, 'paillier-zk-v')
6363
steps:
64-
- uses: actions/checkout@v3
64+
- uses: actions/checkout@v4
6565
- run: cargo publish -p paillier-zk
6666
env:
6767
CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_TOKEN }}

.github/workflows/readme.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
check_readme:
1313
runs-on: ubuntu-latest
1414
steps:
15-
- uses: actions/checkout@v3
15+
- uses: actions/checkout@v4
1616
- name: Install cargo-hakari
1717
uses: baptiste0928/cargo-install@v1
1818
with:

.github/workflows/rust.yml

+13-13
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ jobs:
1515
build:
1616
runs-on: ubuntu-latest
1717
steps:
18-
- uses: actions/checkout@v3
18+
- uses: actions/checkout@v4
1919
- uses: Swatinem/rust-cache@v2
2020
with:
2121
cache-on-failure: "true"
2222
- name: Build
2323
run: cargo build --release --all-features
24-
- uses: actions/upload-artifact@v3
24+
- uses: actions/upload-artifact@v4
2525
with:
2626
name: benchmark-tool
2727
path: target/release/measure_perf
@@ -36,7 +36,7 @@ jobs:
3636
- cggmp21
3737
- paillier-zk
3838
steps:
39-
- uses: actions/checkout@v3
39+
- uses: actions/checkout@v4
4040
- uses: Swatinem/rust-cache@v2
4141
with:
4242
cache-on-failure: "true"
@@ -45,7 +45,7 @@ jobs:
4545
build-wasm-nostd:
4646
runs-on: ubuntu-latest
4747
steps:
48-
- uses: actions/checkout@v3
48+
- uses: actions/checkout@v4
4949
- uses: Swatinem/rust-cache@v2
5050
with:
5151
cache-on-failure: "true"
@@ -59,7 +59,7 @@ jobs:
5959
test-default-features:
6060
runs-on: ubuntu-latest
6161
steps:
62-
- uses: actions/checkout@v3
62+
- uses: actions/checkout@v4
6363
- uses: Swatinem/rust-cache@v2
6464
with:
6565
cache-on-failure: "true"
@@ -70,7 +70,7 @@ jobs:
7070
test-all-features:
7171
runs-on: ubuntu-latest
7272
steps:
73-
- uses: actions/checkout@v3
73+
- uses: actions/checkout@v4
7474
- uses: Swatinem/rust-cache@v2
7575
with:
7676
cache-on-failure: "true"
@@ -80,13 +80,13 @@ jobs:
8080
fmt:
8181
runs-on: ubuntu-latest
8282
steps:
83-
- uses: actions/checkout@v3
83+
- uses: actions/checkout@v4
8484
- name: Check formatting
8585
run: cargo fmt --all -- --check
8686
clippy:
8787
runs-on: ubuntu-latest
8888
steps:
89-
- uses: actions/checkout@v3
89+
- uses: actions/checkout@v4
9090
- uses: Swatinem/rust-cache@v2
9191
with:
9292
cache-on-failure: "true"
@@ -95,7 +95,7 @@ jobs:
9595
clippy-tests:
9696
runs-on: ubuntu-latest
9797
steps:
98-
- uses: actions/checkout@v3
98+
- uses: actions/checkout@v4
9999
- uses: Swatinem/rust-cache@v2
100100
with:
101101
cache-on-failure: "true"
@@ -106,7 +106,7 @@ jobs:
106106
runs-on: ubuntu-latest
107107
steps:
108108
- uses: dtolnay/rust-toolchain@nightly
109-
- uses: actions/checkout@v3
109+
- uses: actions/checkout@v4
110110
- uses: Swatinem/rust-cache@v2
111111
with:
112112
cache-on-failure: "true"
@@ -120,8 +120,8 @@ jobs:
120120
pull-requests: write
121121
needs: build
122122
steps:
123-
- uses: actions/checkout@v3
124-
- uses: actions/download-artifact@v3
123+
- uses: actions/checkout@v4
124+
- uses: actions/download-artifact@v4
125125
with:
126126
name: benchmark-tool
127127
- name: Set file permissions
@@ -138,6 +138,6 @@ jobs:
138138
check-changelog:
139139
runs-on: ubuntu-latest
140140
steps:
141-
- uses: actions/checkout@v3
141+
- uses: actions/checkout@v4
142142
- name: Check changelogs
143143
run: ./.github/changelog.sh

Cargo.lock

+24-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+3-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ paillier-zk = { version = "0.4.1", path = "paillier-zk", default-features = fals
1919

2020
generic-ec = { version = "0.4.1", default-features = false }
2121
generic-ec-zkp = { version = "0.4.1", default-features = false }
22-
round-based = { version = "0.4", default-features = false }
22+
round-based = { version = "0.4.1", default-features = false }
2323

2424
udigest = { version = "0.2.1", default-features = false }
2525

@@ -31,7 +31,8 @@ rand_core = { version = "0.6", default-features = false }
3131
rand_hash = { version = "0.1" }
3232
rand_dev = "0.1"
3333

34-
futures = "0.3"
34+
futures = { version = "0.3", default-features = false }
35+
futures-util = { version = "0.3", default-features = false }
3536

3637
anyhow = "1"
3738
thiserror = "1"

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ Our implementation has been audited by Kudelski. Report can be found [here][repo
5353

5454
> About notion of threshold and non-threshold keys: originally, CGGMP21 paper does not have support of
5555
arbitrary `t` and only works with non-threshold n-out-of-n keys. We have added support of arbitrary
56-
threshold $2 \le t \le n$, however, we made it possible to opt out therhsoldness so original CGGMP21
56+
threshold $2 \le t \le n$, however, we made it possible to opt out thresholdness so original CGGMP21
5757
protocol can be carried out if needed.
5858

5959
## Running the protocol
@@ -70,7 +70,7 @@ let outgoing: impl Sink<Outgoing<Msg>>;
7070

7171
where:
7272
* `Msg` is a protocol message (e.g., `signing::msg::Msg`)
73-
* `round_based::Incoming` and `round_based::Outgoing` wrap `Msg` and provide additional data (e.g., sender/recepient)
73+
* `round_based::Incoming` and `round_based::Outgoing` wrap `Msg` and provide additional data (e.g., sender/recipient)
7474
* `futures::Stream` and `futures::Sink` are well-known async primitives.
7575

7676
Once you have that, you can construct an `MpcParty`:
@@ -256,7 +256,7 @@ they are all documented in [the spec].
256256
## Timing attacks
257257
Timing attacks are type of side-channel attacks that leak sensitive information through duration of
258258
execution. We consider timing attacks out of scope as they are nearly impossible to perform for such
259-
complicated protcol as CGGMP21 and impossible to do in our specific deployment. Thus, we intentionally
259+
complicated protocol as CGGMP21 and impossible to do in our specific deployment. Thus, we intentionally
260260
don't do constant-time operations which gives us a significant performance boost.
261261

262262
## Join us in Discord!

cggmp21-keygen/Cargo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ serde = { workspace = true, features = ["derive"] }
2828
serde_with = { workspace = true }
2929
hex = { workspace = true, features = ["serde"] }
3030

31+
futures-util = { workspace = true }
32+
3133
displaydoc = { workspace = true }
3234
thiserror = { workspace = true, optional = true }
3335

cggmp21-keygen/src/threshold.rs

+8-7
Original file line numberDiff line numberDiff line change
@@ -271,21 +271,22 @@ where
271271

272272
tracer.send_msg();
273273
outgoings
274-
.send(Outgoing::broadcast(Msg::Round2Broad(
274+
.feed(Outgoing::broadcast(Msg::Round2Broad(
275275
my_decommitment.clone(),
276276
)))
277277
.await
278278
.map_err(IoError::send_message)?;
279279

280-
for j in utils::iter_peers(i, n) {
280+
let messages = utils::iter_peers(i, n).map(|j| {
281281
let message = MsgRound2Uni {
282282
sigma: sigmas[usize::from(j)],
283283
};
284-
outgoings
285-
.send(Outgoing::p2p(j, Msg::Round2Uni(message)))
286-
.await
287-
.map_err(IoError::send_message)?;
288-
}
284+
Outgoing::p2p(j, Msg::Round2Uni(message))
285+
});
286+
outgoings
287+
.send_all(&mut futures_util::stream::iter(messages.map(Ok)))
288+
.await
289+
.map_err(IoError::send_message)?;
289290
tracer.msg_sent();
290291

291292
// Round 3

cggmp21/src/key_refresh/aux_only.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -418,12 +418,16 @@ where
418418
fac_proof: phi.clone(),
419419
};
420420
outgoings
421-
.send(Outgoing::p2p(j, Msg::Round3(msg)))
421+
.feed(Outgoing::p2p(j, Msg::Round3(msg)))
422422
.await
423423
.map_err(IoError::send_message)?;
424424
tracer.msg_sent();
425425
}
426426

427+
tracer.send_msg();
428+
outgoings.flush().await.map_err(IoError::send_message)?;
429+
tracer.msg_sent();
430+
427431
// Output
428432
tracer.round_begins();
429433

cggmp21/src/key_refresh/non_threshold.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -523,12 +523,16 @@ where
523523
C,
524524
};
525525
outgoings
526-
.send(Outgoing::p2p(j, Msg::Round3(msg)))
526+
.feed(Outgoing::p2p(j, Msg::Round3(msg)))
527527
.await
528528
.map_err(IoError::send_message)?;
529529
tracer.msg_sent();
530530
}
531531

532+
tracer.send_msg();
533+
outgoings.flush().await.map_err(IoError::send_message)?;
534+
tracer.msg_sent();
535+
532536
// Output
533537
tracer.round_begins();
534538

cggmp21/src/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
//!
3636
//! > About notion of threshold and non-threshold keys: originally, CGGMP21 paper does not have support of
3737
//! arbitrary `t` and only works with non-threshold n-out-of-n keys. We have added support of arbitrary
38-
//! threshold $2 \le t \le n$, however, we made it possible to opt out therhsoldness so original CGGMP21
38+
//! threshold $2 \le t \le n$, however, we made it possible to opt out thresholdness so original CGGMP21
3939
//! protocol can be carried out if needed.
4040
//!
4141
//! ## Running the protocol
@@ -52,7 +52,7 @@
5252
//!
5353
//! where:
5454
//! * `Msg` is a protocol message (e.g., [`signing::msg::Msg`])
55-
//! * [`round_based::Incoming`] and [`round_based::Outgoing`] wrap `Msg` and provide additional data (e.g., sender/recepient)
55+
//! * [`round_based::Incoming`] and [`round_based::Outgoing`] wrap `Msg` and provide additional data (e.g., sender/recipient)
5656
//! * [`futures::Stream`] and [`futures::Sink`] are well-known async primitives.
5757
//!
5858
//! Once you have that, you can construct an [`MpcParty`](round_based::MpcParty):
@@ -281,7 +281,7 @@
281281
//! ## Timing attacks
282282
//! Timing attacks are type of side-channel attacks that leak sensitive information through duration of
283283
//! execution. We consider timing attacks out of scope as they are nearly impossible to perform for such
284-
//! complicated protcol as CGGMP21 and impossible to do in our specific deployment. Thus, we intentionally
284+
//! complicated protocol as CGGMP21 and impossible to do in our specific deployment. Thus, we intentionally
285285
//! don't do constant-time operations which gives us a significant performance boost.
286286
//!
287287
//! ## Join us in Discord!

0 commit comments

Comments
 (0)