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

Can't run both CCLST keygen and sign test at the same time #78

Open omershlo opened 4 years ago

omershlo commented 4 years ago

While running protocols::two_party_ecdsa::cclst_2019::test::tests::test_two_party_sign or protocols::two_party_ecdsa::cclst_2019::test::tests::test_full_key_gen is always working and passing. Trying to just cargo test --features=cclst returns a PARI error. Each time a different one:

It can sometimes work, while other times the following errors are received:

  ***   the PARI stack overflows !
  current stack size: 10000000 (9.537 Mbytes)
  [hint] set 'parisizemax' to a non-zero value in your GPRC

  ***   ***   Error in the PARI system. End of program.
  unknown type 31.  ***   Error in the PARI system. End of program
  ***   
the PARI stack overflows !
  current stack size: 10000000 (9.537 Mbytes)
  [hint] set 'parisizemax' to a non-zero value in your GPRC
  ***   Error in the PARI system. End of program.
  ***   unknown type 26.  ***   Error in the PARI system. End of program.

Might be connected topari_init in class_groups lib

trepca commented 4 years ago

happening to me too on MacOS 10.14.6 (PARI installed using homebrew). Have enabled parisizemax in .gprc but didn't help.

omershlo commented 4 years ago

thanks for reporting

omershlo commented 4 years ago

I got two reports for users that on their machines the problem did not occur. I will get more details on their setups. They suggested to consult : http://pari.math.u-bordeaux.fr/pub/pari/manuals/2.11.1/libpari.pdf page 17

omershlo commented 4 years ago

here are the setups that report of NO error: 1) Ubuntu 19.04, with rustc 1.39.0-nightly, gp/pari 2.11.1. I ran 60 times the cargo test --features=cclst without errors.

2) macOS Mojave 10.14.6 and installed rust in a virtualbox 6.0.10 r132072 with debian stable 10.1, rustc 1.39.0-nightly

trepca commented 4 years ago

I setup a fresh Ubuntu 19.04 on Digital Ocean with apt-get install build-essential llvm clang, installed with rustup nightly and still not working. I got a

  process didn't exit successfully: `/root/multi-party-ecdsa/target/debug/build/class_group-2cc3d835d71af03f/build-script-build` (exit code: 101)
--- stderr
wrapper.h:2:10: fatal error: 'pari/pari.h' file not found
wrapper.h:2:10: fatal error: 'pari/pari.h' file not found, err: true
thread 'main' panicked at 'Unable to generate bindings: ()', src/libcore/result.rs:1165:5

Then tried to install PARI via apt-get install pari-gp2c and it build but got a different error:

root@ubuntu-s-2vcpu-2gb-lon1-01:~/multi-party-ecdsa# RUST_BACKTRACE=1 cargo test --features=cclst
   Compiling class_group v0.1.4 (https://github.com/KZen-networks/class-groups?tag=v0.1.4#4501c2b8)
   Compiling multi-party-ecdsa v0.2.3 (/root/multi-party-ecdsa)
error[E0308]: mismatched types
   --> src/protocols/two_party_ecdsa/cclst_2019/party_one.rs:278:13
    |
278 |             GE::generator() * &party_one_private.x1,
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `curv::elliptic::curves::secp256_k1::Secp256k1Point`, found a different struct `curv::elliptic::curves::secp256_k1::Secp256k1Point`
    |
    = note: expected type `curv::elliptic::curves::secp256_k1::Secp256k1Point` (struct `curv::elliptic::curves::secp256_k1::Secp256k1Point`)
               found type `curv::elliptic::curves::secp256_k1::Secp256k1Point` (struct `curv::elliptic::curves::secp256_k1::Secp256k1Point`)
note: Perhaps two different versions of crate `curv` are being used?
   --> src/protocols/two_party_ecdsa/cclst_2019/party_one.rs:278:13
    |
278 |             GE::generator() * &party_one_private.x1,
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to previous error

🤷‍♂️

omershlo commented 4 years ago

@trepca the error you got was my fault. I fixed this error and now it should work. Please confirm

omershlo commented 4 years ago

I check the idea of @amanusk from https://github.com/KZen-networks/class-groups/issues/20 . It appears that running single thread all the tests solves the problem: cargo test --features=cclst -- --test-threads=1

We do need to find a way to run Pari in parallel

trepca commented 4 years ago

great, that works, even natively on MacOS