ZenGo-X / multi-party-ecdsa

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

Run 2-party ECDSA on iOS. #27

Open gbenattar opened 5 years ago

gbenattar commented 5 years ago

The purpose of this task is to build a proof of concept for running this code on iOS. Nice to have: simple benches that we will be able to compare with benches running on a machine.

Success criteria:

GutteApps commented 5 years ago

-Working with "multi-party-ecdsa" version "0.1.0" -changed create-type in Cargo.toml to ["staticlib"] in order to be able to build a static fat library. -build failed for x86_64 (64-bit simulator) architecture, after investigation it turns out ring (dependency of cryptography-utils) added support for this architecture in v 0.13 (was v 0.12): https://github.com/briansmith/ring/pull/584 -forked and upgraded ring: https://github.com/GutteApps/cryptography-utils -managed to build my local copy and integrate with my swift project

in party_one.rs: #[no_mangle] pub extern fn rust_hello_world() -> i32 { println!("Hello, I'm in Rust code! I'm about to return 10."); 10 }

in AppDelegate.swift: func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { let result = rust_hello_world() print("I called Rust and got \(result)") return true }

Output: Hello, I'm in Rust code! I'm about to return 10. I called Rust and got 10

GutteApps commented 5 years ago

Trying to run the following:

`use protocols::two_party_ecdsa::lindell_2017_keygen::*;

[no_mangle]

pub extern fn test_run_from_ios() { let ec_context = EC::new();

    let party_two_d_log_proof =
        party_two::FirstMsgCommitment::create(&ec_context);

    let second_msg_party_two_proof_verification =
        party_one::SecondMsgClientProofVerification::verify(&ec_context, &party_two_d_log_proof);

    println!("{:?}", party_two_d_log_proof);

}`

