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 to [email protected] #144

Merged
merged 98 commits into from
Jan 4, 2022
Merged
Show file tree
Hide file tree
Changes from 97 commits
Commits
Show all changes
98 commits
Select commit Hold shift + click to select a range
a35b6c9
Use [email protected].
tmpfs Oct 20, 2021
f901368
Update rust-paillier dependency.
tmpfs Oct 20, 2021
52821e9
Update zk-paillier dependency.
tmpfs Oct 20, 2021
4f61db2
Update curv dependency to 0.9.
tmpfs Oct 20, 2021
9743c00
Prefer cargo dependencies.
tmpfs Oct 20, 2021
d8949ca
Prefer cargo dependency.
tmpfs Oct 20, 2021
b1cf458
Removing obsolete imports.
tmpfs Oct 21, 2021
5a3d855
Update to sha2::Sha256 in gg_2018/party_i.
tmpfs Oct 21, 2021
5696853
Update NICorrectKeyProof -> NiCorrectKeyProof.
tmpfs Oct 21, 2021
88d8833
Update to sha2::Sha256 in lindell_2017/party_one.
tmpfs Oct 21, 2021
2dbd434
Update to sha2::Sha256.
tmpfs Oct 21, 2021
422354c
Use Point::<Secp256k1> for GE.
tmpfs Oct 21, 2021
a97175a
Update FE to Scalar::<Secp256k1>.
tmpfs Oct 21, 2021
451ecab
Update calls to ECScalar::new_random().
tmpfs Oct 21, 2021
00ceb01
Update calls to ECScalar::from.
tmpfs Oct 21, 2021
5d24676
Update calls to ECPoint::generator.
tmpfs Oct 21, 2021
b63848f
Use IncorrectProof error type.
tmpfs Oct 21, 2021
189af0b
Fix ECPoint trait reference.
tmpfs Oct 21, 2021
217d9c2
Update proof generic type to Sha256.
tmpfs Oct 21, 2021
532ad58
Update type for VerifiableSS.
tmpfs Oct 21, 2021
7b44be6
Fix proof Curve type.
tmpfs Oct 21, 2021
ec0aec6
Update calls to create_hash().
tmpfs Oct 22, 2021
afb497b
Update calls to bytes_compressed_to_big_int().
tmpfs Oct 22, 2021
f648ab4
Use DigestExt trait.
tmpfs Oct 22, 2021
8615134
Update calls to to_big_int().
tmpfs Oct 22, 2021
0fafd30
Update travis config
Oct 22, 2021
281d9a2
Merge branch 'master' of https://github.com/ZenGo-X/multi-party-ecdsa…
tmpfs Oct 25, 2021
b31d5d1
Merge branch 'curv-0.8' of github.com:tmpfs/multi-party-ecdsa into cu…
tmpfs Oct 25, 2021
cd27710
Use concrete types over Curve type parameter.
tmpfs Oct 25, 2021
3f12a71
Tidy unused imports.
tmpfs Oct 25, 2021
f35b0a3
Fix references and HashCommitment type.
tmpfs Oct 25, 2021
3b73d5b
Handle u16 to usize mismatch.
tmpfs Oct 25, 2021
fae5444
Update HashCommitment types.
tmpfs Oct 25, 2021
fdc955d
Replace calls to q() with group_order().
tmpfs Oct 25, 2021
d5b3beb
Various compiler fixes.
tmpfs Oct 25, 2021
9d5ae05
Fix calls to x_coor() and y_coor().
tmpfs Oct 25, 2021
3ef1a12
Various compiler fixes.
tmpfs Oct 26, 2021
ecda23d
Fix arithmetic errors.
tmpfs Oct 26, 2021
fb46bb4
Remove calls to get_element().
tmpfs Oct 26, 2021
3ca8233
Fix more errors.
tmpfs Oct 26, 2021
e8988d0
Fix from conversion for Cow.
tmpfs Oct 26, 2021
341de78
Use unwrap() for invert().
tmpfs Oct 26, 2021
524d803
More Cow fixes.
tmpfs Oct 26, 2021
b7befca
Arithmetic fix and point handling.
tmpfs Oct 26, 2021
4c5a943
Run cargo fmt.
tmpfs Oct 26, 2021
cc5cb11
More usize to u16 conversion.
tmpfs Oct 26, 2021
39e2898
Fix DLogProof type error.
tmpfs Oct 26, 2021
0f74cb2
Remove obsolete calls to zeroize().
tmpfs Oct 27, 2021
e82a85a
Remove zeroize dependency.
tmpfs Oct 27, 2021
dab17fd
WIP: appeasing the borrow checker.
tmpfs Oct 27, 2021
84652e2
WIP: more borrow checker fixes.
tmpfs Oct 27, 2021
2785351
WIP: more borrow checker fixes.
tmpfs Oct 28, 2021
6b9c4ae
WIP: more borrow checker fixes.
tmpfs Oct 28, 2021
65552b1
WIP: more borrow checker fixes.
tmpfs Oct 28, 2021
6f21f90
WIP: more borrow checker fixes.
tmpfs Oct 28, 2021
b4b48d4
Appease the borrow checker!
tmpfs Oct 28, 2021
e6b79ef
Add rust-toolchain file.
tmpfs Oct 28, 2021
74d16f8
Fixing test spec compiler errors.
tmpfs Oct 28, 2021
e09085b
Handle u16 conversion in test specs.
tmpfs Oct 28, 2021
7300b30
Fixing benchmark compiler errors.
tmpfs Oct 28, 2021
b7b3b61
Replace pk_to_key_slice() with to_bytes(false).
tmpfs Oct 28, 2021
b677cd6
Fix test spec compiler errors.
tmpfs Oct 28, 2021
20589e5
Fix examples proof type parameters.
tmpfs Oct 28, 2021
0390da6
Fix for pk_to_key_slice() and get_element().
tmpfs Oct 28, 2021
d25590d
Fix examples compiler errors.
tmpfs Oct 28, 2021
d778c4b
Remove redundant allocations, prettify some of the code
Nov 3, 2021
664774d
Remove redundant unwraps
Nov 3, 2021
e41685e
Fix tests
Nov 3, 2021
79f13a8
Merge branch 'master' into curv-0.8
tmpfs Nov 4, 2021
ab79128
Start fixing compiler errors after rebase.
tmpfs Nov 4, 2021
edd678f
Remove zeroize attributes.
tmpfs Nov 4, 2021
ff4f08c
Fix more errors after rebase.
tmpfs Nov 4, 2021
ab296ba
Run cargo fmt.
tmpfs Nov 4, 2021
f2bd73f
Appease the borrow checker.
tmpfs Nov 4, 2021
55a35ee
Keys for gg_2020 is generic over Curve.
tmpfs Nov 8, 2021
90eef24
Keys for gg_2018 is generic over Curve.
tmpfs Nov 8, 2021
8bea2a8
LocalKey is generic over Curve.
tmpfs Nov 8, 2021
2d803a9
Fix benchmarks for Keys type parameter.
tmpfs Nov 8, 2021
eaf0b4b
Restore Zeroize attributes in range_proof.rs.
tmpfs Nov 9, 2021
68b584a
Tidy unused imports and generate() function.
tmpfs Nov 9, 2021
7531751
Run cargo fmt.
tmpfs Nov 9, 2021
53cc920
Use class_group from crates.io
Nov 9, 2021
545ba12
Start fixing clippy warnings
Nov 9, 2021
7d7de59
Fix more clippy warnings.
tmpfs Nov 10, 2021
f250d54
Use custom errors instead of unit type.
tmpfs Nov 10, 2021
0655909
Remove some types redundancy
Nov 11, 2021
22b2673
cargo fmt
Nov 11, 2021
631f331
Fix cclst compilation errors
Nov 11, 2021
98b6633
Fix tests
Nov 11, 2021
b98fe66
Fix remaining clippy warnings
Nov 11, 2021
96f49e2
Major version bump
Nov 11, 2021
cf4ea7f
Prettify gg18/party_i imports
Nov 19, 2021
d0391e4
Use u16 instead of usize
Nov 19, 2021
84fd325
Prettify the code
Nov 19, 2021
9d6b871
Fix examples
Dec 9, 2021
905208d
fix benches
DmytroTym Dec 17, 2021
dcc2086
Merge pull request #1 from DmytroTym/curv-0.8
tmpfs Dec 20, 2021
d9067bd
cargo fmt
Dec 29, 2021
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
19 changes: 16 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
language: rust
cache: cargo
rust:
- nightly
rust: nightly
virt: lxd

