Giter Site home page Giter Site logo

mercury's Introduction

mercury's People

Contributors

86667 avatar dependabot[bot] avatar lawlawlaw avatar ldeacon avatar nicosey avatar rk16449 avatar sgershuny avatar ssantos21 avatar stakauskas avatar tomt1664 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mercury's Issues

Swap Coordinator Design

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.

HD paths

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).

Mainstay error

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.

Conductor punishment list

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.

Client master key

Random seed generation option: current fixed seed means multiple wallets can't be tested simultaneously.

Fix groupsinfo

Groupsinfo map returns incorrect swap groups in swap failure cases.

Tests failing: key_gen_and_sign, authentication_test_expired_token

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'

Conductor only mode

Implement config option (can be set via env) that enables the server to be run in 'core' only mode, 'conductor' mode, or both.

Add seed generation and recovery to mercury client

Currently, when the client daemon is first started (

pub fn run_wallet_daemon(force_testing_mode: bool) -> Result<()> {
), it looks for a wallet file to load (
let mut wallet = match wallet::wallet::Wallet::load(wallet_data_loc, client_shim.clone()) {
).
If there is no wallet file, it then generates a new seed as a random number (rand::thread_rng().gen() if not in test mode).

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 (

if let Some(matches) = matches.subcommand_matches("wallet") {
) to enable recovery from an entered seed phrase (so the entered seed phrase will generate a new wallet data file and check for bitcoin balances).

Swap registration authentication

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.

Select address from CLI

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.

Encryption

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.

New address format.

For maximum privacy, separate keys should be used for backup and state/proof. The 'address' should include both of these keys.

Watching daemon

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.

Multi-threading tests

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.

Database

Review database options for key storage, state storage and backup transaction storage.

Problem building with openssl 1.1.1g

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

Lockbox ingress

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).

Conductor locktime limit

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.

SMT commitments

Commit previous root in position 00000.....

Commit batch transfer IDs to SMT.

Compile errors

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.

Swap API

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.

Swap transfer/withdraw lockout

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.