getting the following error in xCode: Undefined symbols for architecture x86_64: "_gmpzexport", referenced from: gmp::mpz::$LT$impl$u20$core..convert..From$LT$$RF$$u27$b$u20$gmp..mpz..Mpz$GT$$u20$for$u20$alloc..vec..Vec$LT$u8$GT$$GT$::from::hb079909da8333f52 in libmulti_partyecdsa.a(gmp-570935a6dba9d6de.gmp6-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) "gmpzxor", referenced from: $LT$$RF$$u27$a$u20$gmp..mpz..Mpz$u20$as$u20$core..ops..bit..BitXor$LT$$RF$$u27$b$u20$gmp..mpz..Mpz$GT$$GT$::bitxor::ha3c3f372159bf16a in libmulti_party_ecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) "_gmpz_tdiv_rui", referenced from: $LT$$RF$$u27$a$u20$gmp..mpz..Mpz$u20$as$u20$core..ops..arith..Rem$LT$u64$GT$$GT$::rem::hb7a2ef95b56b6f45 in libmulti_partyecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) "gmpz_mulsi", referenced from: gmp::mpz::$LT$impl$u20$core..ops..arith..Mul$LT$$RF$$u27$a$u20$gmp..mpz..Mpz$GT$$u20$for$u20$i64$GT$::mul::hc593ebc507338380 in libmulti_partyecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) $LT$$RF$$u27$a$u20$gmp..mpz..Mpz$u20$as$u20$core..ops..arith..Mul$LT$i64$GT$$GT$::mul::h55d205791f8d8487 in libmulti_party_ecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) "_gmpz_uisub", referenced from: gmp::mpz::$LT$impl$u20$core..ops..arith..Sub$LT$$RF$$u27$a$u20$gmp..mpz..Mpz$GT$$u20$for$u20$u64$GT$::sub::h466aa9b3b5f0deb8 in libmulti_party_ecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) "_gmpz_gcd", referenced from: gmp::mpz::Mpz::gcd::h1ce7ef3b08d7262e in libmulti_partyecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) "gmpzsub", referenced from: $LT$$RF$$u27$a$u20$gmp..mpz..Mpz$u20$as$u20$core..ops..arith..Sub$LT$$RF$$u27$b$u20$gmp..mpz..Mpz$GT$$GT$::sub::he20cf123623f2096 in libmulti_party_ecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) cryptography_utils::arithmetic::biggmp::$LT$impl$u20$cryptography_utils..arithmetic..traits..Modulo$u20$for$u20$gmp..mpz..Mpz$GT$::mod_sub::hcfce57282861edec in libmulti_party_ecdsa.a(cryptography_utils-13b5522bfc67e689.cryptography_utils4-e7cb4c2b8bd94ea96d616e8ac77e0647.rs.rcgu.o) "___gmpz_com", referenced from: gmp::mpz::Mpz::compl::he60b068223691aa8 in libmulti_partyecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) $LT$$RF$$u27$b$u20$gmp..mpz..Mpz$u20$as$u20$core..ops..bit..Not$GT$::not::ha6e44f0c90082863 in libmulti_partyecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) $LT$gmp..mpz..Mpz$u20$as$u20$core..convert..From$LT$i64$GT$$GT$::from::ha11743e758375ac0 in libmulti_partyecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) $LT$gmp..mpz..Mpz$u20$as$u20$core..convert..From$LT$i32$GT$$GT$::from::he4ea625afe36b5b5 in libmulti_partyecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) "gmpzimport", referenced from: $LT$gmp..mpz..Mpz$u20$as$u20$core..convert..From$LT$$RF$$u27$a$u20$$u5b$u8$u5d$$GT$$GT$::from::h438c1fea33ea0f6a in libmulti_partyecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) $LT$gmp..mpz..Mpz$u20$as$u20$core..convert..From$LT$u64$GT$$GT$::from::h978bb6635fafea70 in libmulti_partyecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) $LT$gmp..mpz..Mpz$u20$as$u20$core..convert..From$LT$u32$GT$$GT$::from::h9a6bd3867471fe61 in libmulti_partyecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) $LT$gmp..mpz..Mpz$u20$as$u20$core..convert..From$LT$i64$GT$$GT$::from::ha11743e758375ac0 in libmulti_partyecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) $LT$gmp..mpz..Mpz$u20$as$u20$core..convert..From$LT$i32$GT$$GT$::from::he4ea625afe36b5b5 in libmulti_party_ecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) "_gmpz_init", referenced from: gmp::mpz::Mpz::new::h42a5e3712dd3989d in libmulti_party_ecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) gmp::mpz::Mpz::compl::he60b068223691aa8 in libmulti_party_ecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) gmp::mpz::Mpz::abs::h0f66b65b9e1785a4 in libmulti_party_ecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) gmp::mpz::Mpz::div_floor::h9ba7e48b47732b2b in libmulti_party_ecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) gmp::mpz::Mpz::mod_floor::h7e32926cea040fa0 in libmulti_party_ecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) gmp::mpz::Mpz::nextprime::h7b804188ede7b3aa in libmulti_party_ecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) gmp::mpz::Mpz::gcd::h1ce7ef3b08d7262e in libmulti_party_ecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) ... "_gmpz_getd", referenced from: gmp::mpz::$LT$impl$u20$core..convert..From$LT$$RF$$u27$a$u20$gmp..mpz..Mpz$GT$$u20$for$u20$f64$GT$::from::hd067bdaa5f1991fc in libmulti_partyecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) "gmpzadd", referenced from: $LT$$RF$$u27$a$u20$gmp..mpz..Mpz$u20$as$u20$core..ops..arith..Add$LT$$RF$$u27$b$u20$gmp..mpz..Mpz$GT$$GT$::add::h89a2a404ac0f422b in libmulti_party_ecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) cryptography_utils::arithmetic::biggmp::$LT$impl$u20$cryptography_utils..arithmetic..traits..Modulo$u20$for$u20$gmp..mpz..Mpz$GT$::mod_sub::hcfce57282861edec in libmulti_party_ecdsa.a(cryptography_utils-13b5522bfc67e689.cryptography_utils4-e7cb4c2b8bd94ea96d616e8ac77e0647.rs.rcgu.o) cryptography_utils::arithmetic::biggmp::$LT$impl$u20$cryptography_utils..arithmetic..traits..Modulo$u20$for$u20$gmp..mpz..Mpz$GT$::mod_add::h0f8029a3a3e5e299 in libmulti_party_ecdsa.a(cryptography_utils-13b5522bfc67e689.cryptography_utils4-e7cb4c2b8bd94ea96d616e8ac77e0647.rs.rcgu.o) cryptography_utils::arithmetic::biggmp::$LT$impl$u20$cryptography_utils..arithmetic..traits..Samplable$u20$for$u20$gmp..mpz..Mpz$GT$::sample_range::hd146049062296779 in libmulti_party_ecdsa.a(cryptography_utils-13b5522bfc67e689.cryptography_utils4-e7cb4c2b8bd94ea96d616e8ac77e0647.rs.rcgu.o) cryptography_utils::arithmetic::biggmp::$LT$impl$u20$cryptography_utils..arithmetic..traits..Samplable$u20$for$u20$gmp..mpz..Mpz$GT$::strict_sample_range::hada7d253b57666a5 in libmulti_party_ecdsa.a(cryptography_utils-13b5522bfc67e689.cryptography_utils4-e7cb4c2b8bd94ea96d616e8ac77e0647.rs.rcgu.o) "___gmpz_tdiv_qui", referenced from: $LT$$RF$$u27$a$u20$gmp..mpz..Mpz$u20$as$u20$core..ops..arith..Div$LT$u64$GT$$GT$::div::h41b7bf767e79ec6b in libmulti_partyecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) "gmpzneg", referenced from: $LT$$RF$$u27$b$u20$gmp..mpz..Mpz$u20$as$u20$core..ops..arith..Neg$GT$::neg::h529901d3e34d0e64 in libmulti_party_ecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) "_gmpz_initset", referenced from: $LT$gmp..mpz..Mpz$u20$as$u20$core..clone..Clone$GT$::clone::hbf6245357ef11255 in libmulti_party_ecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) "___gmpz_addui", referenced from: gmp::mpz::$LT$impl$u20$core..ops..arith..Add$LT$$RF$$u27$a$u20$gmp..mpz..Mpz$GT$$u20$for$u20$u64$GT$::add::h4181f22dd81e203d in libmulti_partyecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) $LT$$RF$$u27$a$u20$gmp..mpz..Mpz$u20$as$u20$core..ops..arith..Add$LT$u64$GT$$GT$::add::h3d4282411f743e73 in libmulti_partyecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) "gmpz_init_set_ui", referenced from: gmp::mpz::Mpz::one::h41e9da39e0ae7117 in libmulti_party_ecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) "_gmpz_fdiv_r", referenced from: gmp::mpz::Mpz::mod_floor::h7e32926cea040fa0 in libmulti_party_ecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) "_gmpz_millerrabin", referenced from: gmp::mpz::Mpz::millerrabin::h0343c5265caaac1a in libmulti_partyecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) "gmpzior", referenced from: $LT$$RF$$u27$a$u20$gmp..mpz..Mpz$u20$as$u20$core..ops..bit..BitOr$LT$$RF$$u27$b$u20$gmp..mpz..Mpz$GT$$GT$::bitor::hc73aabd9e2a7355a in libmulti_partyecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) "gmpz_invert", referenced from: gmp::mpz::Mpz::invert::he6c2d86b87d3de41 in libmulti_party_ecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) "_gmpz_root", referenced from: gmp::mpz::Mpz::root::h0135cd38225f7535 in libmulti_party_ecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) "_gmpz_powm_sec", referenced from: gmp::mpz::Mpz::powm_sec::h3596d2c36cb0ea21 in libmulti_partyecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) "gmpz_clrbit", referenced from: gmp::mpz::Mpz::clrbit::h0fd79de50ed82b50 in libmulti_party_ecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) "___gmpz_probab_prime_p", referenced from: gmp::mpz::Mpz::probab_prime::h8772ccb01dc254d6 in libmulti_partyecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) "gmpz_ui_pow_ui", referenced from: gmp::mpz::Mpz::ui_pow_ui::h0b85a9fca9bc1b85 in libmulti_party_ecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) "_gmpz_set", referenced from: gmp::mpz::Mpz::set::ha82f73fd5d7883d3 in libmulti_party_ecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) "___gmpzand", referenced from: $LT$$RF$$u27$a$u20$gmp..mpz..Mpz$u20$as$u20$core..ops..bit..BitAnd$LT$$RF$$u27$b$u20$gmp..mpz..Mpz$GT$$GT$::bitand::h5a052b9c12d14da4 in libmulti_partyecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) "gmpz_pow_ui", referenced from: gmp::mpz::Mpz::pow::h1eded07239b0415e in libmulti_party_ecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) "_gmpz_popcount", referenced from: gmp::mpz::Mpz::popcount::h4a43292dddfbcefa in libmulti_party_ecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) "_gmpz_mod", referenced from: gmp::mpz::Mpz::modulus::ha222792b6828a236 in libmulti_partyecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) "gmpz_gcdext", referenced from: gmp::mpz::Mpz::gcdext::hfdcb63150507b37c in libmulti_party_ecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) "_gmpz_tdivq", referenced from: $LT$$RF$$u27$a$u20$gmp..mpz..Mpz$u20$as$u20$core..ops..arith..Div$LT$$RF$$u27$b$u20$gmp..mpz..Mpz$GT$$GT$::div::he984dd7204372be5 in libmulti_partyecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) "gmpz_mul2exp", referenced from: $LT$$RF$$u27$b$u20$gmp..mpz..Mpz$u20$as$u20$core..ops..bit..Shl$LT$usize$GT$$GT$::shl::heb14313e9bf5a31e in libmulti_partyecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) $LT$gmp..mpz..Mpz$u20$as$u20$core..ops..bit..Shl$LT$usize$GT$$GT$::shl::h35bb66444c39f433 in libmulti_partyecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) $LT$gmp..mpz..Mpz$u20$as$u20$core..ops..bit..ShlAssign$LT$usize$GT$$GT$::shl_assign::hbbd6b46dd7219a27 in libmulti_partyecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) "gmpz_setbit", referenced from: gmp::mpz::Mpz::setbit::hb989f4aa62445b3d in libmulti_party_ecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) "_gmpz_subui", referenced from: $LT$$RF$$u27$a$u20$gmp..mpz..Mpz$u20$as$u20$core..ops..arith..Sub$LT$u64$GT$$GT$::sub::hc66b150c8d50d702 in libmulti_party_ecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) "_gmpz_fdiv_q2exp", referenced from: $LT$$RF$$u27$b$u20$gmp..mpz..Mpz$u20$as$u20$core..ops..bit..Shr$LT$usize$GT$$GT$::shr::h40b7921a220715b7 in libmulti_partyecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) $LT$gmp..mpz..Mpz$u20$as$u20$core..ops..bit..Shr$LT$usize$GT$$GT$::shr::h4a11eeda9fe74737 in libmulti_partyecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) $LT$gmp..mpz..Mpz$u20$as$u20$core..ops..bit..ShrAssign$LT$usize$GT$$GT$::shr_assign::h1cf6ef7018f3903b in libmulti_partyecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) "gmpz_get_str", referenced from: gmp::mpz::Mpz::to_str_radix::h2afa567169f61b6e in libmulti_partyecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) "gmpz_tdivr", referenced from: $LT$$RF$$u27$a$u20$gmp..mpz..Mpz$u20$as$u20$core..ops..arith..Rem$LT$$RF$$u27$b$u20$gmp..mpz..Mpz$GT$$GT$::rem::h02eb43636aaa10ab in libmulti_party_ecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) "_gmpz_mului", referenced from: gmp::mpz::$LT$impl$u20$core..ops..arith..Mul$LT$$RF$$u27$a$u20$gmp..mpz..Mpz$GT$$u20$for$u20$u64$GT$::mul::h7539c05fe1dff63a in libmulti_partyecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) $LT$$RF$$u27$a$u20$gmp..mpz..Mpz$u20$as$u20$core..ops..arith..Mul$LT$u64$GT$$GT$::mul::hb2c5c29cb1907f46 in libmulti_partyecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) "gmpz_divisible_p", referenced from: gmp::mpz::Mpz::is_multiple_of::h6d6d8de38578bb43 in libmulti_party_ecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) "_gmpz_fdiv_q", referenced from: gmp::mpz::Mpz::div_floor::h9ba7e48b47732b2b in libmulti_party_ecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) "___gmpz_init2", referenced from: gmp::mpz::Mpz::new_reserve::h0b9298ea79a0f6b2 in libmulti_partyecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) "gmpz_set_str", referenced from: gmp::mpz::Mpz::set_from_str_radix::hda599fbd6828d9b2 in libmulti_party_ecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) "_gmpz_hamdist", referenced from: gmp::mpz::Mpz::hamdist::h97a603f9921b81ac in libmulti_party_ecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) "_gmpz_tstbit", referenced from: gmp::mpz::Mpz::tstbit::h608edafdb272ed9e in libmulti_partyecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) "gmpz_combit", referenced from: gmp::mpz::Mpz::combit::hbf8a989e7c462600 in libmulti_party_ecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) "_gmpz_realloc2", referenced from: gmp::mpz::Mpz::reserve::h4dfc09ecf467aa32 in libmulti_partyecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) "gmpz_lcm", referenced from: gmp::mpz::Mpz::lcm::hb86772d844a1b524 in libmulti_party_ecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) "_gmpzcmp", referenced from: $LT$gmp..mpz..Mpz$u20$as$u20$core..cmp..PartialEq$GT$::eq::h524572a991a703d9 in libmulti_partyecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) $LT$gmp..mpz..Mpz$u20$as$u20$core..cmp..Ord$GT$::cmp::h6932b4dda024568c in libmulti_partyecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) $LT$gmp..mpz..Mpz$u20$as$u20$core..cmp..PartialOrd$GT$::partial_cmp::hf933e9b290071472 in libmulti_partyecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) "gmpzclear", referenced from: $LT$gmp..mpz..Mpz$u20$as$u20$core..ops..drop..Drop$GT$::drop::h4f437f6a61d50a73 in libmulti_party_ecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) gmp::mpz::Mpz::from_str_radix::h61c1c4191a35aec7 in libmulti_party_ecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) gmp::mpz::Mpz::invert::he6c2d86b87d3de41 in libmulti_partyecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) $LT$gmp..mpz..Mpz$u20$as$u20$core..ops..bit..Shl$LT$usize$GT$$GT$::shl::h35bb66444c39f433 in libmulti_partyecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) $LT$gmp..mpz..Mpz$u20$as$u20$core..ops..bit..Shr$LT$usize$GT$$GT$::shr::h4a11eeda9fe74737 in libmulti_partyecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) "gmpz_sqrt", referenced from: gmp::mpz::Mpz::sqrt::hfad35807ace04afe in libmulti_party_ecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) "_gmpz_sizeinbase", referenced from: gmp::mpz::Mpz::reserve::h4dfc09ecf467aa32 in libmulti_party_ecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) gmp::mpz::Mpz::size_in_base::h4027d5b56db97cef in libmulti_party_ecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) gmp::mpz::Mpz::to_str_radix::h2afa567169f61b6e in libmulti_party_ecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) gmp::mpz::Mpz::bit_length::hac6653b5ffd0953a in libmulti_partyecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) gmp::mpz::$LT$impl$u20$core..convert..From$LT$$RF$$u27$b$u20$gmp..mpz..Mpz$GT$$u20$for$u20$alloc..vec..Vec$LT$u8$GT$$GT$::from::hb079909da8333f52 in libmulti_partyecdsa.a(gmp-570935a6dba9d6de.gmp6-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) "gmpz_nextprime", referenced from: gmp::mpz::Mpz::nextprime::h7b804188ede7b3aa in libmulti_party_ecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) "_gmpz_init_set_str", referenced from: gmp::mpz::Mpz::from_str_radix::h61c1c4191a35aec7 in libmulti_partyecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) "gmpz_powm", referenced from: gmp::mpz::Mpz::powm::h78a2a83c2c7fdc1f in libmulti_party_ecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) "_gmpzmul", referenced from: $LT$$RF$$u27$a$u20$gmp..mpz..Mpz$u20$as$u20$core..ops..arith..Mul$LT$$RF$$u27$b$u20$gmp..mpz..Mpz$GT$$GT$::mul::hc711faa185badc9e in libmulti_party_ecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) cryptography_utils::arithmetic::biggmp::$LT$impl$u20$cryptography_utils..arithmetic..traits..Modulo$u20$for$u20$gmp..mpz..Mpz$GT$::mod_mul::h812dd6c095a03c8d in libmulti_party_ecdsa.a(cryptography_utils-13b5522bfc67e689.cryptographyutils4-e7cb4c2b8bd94ea96d616e8ac77e0647.rs.rcgu.o) "gmpz_abs", referenced from: gmp::mpz::Mpz::abs::h0f66b65b9e1785a4 in libmulti_party_ecdsa.a(gmp-570935a6dba9d6de.gmp0-d38f7da9e4e919d7ed56ecef380583c0.rs.rcgu.o) ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

