ZenGo-X / multi-party-ecdsa

Rust implementation of {t,n}-threshold ECDSA (elliptic curve digital signature algorithm).
GNU General Public License v3.0
975 stars 308 forks source link

A small code suggest for gg20_sign_client #104

Closed Ljiacheng closed 3 years ago

Ljiacheng commented 3 years ago

If we run gg20_keygen_client in order(terminals: 1, 2, 3) and run gg20_sign_client, we can only run 1, 2 in order (the leader t+1 parties). If we try to run sign_client like 1,3 or 2,3 or 2,1 we will get this panic:

number: 1, uuid: "8729ac74-53d8-4cb5-be9e-9f90fcbf6a58" ["round0"] party 2 => party 1 ["round1"] party 2 => party 1 thread 'main' panicked at 'assertion failed: (left == right) left: 1, right: 2', examples/gg20_sign_client.rs:182:5 note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

here is my suggest: change the code: _if k != (party_numint - 1) as usize into _if k != signers_vec[party_numint as usize - 1] as usize at gg20_sign_client: line 174. Then we can run terminals in any order (like 2,1 or 2,3). In my test,every terminal generates their own keys.store and read it to sign. But i'm not sure if it is correct, you can make a check.

omershlo commented 3 years ago

awesome, I was just about to push a fix for your previous issue, let me add this one as well!

omershlo commented 3 years ago

I agree with your suggested fix.
added it to latest commit, please check: https://github.com/ZenGo-X/multi-party-ecdsa/commit/685889e61e11a68607678218f84e1d3cc884044d