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

invalid enc_keys in gg20_keygen #103

Closed Ljiacheng closed 3 years ago

Ljiacheng commented 3 years ago

Hi, I have tried many times to run gg20_keygen_client, and I find a panic here:

_["round1"] party 2 => party 1 ["round1"] party 3 => party 1 ["round2"] party 2 => party 1 ["round2"] party 3 => party 1 thread 'main' panicked at 'assertion failed: key.len() == 16 || key.len() == 24 || key.len() == 32', /home/abmatrix/.cargo/registry/src/github.com-1ecc6299db9ec823/rust-crypto-0.2.36/src/aes_gcm.rs:23:9 note: run with RUST_BACKTRACE=1 environment variable to display a backtrace_

It happens when use function aes_encrypt() or aes_decrypt(). And I find the actual key.len() is allways 31. So I think the problem is caused by enc_keys. I don't know how it happens. May gg20_sign_client also has this problem? This panic does not happen every time, but it will happen as more times you try.

omershlo commented 3 years ago

Hi @Turntogamer ! thanks for opening this issue, I will fix it now and update. It is a very easy fix, what happens is that since the key is random it sometimes happens that the leading bits are zero and therefore key length do not match the check

Ljiacheng commented 3 years ago

Oh, thanks for your fast reply, now I know the reason :)

omershlo commented 3 years ago

please check: https://github.com/ZenGo-X/multi-party-ecdsa/commit/685889e61e11a68607678218f84e1d3cc884044d