trying to build the rust lib with debug symbols

gbenattar commented 5 years ago

Sounds related to gcc on iOS, I will dive deep. One solution could be to use for iOS a different big number library (pure Rust).

gbenattar commented 5 years ago

https://stackoverflow.com/questions/9513626/build-gmp-for-ios

GutteApps commented 5 years ago

@gbenattar, Iv'e managed to build gmp for iOS architectures using this script: https://gist.github.com/sakrist/0ceaa98fb16535998020

if I understand correctly, cryptography-utils is using gmp indirectly via: https://github.com/thestinger/rust-gmp

how is rust-gmp linking against gmp?

GutteApps commented 5 years ago

Solved:

vhnatyk commented 5 years ago

Is it still open? I see solved but... no benches?

omershlo commented 5 years ago

that's an excellent question. I think that the actual work is on another repo. @GutteApps/ @gbenattar : can you please elaborate what is the current status of running rust cryptography on iOS? specifically - what are the performance for various steps on iOS? and do you have any bottlenecks? maybe @vhnatyk will be able to assist.

vhnatyk commented 5 years ago

Ok - 1 day to build multiparty on Windows, 1 hour to build on Ubuntu:), weekend to build and run multiparty tests on iOS on armv7 and aarch64 and all that after 20+ days in dependency hell on Mac OS :D