before_install:
- rustup component add rustfmt clippy

script:
- cargo build --verbose
- cargo build --benches --verbose
- cargo test --verbose
- cargo fmt --all -- --check
- cargo clippy -- -D clippy::all

deploy:
provider: cargo
token:
secure: "QChykAD/vntzVNHePGuCHRNyLJwiqRAqIYw1uCqWVaca5IYMuItv2Qs6hShWt8AVQ631ZC5O5mnYTsPyxO3ZLZAPM/UEtmJiR9zf7v9DJyPPyyaT9kw+YrELVwit/xab2uJzJIZ1mBHSx0An/67gfdTITLjQmW2UVPhu3pdUz3rSrYBxp2quD7OgMfHeXXP8yk2xtZIXQ2mcNuNPnEkCk/siGTyS1Py/cpEFBsGfHSMPLyZq9Mn/PFPttPtebZiWUPvfDHFqbTd73SB2DmJrrdJ/rpeiHKNuPJUbc8qA1yDQjLATUNmDXjg+q8gcPIraj+zifeR6M+TIG0tLPU1NKVI1Oxta1CUurV+m5qY9YmFxtNyTNquOI4ehbckXADgZhIOLDD9/rfYETXdkxXwYh0WozNOp+yqZj+wGqFfxB3+DfMRKk/ooYQqCYJ2Pun+SzTSnv2REa0Sa70a67hADMV6h6qfumEq3XxgKouNHd3gg+b1urB6JKfL8RI9SrOwKgkU/mBl+qCzP+UwAUPqnzp/r9GONm86gsUZXuhwDJmru30B9YLOrzwnKdGjZEBWDV6OuT5p9e1R+rot069qeTqMOiu8ZAAulttBAEpFoG99vTW1elE3aSBasVa9/YS0M1kY4n4Yz8GTP8w8p9WXM6hX6MU8iR//hPsNHQiNwJws="
on:
tags: true
condition: '"$TRAVIS_TAG" =~ ^v[0-9].+$'
30 changes: 10 additions & 20 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "multi-party-ecdsa"
version = "0.7.4"
version = "0.8.0"
edition = "2018"
authors = [
"Gary <[email protected]>",
Expand All @@ -26,37 +26,30 @@ categories = ["cryptography"]
crate-type = ["lib"]

[features]
default = ["curv/rust-gmp-kzen"]
default = ["curv-kzen/rust-gmp-kzen"]
cclst = ["class_group"]

[dependencies]
subtle = { version = "2" }
serde = { version = "1.0", features = ["derive"] }
zeroize = "1"
libsecp256k1 = "0.3.2"
curv = { package = "curv-kzen", version = "0.7", default-features = false }
curv-kzen = { version = "0.9", default-features = false }
centipede = { version = "0.3", default-features = false }
zk-paillier = { version = "0.4.2", default-features = false }
round-based = { version = "0.1.4", features = [] }
thiserror = "1.0.23"
derivative = "2"

[dependencies.centipede]
git = "https://github.com/KZen-networks/centipede"
tag = "v0.2.12"
default-features = false
sha2 = "0.9"

[dependencies.paillier]
git = "https://github.com/KZen-networks/rust-paillier"
tag = "v0.3.10"
default-features = false

[dependencies.zk-paillier]
git = "https://github.com/KZen-networks/zk-paillier"
tag = "v0.3.12"
version = "0.4.2"
package = "kzen-paillier"
default-features = false

[dependencies.class_group]
git = "https://github.com/KZen-networks/class"
tag = "v0.5.2"
version = "0.6"
default-features = false
optional = true

[dev-dependencies]
Expand All @@ -73,9 +66,6 @@ rand = "0.7"
thiserror = "1.0.23"
round-based = { version = "0.1.4", features = ["dev"] }

[patch.crates-io]
rust-gmp = { version = "0.5.0", features = ["serde_support"], git = "https://github.com/KZen-networks/rust-gmp" }

[[example]]
name = "sm_manager"

Expand Down
39 changes: 26 additions & 13 deletions benches/multi_party_ecdsa/gg18/keygen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ use criterion::criterion_main;
mod bench {
use criterion::{criterion_group, Criterion};
use curv::cryptographic_primitives::secret_sharing::feldman_vss::VerifiableSS;
use curv::elliptic::curves::secp256_k1::{FE, GE};
use curv::elliptic::curves::traits::*;
use curv::elliptic::curves::{secp256_k1::Secp256k1, Point, Scalar};
use multi_party_ecdsa::protocols::multi_party_ecdsa::gg_2018::party_i::*;
pub fn bench_full_keygen_party_one_two(c: &mut Criterion) {
c.bench_function("keygen t=1 n=2", move |b| {
Expand All @@ -23,13 +22,19 @@ mod bench {
pub fn keygen_t_n_parties(
t: u16,
n: u16,
) -> (Vec<Keys>, Vec<SharedKeys>, Vec<GE>, GE, VerifiableSS<GE>) {
) -> (
Vec<Keys>,
Vec<SharedKeys>,
Vec<Point<Secp256k1>>,
Point<Secp256k1>,
VerifiableSS<Secp256k1>,
) {
let parames = Parameters {
threshold: t,
share_count: n,
};
let (t, n) = (t as usize, n as usize);
let party_keys_vec = (0..n).map(Keys::create).collect::<Vec<Keys>>();
let party_keys_vec = (0..n).map(|i| Keys::create(i as u16)).collect::<Vec<Keys>>();

let mut bc1_vec = Vec::new();
let mut decom_vec = Vec::new();
Expand All @@ -40,7 +45,9 @@ mod bench {
decom_vec.push(decom1);
}

let y_vec = (0..n).map(|i| decom_vec[i].y_i).collect::<Vec<GE>>();
let y_vec = (0..n)
.map(|i| decom_vec[i].y_i.clone())
.collect::<Vec<Point<Secp256k1>>>();
let mut y_vec_iter = y_vec.iter();
let head = y_vec_iter.next().unwrap();
let tail = y_vec_iter;
Expand All @@ -56,7 +63,7 @@ mod bench {
.expect("invalid key");
vss_scheme_vec.push(vss_scheme);
secret_shares_vec.push(secret_shares);
index_vec.push(index);
index_vec.push(index as u16);
}
let vss_scheme_for_test = vss_scheme_vec.clone();

Expand All @@ -65,11 +72,11 @@ mod bench {
(0..n)
.map(|j| {
let vec_j = &secret_shares_vec[j];
vec_j[i]
vec_j[i].clone()
})
.collect::<Vec<FE>>()
.collect::<Vec<Scalar<Secp256k1>>>()
survived marked this conversation as resolved.
Show resolved Hide resolved
})
.collect::<Vec<Vec<FE>>>();
.collect::<Vec<Vec<Scalar<Secp256k1>>>>();

let mut shared_keys_vec = Vec::new();
let mut dlog_proof_vec = Vec::new();
Expand All @@ -80,24 +87,30 @@ mod bench {
&y_vec,
&party_shares[i],
&vss_scheme_vec,
&index_vec[i] + 1,
(&index_vec[i] + 1).into(),
)
.expect("invalid vss");
shared_keys_vec.push(shared_keys);
dlog_proof_vec.push(dlog_proof);
}

let pk_vec = (0..n).map(|i| dlog_proof_vec[i].pk).collect::<Vec<GE>>();
let pk_vec = (0..n)
.map(|i| dlog_proof_vec[i].pk.clone())
.collect::<Vec<Point<Secp256k1>>>();

//both parties run:
Keys::verify_dlog_proofs(&parames, &dlog_proof_vec, &y_vec).expect("bad dlog proof");

//test
let xi_vec = (0..=t).map(|i| shared_keys_vec[i].x_i).collect::<Vec<FE>>();
let xi_vec = (0..=t)
.map(|i| shared_keys_vec[i].x_i.clone())
.collect::<Vec<Scalar<Secp256k1>>>();
let x = vss_scheme_for_test[0]
.clone()
.reconstruct(&index_vec[0..=t], &xi_vec);
let sum_u_i = party_keys_vec.iter().fold(FE::zero(), |acc, x| acc + x.u_i);
let sum_u_i = party_keys_vec
.iter()
.fold(Scalar::<Secp256k1>::zero(), |acc, x| acc + &x.u_i);
assert_eq!(x, sum_u_i);

(
Expand Down
4 changes: 2 additions & 2 deletions benches/two_party_ecdsa/cclst_2019/keygen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ mod bench {

let (party_one_first_message, comm_witness, ec_key_pair_party1) =
party_one::KeyGenFirstMsg::create_commitments_with_fixed_secret_share(
ECScalar::new_random(),
Scalar::<Secp256k1>::random(),
);
let (party_two_first_message, _ec_key_pair_party2) =
party_two::KeyGenFirstMsg::create_with_fixed_secret_share(ECScalar::from(&BigInt::from(
party_two::KeyGenFirstMsg::create_with_fixed_secret_share(Scalar::<Secp256k1>::from(&BigInt::from(
10,
)));
let party_one_second_message = party_one::KeyGenSecondMsg::verify_and_decommit(
Expand Down
10 changes: 5 additions & 5 deletions benches/two_party_ecdsa/lindell_2017/keygen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use criterion::criterion_main;
mod bench {
use criterion::{criterion_group, Criterion};
use curv::arithmetic::traits::Samplable;
use curv::elliptic::curves::traits::*;
use curv::elliptic::curves::{secp256_k1::Secp256k1, Scalar};
use curv::BigInt;
use multi_party_ecdsa::protocols::two_party_ecdsa::lindell_2017::*;

Expand All @@ -12,12 +12,12 @@ mod bench {
b.iter(|| {
let (party_one_first_message, comm_witness, ec_key_pair_party1) =
party_one::KeyGenFirstMsg::create_commitments_with_fixed_secret_share(
ECScalar::from(&BigInt::sample(253)),
Scalar::<Secp256k1>::from(&BigInt::sample(253)),
);
let (party_two_first_message, _ec_key_pair_party2) =
party_two::KeyGenFirstMsg::create_with_fixed_secret_share(ECScalar::from(
&BigInt::from(10),
));
party_two::KeyGenFirstMsg::create_with_fixed_secret_share(
Scalar::<Secp256k1>::from(&BigInt::from(10)),
);
let party_one_second_message = party_one::KeyGenSecondMsg::verify_and_decommit(
comm_witness,
&party_two_first_message.d_log_proof,
Expand Down
34 changes: 16 additions & 18 deletions examples/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ use crypto::{
};
use curv::{
arithmetic::traits::Converter,
elliptic::curves::secp256_k1::{FE, GE},
elliptic::curves::traits::{ECPoint, ECScalar},
elliptic::curves::{secp256_k1::Secp256k1, Point, Scalar},
BigInt,
};
use reqwest::Client;
Expand Down Expand Up @@ -55,7 +54,7 @@ pub fn aes_encrypt(key: &[u8], plaintext: &[u8]) -> AEAD {
let mut gcm = AesGcm::new(KeySize256, key, &nonce[..], &aad);
let mut out: Vec<u8> = repeat(0).take(plaintext.len()).collect();
let mut out_tag: Vec<u8> = repeat(0).take(16).collect();
gcm.encrypt(&plaintext[..], &mut out[..], &mut out_tag[..]);
gcm.encrypt(plaintext, &mut out[..], &mut out_tag[..]);
AEAD {
ciphertext: out.to_vec(),
tag: out_tag.to_vec(),
Expand Down Expand Up @@ -103,12 +102,9 @@ pub fn broadcast(
sender_uuid: String,
) -> Result<(), ()> {
let key = format!("{}-{}-{}", party_num, round, sender_uuid);
let entry = Entry {
key: key.clone(),
value: data,
};
let entry = Entry { key, value: data };

let res_body = postb(&client, "set", entry).unwrap();
let res_body = postb(client, "set", entry).unwrap();
serde_json::from_str(&res_body).unwrap()
}

Expand All @@ -122,12 +118,9 @@ pub fn sendp2p(
) -> Result<(), ()> {
let key = format!("{}-{}-{}-{}", party_from, party_to, round, sender_uuid);

let entry = Entry {
key: key.clone(),
value: data,
};
let entry = Entry { key, value: data };

let res_body = postb(&client, "set", entry).unwrap();
let res_body = postb(client, "set", entry).unwrap();
serde_json::from_str(&res_body).unwrap()
}

Expand Down Expand Up @@ -190,27 +183,32 @@ pub fn poll_for_p2p(
}

#[allow(dead_code)]
pub fn check_sig(r: &FE, s: &FE, msg: &BigInt, pk: &GE) {
pub fn check_sig(
r: &Scalar<Secp256k1>,
s: &Scalar<Secp256k1>,
msg: &BigInt,
pk: &Point<Secp256k1>,
) {
use secp256k1::{verify, Message, PublicKey, PublicKeyFormat, Signature};

let raw_msg = BigInt::to_bytes(&msg);
let raw_msg = BigInt::to_bytes(msg);
let mut msg: Vec<u8> = Vec::new(); // padding
msg.extend(vec![0u8; 32 - raw_msg.len()]);
msg.extend(raw_msg.iter());

let msg = Message::parse_slice(msg.as_slice()).unwrap();
let mut raw_pk = pk.pk_to_key_slice();
let mut raw_pk = pk.to_bytes(false).to_vec();
if raw_pk.len() == 64 {
raw_pk.insert(0, 4u8);
}
let pk = PublicKey::parse_slice(&raw_pk, Some(PublicKeyFormat::Full)).unwrap();

let mut compact: Vec<u8> = Vec::new();
let bytes_r = &r.get_element()[..];
let bytes_r = &r.to_bytes().to_vec();
compact.extend(vec![0u8; 32 - bytes_r.len()]);
compact.extend(bytes_r.iter());

let bytes_s = &s.get_element()[..];
let bytes_s = &s.to_bytes().to_vec();
compact.extend(vec![0u8; 32 - bytes_s.len()]);
compact.extend(bytes_s.iter());

Expand Down
Loading