From f622a3bcd8c1e837dc9ed454b603fced215ae637 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Fri, 30 Nov 2018 09:32:16 +0000 Subject: [PATCH 01/14] Persist received notes in an SQLite database --- .../cash/z/wallet/sdk/jni/JniConverter.kt | 2 +- src/main/rust/lib.rs | 165 ++++++++++++------ 2 files changed, 117 insertions(+), 50 deletions(-) diff --git a/src/main/java/cash/z/wallet/sdk/jni/JniConverter.kt b/src/main/java/cash/z/wallet/sdk/jni/JniConverter.kt index 02164dfd..87e00f2c 100644 --- a/src/main/java/cash/z/wallet/sdk/jni/JniConverter.kt +++ b/src/main/java/cash/z/wallet/sdk/jni/JniConverter.kt @@ -4,7 +4,7 @@ class JniConverter { external fun getAddress(seed: ByteArray): String - external fun scanBlocks(db: String, start: Int, end: Int, seed: ByteArray): Array + external fun scanBlocks(db_cache: String, db_data: String, seed: ByteArray) external fun initLogs() diff --git a/src/main/rust/lib.rs b/src/main/rust/lib.rs index deb50e73..90fc6c8c 100644 --- a/src/main/rust/lib.rs +++ b/src/main/rust/lib.rs @@ -8,15 +8,13 @@ extern crate zip32; mod protos; -use rusqlite::Connection; +use rusqlite::{types::ToSql, Connection, NO_PARAMS}; use zcash_client_backend::{ address::encode_payment_address, constants::HRP_SAPLING_EXTENDED_SPENDING_KEY_TEST, welding_rig::scan_block_from_bytes, }; use zip32::{ChildIndex, ExtendedFullViewingKey, ExtendedSpendingKey}; -use protos::ValueReceived::ValueReceived; - fn extfvk_from_seed(seed: &[u8]) -> ExtendedFullViewingKey { let master = ExtendedSpendingKey::master(seed); let extsk = ExtendedSpendingKey::from_path( @@ -35,43 +33,123 @@ fn address_from_extfvk(extfvk: &ExtendedFullViewingKey) -> String { encode_payment_address(HRP_SAPLING_EXTENDED_SPENDING_KEY_TEST, &addr) } +fn init_data_database(db_data: &str) -> rusqlite::Result<()> { + let data = Connection::open(db_data)?; + data.execute( + "CREATE TABLE IF NOT EXISTS blocks ( + height INTEGER PRIMARY KEY, + time INTEGER + )", + NO_PARAMS, + )?; + data.execute( + "CREATE TABLE IF NOT EXISTS transactions ( + id_tx INTEGER PRIMARY KEY, + txid BLOB NOT NULL UNIQUE, + block INTEGER NOT NULL, + FOREIGN KEY (block) REFERENCES blocks(height) + )", + NO_PARAMS, + )?; + data.execute( + "CREATE TABLE IF NOT EXISTS received_notes ( + id_note INTEGER PRIMARY KEY, + tx INTEGER NOT NULL, + output_index INTEGER NOT NULL, + value INTEGER NOT NULL, + FOREIGN KEY (tx) REFERENCES transactions(id_tx), + CONSTRAINT tx_output UNIQUE (tx, output_index) + )", + NO_PARAMS, + )?; + Ok(()) +} + struct CompactBlockRow { height: i32, data: Vec, } -/// Scans the given block range for any transactions received by the given -/// ExtendedFullViewingKeys. Returns a Vec of block height, txid and value. +/// Scans new blocks added to the cache for any transactions received by the given +/// ExtendedFullViewingKeys. +/// +/// Assumes that the caller is handling rollbacks. fn scan_cached_blocks( - db: String, - start: i32, - end: i32, + db_cache: &str, + db_data: &str, extfvks: &[ExtendedFullViewingKey], -) -> Vec { - let conn = Connection::open(db).unwrap(); - let mut stmt = conn - .prepare("SELECT height, data FROM compactblocks WHERE height >= ? AND height <= ?") - .unwrap(); - let rows = stmt - .query_map(&[start, end], |row| CompactBlockRow { - height: row.get(0), - data: row.get(1), - }).unwrap(); +) -> rusqlite::Result<()> { + let cache = Connection::open(db_cache)?; + let data = Connection::open(db_data)?; + + // Recall where we synced up to previously. + // If we have never synced, use 0 to select all cached CompactBlocks. + let mut last_height = + data.query_row( + "SELECT MAX(height) FROM blocks", + NO_PARAMS, + |row| match row.get_checked(0) { + Ok(h) => h, + Err(_) => 0, + }, + )?; + + // Prepare necessary SQL statements + let mut stmt_blocks = cache + .prepare("SELECT height, data FROM compactblocks WHERE height > ? ORDER BY height ASC")?; + let mut stmt_insert_block = data.prepare( + "INSERT INTO blocks (height) + VALUES (?)", + )?; + let mut stmt_insert_tx = data.prepare( + "INSERT INTO transactions (txid, block) + VALUES (?, ?)", + )?; + let mut stmt_insert_note = data.prepare( + "INSERT INTO received_notes (tx, output_index, value) + VALUES (?, ?, ?)", + )?; + + // Fetch the CompactBlocks we need to scan + let rows = stmt_blocks.query_map(&[last_height], |row| CompactBlockRow { + height: row.get(0), + data: row.get(1), + })?; - let mut received = vec![]; for row in rows { - let row = row.unwrap(); + let row = row?; + + // Scanned blocks MUST be height-seqential. + if row.height != (last_height + 1) { + error!( + "Expected height of next CompactBlock to be {}, but was {}", + last_height + 1, + row.height + ); + // Nothing more we can do + break; + } + last_height = row.height; + + // Insert the block into the database. + stmt_insert_block.execute(&[row.height.to_sql()?])?; + for tx in scan_block_from_bytes(&row.data, &extfvks) { + // Insert our transaction into the database. + stmt_insert_tx.execute(&[tx.txid.0.to_vec().to_sql()?, row.height.to_sql()?])?; + let tx_row = data.last_insert_rowid(); + for output in tx.shielded_outputs { - let mut vr = ValueReceived::new(); - vr.set_blockHeight(row.height as u64); - vr.set_txHash(tx.txid.0.to_vec()); - vr.set_value(output.value); - received.push(vr); + // Insert received note into the database. + // Assumptions: + // - A transaction will not contain more than 2^63 shielded outputs. + // - A note value will never exceed 2^63 zatoshis. + stmt_insert_note.execute(&[tx_row, output.index as i64, output.value as i64])?; } } } - received + + Ok(()) } /// JNI interface @@ -83,11 +161,10 @@ pub mod android { extern crate log_panics; use log::Level; - use protobuf::Message; use self::android_logger::Filter; use self::jni::objects::{JClass, JString}; - use self::jni::sys::{jbyteArray, jint, jobjectArray, jsize, jstring}; + use self::jni::sys::{jbyteArray, jstring}; use self::jni::JNIEnv; use super::{address_from_extfvk, extfvk_from_seed, scan_cached_blocks}; @@ -125,32 +202,22 @@ pub mod android { pub unsafe extern "C" fn Java_cash_z_wallet_sdk_jni_JniConverter_scanBlocks( env: JNIEnv, _: JClass, - db: JString, - start: jint, - end: jint, + db_cache: JString, + db_data: JString, seed: jbyteArray, - ) -> jobjectArray { - let db = env - .get_string(db) + ) { + let db_cache: String = env + .get_string(db_cache) + .expect("Couldn't get Java string!") + .into(); + let db_data: String = env + .get_string(db_data) .expect("Couldn't get Java string!") .into(); let seed = env.convert_byte_array(seed).unwrap(); - let received = scan_cached_blocks(db, start, end, &[extfvk_from_seed(&seed)]); - - let jreceived = env - .new_object_array( - received.len() as jsize, - "[B", - env.new_byte_array(0).unwrap().into(), - ).unwrap(); - for (i, vr) in received.into_iter().enumerate() { - let jvr = env - .byte_array_from_slice(&vr.write_to_bytes().unwrap()) - .unwrap(); - env.set_object_array_element(jreceived, i as jsize, jvr.into()) - .unwrap(); + if let Err(e) = scan_cached_blocks(&db_cache, &db_data, &[extfvk_from_seed(&seed)]) { + error!("Error while scanning blocks: {}", e); } - jreceived } } From 3188cf8942c6c83177e62790f29456541bdfb0b3 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Sat, 1 Dec 2018 02:14:30 +0000 Subject: [PATCH 02/14] Remove now-unused ValueReceived protobuf --- .gitignore | 1 - Cargo.lock | 2 -- Cargo.toml | 4 ---- build.rs | 10 ---------- src/main/proto/ValueReceived.proto | 9 --------- src/main/rust/lib.rs | 3 --- src/main/rust/protos/mod.rs | 1 - 7 files changed, 30 deletions(-) delete mode 100644 build.rs delete mode 100644 src/main/proto/ValueReceived.proto delete mode 100644 src/main/rust/protos/mod.rs diff --git a/.gitignore b/.gitignore index 9ec09f40..ae5af120 100644 --- a/.gitignore +++ b/.gitignore @@ -13,7 +13,6 @@ bin/ gen/ out/ -src/main/rust/protos/ target/ jniLibs/ diff --git a/Cargo.lock b/Cargo.lock index f26b1e92..fa2c362b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -609,8 +609,6 @@ dependencies = [ "jni 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "log-panics 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "protobuf 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "protobuf-codegen-pure 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "rusqlite 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", "zcash_client_backend 0.0.0 (git+https://github.com/str4d/librustzcash.git?rev=63ec78bb857a258a97d25a5a6e747389996e566a)", diff --git a/Cargo.toml b/Cargo.toml index f1343793..8f95f8d5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,6 @@ description = "Simple PoC that rust can work with protobufs over JNI" publish = false [dependencies] -protobuf = "2" rand = "0.4" rusqlite = { version = "0.15", features = ["bundled"] } log = "0.4" @@ -24,9 +23,6 @@ jni = { version = "0.10", default-features = false } android_logger = "0.6" log-panics = "2.0.0" -[build-dependencies] -protobuf-codegen-pure = "2" - [lib] name = "zcashwalletsdk" path = "src/main/rust/lib.rs" diff --git a/build.rs b/build.rs deleted file mode 100644 index a5069d57..00000000 --- a/build.rs +++ /dev/null @@ -1,10 +0,0 @@ -extern crate protobuf_codegen_pure; - -fn main() { - protobuf_codegen_pure::run(protobuf_codegen_pure::Args { - out_dir: "src/main/rust/protos", - input: &["src/main/proto/ValueReceived.proto"], - includes: &["src/main/proto"], - customize: Default::default(), - }).expect("protoc"); -} diff --git a/src/main/proto/ValueReceived.proto b/src/main/proto/ValueReceived.proto deleted file mode 100644 index 9fddcafb..00000000 --- a/src/main/proto/ValueReceived.proto +++ /dev/null @@ -1,9 +0,0 @@ -syntax = "proto3"; - -package cash.z.wallet.sdk.proto; - -message ValueReceived { - uint64 blockHeight = 1; - bytes txHash = 2; - uint64 value = 3; -} \ No newline at end of file diff --git a/src/main/rust/lib.rs b/src/main/rust/lib.rs index 90fc6c8c..19a392d6 100644 --- a/src/main/rust/lib.rs +++ b/src/main/rust/lib.rs @@ -1,13 +1,10 @@ #[macro_use] extern crate log; -extern crate protobuf; extern crate rusqlite; extern crate zcash_client_backend; extern crate zip32; -mod protos; - use rusqlite::{types::ToSql, Connection, NO_PARAMS}; use zcash_client_backend::{ address::encode_payment_address, constants::HRP_SAPLING_EXTENDED_SPENDING_KEY_TEST, diff --git a/src/main/rust/protos/mod.rs b/src/main/rust/protos/mod.rs deleted file mode 100644 index 661d6e8d..00000000 --- a/src/main/rust/protos/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod ValueReceived; From ab2b5903a03ee1c312c36eb4d1caa367d6e90372 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Sun, 2 Dec 2018 12:48:13 +0000 Subject: [PATCH 03/14] Improvements to JniConverter.scanBlocks() - Store Sapling tree with blocks - Store witnesses with full notes - Track note spends - Track change notes - Store index within block for each transaction - This will make it easier to request entire blocks of transactions at some point, and then filter out only the transactions we care about. - Store block times while scanning blocks - Return bool with error state from JniConverter.scanBlocks() - Support cached blocks that are height-ascending but not sequential - Blocks that do not contain Sapling data may be skipped. - Return error from scan_cached_blocks() if heights are not ascending --- Cargo.lock | 199 ++++++++++++-- Cargo.toml | 18 +- .../cash/z/wallet/sdk/jni/JniConverter.kt | 2 +- src/main/rust/lib.rs | 257 +++++++++++++++--- 4 files changed, 414 insertions(+), 62 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fa2c362b..a743e230 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -85,15 +85,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "bellman" version = "0.1.0" -source = "git+https://github.com/str4d/librustzcash.git?rev=63ec78bb857a258a97d25a5a6e747389996e566a#63ec78bb857a258a97d25a5a6e747389996e566a" +source = "git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666#89cfef8515d5d88809c485a44fdc54572b9e5666" dependencies = [ "bit-vec 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "ff 0.4.0 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", + "group 0.1.0 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)", "num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "pairing 0.14.2 (git+https://github.com/str4d/librustzcash.git?rev=63ec78bb857a258a97d25a5a6e747389996e566a)", + "pairing 0.14.2 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)", "rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -117,6 +119,17 @@ dependencies = [ "constant_time_eq 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "block-buffer" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "block-padding 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "byte-tools 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)", + "generic-array 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "block-cipher-trait" version = "0.5.3" @@ -125,11 +138,24 @@ dependencies = [ "generic-array 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "block-padding" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "byte-tools 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "byte-tools" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "byte-tools" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "byteorder" version = "1.2.7" @@ -188,6 +214,14 @@ dependencies = [ "generic-array 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "digest" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "generic-array 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "either" version = "1.5.0" @@ -218,6 +252,34 @@ dependencies = [ "synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "fake-simd" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "ff" +version = "0.4.0" +source = "git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666#89cfef8515d5d88809c485a44fdc54572b9e5666" +dependencies = [ + "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)", + "ff_derive 0.3.0 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)", + "rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "ff_derive" +version = "0.3.0" +source = "git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666#89cfef8515d5d88809c485a44fdc54572b9e5666" +dependencies = [ + "num-bigint 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "num-integer 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.14.9 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "fpe" version = "0.1.0" @@ -266,6 +328,23 @@ dependencies = [ "typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "generic-array" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "group" +version = "0.1.0" +source = "git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666#89cfef8515d5d88809c485a44fdc54572b9e5666" +dependencies = [ + "ff 0.4.0 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)", + "rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "hex" version = "0.3.2" @@ -388,12 +467,19 @@ name = "opaque-debug" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "opaque-debug" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "pairing" version = "0.14.2" -source = "git+https://github.com/str4d/librustzcash.git?rev=63ec78bb857a258a97d25a5a6e747389996e566a#63ec78bb857a258a97d25a5a6e747389996e566a" +source = "git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666#89cfef8515d5d88809c485a44fdc54572b9e5666" dependencies = [ "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)", + "ff 0.4.0 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)", + "group 0.1.0 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)", "rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -482,16 +568,28 @@ dependencies = [ [[package]] name = "sapling-crypto" version = "0.0.1" -source = "git+https://github.com/str4d/librustzcash.git?rev=63ec78bb857a258a97d25a5a6e747389996e566a#63ec78bb857a258a97d25a5a6e747389996e566a" +source = "git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666#89cfef8515d5d88809c485a44fdc54572b9e5666" dependencies = [ - "bellman 0.1.0 (git+https://github.com/str4d/librustzcash.git?rev=63ec78bb857a258a97d25a5a6e747389996e566a)", + "bellman 0.1.0 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)", "blake2-rfc 0.2.18 (git+https://github.com/gtank/blake2-rfc?rev=7a5b5fc99ae483a0043db7547fb79a6fa44b88a9)", "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)", "digest 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)", - "pairing 0.14.2 (git+https://github.com/str4d/librustzcash.git?rev=63ec78bb857a258a97d25a5a6e747389996e566a)", + "ff 0.4.0 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)", + "pairing 0.14.2 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)", "rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "sha2" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "block-buffer 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "digest 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "opaque-debug 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "stream-cipher" version = "0.1.1" @@ -500,6 +598,16 @@ dependencies = [ "generic-array 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "syn" +version = "0.14.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "syn" version = "0.15.21" @@ -606,62 +714,88 @@ name = "zcash-wallet-sdk-poc" version = "0.0.1" dependencies = [ "android_logger 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "ff 0.4.0 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)", "jni 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "log-panics 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "pairing 0.14.2 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)", + "protobuf 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "rusqlite 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", - "zcash_client_backend 0.0.0 (git+https://github.com/str4d/librustzcash.git?rev=63ec78bb857a258a97d25a5a6e747389996e566a)", - "zip32 0.0.0 (git+https://github.com/str4d/librustzcash.git?rev=63ec78bb857a258a97d25a5a6e747389996e566a)", + "zcash_client_backend 0.0.0 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)", + "zcash_primitives 0.0.0 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)", + "zip32 0.0.0 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)", ] [[package]] name = "zcash_client_backend" version = "0.0.0" -source = "git+https://github.com/str4d/librustzcash.git?rev=63ec78bb857a258a97d25a5a6e747389996e566a#63ec78bb857a258a97d25a5a6e747389996e566a" +source = "git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666#89cfef8515d5d88809c485a44fdc54572b9e5666" dependencies = [ "bech32 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "bellman 0.1.0 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)", "blake2-rfc 0.2.18 (git+https://github.com/gtank/blake2-rfc?rev=7a5b5fc99ae483a0043db7547fb79a6fa44b88a9)", "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)", "chacha20-poly1305-aead 0.1.2 (git+https://github.com/gtank/chacha20-poly1305-aead?rev=aefc71f95e8bc43f2070e3c5b08130d9c86bbf4f)", "failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "ff 0.4.0 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)", "hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "pairing 0.14.2 (git+https://github.com/str4d/librustzcash.git?rev=63ec78bb857a258a97d25a5a6e747389996e566a)", + "pairing 0.14.2 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)", "protobuf 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf-codegen-pure 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", - "sapling-crypto 0.0.1 (git+https://github.com/str4d/librustzcash.git?rev=63ec78bb857a258a97d25a5a6e747389996e566a)", - "zcash_primitives 0.0.0 (git+https://github.com/str4d/librustzcash.git?rev=63ec78bb857a258a97d25a5a6e747389996e566a)", - "zip32 0.0.0 (git+https://github.com/str4d/librustzcash.git?rev=63ec78bb857a258a97d25a5a6e747389996e566a)", + "sapling-crypto 0.0.1 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)", + "zcash_primitives 0.0.0 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)", + "zcash_proofs 0.0.0 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)", + "zip32 0.0.0 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)", ] [[package]] name = "zcash_primitives" version = "0.0.0" -source = "git+https://github.com/str4d/librustzcash.git?rev=63ec78bb857a258a97d25a5a6e747389996e566a#63ec78bb857a258a97d25a5a6e747389996e566a" +source = "git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666#89cfef8515d5d88809c485a44fdc54572b9e5666" dependencies = [ "blake2-rfc 0.2.18 (git+https://github.com/gtank/blake2-rfc?rev=7a5b5fc99ae483a0043db7547fb79a6fa44b88a9)", "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "ff 0.4.0 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)", "hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "pairing 0.14.2 (git+https://github.com/str4d/librustzcash.git?rev=63ec78bb857a258a97d25a5a6e747389996e566a)", + "pairing 0.14.2 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)", "rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", - "sapling-crypto 0.0.1 (git+https://github.com/str4d/librustzcash.git?rev=63ec78bb857a258a97d25a5a6e747389996e566a)", + "sapling-crypto 0.0.1 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)", + "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "zcash_proofs" +version = "0.0.0" +source = "git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666#89cfef8515d5d88809c485a44fdc54572b9e5666" +dependencies = [ + "bellman 0.1.0 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)", + "blake2-rfc 0.2.18 (git+https://github.com/gtank/blake2-rfc?rev=7a5b5fc99ae483a0043db7547fb79a6fa44b88a9)", + "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)", + "ff 0.4.0 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)", + "pairing 0.14.2 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)", + "rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "sapling-crypto 0.0.1 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)", + "zcash_primitives 0.0.0 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)", ] [[package]] name = "zip32" version = "0.0.0" -source = "git+https://github.com/str4d/librustzcash.git?rev=63ec78bb857a258a97d25a5a6e747389996e566a#63ec78bb857a258a97d25a5a6e747389996e566a" +source = "git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666#89cfef8515d5d88809c485a44fdc54572b9e5666" dependencies = [ "aes 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "blake2-rfc 0.2.18 (git+https://github.com/gtank/blake2-rfc?rev=7a5b5fc99ae483a0043db7547fb79a6fa44b88a9)", "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)", + "ff 0.4.0 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)", "fpe 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "pairing 0.14.2 (git+https://github.com/str4d/librustzcash.git?rev=63ec78bb857a258a97d25a5a6e747389996e566a)", - "sapling-crypto 0.0.1 (git+https://github.com/str4d/librustzcash.git?rev=63ec78bb857a258a97d25a5a6e747389996e566a)", - "zcash_primitives 0.0.0 (git+https://github.com/str4d/librustzcash.git?rev=63ec78bb857a258a97d25a5a6e747389996e566a)", + "pairing 0.14.2 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)", + "sapling-crypto 0.0.1 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)", + "zcash_primitives 0.0.0 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)", ] [metadata] @@ -675,12 +809,15 @@ dependencies = [ "checksum backtrace 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "89a47830402e9981c5c41223151efcced65a0510c13097c769cede7efb34782a" "checksum backtrace-sys 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)" = "c66d56ac8dabd07f6aacdaf633f4b8262f5b3601a810a0dcddffd5c22c69daa0" "checksum bech32 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ad20b907fd16610c3960c7fe9dae13dd243343409bab80299774c9a8b5d7bed8" -"checksum bellman 0.1.0 (git+https://github.com/str4d/librustzcash.git?rev=63ec78bb857a258a97d25a5a6e747389996e566a)" = "" +"checksum bellman 0.1.0 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)" = "" "checksum bit-vec 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "02b4ff8b16e6076c3e14220b39fbc1fabb6737522281a388998046859400895f" "checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" "checksum blake2-rfc 0.2.18 (git+https://github.com/gtank/blake2-rfc?rev=7a5b5fc99ae483a0043db7547fb79a6fa44b88a9)" = "" +"checksum block-buffer 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "49665c62e0e700857531fa5d3763e91b539ff1abeebd56808d378b495870d60d" "checksum block-cipher-trait 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "370424437b9459f3dfd68428ed9376ddfe03d8b70ede29cc533b3557df186ab4" +"checksum block-padding 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4fc4358306e344bf9775d0197fd00d2603e5afb0771bb353538630f022068ea3" "checksum byte-tools 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "560c32574a12a89ecd91f5e742165893f86e3ab98d21f8ea548658eb9eef5f40" +"checksum byte-tools 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "980479e6fde23246dfb54d47580d66b4e99202e7579c5eaa9fe10ecb5ebd2182" "checksum byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "94f88df23a25417badc922ab0f5716cc1330e87f71ddd9203b3a3ccd9cedf75d" "checksum cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)" = "f159dfd43363c4d08055a07703eb7a3406b0dac4d0584d96965a3262db3c9d16" "checksum cesu8 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c" @@ -690,16 +827,22 @@ dependencies = [ "checksum constant_time_eq 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8ff012e225ce166d4422e0e78419d901719760f62ae2b7969ca6b564d1b54a9e" "checksum crossbeam 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "24ce9782d4d5c53674646a6a4c1863a21a8fc0cb649b3c94dfc16e45071dea19" "checksum digest 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)" = "03b072242a8cbaf9c145665af9d250c59af3b958f83ed6824e13533cf76d5b90" +"checksum digest 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "05f47366984d3ad862010e22c7ce81a7dbcaebbdfb37241a620f8b6596ee135c" "checksum either 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3be565ca5c557d7f59e7cfcf1844f9e3033650c929c6566f511e8005f205c1d0" "checksum error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "07e791d3be96241c77c43846b665ef1384606da2cd2a48730abe606a12906e02" "checksum failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6dd377bcc1b1b7ce911967e3ec24fa19c3224394ec05b54aa7b083d498341ac7" "checksum failure_derive 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "64c2d913fe8ed3b6c6518eedf4538255b989945c14c2a7d5cbff62a5e2120596" +"checksum fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" +"checksum ff 0.4.0 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)" = "" +"checksum ff_derive 0.3.0 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)" = "" "checksum fpe 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ce3371c82bfbd984f624cab093f55e7336f5a6e589f8518e1258f54f011b89ad" "checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" "checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" "checksum futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)" = "49e7653e374fe0d0c12de4250f0bdb60680b8c80eed558c5c7538eec9c89e21b" "checksum futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "ab90cde24b3319636588d0c35fe03b1333857621051837ed769faefb4c2162e4" +"checksum generic-array 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3c0f28c2f5bfb5960175af447a2da7c18900693738343dc896ffbcabd9839592" "checksum generic-array 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ef25c5683767570c2bbd7deba372926a55eaae9982d7726ee2a1050239d45b9d" +"checksum group 0.1.0 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)" = "" "checksum hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "805026a5d0141ffc30abb3be3173848ad46a1b1664fe632428479619a3644d77" "checksum jni 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1ecfa3b81afc64d9a6539c4eece96ac9a93c551c713a313800dade8e33d7b5c1" "checksum jni-sys 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" @@ -717,7 +860,8 @@ dependencies = [ "checksum num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0b3a5d7cc97d6d30d8b9bc8fa19bf45349ffe46241e8816f50f62f6d6aaabee1" "checksum num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c51a3322e4bca9d212ad9a158a02abc6934d005490c054a2778df73a70aa0a30" "checksum opaque-debug 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d620c9c26834b34f039489ac0dfdb12c7ac15ccaf818350a64c9b5334a452ad7" -"checksum pairing 0.14.2 (git+https://github.com/str4d/librustzcash.git?rev=63ec78bb857a258a97d25a5a6e747389996e566a)" = "" +"checksum opaque-debug 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "51ecbcb821e1bd256d456fe858aaa7f380b63863eab2eb86eee1bd9f33dd6682" +"checksum pairing 0.14.2 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)" = "" "checksum pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)" = "676e8eb2b1b4c9043511a9b7bea0915320d7e502b0a079fb03f9635a5252b18c" "checksum proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)" = "77619697826f31a02ae974457af0b29b723e5619e113e9397b8b82c6bd253f09" "checksum protobuf 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cbd08d128db199b1c6bb662e343d7d1a8f6d0060b411675766d88e5146a4bb38" @@ -729,8 +873,10 @@ dependencies = [ "checksum rusqlite 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "39bae767eb27866f5c0be918635ae54af705bc09db11be2c43a3c6b361cf3462" "checksum rustc-demangle 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "bcfe5b13211b4d78e5c2cadfebd7769197d95c639c35a50057eb4c05de811395" "checksum same-file 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8f20c4be53a8a1ff4c1f1b2bd14570d2f634628709752f0702ecdd2b3f9a5267" -"checksum sapling-crypto 0.0.1 (git+https://github.com/str4d/librustzcash.git?rev=63ec78bb857a258a97d25a5a6e747389996e566a)" = "" +"checksum sapling-crypto 0.0.1 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)" = "" +"checksum sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b4d8bfd0e469f417657573d8451fb33d16cfe0989359b93baf3a1ffc639543d" "checksum stream-cipher 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "30dc6118470d69ce0fdcf7e6f95e95853f7f4f72f80d835d4519577c323814ab" +"checksum syn 0.14.9 (registry+https://github.com/rust-lang/crates.io-index)" = "261ae9ecaa397c42b960649561949d69311f08eeaea86a65696e6e46517cf741" "checksum syn 0.15.21 (registry+https://github.com/rust-lang/crates.io-index)" = "816b7af21405b011a23554ea2dc3f6576dc86ca557047c34098c1d741f10f823" "checksum synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "73687139bf99285483c96ac0add482c3776528beac1d97d444f6e91f203a2015" "checksum time 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "d825be0eb33fda1a7e68012d51e9c7f451dc1a69391e7fdc197060bb8c56667b" @@ -745,6 +891,7 @@ dependencies = [ "checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" "checksum winapi-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "afc5508759c5bf4285e61feb862b6083c8480aec864fa17a81fdec6f69b461ab" "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -"checksum zcash_client_backend 0.0.0 (git+https://github.com/str4d/librustzcash.git?rev=63ec78bb857a258a97d25a5a6e747389996e566a)" = "" -"checksum zcash_primitives 0.0.0 (git+https://github.com/str4d/librustzcash.git?rev=63ec78bb857a258a97d25a5a6e747389996e566a)" = "" -"checksum zip32 0.0.0 (git+https://github.com/str4d/librustzcash.git?rev=63ec78bb857a258a97d25a5a6e747389996e566a)" = "" +"checksum zcash_client_backend 0.0.0 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)" = "" +"checksum zcash_primitives 0.0.0 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)" = "" +"checksum zcash_proofs 0.0.0 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)" = "" +"checksum zip32 0.0.0 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)" = "" diff --git a/Cargo.toml b/Cargo.toml index 8f95f8d5..d1531703 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,17 +6,31 @@ description = "Simple PoC that rust can work with protobufs over JNI" publish = false [dependencies] +failure = "0.1" +protobuf = "2" rand = "0.4" rusqlite = { version = "0.15", features = ["bundled"] } log = "0.4" +[dependencies.ff] +git = "https://github.com/str4d/librustzcash.git" +rev = "89cfef8515d5d88809c485a44fdc54572b9e5666" + +[dependencies.pairing] +git = "https://github.com/str4d/librustzcash.git" +rev = "89cfef8515d5d88809c485a44fdc54572b9e5666" + [dependencies.zcash_client_backend] git = "https://github.com/str4d/librustzcash.git" -rev = "63ec78bb857a258a97d25a5a6e747389996e566a" +rev = "89cfef8515d5d88809c485a44fdc54572b9e5666" + +[dependencies.zcash_primitives] +git = "https://github.com/str4d/librustzcash.git" +rev = "89cfef8515d5d88809c485a44fdc54572b9e5666" [dependencies.zip32] git = "https://github.com/str4d/librustzcash.git" -rev = "63ec78bb857a258a97d25a5a6e747389996e566a" +rev = "89cfef8515d5d88809c485a44fdc54572b9e5666" [target.'cfg(target_os="android")'.dependencies] jni = { version = "0.10", default-features = false } diff --git a/src/main/java/cash/z/wallet/sdk/jni/JniConverter.kt b/src/main/java/cash/z/wallet/sdk/jni/JniConverter.kt index 87e00f2c..ae79bacb 100644 --- a/src/main/java/cash/z/wallet/sdk/jni/JniConverter.kt +++ b/src/main/java/cash/z/wallet/sdk/jni/JniConverter.kt @@ -4,7 +4,7 @@ class JniConverter { external fun getAddress(seed: ByteArray): String - external fun scanBlocks(db_cache: String, db_data: String, seed: ByteArray) + external fun scanBlocks(db_cache: String, db_data: String, seed: ByteArray): Boolean external fun initLogs() diff --git a/src/main/rust/lib.rs b/src/main/rust/lib.rs index 19a392d6..0a7698f6 100644 --- a/src/main/rust/lib.rs +++ b/src/main/rust/lib.rs @@ -1,14 +1,27 @@ +extern crate failure; + #[macro_use] extern crate log; +extern crate ff; +extern crate pairing; +extern crate protobuf; extern crate rusqlite; extern crate zcash_client_backend; +extern crate zcash_primitives; extern crate zip32; +use failure::{format_err, Error}; +use ff::{PrimeField, PrimeFieldRepr}; +use protobuf::parse_from_bytes; use rusqlite::{types::ToSql, Connection, NO_PARAMS}; use zcash_client_backend::{ - address::encode_payment_address, constants::HRP_SAPLING_EXTENDED_SPENDING_KEY_TEST, - welding_rig::scan_block_from_bytes, + constants::HRP_SAPLING_PAYMENT_ADDRESS_TEST, encoding::encode_payment_address, + proto::compact_formats::CompactBlock, welding_rig::scan_block, +}; +use zcash_primitives::{ + merkle_tree::{CommitmentTree, IncrementalWitness}, + JUBJUB, }; use zip32::{ChildIndex, ExtendedFullViewingKey, ExtendedSpendingKey}; @@ -27,7 +40,7 @@ fn extfvk_from_seed(seed: &[u8]) -> ExtendedFullViewingKey { fn address_from_extfvk(extfvk: &ExtendedFullViewingKey) -> String { let addr = extfvk.default_address().unwrap().1; - encode_payment_address(HRP_SAPLING_EXTENDED_SPENDING_KEY_TEST, &addr) + encode_payment_address(HRP_SAPLING_PAYMENT_ADDRESS_TEST, &addr) } fn init_data_database(db_data: &str) -> rusqlite::Result<()> { @@ -35,7 +48,8 @@ fn init_data_database(db_data: &str) -> rusqlite::Result<()> { data.execute( "CREATE TABLE IF NOT EXISTS blocks ( height INTEGER PRIMARY KEY, - time INTEGER + time INTEGER NOT NULL, + sapling_tree BLOB NOT NULL )", NO_PARAMS, )?; @@ -43,7 +57,9 @@ fn init_data_database(db_data: &str) -> rusqlite::Result<()> { "CREATE TABLE IF NOT EXISTS transactions ( id_tx INTEGER PRIMARY KEY, txid BLOB NOT NULL UNIQUE, - block INTEGER NOT NULL, + block INTEGER, + tx_index INTEGER, + raw BLOB, FOREIGN KEY (block) REFERENCES blocks(height) )", NO_PARAMS, @@ -53,12 +69,32 @@ fn init_data_database(db_data: &str) -> rusqlite::Result<()> { id_note INTEGER PRIMARY KEY, tx INTEGER NOT NULL, output_index INTEGER NOT NULL, + account INTEGER NOT NULL, + diversifier BLOB NOT NULL, value INTEGER NOT NULL, + rcm BLOB NOT NULL, + nf BLOB NOT NULL UNIQUE, + is_change BOOLEAN NOT NULL, + memo BLOB, + spent INTEGER, FOREIGN KEY (tx) REFERENCES transactions(id_tx), + FOREIGN KEY (spent) REFERENCES transactions(id_tx), CONSTRAINT tx_output UNIQUE (tx, output_index) )", NO_PARAMS, )?; + data.execute( + "CREATE TABLE IF NOT EXISTS sapling_witnesses ( + id_witness INTEGER PRIMARY KEY, + note INTEGER NOT NULL, + block INTEGER NOT NULL, + witness BLOB NOT NULL, + FOREIGN KEY (note) REFERENCES received_notes(id_note), + FOREIGN KEY (block) REFERENCES blocks(height), + CONSTRAINT witness_height UNIQUE (note, block) + )", + NO_PARAMS, + )?; Ok(()) } @@ -67,6 +103,12 @@ struct CompactBlockRow { data: Vec, } +#[derive(Clone)] +struct WitnessRow { + id_note: i64, + witness: IncrementalWitness, +} + /// Scans new blocks added to the cache for any transactions received by the given /// ExtendedFullViewingKeys. /// @@ -75,7 +117,7 @@ fn scan_cached_blocks( db_cache: &str, db_data: &str, extfvks: &[ExtendedFullViewingKey], -) -> rusqlite::Result<()> { +) -> Result<(), Error> { let cache = Connection::open(db_cache)?; let data = Connection::open(db_data)?; @@ -94,18 +136,35 @@ fn scan_cached_blocks( // Prepare necessary SQL statements let mut stmt_blocks = cache .prepare("SELECT height, data FROM compactblocks WHERE height > ? ORDER BY height ASC")?; + let mut stmt_fetch_tree = data.prepare("SELECT sapling_tree FROM blocks WHERE height = ?")?; + let mut stmt_fetch_witnesses = + data.prepare("SELECT note, witness FROM sapling_witnesses WHERE block = ?")?; + let mut stmt_fetch_nullifiers = + data.prepare("SELECT id_note, nf, account FROM received_notes WHERE spent IS NULL")?; let mut stmt_insert_block = data.prepare( - "INSERT INTO blocks (height) - VALUES (?)", - )?; - let mut stmt_insert_tx = data.prepare( - "INSERT INTO transactions (txid, block) - VALUES (?, ?)", - )?; - let mut stmt_insert_note = data.prepare( - "INSERT INTO received_notes (tx, output_index, value) + "INSERT INTO blocks (height, time, sapling_tree) VALUES (?, ?, ?)", )?; + let mut stmt_update_tx = data.prepare( + "UPDATE transactions + SET block = ?, tx_index = ? WHERE txid = ?", + )?; + let mut stmt_insert_tx = data.prepare( + "INSERT INTO transactions (txid, block, tx_index) + VALUES (?, ?, ?)", + )?; + let mut stmt_select_tx = data.prepare("SELECT id_tx FROM transactions WHERE txid = ?")?; + let mut stmt_mark_spent_note = + data.prepare("UPDATE received_notes SET spent = ? WHERE nf = ?")?; + let mut stmt_insert_note = data.prepare( + "INSERT INTO received_notes (tx, output_index, account, diversifier, value, rcm, nf, is_change) + VALUES (?, ?, ?, ?, ?, ?, ?, ?)", + )?; + let mut stmt_insert_witness = data.prepare( + "INSERT INTO sapling_witnesses (note, block, witness) + VALUES (?, ?, ?)", + )?; + let mut stmt_prune_witnesses = data.prepare("DELETE FROM sapling_witnesses WHERE block < ?")?; // Fetch the CompactBlocks we need to scan let rows = stmt_blocks.query_map(&[last_height], |row| CompactBlockRow { @@ -113,37 +172,165 @@ fn scan_cached_blocks( data: row.get(1), })?; + // Get the most recent CommitmentTree + let mut tree = match stmt_fetch_tree.query_row(&[last_height], |row| match row.get_checked(0) { + Ok(data) => { + let data: Vec<_> = data; + CommitmentTree::read(&data[..]).unwrap() + } + Err(_) => CommitmentTree::new(), + }) { + Ok(tree) => tree, + Err(_) => CommitmentTree::new(), + }; + + // Get most recent incremental witnesses for the notes we are tracking + let witnesses = stmt_fetch_witnesses.query_map(&[last_height], |row| { + let data: Vec<_> = row.get(1); + WitnessRow { + id_note: row.get(0), + witness: IncrementalWitness::read(&data[..]).unwrap(), + } + })?; + let mut witnesses: Vec<_> = witnesses.collect::>()?; + + // Get the nullifiers for the notes we are tracking + let nullifiers = stmt_fetch_nullifiers.query_map(NO_PARAMS, |row| { + let nf: Vec<_> = row.get(1); + let account: i64 = row.get(2); + (nf, account as usize) + })?; + let mut nullifiers: Vec<_> = nullifiers.collect::>()?; + for row in rows { let row = row?; - // Scanned blocks MUST be height-seqential. - if row.height != (last_height + 1) { - error!( - "Expected height of next CompactBlock to be {}, but was {}", + // Start an SQL transaction for this block. + data.execute("BEGIN IMMEDIATE", NO_PARAMS)?; + + // Scanned blocks MUST be height-ascending, but they might not be height-sequential + // (e.g. if blocks that don't contain Sapling data are skipped). Note that this + // introduces a risk that a block containing Sapling data is skipped; it is up to + // the caller to ensure this does not happen. + if row.height <= last_height { + return Err(format_err!( + "Expected height of next CompactBlock to be at least {}, but was {}", last_height + 1, row.height - ); - // Nothing more we can do - break; + )); } last_height = row.height; + let block: CompactBlock = parse_from_bytes(&row.data)?; + let block_time = block.time; + + let txs = { + let nf_refs: Vec<_> = nullifiers.iter().map(|(nf, acc)| (&nf[..], *acc)).collect(); + let mut witness_refs: Vec<_> = witnesses.iter_mut().map(|w| &mut w.witness).collect(); + scan_block(block, &extfvks, &nf_refs, &mut tree, &mut witness_refs[..]) + }; + // Insert the block into the database. - stmt_insert_block.execute(&[row.height.to_sql()?])?; + let mut encoded_tree = Vec::new(); + tree.write(&mut encoded_tree).unwrap(); + stmt_insert_block.execute(&[ + row.height.to_sql()?, + block_time.to_sql()?, + encoded_tree.to_sql()?, + ])?; - for tx in scan_block_from_bytes(&row.data, &extfvks) { - // Insert our transaction into the database. - stmt_insert_tx.execute(&[tx.txid.0.to_vec().to_sql()?, row.height.to_sql()?])?; - let tx_row = data.last_insert_rowid(); + for (tx, new_witnesses) in txs { + // First try update an existing transaction in the database. + let txid = tx.txid.0.to_vec(); + let tx_row = if stmt_update_tx.execute(&[ + row.height.to_sql()?, + (tx.index as i64).to_sql()?, + txid.to_sql()?, + ])? == 0 + { + // It isn't there, so insert our transaction into the database. + stmt_insert_tx.execute(&[ + txid.to_sql()?, + row.height.to_sql()?, + (tx.index as i64).to_sql()?, + ])?; + data.last_insert_rowid() + } else { + // It was there, so grab its row number. + stmt_select_tx.query_row(&[txid], |row| row.get(0))? + }; + + // Mark notes as spent and remove them from the scanning cache + for spend in &tx.shielded_spends { + stmt_mark_spent_note.execute(&[tx_row.to_sql()?, spend.nf.to_sql()?])?; + } + nullifiers = nullifiers + .into_iter() + .filter(|(nf, _acc)| { + tx.shielded_spends + .iter() + .find(|spend| &spend.nf == nf) + .is_none() + }) + .collect(); + + for (output, witness) in tx + .shielded_outputs + .into_iter() + .zip(new_witnesses.into_iter()) + { + let mut rcm = [0; 32]; + output.note.r.into_repr().write_le(&mut rcm[..])?; + let nf = output.note.nf( + &extfvks[output.account].fvk.vk, + witness.position() as u64, + &JUBJUB, + ); - for output in tx.shielded_outputs { // Insert received note into the database. // Assumptions: // - A transaction will not contain more than 2^63 shielded outputs. // - A note value will never exceed 2^63 zatoshis. - stmt_insert_note.execute(&[tx_row, output.index as i64, output.value as i64])?; + stmt_insert_note.execute(&[ + tx_row.to_sql()?, + (output.index as i64).to_sql()?, + (output.account as i64).to_sql()?, + output.to.diversifier.0.to_sql()?, + (output.note.value as i64).to_sql()?, + rcm.to_sql()?, + nf.to_sql()?, + output.is_change.to_sql()?, + ])?; + let note_row = data.last_insert_rowid(); + + // Save witness for note. + witnesses.push(WitnessRow { + id_note: note_row, + witness, + }); + + // Cache nullifier for note (to detect subsequent spends in this scan). + nullifiers.push((nf, output.account)); } } + + // Insert current witnesses into the database. + let mut encoded = Vec::new(); + for witness_row in witnesses.iter() { + encoded.clear(); + witness_row.witness.write(&mut encoded).unwrap(); + stmt_insert_witness.execute(&[ + witness_row.id_note.to_sql()?, + last_height.to_sql()?, + encoded.to_sql()?, + ])?; + } + + // Prune the stored witnesses (we only expect rollbacks of at most 100 blocks). + stmt_prune_witnesses.execute(&[last_height - 100])?; + + // Commit the SQL transaction, writing this block's data atomically. + data.execute("COMMIT", NO_PARAMS)?; } Ok(()) @@ -161,7 +348,7 @@ pub mod android { use self::android_logger::Filter; use self::jni::objects::{JClass, JString}; - use self::jni::sys::{jbyteArray, jstring}; + use self::jni::sys::{jboolean, jbyteArray, jstring, JNI_FALSE, JNI_TRUE}; use self::jni::JNIEnv; use super::{address_from_extfvk, extfvk_from_seed, scan_cached_blocks}; @@ -202,7 +389,7 @@ pub mod android { db_cache: JString, db_data: JString, seed: jbyteArray, - ) { + ) -> jboolean { let db_cache: String = env .get_string(db_cache) .expect("Couldn't get Java string!") @@ -213,8 +400,12 @@ pub mod android { .into(); let seed = env.convert_byte_array(seed).unwrap(); - if let Err(e) = scan_cached_blocks(&db_cache, &db_data, &[extfvk_from_seed(&seed)]) { - error!("Error while scanning blocks: {}", e); + match scan_cached_blocks(&db_cache, &db_data, &[extfvk_from_seed(&seed)]) { + Ok(()) => JNI_TRUE, + Err(e) => { + error!("Error while scanning blocks: {}", e); + JNI_FALSE + } } } } From 3966798f5367e80b3b9093d78536cee3bda19fa8 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Mon, 3 Dec 2018 02:44:42 +0000 Subject: [PATCH 04/14] API for creating transactions --- Cargo.lock | 1 + Cargo.toml | 4 + src/main/rust/lib.rs | 207 ++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 211 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index a743e230..a020b462 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -723,6 +723,7 @@ dependencies = [ "protobuf 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "rusqlite 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sapling-crypto 0.0.1 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)", "zcash_client_backend 0.0.0 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)", "zcash_primitives 0.0.0 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)", "zip32 0.0.0 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)", diff --git a/Cargo.toml b/Cargo.toml index d1531703..680089cd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,6 +20,10 @@ rev = "89cfef8515d5d88809c485a44fdc54572b9e5666" git = "https://github.com/str4d/librustzcash.git" rev = "89cfef8515d5d88809c485a44fdc54572b9e5666" +[dependencies.sapling-crypto] +git = "https://github.com/str4d/librustzcash.git" +rev = "89cfef8515d5d88809c485a44fdc54572b9e5666" + [dependencies.zcash_client_backend] git = "https://github.com/str4d/librustzcash.git" rev = "89cfef8515d5d88809c485a44fdc54572b9e5666" diff --git a/src/main/rust/lib.rs b/src/main/rust/lib.rs index 0a7698f6..ab8a9ad4 100644 --- a/src/main/rust/lib.rs +++ b/src/main/rust/lib.rs @@ -7,24 +7,34 @@ extern crate ff; extern crate pairing; extern crate protobuf; extern crate rusqlite; +extern crate sapling_crypto; extern crate zcash_client_backend; extern crate zcash_primitives; extern crate zip32; use failure::{format_err, Error}; use ff::{PrimeField, PrimeFieldRepr}; +use pairing::bls12_381::Bls12; use protobuf::parse_from_bytes; use rusqlite::{types::ToSql, Connection, NO_PARAMS}; +use sapling_crypto::{ + jubjub::fs::{Fs, FsRepr}, + primitives::{Diversifier, Note, PaymentAddress}, +}; use zcash_client_backend::{ constants::HRP_SAPLING_PAYMENT_ADDRESS_TEST, encoding::encode_payment_address, - proto::compact_formats::CompactBlock, welding_rig::scan_block, + note_encryption::Memo, proto::compact_formats::CompactBlock, prover::TxProver, + transaction::Builder, welding_rig::scan_block, }; use zcash_primitives::{ merkle_tree::{CommitmentTree, IncrementalWitness}, + transaction::components::Amount, JUBJUB, }; use zip32::{ChildIndex, ExtendedFullViewingKey, ExtendedSpendingKey}; +const ANCHOR_OFFSET: u32 = 10; + fn extfvk_from_seed(seed: &[u8]) -> ExtendedFullViewingKey { let master = ExtendedSpendingKey::master(seed); let extsk = ExtendedSpendingKey::from_path( @@ -95,6 +105,20 @@ fn init_data_database(db_data: &str) -> rusqlite::Result<()> { )", NO_PARAMS, )?; + data.execute( + "CREATE TABLE IF NOT EXISTS sent_notes ( + id_note INTEGER PRIMARY KEY, + tx INTEGER NOT NULL, + output_index INTEGER NOT NULL, + from_account INTEGER NOT NULL, + address TEXT NOT NULL, + value INTEGER NOT NULL, + memo BLOB, + FOREIGN KEY (tx) REFERENCES transactions(id_tx), + CONSTRAINT tx_output UNIQUE (tx, output_index) + )", + NO_PARAMS, + )?; Ok(()) } @@ -336,6 +360,187 @@ fn scan_cached_blocks( Ok(()) } +struct SelectedNoteRow { + diversifier: Diversifier, + note: Note, + witness: IncrementalWitness, +} + +/// Creates a transaction paying the specified address. +fn send_to_address( + db_data: &str, + consensus_branch_id: u32, + prover: impl TxProver, + account: u32, + extsk: &ExtendedSpendingKey, + to: &PaymentAddress, + value: Amount, + memo: Option, +) -> Result { + let data = Connection::open(db_data)?; + + // Check that the ExtendedSpendingKey we have been given corresponds to the + // ExtendedFullViewingKey for the account we are spending from. + let extfvk = ExtendedFullViewingKey::from(extsk); + if !data + .prepare("SELECT * FROM accounts WHERE account = ? AND extfvk = ?")? + .exists(&[ + account.to_sql()?, + encode_extended_full_viewing_key(HRP_SAPLING_EXTENDED_FULL_VIEWING_KEY_TEST, &extfvk) + .to_sql()?, + ])? + { + return Err(format_err!( + "Incorrect ExtendedSpendingKey for account {}", + account + )); + } + let ovk = extfvk.fvk.ovk; + + // Target the next block, assuming we are up-to-date. + let height = data.query_row_and_then("SELECT MAX(height) FROM blocks", NO_PARAMS, |row| { + let ret: Result = row.get_checked(0); + ret + })? + 1; + + // The goal of this SQL statement is to select the oldest notes until the required + // value has been reached, and then fetch the witnesses at the desired height for the + // selected notes. This is achieved in several steps: + // + // 1) Use a window function to create a view of all notes, ordered from oldest to + // newest, with an additional column containing a running sum: + // - Unspent notes accumulate the values of all unspent notes in that note's + // account, up to itself. + // - Spent notes accumulate the values of all notes in the transaction they were + // spent in, up to itself. + // + // 2) Select all unspent notes in the desired account, along with their running sum. + // + // 3) Select all notes for which the running sum was less than the required value, as + // well as a single note for which the sum was greater than or equal to the + // required value, bringing the sum of all selected notes across the threshold. + // + // 4) Match the selected notes against the witnesses at the desired height. + let mut stmt_select_notes = data.prepare( + "WITH selected AS ( + WITH eligible AS ( + SELECT id_note, diversifier, value, rcm, + SUM(value) OVER + (PARTITION BY account, spent ORDER BY id_note) AS so_far + FROM received_notes + WHERE account = ? AND spent IS NULL + ) + SELECT * FROM eligible WHERE so_far < ? + UNION + SELECT * FROM (SELECT * FROM eligible WHERE so_far >= ? LIMIT 1) + ), witnesses AS ( + SELECT note, witness FROM sapling_witnesses + WHERE block = ? + ) + SELECT selected.diversifier, selected.value, selected.rcm, witnesses.witness + FROM selected + INNER JOIN witnesses ON selected.id_note = witnesses.note", + )?; + + // Select notes + let notes = stmt_select_notes.query_and_then::<_, Error, _, _>( + &[ + account as i64, + value.0, + value.0, + (height - ANCHOR_OFFSET) as i64, + ], + |row| { + let mut diversifier = Diversifier([0; 11]); + let d: Vec<_> = row.get(0); + diversifier.0.copy_from_slice(&d); + + let note_value: i64 = row.get(1); + + let d: Vec<_> = row.get(2); + let rcm = { + let mut tmp = FsRepr::default(); + tmp.read_le(&d[..])?; + Fs::from_repr(tmp)? + }; + + let from = extfvk + .fvk + .vk + .into_payment_address(diversifier, &JUBJUB) + .unwrap(); + let note = from.create_note(note_value as u64, rcm, &JUBJUB).unwrap(); + + let d: Vec<_> = row.get(3); + let witness = IncrementalWitness::read(&d[..])?; + + Ok(SelectedNoteRow { + diversifier, + note, + witness, + }) + }, + )?; + + // Create the transaction + let mut builder = Builder::new(height); + for selected in notes { + let selected = selected?; + builder.add_sapling_spend( + extsk.clone(), + selected.diversifier, + selected.note, + selected.witness, + )?; + } + builder.add_sapling_output(ovk, to.clone(), value, memo.clone())?; + let (tx, tx_metadata) = builder.build(consensus_branch_id, prover)?; + // We only called add_sapling_output() once. + let output_index = tx_metadata.output_index(0).unwrap() as i64; + + // Save the transaction in the database. + let mut raw_tx = vec![]; + tx.write(&mut raw_tx)?; + let mut stmt_insert_tx = data.prepare( + "INSERT INTO transactions (txid, raw) + VALUES (?, ?)", + )?; + stmt_insert_tx.execute(&[&tx.txid().0[..], &raw_tx[..]])?; + let id_tx = data.last_insert_rowid(); + + // Save the sent note in the database. + let to_str = encode_payment_address(HRP_SAPLING_PAYMENT_ADDRESS_TEST, to); + if memo.is_some() { + let mut stmt_insert_sent_note = data.prepare( + "INSERT INTO sent_notes (tx, output_index, from_account, address, value, memo) + VALUES (?, ?, ?, ?, ?, ?)", + )?; + stmt_insert_sent_note.execute(&[ + id_tx.to_sql()?, + output_index.to_sql()?, + account.to_sql()?, + to_str.to_sql()?, + value.0.to_sql()?, + memo.unwrap().as_bytes().to_sql()?, + ])?; + } else { + let mut stmt_insert_sent_note = data.prepare( + "INSERT INTO sent_notes (tx, output_index, from_account, address, value) + VALUES (?, ?, ?, ?, ?)", + )?; + stmt_insert_sent_note.execute(&[ + id_tx.to_sql()?, + output_index.to_sql()?, + account.to_sql()?, + to_str.to_sql()?, + value.0.to_sql()?, + ])?; + } + + // Return the row number of the transaction, so the caller can fetch it for sending. + Ok(id_tx) +} + /// JNI interface #[cfg(target_os = "android")] #[allow(non_snake_case)] From d98191d11034c36941c5e86aa1b7063802fde977 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Tue, 4 Dec 2018 16:36:47 +0000 Subject: [PATCH 05/14] JniConverter.sendToAddress() --- .../cash/z/wallet/sdk/jni/JniConverter.kt | 9 ++ src/main/rust/lib.rs | 112 +++++++++++++++++- 2 files changed, 119 insertions(+), 2 deletions(-) diff --git a/src/main/java/cash/z/wallet/sdk/jni/JniConverter.kt b/src/main/java/cash/z/wallet/sdk/jni/JniConverter.kt index ae79bacb..200ef0ac 100644 --- a/src/main/java/cash/z/wallet/sdk/jni/JniConverter.kt +++ b/src/main/java/cash/z/wallet/sdk/jni/JniConverter.kt @@ -6,6 +6,15 @@ class JniConverter { external fun scanBlocks(db_cache: String, db_data: String, seed: ByteArray): Boolean + external fun sendToAddress( + dbData: String, + seed: ByteArray, + to: String, + value: Long, + memo: String, + spendParams: String, + outputParams: String): Long + external fun initLogs() companion object { diff --git a/src/main/rust/lib.rs b/src/main/rust/lib.rs index ab8a9ad4..c85e7b4b 100644 --- a/src/main/rust/lib.rs +++ b/src/main/rust/lib.rs @@ -33,6 +33,8 @@ use zcash_primitives::{ }; use zip32::{ChildIndex, ExtendedFullViewingKey, ExtendedSpendingKey}; +const SAPLING_CONSENSUS_BRANCH_ID: u32 = 0x76b8_09bb; + const ANCHOR_OFFSET: u32 = 10; fn extfvk_from_seed(seed: &[u8]) -> ExtendedFullViewingKey { @@ -550,13 +552,24 @@ pub mod android { extern crate log_panics; use log::Level; + use std::path::Path; + use zcash_client_backend::{ + constants::{HRP_SAPLING_EXTENDED_SPENDING_KEY_TEST, HRP_SAPLING_PAYMENT_ADDRESS_TEST}, + encoding::{decode_extended_spending_key, decode_payment_address}, + note_encryption::Memo, + prover::LocalTxProver, + }; + use zcash_primitives::transaction::components::Amount; use self::android_logger::Filter; use self::jni::objects::{JClass, JString}; - use self::jni::sys::{jboolean, jbyteArray, jstring, JNI_FALSE, JNI_TRUE}; + use self::jni::sys::{jboolean, jbyteArray, jint, jlong, jstring, JNI_FALSE, JNI_TRUE}; use self::jni::JNIEnv; - use super::{address_from_extfvk, extfvk_from_seed, scan_cached_blocks}; + use super::{ + address_from_extfvk, extfvk_from_seed, scan_cached_blocks, send_to_address, + SAPLING_CONSENSUS_BRANCH_ID, + }; #[no_mangle] pub unsafe extern "C" fn Java_cash_z_wallet_sdk_jni_JniConverter_initLogs( @@ -613,4 +626,99 @@ pub mod android { } } } + + #[no_mangle] + pub unsafe extern "C" fn Java_cash_z_wallet_sdk_jni_JniConverter_sendToAddress( + env: JNIEnv, + _: JClass, + db_data: JString, + account: jint, + extsk: JString, + to: JString, + value: jlong, + memo: JString, + spend_params: JString, + output_params: JString, + ) -> jlong { + let db_data: String = env + .get_string(db_data) + .expect("Couldn't get Java string!") + .into(); + let account = if account >= 0 { + account as u32 + } else { + error!("account argument must be positive"); + return -1; + }; + let extsk: String = env + .get_string(extsk) + .expect("Couldn't get Java string!") + .into(); + let to: String = env + .get_string(to) + .expect("Couldn't get Java string!") + .into(); + let value = Amount(value); + let memo: String = env + .get_string(memo) + .expect("Couldn't get Java string!") + .into(); + let spend_params: String = env + .get_string(spend_params) + .expect("Couldn't get Java string!") + .into(); + let output_params: String = env + .get_string(output_params) + .expect("Couldn't get Java string!") + .into(); + + let extsk = + match decode_extended_spending_key(HRP_SAPLING_EXTENDED_SPENDING_KEY_TEST, &extsk) { + Ok(extsk) => extsk, + Err(e) => { + error!("Invalid ExtendedSpendingKey: {}", e); + return -1; + } + }; + + let to = match decode_payment_address(HRP_SAPLING_PAYMENT_ADDRESS_TEST, &to) { + Ok(to) => to, + Err(e) => { + error!("Invalid PaymentAddress: {}", e); + return -1; + } + }; + + let memo = match Memo::from_str(&memo) { + Ok(memo) => Some(memo), + Err(()) => { + error!("Memo is too long"); + return -1; + } + }; + + let prover = LocalTxProver::new( + Path::new(&spend_params), + "8270785a1a0d0bc77196f000ee6d221c9c9894f55307bd9357c3f0105d31ca63991ab91324160d8f53e2bbd3c2633a6eb8bdf5205d822e7f3f73edac51b2b70c", + Path::new(&output_params), + "657e3d38dbb5cb5e7dd2970e8b03d69b4787dd907285b5a7f0790dcc8072f60bf593b32cc2d1c030e00ff5ae64bf84c5c3beb84ddc841d48264b4a171744d028", + ); + + match send_to_address( + &db_data, + SAPLING_CONSENSUS_BRANCH_ID, + prover, + account, + &extsk, + &to, + value, + memo, + ) { + Ok(tx_row) => tx_row, + Err(e) => { + error!("Error while sending funds: {}", e); + -1 + } + } + } } From aa391063d17c001220a49f79cab5238e61935466 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Tue, 4 Dec 2018 16:46:24 +0000 Subject: [PATCH 06/14] JniConverter.getBalance() --- .../cash/z/wallet/sdk/jni/JniConverter.kt | 2 + src/main/rust/lib.rs | 42 ++++++++++++++++++- 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/src/main/java/cash/z/wallet/sdk/jni/JniConverter.kt b/src/main/java/cash/z/wallet/sdk/jni/JniConverter.kt index 200ef0ac..8ace0956 100644 --- a/src/main/java/cash/z/wallet/sdk/jni/JniConverter.kt +++ b/src/main/java/cash/z/wallet/sdk/jni/JniConverter.kt @@ -4,6 +4,8 @@ class JniConverter { external fun getAddress(seed: ByteArray): String + external fun getBalance(dbData: String, account: Int): Long + external fun scanBlocks(db_cache: String, db_data: String, seed: ByteArray): Boolean external fun sendToAddress( diff --git a/src/main/rust/lib.rs b/src/main/rust/lib.rs index c85e7b4b..81a86bcc 100644 --- a/src/main/rust/lib.rs +++ b/src/main/rust/lib.rs @@ -135,6 +135,19 @@ struct WitnessRow { witness: IncrementalWitness, } +fn get_balance(db_data: &str, account: u32) -> Result { + let data = Connection::open(db_data)?; + + let balance = data.query_row( + "SELECT SUM(value) FROM received_notes + WHERE account = ? AND spent IS NULL", + &[account], + |row| row.get_checked(0).unwrap_or(0), + )?; + + Ok(Amount(balance)) +} + /// Scans new blocks added to the cache for any transactions received by the given /// ExtendedFullViewingKeys. /// @@ -567,7 +580,7 @@ pub mod android { use self::jni::JNIEnv; use super::{ - address_from_extfvk, extfvk_from_seed, scan_cached_blocks, send_to_address, + address_from_extfvk, extfvk_from_seed, get_balance, scan_cached_blocks, send_to_address, SAPLING_CONSENSUS_BRANCH_ID, }; @@ -600,6 +613,33 @@ pub mod android { output.into_inner() } + #[no_mangle] + pub unsafe extern "C" fn Java_cash_z_wallet_sdk_jni_JniConverter_getBalance( + env: JNIEnv, + _: JClass, + db_data: JString, + account: jint, + ) -> jlong { + let db_data: String = env + .get_string(db_data) + .expect("Couldn't get Java string!") + .into(); + let account = if account >= 0 { + account as u32 + } else { + error!("account argument must be positive"); + return -1; + }; + + match get_balance(&db_data, account) { + Ok(balance) => balance.0, + Err(e) => { + error!("Error while fetching balance: {}", e); + -1 + } + } + } + #[no_mangle] pub unsafe extern "C" fn Java_cash_z_wallet_sdk_jni_JniConverter_scanBlocks( env: JNIEnv, From 41bb9a1a4b12dcd36d50b73cb43939e5ca560373 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Mon, 14 Jan 2019 16:31:26 -0800 Subject: [PATCH 07/14] JniConverter.initDataDb() --- .../cash/z/wallet/sdk/jni/JniConverter.kt | 2 ++ src/main/rust/lib.rs | 24 +++++++++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/main/java/cash/z/wallet/sdk/jni/JniConverter.kt b/src/main/java/cash/z/wallet/sdk/jni/JniConverter.kt index 8ace0956..cd2be3c7 100644 --- a/src/main/java/cash/z/wallet/sdk/jni/JniConverter.kt +++ b/src/main/java/cash/z/wallet/sdk/jni/JniConverter.kt @@ -2,6 +2,8 @@ package cash.z.wallet.sdk.jni class JniConverter { + external fun initDataDb(dbData: String): Boolean + external fun getAddress(seed: ByteArray): String external fun getBalance(dbData: String, account: Int): Long diff --git a/src/main/rust/lib.rs b/src/main/rust/lib.rs index 81a86bcc..9832d79a 100644 --- a/src/main/rust/lib.rs +++ b/src/main/rust/lib.rs @@ -580,8 +580,8 @@ pub mod android { use self::jni::JNIEnv; use super::{ - address_from_extfvk, extfvk_from_seed, get_balance, scan_cached_blocks, send_to_address, - SAPLING_CONSENSUS_BRANCH_ID, + address_from_extfvk, extfvk_from_seed, get_balance, init_data_database, scan_cached_blocks, + send_to_address, SAPLING_CONSENSUS_BRANCH_ID, }; #[no_mangle] @@ -599,6 +599,26 @@ pub mod android { debug!("logs have been initialized successfully"); } + #[no_mangle] + pub unsafe extern "C" fn Java_cash_z_wallet_sdk_jni_JniConverter_initDataDb( + env: JNIEnv, + _: JClass, + db_data: JString, + ) -> jboolean { + let db_data: String = env + .get_string(db_data) + .expect("Couldn't get Java string!") + .into(); + + match init_data_database(&db_data) { + Ok(()) => JNI_TRUE, + Err(e) => { + error!("Error while initializing data DB: {}", e); + JNI_FALSE + } + } + } + #[no_mangle] pub unsafe extern "C" fn Java_cash_z_wallet_sdk_jni_JniConverter_getAddress( env: JNIEnv, From e3b85f0e97e1c19b6ee0fe8d6a952871b19eeb3e Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Tue, 15 Jan 2019 11:38:40 -0800 Subject: [PATCH 08/14] build script: Exit if ANDROID_HOME environment variable is not set --- build-ndk-standalone.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/build-ndk-standalone.sh b/build-ndk-standalone.sh index cca68b30..0d927199 100755 --- a/build-ndk-standalone.sh +++ b/build-ndk-standalone.sh @@ -14,6 +14,7 @@ function generate_standalone_ndk() # Try to find and print some info about the NDK based on the location of the toolchain script if [ ! -f "$standalone_script" ]; then echo "NDK not found. Please make sure that ANDROID_HOME is set and the NDK has been installed there" + exit 40 else echo "Standalone NDK files appear to be missing.\n Attempting to install them..." ndk_dir=$(dirname $(dirname $(dirname $standalone_script 2>/dev/null) 2>/dev/null) 2>/dev/null) From c26249373d2e507edc27ea4ed8423f17d742e3cb Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Mon, 28 Jan 2019 13:05:12 +0000 Subject: [PATCH 09/14] JniConverter.initBlocksTable() --- .../cash/z/wallet/sdk/jni/JniConverter.kt | 6 ++ src/main/rust/lib.rs | 56 ++++++++++++++++++- 2 files changed, 60 insertions(+), 2 deletions(-) diff --git a/src/main/java/cash/z/wallet/sdk/jni/JniConverter.kt b/src/main/java/cash/z/wallet/sdk/jni/JniConverter.kt index cd2be3c7..73abd3fc 100644 --- a/src/main/java/cash/z/wallet/sdk/jni/JniConverter.kt +++ b/src/main/java/cash/z/wallet/sdk/jni/JniConverter.kt @@ -4,6 +4,12 @@ class JniConverter { external fun initDataDb(dbData: String): Boolean + external fun initBlocksTable( + dbData: String, + height: Int, + time: Long, + saplingTree: ByteArray): Boolean + external fun getAddress(seed: ByteArray): String external fun getBalance(dbData: String, account: Int): Long diff --git a/src/main/rust/lib.rs b/src/main/rust/lib.rs index 9832d79a..44d0d0b0 100644 --- a/src/main/rust/lib.rs +++ b/src/main/rust/lib.rs @@ -124,6 +124,28 @@ fn init_data_database(db_data: &str) -> rusqlite::Result<()> { Ok(()) } +fn init_blocks_table( + db_data: &str, + height: i32, + time: u32, + sapling_tree: &[u8], +) -> Result<(), Error> { + let data = Connection::open(db_data)?; + + let mut empty_check = data.prepare("SELECT * FROM blocks LIMIT 1")?; + if empty_check.exists(NO_PARAMS)? { + return Err(format_err!("blocks table is not empty")); + } + + data.execute( + "INSERT INTO blocks (height, time, sapling_tree) + VALUES (?, ?, ?)", + &[height.to_sql()?, time.to_sql()?, sapling_tree.to_sql()?], + )?; + + Ok(()) +} + struct CompactBlockRow { height: i32, data: Vec, @@ -580,8 +602,8 @@ pub mod android { use self::jni::JNIEnv; use super::{ - address_from_extfvk, extfvk_from_seed, get_balance, init_data_database, scan_cached_blocks, - send_to_address, SAPLING_CONSENSUS_BRANCH_ID, + address_from_extfvk, extfvk_from_seed, get_balance, init_blocks_table, init_data_database, + scan_cached_blocks, send_to_address, SAPLING_CONSENSUS_BRANCH_ID, }; #[no_mangle] @@ -619,6 +641,36 @@ pub mod android { } } + #[no_mangle] + pub unsafe extern "C" fn Java_cash_z_wallet_sdk_jni_JniConverter_initBlocksTable( + env: JNIEnv, + _: JClass, + db_data: JString, + height: jint, + time: jlong, + sapling_tree: jbyteArray, + ) -> jboolean { + let db_data: String = env + .get_string(db_data) + .expect("Couldn't get Java string!") + .into(); + let time = if time >= 0 && time <= (u32::max_value() as jlong) { + time as u32 + } else { + error!("time argument must fit in a u32"); + return JNI_FALSE; + }; + let sapling_tree = env.convert_byte_array(sapling_tree).unwrap(); + + match init_blocks_table(&db_data, height, time, &sapling_tree) { + Ok(()) => JNI_TRUE, + Err(e) => { + error!("Error while initializing data DB: {}", e); + JNI_FALSE + } + } + } + #[no_mangle] pub unsafe extern "C" fn Java_cash_z_wallet_sdk_jni_JniConverter_getAddress( env: JNIEnv, From d9232c885db40bb85ef52c55fe79514288089e20 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Wed, 30 Jan 2019 01:41:50 +0000 Subject: [PATCH 10/14] JniConverter.initAccountsTable() --- .../cash/z/wallet/sdk/jni/JniConverter.kt | 5 + src/main/rust/lib.rs | 129 +++++++++++++++++- 2 files changed, 127 insertions(+), 7 deletions(-) diff --git a/src/main/java/cash/z/wallet/sdk/jni/JniConverter.kt b/src/main/java/cash/z/wallet/sdk/jni/JniConverter.kt index 73abd3fc..79f974e8 100644 --- a/src/main/java/cash/z/wallet/sdk/jni/JniConverter.kt +++ b/src/main/java/cash/z/wallet/sdk/jni/JniConverter.kt @@ -4,6 +4,11 @@ class JniConverter { external fun initDataDb(dbData: String): Boolean + external fun initAccountsTable( + dbData: String, + seed: ByteArray, + accounts: Int): Array + external fun initBlocksTable( dbData: String, height: Int, diff --git a/src/main/rust/lib.rs b/src/main/rust/lib.rs index 44d0d0b0..13822c78 100644 --- a/src/main/rust/lib.rs +++ b/src/main/rust/lib.rs @@ -22,9 +22,13 @@ use sapling_crypto::{ primitives::{Diversifier, Note, PaymentAddress}, }; use zcash_client_backend::{ - constants::HRP_SAPLING_PAYMENT_ADDRESS_TEST, encoding::encode_payment_address, - note_encryption::Memo, proto::compact_formats::CompactBlock, prover::TxProver, - transaction::Builder, welding_rig::scan_block, + constants::{HRP_SAPLING_EXTENDED_FULL_VIEWING_KEY_TEST, HRP_SAPLING_PAYMENT_ADDRESS_TEST}, + encoding::{encode_extended_full_viewing_key, encode_payment_address}, + note_encryption::Memo, + proto::compact_formats::CompactBlock, + prover::TxProver, + transaction::Builder, + welding_rig::scan_block, }; use zcash_primitives::{ merkle_tree::{CommitmentTree, IncrementalWitness}, @@ -57,6 +61,14 @@ fn address_from_extfvk(extfvk: &ExtendedFullViewingKey) -> String { fn init_data_database(db_data: &str) -> rusqlite::Result<()> { let data = Connection::open(db_data)?; + data.execute( + "CREATE TABLE IF NOT EXISTS accounts ( + account INTEGER PRIMARY KEY, + extfvk TEXT NOT NULL, + address TEXT NOT NULL + )", + NO_PARAMS, + )?; data.execute( "CREATE TABLE IF NOT EXISTS blocks ( height INTEGER PRIMARY KEY, @@ -90,6 +102,7 @@ fn init_data_database(db_data: &str) -> rusqlite::Result<()> { memo BLOB, spent INTEGER, FOREIGN KEY (tx) REFERENCES transactions(id_tx), + FOREIGN KEY (account) REFERENCES accounts(account), FOREIGN KEY (spent) REFERENCES transactions(id_tx), CONSTRAINT tx_output UNIQUE (tx, output_index) )", @@ -117,6 +130,7 @@ fn init_data_database(db_data: &str) -> rusqlite::Result<()> { value INTEGER NOT NULL, memo BLOB, FOREIGN KEY (tx) REFERENCES transactions(id_tx), + FOREIGN KEY (from_account) REFERENCES accounts(account), CONSTRAINT tx_output UNIQUE (tx, output_index) )", NO_PARAMS, @@ -124,6 +138,35 @@ fn init_data_database(db_data: &str) -> rusqlite::Result<()> { Ok(()) } +fn init_accounts_table(db_data: &str, extfvks: &[ExtendedFullViewingKey]) -> Result<(), Error> { + let data = Connection::open(db_data)?; + + let mut empty_check = data.prepare("SELECT * FROM accounts LIMIT 1")?; + if empty_check.exists(NO_PARAMS)? { + return Err(format_err!("accounts table is not empty")); + } + + // Insert accounts atomically + data.execute("BEGIN IMMEDIATE", NO_PARAMS)?; + for (account, extfvk) in extfvks.iter().enumerate() { + let address = address_from_extfvk(extfvk); + let extfvk = + encode_extended_full_viewing_key(HRP_SAPLING_EXTENDED_FULL_VIEWING_KEY_TEST, extfvk); + data.execute( + "INSERT INTO accounts (account, extfvk, address) + VALUES (?, ?, ?)", + &[ + (account as u32).to_sql()?, + extfvk.to_sql()?, + address.to_sql()?, + ], + )?; + } + data.execute("COMMIT", NO_PARAMS)?; + + Ok(()) +} + fn init_blocks_table( db_data: &str, height: i32, @@ -590,20 +633,25 @@ pub mod android { use std::path::Path; use zcash_client_backend::{ constants::{HRP_SAPLING_EXTENDED_SPENDING_KEY_TEST, HRP_SAPLING_PAYMENT_ADDRESS_TEST}, - encoding::{decode_extended_spending_key, decode_payment_address}, + encoding::{ + decode_extended_spending_key, decode_payment_address, encode_extended_spending_key, + }, note_encryption::Memo, prover::LocalTxProver, }; use zcash_primitives::transaction::components::Amount; + use zip32::{ChildIndex, ExtendedFullViewingKey, ExtendedSpendingKey}; use self::android_logger::Filter; use self::jni::objects::{JClass, JString}; - use self::jni::sys::{jboolean, jbyteArray, jint, jlong, jstring, JNI_FALSE, JNI_TRUE}; + use self::jni::sys::{ + jboolean, jbyteArray, jint, jlong, jobjectArray, jsize, jstring, JNI_FALSE, JNI_TRUE, + }; use self::jni::JNIEnv; use super::{ - address_from_extfvk, extfvk_from_seed, get_balance, init_blocks_table, init_data_database, - scan_cached_blocks, send_to_address, SAPLING_CONSENSUS_BRANCH_ID, + address_from_extfvk, extfvk_from_seed, get_balance, init_accounts_table, init_blocks_table, + init_data_database, scan_cached_blocks, send_to_address, SAPLING_CONSENSUS_BRANCH_ID, }; #[no_mangle] @@ -641,6 +689,73 @@ pub mod android { } } + #[no_mangle] + pub unsafe extern "C" fn Java_cash_z_wallet_sdk_jni_JniConverter_initAccountsTable( + env: JNIEnv, + _: JClass, + db_data: JString, + seed: jbyteArray, + accounts: jint, + ) -> jobjectArray { + let db_data: String = env + .get_string(db_data) + .expect("Couldn't get Java string!") + .into(); + let seed = env.convert_byte_array(seed).unwrap(); + + let ret = if accounts >= 0 { + let master = ExtendedSpendingKey::master(&seed); + let extsks: Vec<_> = (0..accounts as u32) + .map(|account| { + ExtendedSpendingKey::from_path( + &master, + &[ + ChildIndex::Hardened(32), + ChildIndex::Hardened(1), + ChildIndex::Hardened(account), + ], + ) + }) + .collect(); + let extfvks: Vec<_> = extsks + .iter() + .map(|extsk| ExtendedFullViewingKey::from(extsk)) + .collect(); + + match init_accounts_table(&db_data, &extfvks) { + Ok(()) => { + // Return the ExtendedSpendingKeys for the created accounts + extsks + } + Err(e) => { + error!("Error while initializing accounts: {}", e); + // Return an empty array to indicate an error + vec![] + } + } + } else { + error!("accounts argument must be positive"); + // Return an empty array to indicate an error + vec![] + }; + + let jempty = env.new_string("").expect("Couldn't create Java string!"); + let jret = env + .new_object_array(ret.len() as jsize, "java/lang/String", *jempty) + .expect("Couldn't create Java array!"); + for (i, extsk) in ret.into_iter().enumerate() { + let jextsk = env + .new_string(encode_extended_spending_key( + HRP_SAPLING_EXTENDED_SPENDING_KEY_TEST, + &extsk, + )) + .expect("Couldn't create Java string!"); + env.set_object_array_element(jret, i as jsize, *jextsk) + .expect("Couldn't set Java array element!"); + } + jret + } + #[no_mangle] pub unsafe extern "C" fn Java_cash_z_wallet_sdk_jni_JniConverter_initBlocksTable( env: JNIEnv, From b608b026ed1b7708fbc5b82a832094c0d35e8c1d Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Wed, 30 Jan 2019 01:51:50 +0000 Subject: [PATCH 11/14] Remove seed argument from JniConverter.scanBlocks() The API now scans cached CompactBlocks using the ExtendedFullViewingKeys for the internally-tracked accounts. --- .../cash/z/wallet/sdk/jni/JniConverter.kt | 2 +- src/main/rust/lib.rs | 36 ++++++++++++------- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/src/main/java/cash/z/wallet/sdk/jni/JniConverter.kt b/src/main/java/cash/z/wallet/sdk/jni/JniConverter.kt index 79f974e8..35a94d1a 100644 --- a/src/main/java/cash/z/wallet/sdk/jni/JniConverter.kt +++ b/src/main/java/cash/z/wallet/sdk/jni/JniConverter.kt @@ -19,7 +19,7 @@ class JniConverter { external fun getBalance(dbData: String, account: Int): Long - external fun scanBlocks(db_cache: String, db_data: String, seed: ByteArray): Boolean + external fun scanBlocks(db_cache: String, db_data: String): Boolean external fun sendToAddress( dbData: String, diff --git a/src/main/rust/lib.rs b/src/main/rust/lib.rs index 13822c78..3e4f607c 100644 --- a/src/main/rust/lib.rs +++ b/src/main/rust/lib.rs @@ -23,7 +23,9 @@ use sapling_crypto::{ }; use zcash_client_backend::{ constants::{HRP_SAPLING_EXTENDED_FULL_VIEWING_KEY_TEST, HRP_SAPLING_PAYMENT_ADDRESS_TEST}, - encoding::{encode_extended_full_viewing_key, encode_payment_address}, + encoding::{ + decode_extended_full_viewing_key, encode_extended_full_viewing_key, encode_payment_address, + }, note_encryption::Memo, proto::compact_formats::CompactBlock, prover::TxProver, @@ -213,15 +215,11 @@ fn get_balance(db_data: &str, account: u32) -> Result { Ok(Amount(balance)) } -/// Scans new blocks added to the cache for any transactions received by the given -/// ExtendedFullViewingKeys. +/// Scans new blocks added to the cache for any transactions received by the +/// tracked accounts. /// /// Assumes that the caller is handling rollbacks. -fn scan_cached_blocks( - db_cache: &str, - db_data: &str, - extfvks: &[ExtendedFullViewingKey], -) -> Result<(), Error> { +fn scan_cached_blocks(db_cache: &str, db_data: &str) -> Result<(), Error> { let cache = Connection::open(db_cache)?; let data = Connection::open(db_data)?; @@ -276,6 +274,16 @@ fn scan_cached_blocks( data: row.get(1), })?; + // Fetch the ExtendedFullViewingKeys we are tracking + let mut stmt_fetch_accounts = + data.prepare("SELECT extfvk FROM accounts ORDER BY account ASC")?; + let extfvks = stmt_fetch_accounts.query_map(NO_PARAMS, |row| { + let extfvk: String = row.get(0); + decode_extended_full_viewing_key(HRP_SAPLING_EXTENDED_FULL_VIEWING_KEY_TEST, &extfvk) + })?; + // Raise SQL errors from the query, and IO errors from parsing. + let extfvks: Vec<_> = extfvks.collect::, _>>()??; + // Get the most recent CommitmentTree let mut tree = match stmt_fetch_tree.query_row(&[last_height], |row| match row.get_checked(0) { Ok(data) => { @@ -331,7 +339,13 @@ fn scan_cached_blocks( let txs = { let nf_refs: Vec<_> = nullifiers.iter().map(|(nf, acc)| (&nf[..], *acc)).collect(); let mut witness_refs: Vec<_> = witnesses.iter_mut().map(|w| &mut w.witness).collect(); - scan_block(block, &extfvks, &nf_refs, &mut tree, &mut witness_refs[..]) + scan_block( + block, + &extfvks[..], + &nf_refs, + &mut tree, + &mut witness_refs[..], + ) }; // Insert the block into the database. @@ -833,7 +847,6 @@ pub mod android { _: JClass, db_cache: JString, db_data: JString, - seed: jbyteArray, ) -> jboolean { let db_cache: String = env .get_string(db_cache) @@ -843,9 +856,8 @@ pub mod android { .get_string(db_data) .expect("Couldn't get Java string!") .into(); - let seed = env.convert_byte_array(seed).unwrap(); - match scan_cached_blocks(&db_cache, &db_data, &[extfvk_from_seed(&seed)]) { + match scan_cached_blocks(&db_cache, &db_data) { Ok(()) => JNI_TRUE, Err(e) => { error!("Error while scanning blocks: {}", e); From 62b4d433418e6a4e6b4bac25660e0c718c3f9f4a Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Wed, 30 Jan 2019 02:20:53 +0000 Subject: [PATCH 12/14] Remove seed argument from JniConverter.getAddress(), add account arg --- .../cash/z/wallet/sdk/jni/JniConverter.kt | 2 +- src/main/rust/lib.rs | 56 ++++++++++++------- 2 files changed, 38 insertions(+), 20 deletions(-) diff --git a/src/main/java/cash/z/wallet/sdk/jni/JniConverter.kt b/src/main/java/cash/z/wallet/sdk/jni/JniConverter.kt index 35a94d1a..bebd5386 100644 --- a/src/main/java/cash/z/wallet/sdk/jni/JniConverter.kt +++ b/src/main/java/cash/z/wallet/sdk/jni/JniConverter.kt @@ -15,7 +15,7 @@ class JniConverter { time: Long, saplingTree: ByteArray): Boolean - external fun getAddress(seed: ByteArray): String + external fun getAddress(dbData: String, account: Int): String external fun getBalance(dbData: String, account: Int): Long diff --git a/src/main/rust/lib.rs b/src/main/rust/lib.rs index 3e4f607c..5e4d3f98 100644 --- a/src/main/rust/lib.rs +++ b/src/main/rust/lib.rs @@ -37,25 +37,12 @@ use zcash_primitives::{ transaction::components::Amount, JUBJUB, }; -use zip32::{ChildIndex, ExtendedFullViewingKey, ExtendedSpendingKey}; +use zip32::{ExtendedFullViewingKey, ExtendedSpendingKey}; const SAPLING_CONSENSUS_BRANCH_ID: u32 = 0x76b8_09bb; const ANCHOR_OFFSET: u32 = 10; -fn extfvk_from_seed(seed: &[u8]) -> ExtendedFullViewingKey { - let master = ExtendedSpendingKey::master(seed); - let extsk = ExtendedSpendingKey::from_path( - &master, - &[ - ChildIndex::Hardened(32), - ChildIndex::Hardened(1), - ChildIndex::Hardened(0), - ], - ); - ExtendedFullViewingKey::from(&extsk) -} - fn address_from_extfvk(extfvk: &ExtendedFullViewingKey) -> String { let addr = extfvk.default_address().unwrap().1; encode_payment_address(HRP_SAPLING_PAYMENT_ADDRESS_TEST, &addr) @@ -202,6 +189,19 @@ struct WitnessRow { witness: IncrementalWitness, } +fn get_address(db_data: &str, account: u32) -> Result { + let data = Connection::open(db_data)?; + + let addr = data.query_row( + "SELECT address FROM accounts + WHERE account = ?", + &[account], + |row| row.get(0), + )?; + + Ok(addr) +} + fn get_balance(db_data: &str, account: u32) -> Result { let data = Connection::open(db_data)?; @@ -664,8 +664,8 @@ pub mod android { use self::jni::JNIEnv; use super::{ - address_from_extfvk, extfvk_from_seed, get_balance, init_accounts_table, init_blocks_table, - init_data_database, scan_cached_blocks, send_to_address, SAPLING_CONSENSUS_BRANCH_ID, + get_address, get_balance, init_accounts_table, init_blocks_table, init_data_database, + scan_cached_blocks, send_to_address, SAPLING_CONSENSUS_BRANCH_ID, }; #[no_mangle] @@ -804,11 +804,29 @@ pub mod android { pub unsafe extern "C" fn Java_cash_z_wallet_sdk_jni_JniConverter_getAddress( env: JNIEnv, _: JClass, - seed: jbyteArray, + db_data: JString, + account: jint, ) -> jstring { - let seed = env.convert_byte_array(seed).unwrap(); + let db_data: String = env + .get_string(db_data) + .expect("Couldn't get Java string!") + .into(); - let addr = address_from_extfvk(&extfvk_from_seed(&seed)); + let addr = match account { + acc if acc >= 0 => match get_address(&db_data, acc as u32) { + Ok(addr) => addr, + Err(e) => { + error!("Error while fetching address: {}", e); + // Return an empty string to indicate an error + String::default() + } + }, + _ => { + error!("account argument must be positive"); + // Return an empty string to indicate an error + String::default() + } + }; let output = env.new_string(addr).expect("Couldn't create Java string!"); output.into_inner() From cc53f14f96fa64b7c1c5055ca196dc30d4e5f450 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Fri, 1 Feb 2019 17:46:43 +0000 Subject: [PATCH 13/14] cargo update --- Cargo.lock | 308 ++++++++++++++++++++++++++++------------------------- 1 file changed, 162 insertions(+), 146 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a020b462..4ab1c41f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -45,7 +45,7 @@ dependencies = [ [[package]] name = "arrayvec" -version = "0.4.7" +version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", @@ -56,25 +56,31 @@ name = "ascii" version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "autocfg" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "backtrace" -version = "0.3.9" +version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "backtrace-sys 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-demangle 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-demangle 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "backtrace-sys" -version = "0.1.24" +version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -88,15 +94,15 @@ version = "0.1.0" source = "git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666#89cfef8515d5d88809c485a44fdc54572b9e5666" dependencies = [ "bit-vec 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", - "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "ff 0.4.0 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "group 0.1.0 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)", - "num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "num_cpus 1.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "pairing 0.14.2 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)", - "rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -114,19 +120,19 @@ name = "blake2-rfc" version = "0.2.18" source = "git+https://github.com/gtank/blake2-rfc?rev=7a5b5fc99ae483a0043db7547fb79a6fa44b88a9#7a5b5fc99ae483a0043db7547fb79a6fa44b88a9" dependencies = [ - "arrayvec 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", - "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)", + "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "constant_time_eq 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "block-buffer" -version = "0.7.0" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "block-padding 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "byte-tools 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)", + "block-padding 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "generic-array 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -140,10 +146,10 @@ dependencies = [ [[package]] name = "block-padding" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "byte-tools 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -153,17 +159,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "byte-tools" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "byteorder" -version = "1.2.7" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cc" -version = "1.0.25" +version = "1.0.28" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -186,13 +192,13 @@ dependencies = [ [[package]] name = "combine" -version = "3.6.3" +version = "3.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "ascii 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", - "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "either 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "memchr 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -234,21 +240,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "failure" -version = "0.1.3" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "backtrace 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "failure_derive 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "backtrace 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)", + "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "failure_derive" -version = "0.1.3" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.21 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)", "synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -262,9 +268,9 @@ name = "ff" version = "0.4.0" source = "git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666#89cfef8515d5d88809c485a44fdc54572b9e5666" dependencies = [ - "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "ff_derive 0.3.0 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)", - "rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -272,11 +278,11 @@ name = "ff_derive" version = "0.3.0" source = "git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666#89cfef8515d5d88809c485a44fdc54572b9e5666" dependencies = [ - "num-bigint 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "num-bigint 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "num-integer 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.14.9 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -286,24 +292,15 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "aes 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)", - "num-bigint 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "num-bigint 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "num-integer 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "fuchsia-zircon" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "fuchsia-zircon-sys" -version = "0.3.3" +name = "fuchsia-cprng" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -317,7 +314,7 @@ version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "num_cpus 1.9.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -342,7 +339,7 @@ version = "0.1.0" source = "git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666#89cfef8515d5d88809c485a44fdc54572b9e5666" dependencies = [ "ff 0.4.0 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)", - "rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -356,7 +353,7 @@ version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cesu8 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "combine 3.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "combine 3.6.6 (registry+https://github.com/rust-lang/crates.io-index)", "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "jni-sys 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -375,7 +372,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libc" -version = "0.2.43" +version = "0.2.48" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -383,7 +380,7 @@ name = "libsqlite3-sys" version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", "vcpkg 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -419,12 +416,11 @@ dependencies = [ [[package]] name = "memchr" -version = "2.1.1" +version = "2.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", - "version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -434,7 +430,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "num-bigint" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "num-integer 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)", @@ -456,10 +452,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "num_cpus" -version = "1.8.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -469,7 +465,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "opaque-debug" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -477,10 +473,10 @@ name = "pairing" version = "0.14.2" source = "git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666#89cfef8515d5d88809c485a44fdc54572b9e5666" dependencies = [ - "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "ff 0.4.0 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)", "group 0.1.0 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)", - "rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -490,7 +486,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "proc-macro2" -version = "0.4.24" +version = "0.4.27" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -498,47 +494,70 @@ dependencies = [ [[package]] name = "protobuf" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "protobuf-codegen" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "protobuf 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "protobuf 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "protobuf-codegen-pure" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "protobuf 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "protobuf-codegen 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "protobuf 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "protobuf-codegen 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "quote" -version = "0.6.10" +version = "0.6.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rand" -version = "0.4.3" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", + "fuchsia-cprng 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "rand_core" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rand_core" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "rdrand" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "redox_syscall" -version = "0.1.42" +version = "0.1.51" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -549,12 +568,12 @@ dependencies = [ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "libsqlite3-sys 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "lru-cache 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "time 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", + "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rustc-demangle" -version = "0.1.9" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -562,7 +581,7 @@ name = "same-file" version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "winapi-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -572,11 +591,11 @@ source = "git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c4 dependencies = [ "bellman 0.1.0 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)", "blake2-rfc 0.2.18 (git+https://github.com/gtank/blake2-rfc?rev=7a5b5fc99ae483a0043db7547fb79a6fa44b88a9)", - "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "digest 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)", "ff 0.4.0 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)", "pairing 0.14.2 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)", - "rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -584,10 +603,10 @@ name = "sha2" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "block-buffer 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "block-buffer 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "digest 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "opaque-debug 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "opaque-debug 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -603,18 +622,18 @@ name = "syn" version = "0.14.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "syn" -version = "0.15.21" +version = "0.15.26" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -623,19 +642,19 @@ name = "synstructure" version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.21 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "time" -version = "0.1.40" +version = "0.1.42" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -662,11 +681,6 @@ name = "vcpkg" version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "version_check" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "void" version = "1.0.2" @@ -679,7 +693,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "same-file 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -698,7 +712,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "winapi-util" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -714,14 +728,14 @@ name = "zcash-wallet-sdk-poc" version = "0.0.1" dependencies = [ "android_logger 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "ff 0.4.0 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)", "jni 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "log-panics 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "pairing 0.14.2 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)", - "protobuf 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "protobuf 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "rusqlite 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", "sapling-crypto 0.0.1 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)", "zcash_client_backend 0.0.0 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)", @@ -737,15 +751,15 @@ dependencies = [ "bech32 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "bellman 0.1.0 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)", "blake2-rfc 0.2.18 (git+https://github.com/gtank/blake2-rfc?rev=7a5b5fc99ae483a0043db7547fb79a6fa44b88a9)", - "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "chacha20-poly1305-aead 0.1.2 (git+https://github.com/gtank/chacha20-poly1305-aead?rev=aefc71f95e8bc43f2070e3c5b08130d9c86bbf4f)", - "failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "ff 0.4.0 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)", "hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "pairing 0.14.2 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)", - "protobuf 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "protobuf-codegen-pure 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "protobuf 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "protobuf-codegen-pure 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "sapling-crypto 0.0.1 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)", "zcash_primitives 0.0.0 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)", "zcash_proofs 0.0.0 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)", @@ -758,13 +772,13 @@ version = "0.0.0" source = "git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666#89cfef8515d5d88809c485a44fdc54572b9e5666" dependencies = [ "blake2-rfc 0.2.18 (git+https://github.com/gtank/blake2-rfc?rev=7a5b5fc99ae483a0043db7547fb79a6fa44b88a9)", - "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)", - "failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "ff 0.4.0 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)", "hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "pairing 0.14.2 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)", - "rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "sapling-crypto 0.0.1 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -776,10 +790,10 @@ source = "git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c4 dependencies = [ "bellman 0.1.0 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)", "blake2-rfc 0.2.18 (git+https://github.com/gtank/blake2-rfc?rev=7a5b5fc99ae483a0043db7547fb79a6fa44b88a9)", - "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "ff 0.4.0 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)", "pairing 0.14.2 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)", - "rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "sapling-crypto 0.0.1 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)", "zcash_primitives 0.0.0 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)", ] @@ -791,7 +805,7 @@ source = "git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c4 dependencies = [ "aes 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "blake2-rfc 0.2.18 (git+https://github.com/gtank/blake2-rfc?rev=7a5b5fc99ae483a0043db7547fb79a6fa44b88a9)", - "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "ff 0.4.0 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)", "fpe 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "pairing 0.14.2 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)", @@ -805,40 +819,40 @@ dependencies = [ "checksum aesni 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6810b7fb9f2bb4f76f05ac1c170b8dde285b6308955dc3afd89710268c958d9e" "checksum android_log-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b8052e2d8aabbb8d556d6abbcce2a22b9590996c5f849b9c7ce4544a2e3b984e" "checksum android_logger 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bad99185bc195e796e1591740c26716667b58ac9210a48731f71f803fc6ca43a" -"checksum arrayvec 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "a1e964f9e24d588183fcb43503abda40d288c8657dfc27311516ce2f05675aef" +"checksum arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "92c7fb76bc8826a8b33b4ee5bb07a247a81e76764ab4d55e8f73e3a4d8808c71" "checksum ascii 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a5fc969a8ce2c9c0c4b0429bb8431544f6658283c8326ba5ff8c762b75369335" -"checksum backtrace 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "89a47830402e9981c5c41223151efcced65a0510c13097c769cede7efb34782a" -"checksum backtrace-sys 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)" = "c66d56ac8dabd07f6aacdaf633f4b8262f5b3601a810a0dcddffd5c22c69daa0" +"checksum autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a6d640bee2da49f60a4068a7fae53acde8982514ab7bae8b8cea9e88cbcfd799" +"checksum backtrace 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)" = "b5b493b66e03090ebc4343eb02f94ff944e0cbc9ac6571491d170ba026741eb5" +"checksum backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)" = "797c830ac25ccc92a7f8a7b9862bde440715531514594a6154e3d4a54dd769b6" "checksum bech32 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ad20b907fd16610c3960c7fe9dae13dd243343409bab80299774c9a8b5d7bed8" "checksum bellman 0.1.0 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)" = "" "checksum bit-vec 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "02b4ff8b16e6076c3e14220b39fbc1fabb6737522281a388998046859400895f" "checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" "checksum blake2-rfc 0.2.18 (git+https://github.com/gtank/blake2-rfc?rev=7a5b5fc99ae483a0043db7547fb79a6fa44b88a9)" = "" -"checksum block-buffer 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "49665c62e0e700857531fa5d3763e91b539ff1abeebd56808d378b495870d60d" +"checksum block-buffer 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "509de513cca6d92b6aacf9c61acfe7eaa160837323a81068d690cc1f8e5740da" "checksum block-cipher-trait 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "370424437b9459f3dfd68428ed9376ddfe03d8b70ede29cc533b3557df186ab4" -"checksum block-padding 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4fc4358306e344bf9775d0197fd00d2603e5afb0771bb353538630f022068ea3" +"checksum block-padding 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d75255892aeb580d3c566f213a2b6fdc1c66667839f45719ee1d30ebf2aea591" "checksum byte-tools 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "560c32574a12a89ecd91f5e742165893f86e3ab98d21f8ea548658eb9eef5f40" -"checksum byte-tools 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "980479e6fde23246dfb54d47580d66b4e99202e7579c5eaa9fe10ecb5ebd2182" -"checksum byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "94f88df23a25417badc922ab0f5716cc1330e87f71ddd9203b3a3ccd9cedf75d" -"checksum cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)" = "f159dfd43363c4d08055a07703eb7a3406b0dac4d0584d96965a3262db3c9d16" +"checksum byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" +"checksum byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a019b10a2a7cdeb292db131fc8113e57ea2a908f6e7894b0c3c671893b65dbeb" +"checksum cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4a8b715cb4597106ea87c7c84b2f1d452c7492033765df7f32651e66fcf749" "checksum cesu8 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c" "checksum cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "082bb9b28e00d3c9d39cc03e64ce4cea0f1bb9b3fde493f0cbc008472d22bdf4" "checksum chacha20-poly1305-aead 0.1.2 (git+https://github.com/gtank/chacha20-poly1305-aead?rev=aefc71f95e8bc43f2070e3c5b08130d9c86bbf4f)" = "" -"checksum combine 3.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "db733c5d0f4f52e78d4417959cadf0eecc7476e7f9ece05677912571a4af34e2" +"checksum combine 3.6.6 (registry+https://github.com/rust-lang/crates.io-index)" = "3d64b57f9d8186d72311c241e580409b31e5d340c67fd2d9c74f05eda6d3aa54" "checksum constant_time_eq 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8ff012e225ce166d4422e0e78419d901719760f62ae2b7969ca6b564d1b54a9e" "checksum crossbeam 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "24ce9782d4d5c53674646a6a4c1863a21a8fc0cb649b3c94dfc16e45071dea19" "checksum digest 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)" = "03b072242a8cbaf9c145665af9d250c59af3b958f83ed6824e13533cf76d5b90" "checksum digest 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "05f47366984d3ad862010e22c7ce81a7dbcaebbdfb37241a620f8b6596ee135c" "checksum either 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3be565ca5c557d7f59e7cfcf1844f9e3033650c929c6566f511e8005f205c1d0" "checksum error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "07e791d3be96241c77c43846b665ef1384606da2cd2a48730abe606a12906e02" -"checksum failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6dd377bcc1b1b7ce911967e3ec24fa19c3224394ec05b54aa7b083d498341ac7" -"checksum failure_derive 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "64c2d913fe8ed3b6c6518eedf4538255b989945c14c2a7d5cbff62a5e2120596" +"checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2" +"checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1" "checksum fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" "checksum ff 0.4.0 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)" = "" "checksum ff_derive 0.3.0 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)" = "" "checksum fpe 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ce3371c82bfbd984f624cab093f55e7336f5a6e589f8518e1258f54f011b89ad" -"checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" -"checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" +"checksum fuchsia-cprng 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "81f7f8eb465745ea9b02e2704612a9946a59fa40572086c6fd49d6ddcf30bf31" "checksum futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)" = "49e7653e374fe0d0c12de4250f0bdb60680b8c80eed558c5c7538eec9c89e21b" "checksum futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "ab90cde24b3319636588d0c35fe03b1333857621051837ed769faefb4c2162e4" "checksum generic-array 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3c0f28c2f5bfb5960175af447a2da7c18900693738343dc896ffbcabd9839592" @@ -848,49 +862,51 @@ dependencies = [ "checksum jni 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1ecfa3b81afc64d9a6539c4eece96ac9a93c551c713a313800dade8e33d7b5c1" "checksum jni-sys 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" "checksum lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a374c89b9db55895453a74c1e38861d9deec0b01b405a82516e9d5de4820dea1" -"checksum libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)" = "76e3a3ef172f1a0b9a9ff0dd1491ae5e6c948b94479a3021819ba7d860c8645d" +"checksum libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)" = "e962c7641008ac010fa60a7dfdc1712449f29c44ef2d4702394aea943ee75047" "checksum libsqlite3-sys 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "742b695cbfb89e549dca6960a55e6802f67d352e33e97859ee46dee835211b0f" "checksum linked-hash-map 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7860ec297f7008ff7a1e3382d7f7e1dcd69efc94751a2284bafc3d013c2aa939" "checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6" "checksum log-panics 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ae0136257df209261daa18d6c16394757c63e032e27aafd8b07788b051082bef" "checksum lru-cache 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4d06ff7ff06f729ce5f4e227876cb88d10bc59cd4ae1e09fbb2bde15c850dc21" -"checksum memchr 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0a3eb002f0535929f1199681417029ebea04aadc0c7a4224b46be99c7f5d6a16" +"checksum memchr 2.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e1dd4eaac298c32ce07eb6ed9242eda7d82955b9170b7d6db59b2e02cc63fcb8" "checksum nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9667ddcc6cc8a43afc9b7917599d7216aa09c463919ea32c59ed6cac8bc945" -"checksum num-bigint 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "10b8423ea72ec64751198856a853e07b37087cfc9b53a87ecb19bff67b6d1320" +"checksum num-bigint 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "57450397855d951f1a41305e54851b1a7b8f5d2e349543a02a2effe25459f718" "checksum num-integer 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)" = "e83d528d2677f0518c570baf2b7abdcf0cd2d248860b68507bdcb3e91d4c0cea" "checksum num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0b3a5d7cc97d6d30d8b9bc8fa19bf45349ffe46241e8816f50f62f6d6aaabee1" -"checksum num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c51a3322e4bca9d212ad9a158a02abc6934d005490c054a2778df73a70aa0a30" +"checksum num_cpus 1.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5a69d464bdc213aaaff628444e99578ede64e9c854025aa43b9796530afa9238" "checksum opaque-debug 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d620c9c26834b34f039489ac0dfdb12c7ac15ccaf818350a64c9b5334a452ad7" -"checksum opaque-debug 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "51ecbcb821e1bd256d456fe858aaa7f380b63863eab2eb86eee1bd9f33dd6682" +"checksum opaque-debug 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "93f5bb2e8e8dec81642920ccff6b61f1eb94fa3020c5a325c9851ff604152409" "checksum pairing 0.14.2 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)" = "" "checksum pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)" = "676e8eb2b1b4c9043511a9b7bea0915320d7e502b0a079fb03f9635a5252b18c" -"checksum proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)" = "77619697826f31a02ae974457af0b29b723e5619e113e9397b8b82c6bd253f09" -"checksum protobuf 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cbd08d128db199b1c6bb662e343d7d1a8f6d0060b411675766d88e5146a4bb38" -"checksum protobuf-codegen 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c5730e51a78ee86d308caaafeb4b01a0bd79fb92b9ab5a8fd4b94c56786e0862" -"checksum protobuf-codegen-pure 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9b0e4940ec64bbd5a7379b315b97452ca9182f3db697ff630f2bb19b3f9fa379" -"checksum quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "53fa22a1994bd0f9372d7a816207d8a2677ad0325b073f5c5332760f0fb62b5c" -"checksum rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8356f47b32624fef5b3301c1be97e5944ecdd595409cc5da11d05f211db6cfbd" -"checksum redox_syscall 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "cf8fb82a4d1c9b28f1c26c574a5b541f5ffb4315f6c9a791fa47b6a04438fe93" +"checksum proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)" = "4d317f9caece796be1980837fd5cb3dfec5613ebdb04ad0956deea83ce168915" +"checksum protobuf 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d82d117bc7565ce6be0150159251c9b1eeec7b129f5a2aa86e10acb5970de1cb" +"checksum protobuf-codegen 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5f25bf531a031dd128d4e7285401caed1038d4f732b56bb1d99f02bdad4ad125" +"checksum protobuf-codegen-pure 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "54f908fafe335c1e04c0ba4ea4e0c3ca63fcf1a5dec97db98acc95521e7fc44d" +"checksum quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)" = "cdd8e04bd9c52e0342b406469d494fcb033be4bdbe5c606016defbb1681411e1" +"checksum rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293" +"checksum rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" +"checksum rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d0e7a549d590831370895ab7ba4ea0c1b6b011d106b5ff2da6eee112615e6dc0" +"checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" +"checksum redox_syscall 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)" = "423e376fffca3dfa06c9e9790a9ccd282fafb3cc6e6397d01dbf64f9bacc6b85" "checksum rusqlite 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "39bae767eb27866f5c0be918635ae54af705bc09db11be2c43a3c6b361cf3462" -"checksum rustc-demangle 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "bcfe5b13211b4d78e5c2cadfebd7769197d95c639c35a50057eb4c05de811395" +"checksum rustc-demangle 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "adacaae16d02b6ec37fdc7acfcddf365978de76d1983d3ee22afc260e1ca9619" "checksum same-file 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8f20c4be53a8a1ff4c1f1b2bd14570d2f634628709752f0702ecdd2b3f9a5267" "checksum sapling-crypto 0.0.1 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)" = "" "checksum sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b4d8bfd0e469f417657573d8451fb33d16cfe0989359b93baf3a1ffc639543d" "checksum stream-cipher 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "30dc6118470d69ce0fdcf7e6f95e95853f7f4f72f80d835d4519577c323814ab" "checksum syn 0.14.9 (registry+https://github.com/rust-lang/crates.io-index)" = "261ae9ecaa397c42b960649561949d69311f08eeaea86a65696e6e46517cf741" -"checksum syn 0.15.21 (registry+https://github.com/rust-lang/crates.io-index)" = "816b7af21405b011a23554ea2dc3f6576dc86ca557047c34098c1d741f10f823" +"checksum syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)" = "f92e629aa1d9c827b2bb8297046c1ccffc57c99b947a680d3ccff1f136a3bee9" "checksum synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "73687139bf99285483c96ac0add482c3776528beac1d97d444f6e91f203a2015" -"checksum time 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "d825be0eb33fda1a7e68012d51e9c7f451dc1a69391e7fdc197060bb8c56667b" +"checksum time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f" "checksum typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "612d636f949607bdf9b123b4a6f6d966dedf3ff669f7f045890d3a4a73948169" "checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" "checksum unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "382810877fe448991dfc7f0dd6e3ae5d58088fd0ea5e35189655f84e6814fa56" "checksum vcpkg 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "def296d3eb3b12371b2c7d0e83bfe1403e4db2d7a0bba324a12b21c4ee13143d" -"checksum version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd" "checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" "checksum walkdir 2.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "9d9d7ed3431229a144296213105a390676cc49c9b6a72bd19f3176c98e129fa1" "checksum winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "92c1eb33641e276cfa214a0522acad57be5c56b10cb348b3c5117db75f3ac4b0" "checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" -"checksum winapi-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "afc5508759c5bf4285e61feb862b6083c8480aec864fa17a81fdec6f69b461ab" +"checksum winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7168bab6e1daee33b4557efd0e95d5ca70a03706d39fa5f3fe7a236f584b03c9" "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" "checksum zcash_client_backend 0.0.0 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)" = "" "checksum zcash_primitives 0.0.0 (git+https://github.com/str4d/librustzcash.git?rev=89cfef8515d5d88809c485a44fdc54572b9e5666)" = "" From a290c9165a26f98842207c0b39e7fc63bd16c6b7 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Fri, 1 Feb 2019 17:48:59 +0000 Subject: [PATCH 14/14] Update package details for Rust crate --- Cargo.lock | 2 +- Cargo.toml | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4ab1c41f..3c138948 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -724,7 +724,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] -name = "zcash-wallet-sdk-poc" +name = "zcash-android-wallet-sdk" version = "0.0.1" dependencies = [ "android_logger 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml index 680089cd..dcc6738c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,8 +1,11 @@ [package] -name = "zcash-wallet-sdk-poc" +name = "zcash-android-wallet-sdk" version = "0.0.1" -authors = ["Kevin Gorham "] -description = "Simple PoC that rust can work with protobufs over JNI" +authors = [ + "Jack Grigg ", + "Kevin Gorham ", +] +description = "JNI backend for the Android wallet SDK" publish = false [dependencies]