zengo-x / gotham-city Goto Github PK
View Code? Open in Web Editor NEWGotham city is a fully functional project to demonstrate real-life example of minimalist Bitcoin decentralized HD wallet using 2 party ECDSA
License: Other
Gotham city is a fully functional project to demonstrate real-life example of minimalist Bitcoin decentralized HD wallet using 2 party ECDSA
License: Other
Compiling paillier v0.3.0 (https://github.com/KZen-networks/rust-paillier?tag=v0.3.0#735c95ec)
Compiling publicsuffix v1.5.4
error[E0557]: feature has been removed
--> /root/.cargo/git/checkouts/rust-paillier-5e0399ff4bbd1793/735c95e/src/lib.rs:1:12
|
1 | #![feature(custom_attribute)]
| ^^^^^^^^^^^^^^^^ feature has been removed
|
= note: removed in favor of #![register_tool]
and #![register_attr]
error: aborting due to previous error
For more information about this error, try rustc --explain E0557
.
error: could not compile paillier
.
To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: build failed
Same as ZenGo-X/curv#66
Hello KZen people,
First, thank you very much for your cool product 👍 .
Really like multi-parties idea, I wish to try gotham-city as a wallet on testnet.
Currently, I was setup the server and was able to build your client.
After run "./cli create-wallet", got
(id: 0ce94885-fe95-4d11-b497-85d92f5aae74) Took: PT4.914320007S
Network: [testnet], Wallet saved to disk
When digging to wallet.data, I found that "master_key" is created.
Please help me that: at this step, how do I get the master address and master key (manually)?
Thank you.
Sincerely,
Quang, VU
The library has many points of improvements at the system/networking level:
Observations:
Possible directions:
[Gotham 2.0]
[Gotham 3.0]
When trying to compile gotham-client
on cyclic-dependency
branch, getting the error below:
Updating git repository `https://github.com/KZen-networks/rust-gmp`
Updating crates.io index
Updating git repository `https://github.com/KZen-networks/centipede`
Updating git repository `https://github.com/KZen-networks/curv`
Updating git repository `https://github.com/KZen-networks/rust-electrumx-client`
Updating git repository `https://github.com/KZen-networks/kms-secp256k1`
Updating git repository `https://github.com/KZen-networks/multi-party-ecdsa`
Updating git repository `https://github.com/KZen-networks/multi-party-eddsa`
Updating git repository `https://github.com/KZen-networks/multi-party-schnorr`
Updating git repository `https://github.com/KZen-networks/zk-paillier`
Updating git repository `https://github.com/KZen-networks/bulletproofs`
error: failed to select a version for the requirement `zeroize = "^0.10"`
candidate versions found which didn't match: 1.5.0, 1.4.3, 1.4.2, ...
location searched: crates.io index
required by package `curv v0.2.3 (https://github.com/KZen-networks/curv?tag=v0.2.3#d6c575b5)`
... which is depended on by `gotham-client v0.1.3 (/home/akurt/gotham-city/gotham-client)`
Ubuntu 16.04
rustc version: rustc 1.44.0-nightly (b2e36e6c2 2020-04-22)
rustup version: rustup 1.24.3 (ce5817a94 2021-05-31)
right now we need serialize/ deserialize to support:
client side:
[A] save and load wallet
[B] c API call to sign reads wallet from input json
server side:
[A] to save and load master key, and private share to the DB
1A is easy since I can just remove this save/load functionality. @gbenattar any ideas about 1B and 2A ?
I use rust toolchain [rustc 1.72.0-nightly (8b35c0bb0 2023-06-08)] to compile the gotham-city/gotham-client, but error appears:
Compiling tokio-io v0.1.13
Compiling net2 v0.2.38
Compiling lock_api v0.3.4
Compiling openssl-sys v0.9.84
error[E0599]: no method named `includes` found for mutable reference `&mut Build` in the current scope
--> /home/node/.cargo/registry/src/index.crates.io-6f17d22bba15001f/openssl-sys-0.9.84/build/run_bindgen.rs:192:10
|
190 | / cc::Build::new()
191 | | .file(out_dir.join("boring_static_wrapper.c"))
192 | | .includes(include_dirs)
| | -^^^^^^^^ help: there is a method with a similar name: `include`
| |_________|
|
For more information about this error, try `rustc --explain E0599`.
error: could not compile `openssl-sys` (build script) due to previous error
which version of rust should I use? help!
hello,
When i sign same transcation,but sign with server result not same.is once sign always create new private and public key?
note: ld: library not found for -lgmp
cargo run --release
rustc 1.71.1 (eb26296b5 2023-08-03)
OS + Version:
Cargo Version:
HW type:
Please provide any additional context that may be helpful in confirming and resolving this issue.
Maybe if at trait default implementation we can parametrize to take another trait impl as input. Sth like dynamic dispatcher in c++. We would like the keygen and sign to decide at compile time which specific keygen and sign will execute. Can we?
//idea is to have all traits implement all default behavior and being generic over db and authenticator. Problem is the async nature of gotham functions which is not supported maturely enough by traits in current stable rust.
enum dbConnector {
rocksDB,
dynamoDB,
...
}
enum authenticator {
None,
jwt,
...
}
Struct PublicGotham{
dbType: dbConnector;
auth: authenticator;
}
Struct PrivateGotham{
dbType: dbConnector;
auth: authenticator;
}
pub trait Db {
type dbConnector;
fn insert(&self,db:dbConnector,item) -> Result<>;
fn delete(&self,db:dbConnector,item) -> Result<>;
fn get(&self,db:dbConnector,item) -> Result<>;
}
impl Db for PublicGotham{
fn insert(&self,db:dbConnector,item) -> Result<>{
...
}
fn delete(&self,db:dbConnector,item) -> Result<>
{
...
}
fn get(&self,db:dbConnector,item) -> Result<>
{
...
}
}
impl Db for PrivateGotham{
fn insert(&self,db:dbConnector,item) -> Result<>{
...
}
fn delete(&self,db:dbConnector,item) -> Result<>
{
...
}
fn get(&self,db:dbConnector,item) -> Result<>
{
...
}
}
//async trait might be a blocker: https://rust-lang.github.io/async-book/07_workarounds/05_async_in_traits.html
//only in nightly and not mature enough: https://blog.rust-lang.org/inside-rust/2022/11/17/async-fn-in-trait-nightly.html
//not sure if the macros of rocket framework for http endpoints can be implemented at default trait functions
//might be impossible to connect trait functions as routes to rocket: https://github.com/ZenGo-X/zengo-gotham-city/blob/77cf354d8fcfd2865e2549110d0054d52bc96292/gotham-server/src/server.rs#L77
// trait functions are callable from their struct types. but here those functions are never explicitely called they are http async endpoints. Do not know how to call them.
trait KeyGen<S: Db> {
#[post("/ecdsa/keygen/first", format = "json")]
async fn first(&self, dbConn: S){
S.insert()...// at this point trait does not know which gotham will be run time called thanks to dbConn abstraction. That is what we want. Not sure it compiles though.
two_party_ecdsa...
S.get()...
}
#[post("/ecdsa/keygen/<id>/second", format = "json", data = "<dlog_proof>")]
async fn second(&self, dbConn: S){
...
}
#[post(
"/ecdsa/keygen/<id>/third",
format = "json",
data = "<party_2_pdl_first_message>"
)]
async fn third(&self, dbConn: S){
...
}
#[post(
"/ecdsa/keygen/<id>/fourth",
format = "json",
data = "<party_two_pdl_second_message>"
)]
async fn fourth(&self, dbConn: S){
...
}
}
trait Sign<S: Db> {
async fn sign_first(&self, dbConn: S){
...
}
async fn sign_second(&self, dbConn: S){
...
}
}
impl<S: Db> KeyGen<S> for PublicGotham {}
impl<S: Db> KeyGen<S> for PrivateGotham {}
impl<S: Db> Sign<S> for PublicGotham {}
impl<S: Db> Sign<S> for PrivateGotham {}
let public = PublicGotham {
dbType: dbConnector::rocksDB,
auth: authenticator::None,
};
let private = PrivateGotham {
dbType: dbConnector::dynamoDB,
auth: authenticator::jwt,
};
//the question is can we put the trait default functions as routes to rocket:
rocket::Rocket::build()
.mount(
"/",
routes![
crate::routes::ecdsa::public::first,
crate::routes::ecdsa::public::second,
crate::routes::ecdsa::public::third,
crate::routes::ecdsa::public::fourth,
crate::routes::ecdsa::public::sign_first,
crate::routes::ecdsa::public::sign_second,
],
)
//and appropriately for PrivateGotham Struct:
rocket::Rocket::build()
.mount(
"/",
routes![
crate::routes::ecdsa::private::first,
crate::routes::ecdsa::private::second,
crate::routes::ecdsa::private::third,
crate::routes::ecdsa::private::fourth,
crate::routes::ecdsa::private::sign_first,
crate::routes::ecdsa::private::sign_second,
],
)`
I think there has a security problem according to the logic of gotham-city. The private key x2 of client and a common public share "master key" are saved on the client side. If the attacker gets the data of the client, can the private key of the wallet be calculated according to Q and x2?
Description:
I encountered the above build error while working on the project. It seems to be caused by conflicting versions of the two_party_ecdsa crate. Specifically, the error suggests that there are two different versions of the crate being used, resulting in incompatible trait signatures for methods insert and get.
Error:
error[E0053]: method `insert` has an incompatible type for trait
--> gotham-server/src/public_gotham.rs:56:1
|
56 | #[async_trait]
| ^^^^^^^^^^^^^^ expected trait `two_party_ecdsa::party_one::Value`, found a different trait `two_party_ecdsa::party_one::Value`
|
= note: expected signature `fn(&'life0 PublicGotham, &'life1 gotham_engine::types::DbIndex, &'life2 (dyn gotham_engine::traits::MPCStruct + 'life2), &'life3 (dyn two_party_ecdsa::party_one::Value + 'static)) -> Pin<_>`
found signature `fn(&'life0 PublicGotham, &'life1 gotham_engine::types::DbIndex, &'life2 (dyn gotham_engine::traits::MPCStruct + 'life2), &'life3 (dyn two_party_ecdsa::party_one::Value + 'static)) -> Pin<_>`
= note: perhaps two different versions of crate `two_party_ecdsa` are being used?
error[E0053]: method `get` has an incompatible type for trait
--> gotham-server/src/public_gotham.rs:56:1
|
56 | #[async_trait]
| ^^^^^^^^^^^^^^ expected trait `two_party_ecdsa::party_one::Value`, found a different trait `two_party_ecdsa::party_one::Value`
|
= note: expected signature `fn(&'life0 PublicGotham, &'life1 gotham_engine::types::DbIndex, &'life2 (dyn gotham_engine::traits::MPCStruct + 'life2)) -> Pin<Box<(dyn std::future::Future<Output = Result<std::option::Option<Box<(dyn two_party_ecdsa::party_one::Value + 'static)>>, gotham_engine::types::DatabaseError>> + std::marker::Send + 'async_trait)>>`
found signature `fn(&'life0 PublicGotham, &'life1 gotham_engine::types::DbIndex, &'life2 (dyn gotham_engine::traits::MPCStruct + 'life2)) -> Pin<Box<(dyn std::future::Future<Output = Result<std::option::Option<Box<(dyn two_party_ecdsa::party_one::Value + 'static)>>, gotham_engine::types::DatabaseError>> + std::marker::Send + 'async_trait)>>`
= note: perhaps two different versions of crate `two_party_ecdsa` are being used?
Environment:
rustc 1.75.0
Hello KZen people,
I've have a wallet with 2 derivative addresses. When I do the transaction within these 2 addresses, there are no error.
However when I try to transfer BTC to an outside address, I got this error:
thread 'main' panicked at 'called Result::unwrap()
on an Err
value: Error("missing field result
", line: 1, column: 122)', src/libcore/result.rs:xxx:xx
The command is:
Tried to take the raw transaction out and send it manually through https://testnet.smartbit.com.au/txs/pushtx, I got this error
PUSH TRANSACTION ERROR: 16: BAD-TXNS-VOUT-NEGATIVE
After decode the transaction, I found this in the output
{
"addresses": null,
"script": "001429dd1071596903f049574e8e1f8529e14a4a4737",
"script_type": "pay-to-witness-pubkey-hash",
"value": -10000
}
The whole raw is
000000000001011c65b37fa305ef8b4c4ccb9731c2b14aa7dc933acbf08e0dc845c5148c7ea8180000000000ffffffff02e8030000000000001976a91452db02dda5c812097c67307ee63c23c22ea955e288acf0d8ffffffffffff16001429dd1071596903f049574e8e1f8529e14a4a473702473044022065ef7a2f120198f4acb7048edf90d070622583149eeb38c5fecb9f669e669b6202200532d8662932be31ae2586364f8fb7862ac93d0464eb07599e518eb468f0f0830121036b3a6ead2e7617c155f39f2f1b9a8ec963c0fb0b3c46154ea1074fe14d4221bb00000000
Hope to hear from you soon :)
Thank you
Currently running into the following runtime error when loading .so after compiling GMP and Gotham City and linking in Android:
java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "SSL_CTX_free" referenced by /lib/arm64/libclient_lib.so
Reproduce
Android Folder Structure
app
|_src
|__main
|___java
|___jniLibs
|____arm64-v8a
|_____libclient_lib.so
|_____libgmp.so
In android app build.gradle I have:
ndk { abiFilters "arm64-v8a" }
In MainActivity.kt I have:
companion object{
init {
System.loadLibrary("gmp")
System.loadLibrary("client_lib")
}
}
Project Folder Structure
project
|__rust
|___gmp-6.1.2 (source)
|___src (gotham-city/gotham-client source)
build_gmp.sh
build_gotham.sh
GMP Build Script
---------START SCRIPT---------
out_dir="out"
out_dir_temp="out_temp"
root=$PWD/rust/gmp-6.1.2/
rm -rf ${root}/${out_dir_temp}
mkdir ${root}/${out_dir_temp}
mv
export BASE_CFLAGS='-O2 -g -pedantic -fomit-frame-pointer -Wa,--noexecstack -ffunction-sections -funwind-tables -no-canonical-prefixes -fno-strict-aliasing'
cd ./rust/gmp-6.1.2/
export LDFLAGS='-Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now'
export CFLAGS="${BASE_CFLAGS} -fstack-protector-strong -finline-limit=300 -funswitch-loops"
export CC="aarch64-linux-android23-clang"
export CXX="aarch64-linux-android23-clang++"
./configure --prefix=/usr --disable-shared --enable-cxx --build=x86_64-pc-linux-gnu --host=aarch64-linux-android MPN_PATH="arm64 generic"
sed -i.bak '/HAVE_LOCALECONV 1/d' ./config.h
make -j8 V=1 2>&1 | tee arm64-v8a.log
mkdir ${out_dir}/aarch64-linux-android
make install DESTDIR=$PWD/${out_dir}/aarch64-linux-android
cd ${out_dir}/aarch64-linux-android && mv usr/lib/* ./ && mv usr/include/* ./ && rm -rf usr
---------END SCRIPT---------
Gotham Compilation
---------START SCRIPT---------
root=$PWD
cd ./rust
export SYSROOT="$toolchain_bin_dir/../sysroot"
CC=Library/Android/sdk/ndk/20.0.5594570/toolchains/llvm/prebuilt/darwin-x86_64/bin/aarch64-linux-android23-clang
CXX=Library/Android/sdk/ndk/20.0.5594570/toolchains/llvm/prebuilt/darwin-x86_64/bin/aarch64-linux-android23-clang++
LDFLAGS=""
CFLAGS=""
AR=Library/Android/sdk/ndk/20.0.5594570/toolchains/llvm/prebuilt/darwin-x86_64/bin/aarch64-linux-android-ar
cargo rustc --target "aarch64-linux-android" --release -- -L ${root}/rust/gmp-6.1.2/out/aarch64-linux-android
---------END SCRIPT---------
Cargo Config
[target.aarch64-linux-android]
ar = "$HOME/Library/Android/sdk/ndk/20.0.5594570/toolchains/llvm/prebuilt/darwin-x86_64/bin/aarch64-linux-android-ar"
linker = "$HOME/Library/Android/sdk/ndk/20.0.5594570/toolchains/llvm/prebuilt/darwin-x86_64/bin/aarch64-linux-android23-clang"
Dear KZen members,
We noticed that you compared the run times of your repository with our blockchain-crypto-mpc repository. In your code we see that you use multi-threading, so we updated our library to use multi-threading as well. This change should provide a more “apples-to-apples” comparison.
We also added a benchmarking tool for our algorithms that, we feel, provides a more accurate measurement of the run time.
We kindly suggest you run the tests again – we are interested in seeing the results.
Best Regards,
Dr. Samuel Ranellucci
Cryptographer, Unbound Tech
The client cli is not supported anymore with the new gotham in v1.0.0
port the old client cli to new gotham
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.