Mercury
Mercury is no longer supported. It has been replaced with mercury layer: http://github.com/commerceblock/mercurylayer
An implementation of statechains
License: GNU General Public License v3.0
Mercury is no longer supported. It has been replaced with mercury layer: http://github.com/commerceblock/mercurylayer
A swap is an atomic batch-transfer of UTXOs between n
participants. A swap is initiated by a coordinator providing a batch_id
and n
signatures - one from each participant. The signatures sign for their UTXO to be involved in a swap with a particular batch_id
and to occur within some time frame. Once the desired number of participants is reached the coordinator matches senders and receivers together for each individual transfer. The swap can then commence.
The wallet requires 3 sets of keys on different paths: (1) Key shares (2) Proof keys (3) Backup keys.
It might be convenient for these paths to encode the TxID of the output (i.e. like BIP175).
Cancel swaps where any participants become unresponsive.
Handle a failure of the mainstay API. Coins seem to get stuck if protocol fails due to mainstay attestation failing.
StateEntityError("SharedLibError Error: MainstayAPIError)
Failure of the attestation should not stop the server.
Once a specific coin (without changing owner) fails 3 swaps in a row, it is added to a punishment list where the coin cannot be registered to a swap group for 12 hours.
Random seed generation option: current fixed seed means multiple wallets can't be tested simultaneously.
Groupsinfo map returns incorrect swap groups in swap failure cases.
Registered UTXOs are dropped from swap groups if they fail to poll for some timeout (0-60s).
Output of "cargo test" is below.
running 9 tests
test auth::cognito::tests::get_user_id_test ... ok
test auth::jwt::tests::decode_token_test ... ok
test storage::mock::tests::quick_tests ... ok
test auth::jwt::tests::get_claims_test ... ok
(took PT0.007932S) test tests::tests::key_gen_and_sign ... FAILED
test tests::tests::authentication_test_expired_token ... FAILED
test tests::tests::authentication_test_invalid_token ... ok
test util::tests::sign ... ok
test util::tests::transaction ... ok
failures:
---- tests::tests::key_gen_and_sign stdout ----
thread 'tests::tests::key_gen_and_sign' panicked at 'called `Result::unwrap()` on an `Err` value: Error { message: "IO error: lock : ./db/LOCK: No locks available" }', server/src/server.rs:148:28
---- tests::tests::authentication_test_expired_token stdout ----
thread 'tests::tests::authentication_test_expired_token' panicked at 'called `Result::unwrap()` on an `Err` value: Error { message: "IO error: lock : ./db/LOCK: No locks available" }', server/src/server.rs:148:28
failures:
tests::tests::authentication_test_expired_token
tests::tests::key_gen_and_sign
test result: FAILED. 7 passed; 2 failed; 0 ignored; 0 measured; 0 filtered out
error: test failed, to rerun pass '-p server --lib'
New compiler warnings have appeared, mainly due to upcoming changes to the language in which only string literals can be passed to panic! statements.
Implement config option (can be set via env) that enables the server to be run in 'core' only mode, 'conductor' mode, or both.
Currently, when the client daemon is first started (
Line 72 in 3845dbf
Line 114 in 3845dbf
Using the BIP39 crate, convert this seed generation to BIP39 and output the mnemonic to the console.
https://docs.rs/bip39/0.5.1/bip39/
Add a new command to the wallet CLI (
Line 28 in 3845dbf
Registration for swap groups should be authenticated - which will require DB access.
Swap registration should only be authorised if: 1. The statecoin is listed in the DB. 2. The request is authenticated with a code or signature. 3. The locktime limit has not passed. 4. The coin is not on the punish list.
The backup tx (as part of transfer msg 3) is revealed to the receiver before transfer_finalise. This must be hidden until completion, and the coordinator must verify validity.
When there are multiple addresses in the CLI tool it's not clear which address the statecoin will be sent from.
Need to have send function choose an address.
Add an EC encryption functionality (ECIES) for key rotation material passed between the server, old owner, new owner and then back to the server.
A random key is generated by the server (on request of the owner) - this must be encrypted with a public key belonging to the owner and sent to the owner. The owner (wallet) then decrypts this.
For maximum privacy, separate keys should be used for backup and state/proof. The 'address' should include both of these keys.
Separate application (maybe included as a utility) that is run in a separate location (possibly multiple locations) to the main server (i.e. the server handles signing and key shares).
This daemon is sent the latest backup transaction of each active UTXO by the SE main server as they are generated. The daemon only needs to keep the latest backup transaction.
The daemon connects to a local instance of bitcoind (which is connected to the Bitcoin network over Tor) and watches for kick-off transactions for any active SE UTXO, and submits the latest backup transaction in case it is seen confirmed.
The daemon can ping other daemons - if more than a threshold are unreachable (i.e. signifying an attack), then they submit the current backup transactions for each UTXO.
After transfer a statecoin worth 5BTC receives back value 5.000007BTC from /info/statechain/
Add multiple thread support for Server.
Currenlty tests involving server must be run on a single thread because of problems with locking DB and monotree implementation restrictions on DB.
If I call the following:
cli wallet -h
Swap command is not listed
Waiting on Rocket 0.5 release.
rwf2/Rocket#19 (comment)
Review database options for key storage, state storage and backup transaction storage.
Enable old fee addresses to pass verification checks
Lawrences-MacBook-Pro:mercury lawrence$ cargo build
Compiling block-buffer v0.3.3
Compiling standback v0.2.3
Compiling rustversion v1.0.2
Compiling error-chain v0.12.2
Compiling openssl-sys v0.6.7
Compiling quote v1.0.3
Compiling jobserver v0.1.21
Compiling time v0.1.43
error: failed to run custom build command for openssl-sys v0.6.7
Caused by:
process didn't exit successfully: /Users/lawrence/Projects/mercury/target/debug/build/openssl-sys-63c28b95e061f8d7/build-script-build
(exit code: 101)
--- stdout
cargo:rustc-link-search=native=/usr/local/Cellar/[email protected]/1.1.1g/lib
cargo:rustc-link-lib=ssl
cargo:rustc-link-lib=crypto
TARGET = Some("x86_64-apple-darwin")
OPT_LEVEL = Some("0")
TARGET = Some("x86_64-apple-darwin")
HOST = Some("x86_64-apple-darwin")
TARGET = Some("x86_64-apple-darwin")
TARGET = Some("x86_64-apple-darwin")
HOST = Some("x86_64-apple-darwin")
CC_x86_64-apple-darwin = None
CC_x86_64_apple_darwin = None
HOST_CC = None
CC = None
HOST = Some("x86_64-apple-darwin")
TARGET = Some("x86_64-apple-darwin")
HOST = Some("x86_64-apple-darwin")
CFLAGS_x86_64-apple-darwin = None
CFLAGS_x86_64_apple_darwin = None
HOST_CFLAGS = None
CFLAGS = None
DEBUG = Some("true")
running: "cc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-m64" "-I" "/usr/local/Cellar/[email protected]/1.1.1g/include" "-Wall" "-Wextra" "-o" "/Users/lawrence/Projects/mercury/target/debug/build/openssl-sys-4eacbcb00f23a914/out/src/openssl_shim.o" "-c" "src/openssl_shim.c"
cargo:warning=src/openssl_shim.c:115:41: warning: unused parameter 'ctx' [-Wunused-parameter]
cargo:warning=int SSL_CTX_set_ecdh_auto_shim(SSL_CTX *ctx, int onoff) {
cargo:warning= ^
cargo:warning=src/openssl_shim.c:126:7: error: incomplete definition of type 'struct dh_st'
cargo:warning= dh->p = p;
cargo:warning= ~~^
cargo:warning=/usr/local/Cellar/[email protected]/1.1.1g/include/openssl/ossl_typ.h:104:16: note: forward declaration of 'struct dh_st'
cargo:warning=typedef struct dh_st DH;
cargo:warning= ^
cargo:warning=src/openssl_shim.c:127:7: error: incomplete definition of type 'struct dh_st'
cargo:warning= dh->g = g;
cargo:warning= ~~^
cargo:warning=/usr/local/Cellar/[email protected]/1.1.1g/include/openssl/ossl_typ.h:104:16: note: forward declaration of 'struct dh_st'
cargo:warning=typedef struct dh_st DH;
cargo:warning= ^
cargo:warning=src/openssl_shim.c:128:7: error: incomplete definition of type 'struct dh_st'
cargo:warning= dh->q = q;
cargo:warning= ~~^
cargo:warning=/usr/local/Cellar/[email protected]/1.1.1g/include/openssl/ossl_typ.h:104:16: note: forward declaration of 'struct dh_st'
cargo:warning=typedef struct dh_st DH;
cargo:warning= ^
cargo:warning=src/openssl_shim.c:137:13: error: incomplete definition of type 'struct x509_st'
cargo:warning= return x->cert_info ? x->cert_info->extensions : NULL;
cargo:warning= ~^
cargo:warning=/usr/local/Cellar/[email protected]/1.1.1g/include/openssl/ossl_typ.h:121:16: note: forward declaration of 'struct x509_st'
cargo:warning=typedef struct x509_st X509;
cargo:warning= ^
cargo:warning=src/openssl_shim.c:137:28: error: incomplete definition of type 'struct x509_st'
cargo:warning= return x->cert_info ? x->cert_info->extensions : NULL;
cargo:warning= ~^
cargo:warning=/usr/local/Cellar/[email protected]/1.1.1g/include/openssl/ossl_typ.h:121:16: note: forward declaration of 'struct x509_st'
cargo:warning=typedef struct x509_st X509;
cargo:warning= ^
cargo:warning=1 warning and 5 errors generated.
exit code: 1
--- stderr
thread 'main' panicked at '
Internal error occurred: Command "cc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-m64" "-I" "/usr/local/Cellar/[email protected]/1.1.1g/include" "-Wall" "-Wextra" "-o" "/Users/lawrence/Projects/mercury/target/debug/build/openssl-sys-4eacbcb00f23a914/out/src/openssl_shim.o" "-c" "src/openssl_shim.c" with args "cc" did not execute successfully (status code exit code: 1).
', /Users/lawrence/.cargo/registry/src/github.com-1ecc6299db9ec823/gcc-0.3.55/src/lib.rs:1672:5
note: run with RUST_BACKTRACE=1
environment variable to display a backtrace.
warning: build failed, waiting for other jobs to finish...
error: build failed
Server to be set up to utilize multiple lockboxes. This will be done to balance load and enable migration.
Individual coins will be assigned to different lockboxes, based either on the alphanumeric sequence of the statecoin_id or on the time the key is initialized.
The input settings in the server Settlings.toml will be in the form of an array of ACTIVE lockbox URLs that statecoin_ids will be distributed across depending on the sequence of the Uuid:
e.g. if there are 3 URLs, the first 1/3 of the statechain_ids (numerically) will be sent to URL 1
the next 1/3 of the statechain_ids (numerically) will be sent to URL 2
the final 1/3 of the statechain_ids (numerically) will be sent to URL 3
When a statecoin is deposited (and the statechain_id generated) the lockbox URL used is added to a new column in the statechain DB table, only if it is currently empty. If there already a URL in this column for the statechain_id, then this is used for all key operations for that statecoin.
This way, when the settings are updated (to new lockbox URLs), all new coins will use the new values and all the existing coins will use the URLs they were initialised on (allowing for migration after all current coins expire).
Server storage of latest backup transactions.
Server connection to Bitcoin node for watching.
The conductor will not process swaps with a backup tx locktime below a certain limit.
This limit is set as a parameter and should be added to the server info API.
Wallets registering UTXOs which end up being expired at the swaps stage should be punished.
Ideally all communication should be routed through Tor.
Commit to SMT root via Mainstay.
To enable recovery to work correctly.
Need to convert electrum server errors to CError and handle.
Commit previous root in position 00000.....
Commit batch transfer IDs to SMT.
Do not return empty groups.
Patched currently with 100ms sleep time before each request is made.
Things to note in your README:
You need to use an experimental branch of rust, not the stable branch:
rustup default nightly
The stable branch will generate a lot of errors along the lines of "Use of unstable feature alloc
" and maybe_uninit
.
FYI I didn't have any problem with the rust-pallier
library indicated in the README.
Develop protocol and implementation to enable atomic swaps.
The server will receive a request to update a collection of states simultaneously, signed by all owners.
If a coin is registered and/or part of an active swap, then it cannot be withdrawn or transfered until either the swap completes or it fails.
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.