armv7 (iPad mini 1st gen ) - 32 bit is a no go :( I was able to drink some tea and few youtubes cause it was running for over 20minutes and finished just a few tests. Pretty expected since 32bit GMP but still, it didn't even finish last test, I dropped.

But aarm64(iPhone 6s) did a pretty good job - it runs almost just like PC i7 8550U I'm running on :D again pretty expected since 64bit GMP. You may wonder - why no exact numbers, it's because I'm still not able to run benches on aarch64 due to

    Undefined symbols for architecture arm64:                        
               "_rust_crypto_util_fixed_time_eq_asm", referenced from:  
                _$LT$crypto..aes_gcm._

It's because seems sidechanell attack safe 64 bit version of the method is missing in outdated rust-crypto for 64 bit ARM:( Good thing all tests for multiparty pass so there may be chance core of multiparty protocol compiles and runs on various platforms just fine Of course @omershlo - you may not wonder at all since looks like you are focused on some server-centric topology or since you already have these results or sort of(via running with rust to c with headers) :) or you may not have benches since multiparty keygen.rs looks very outdated and draft. Perhaps if you have latest bench for multiparty - maybe you would be kind enough to share ;) Because except replacing cryptography-utils with curve what I did there is sort of black magik -

                let (vss_scheme_1, secret_shares_1, index1) = party1_keys
                    .phase1_verify_com_phase3_verify_correct_key_phase2_distribute(
                        &parames, &blind_vec, //&y_vec, 
                        &bc1_vec,
                    )
                    .expect("invalid key");

strange it doesn't fail though 👍 Sorry I suspect it's some sort of savagery - but despite I spent countless hours reading lindell18 before finaly deciding to go with gg18 (mainly due to 8kb messages vs 192kb) I coudn't do anything better (math looks familiar but still... ). So in case you have updates to multiparty benches and would like to share - it would be great. In case you don't and interested - maybe I shoud read contributing guides and at least join your tele chanel?, maybe I wouldn't bug too much with few questions from time to time;) Definitely it would save me few weeks - though it feels a bit valuable experience with various tools and building all that flavors of GMP and dependencies on all that platforms I had to go through those days, kind of 😄 Again - way of running all the tests and benches in full directly on device without leaving Rust - feels solid!

 DEBUG dinghy_lib::ios::xcode  > entitlements file: /Users/admin/repo/multi-party-ecdsa/target/aarch64-apple-ios/debug/dinghy/entitlements.xcent
 DEBUG dinghy_lib::ios::device > mount developper image
 DEBUG dinghy_lib::ios::device > Looking for device support directory in "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport" for iOS version "12.1.2"
 DEBUG dinghy_lib::ios::device > start debugserver on phone
 DEBUG dinghy_lib::ios::device > debug server running
 DEBUG dinghy_lib::ios::device > start local lldb proxy
 DEBUG dinghy_lib::ios::device > start lldb
 DEBUG dinghy_lib::ios::device > Looking for device support directory in "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport" for iOS version "12.1.2"
(lldb) command source -s 1 '/var/folders/pd/f5zx6fp16xsdz40l4l8z13z00000gn/T/mobiledevice-rs-lldb.utAUvogGgTMD/lldb-script'

running 6 tests
test protocols::multi_party_ecdsa::gg_2018::test::tests::test_keygen_t1_n2 ... ok
test protocols::multi_party_ecdsa::gg_2018::test::tests::test_keygen_t2_n3 ... ok
test protocols::multi_party_ecdsa::gg_2018::test::tests::test_mta ... ok
test protocols::multi_party_ecdsa::gg_2018::test::tests::test_keygen_t2_n4 ... ok
test protocols::multi_party_ecdsa::gg_2018::test::tests::test_sign_n5_t2_ttag4 ... ok
test protocols::multi_party_ecdsa::gg_2018::test::tests::test_sign_n8_t4_ttag6 ... test protocols::multi_party_ecdsa::gg_2018::test::tests::test_sign_n8_t4_ttag6 has been running for over 60 seconds
test protocols::multi_party_ecdsa::gg_2018::test::tests::test_sign_n8_t4_ttag6 ... ok

test result: ok. 6 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

Thanks to Dinghy - pure magik, going to run all the stuff tomorrow on Android

omershlo commented 5 years ago

@vhnatyk what a great work! @gbenattar will plug you to some of our channels, so we can continue to chat freely. Let me answer on some points here :

  1. benches on aarch64: I see that the problem is with the library I use for aes_gcm - this is relevant only for the network layer (to create encrypted channels) and can be changed easily (there's a open question if the way I do it is actually valid). It is definitely not core! we can branch the code and remove this part or make it feature dependent or just replace it with something that complies
  2. I am not focusing on server centric topology, I mean - we did use this topology but this is part of an on going research for MPC network layer - we first replaced message passing with shared memory and the next step is to have a distributed shared memory with consensus.
  3. keygen.rs is outdated like you say, we have open issue with benches #45 and this is something we give to candidates to do from time to time so we have few works on benchmarks scattered around :) . This is definitely interesting ! The numbers we use for benchmarks for the 2 party case are including local network and can be found in gotham-city repo (we did not use rust bench tools for that)
  4. The change you did to phase1_verify_com_phase3_verify_correct_key_phase2_distribute is not black magic, This is how the function should work. I am not sure you are using the most updated version of the code. When we worked on the network layer we made some changes to the core code and this is probably one of them. anyway this is the current function signature. you should use the version that is currently in master

good work !

yangmiok commented 4 years ago

Ok - 1 day to build multiparty on Windows, 1 hour to build on Ubuntu:), weekend to build and run multiparty tests on iOS on armv7 and aarch64 and all that after 20+ days in dependency hell on Mac OS :D

armv7 (iPad mini 1st gen ) - 32 bit is a no go :( I was able to drink some tea and few youtubes cause it was running for over 20minutes and finished just a few tests. Pretty expected since 32bit GMP but still, it didn't even finish last test, I dropped.

But aarm64(iPhone 6s) did a pretty good job - it runs almost just like PC i7 8550U I'm running on :D again pretty expected since 64bit GMP. You may wonder - why no exact numbers, it's because I'm still not able to run benches on aarch64 due to

  Undefined symbols for architecture arm64:                        
               "_rust_crypto_util_fixed_time_eq_asm", referenced from:  
                _$LT$crypto..aes_gcm._

It's because seems sidechanell attack safe 64 bit version of the method is missing in outdated rust-crypto for 64 bit ARM:( Good thing all tests for multiparty pass so there may be chance core of multiparty protocol compiles and runs on various platforms just fine Of course @omershlo - you may not wonder at all since looks like you are focused on some server-centric topology or since you already have these results or sort of(via running with rust to c with headers) :) or you may not have benches since multiparty keygen.rs looks very outdated and draft. Perhaps if you have latest bench for multiparty - maybe you would be kind enough to share ;) Because except replacing cryptography-utils with curve what I did there is sort of black magik -

                let (vss_scheme_1, secret_shares_1, index1) = party1_keys
                    .phase1_verify_com_phase3_verify_correct_key_phase2_distribute(
                        &parames, &blind_vec, //&y_vec, 
                        &bc1_vec,
                    )
                    .expect("invalid key");

strange it doesn't fail though 👍 Sorry I suspect it's some sort of savagery - but despite I spent countless hours reading lindell18 before finaly deciding to go with gg18 (mainly due to 8kb messages vs 192kb) I coudn't do anything better (math looks familiar but still... ). So in case you have updates to multiparty benches and would like to share - it would be great. In case you don't and interested - maybe I shoud read contributing guides and at least join your tele chanel?, maybe I wouldn't bug too much with few questions from time to time;) Definitely it would save me few weeks - though it feels a bit valuable experience with various tools and building all that flavors of GMP and dependencies on all that platforms I had to go through those days, kind of 😄 Again - way of running all the tests and benches in full directly on device without leaving Rust - feels solid!

 DEBUG dinghy_lib::ios::xcode  > entitlements file: /Users/admin/repo/multi-party-ecdsa/target/aarch64-apple-ios/debug/dinghy/entitlements.xcent
 DEBUG dinghy_lib::ios::device > mount developper image
 DEBUG dinghy_lib::ios::device > Looking for device support directory in "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport" for iOS version "12.1.2"
 DEBUG dinghy_lib::ios::device > start debugserver on phone
 DEBUG dinghy_lib::ios::device > debug server running
 DEBUG dinghy_lib::ios::device > start local lldb proxy
 DEBUG dinghy_lib::ios::device > start lldb
 DEBUG dinghy_lib::ios::device > Looking for device support directory in "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport" for iOS version "12.1.2"
(lldb) command source -s 1 '/var/folders/pd/f5zx6fp16xsdz40l4l8z13z00000gn/T/mobiledevice-rs-lldb.utAUvogGgTMD/lldb-script'

running 6 tests
test protocols::multi_party_ecdsa::gg_2018::test::tests::test_keygen_t1_n2 ... ok
test protocols::multi_party_ecdsa::gg_2018::test::tests::test_keygen_t2_n3 ... ok
test protocols::multi_party_ecdsa::gg_2018::test::tests::test_mta ... ok
test protocols::multi_party_ecdsa::gg_2018::test::tests::test_keygen_t2_n4 ... ok
test protocols::multi_party_ecdsa::gg_2018::test::tests::test_sign_n5_t2_ttag4 ... ok
test protocols::multi_party_ecdsa::gg_2018::test::tests::test_sign_n8_t4_ttag6 ... test protocols::multi_party_ecdsa::gg_2018::test::tests::test_sign_n8_t4_ttag6 has been running for over 60 seconds
test protocols::multi_party_ecdsa::gg_2018::test::tests::test_sign_n8_t4_ttag6 ... ok

test result: ok. 6 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

Thanks to Dinghy - pure magik, going to run all the stuff tomorrow on Android

can u share the ios or android code?

vhnatyk commented 4 years ago

@zhangtianai hi - umm "the code" is already there:) just that you need Rust tool like dinghy to run it. There is an old stale PR #60 with all the info regarding running on iOS. Just keep in mind that it's nice to keep development going without leaving Rust - so you can test and debug on iOS/Android without a wrapper for another language. Otherwise, to integrate library into your project in another language - you will have to create a wrapper - like Rust <-> C - Swift etc. It's not that hard but of course requires extra efforts. Depending on the amount of API you would want to cover.

yangmiok commented 4 years ago

Solved:

  • needed to build gmp for iOS and link it to my Swift project as a static lib.
  • Managed to run and call the following rust functions from iOS: create_commitments(&ec_context) create(&ec_context) create_commitments(&ec_context)
  • results are serialized returned to the C header in the following data structure:

    [repr(C)]

    pub struct RustByteSlice { pub bytes: *const u8, pub len: usize, }

can you share the ios code?