Browse Source

Merge

checkpoints
Aditya Kulkarni 5 years ago
parent
commit
2c2afcc442
  1. 67
      Cargo.toml
  2. 75
      lib/Cargo.toml
  3. 0
      lib/build.rs
  4. 0
      lib/proto/compact_formats.proto
  5. 0
      lib/proto/service.proto
  6. 2
      lib/src/commands.rs
  7. 0
      lib/src/grpcconnector.rs
  8. 19
      lib/src/lib.rs
  9. 0
      lib/src/lightclient.rs
  10. 4
      lib/src/lightwallet.rs
  11. 0
      lib/src/lightwallet/address.rs
  12. 0
      lib/src/lightwallet/data.rs
  13. 50
      lib/src/lightwallet/extended_key.rs
  14. 0
      lib/src/lightwallet/prover.rs
  15. 0
      lib/src/lightwallet/utils.rs
  16. BIN
      lib/zcash-params/sapling-output.params
  17. BIN
      lib/zcash-params/sapling-spend.params
  18. 22
      src/main.rs

67
Cargo.toml

@ -4,74 +4,13 @@ version = "0.1.0"
edition = "2018"
[dependencies]
tower-grpc = { git = "https://github.com/tower-rs/tower-grpc" }
futures = "0.1"
bytes = "0.4"
base58 = "0.1.0"
rustyline = "5.0.2"
clap = "2.33"
log = "0.4"
log4rs = "0.8.3"
dirs = "2.0.2"
http = "0.1"
prost = "0.5"
tokio = "0.1"
tower-request-modifier = { git = "https://github.com/tower-rs/tower-http" }
tower-util = "0.1"
hex = "0.3"
protobuf = "2"
rustyline = "5.0.2"
byteorder = "1"
json = "0.12.0"
shellwords = "1.0.0"
tiny-bip39 = "0.6.2"
clap = "2.33"
secp256k1 = "=0.15.0"
sha2 = "0.8.0"
ripemd160 = "0.8.0"
ring = "0.14.0"
lazy_static = "1.2.0"
tower-service = "0.2"
tokio-rustls = "0.10.0-alpha.3"
rustls = { version = "0.15.2", features = ["dangerous_configuration"] }
webpki = "0.19.1"
webpki-roots = "0.16.0"
tower-h2 = { git = "https://github.com/tower-rs/tower-h2" }
rust-embed = "5.1.0"
rand = "0.7.2"
[dependencies.bellman]
git = "https://github.com/adityapk00/librustzcash.git"
rev = "188537ea025fcb7fbdfc11266f307a084a5451e4"
default-features = false
features = ["groth16"]
[dependencies.pairing]
git = "https://github.com/adityapk00/librustzcash.git"
rev = "188537ea025fcb7fbdfc11266f307a084a5451e4"
[dependencies.zcash_client_backend]
git = "https://github.com/adityapk00/librustzcash.git"
rev = "188537ea025fcb7fbdfc11266f307a084a5451e4"
default-features = false
[dependencies.zcash_primitives]
git = "https://github.com/adityapk00/librustzcash.git"
rev = "188537ea025fcb7fbdfc11266f307a084a5451e4"
default-features = false
features = ["transparent-inputs"]
[dependencies.zcash_proofs]
git = "https://github.com/adityapk00/librustzcash.git"
rev = "188537ea025fcb7fbdfc11266f307a084a5451e4"
default-features = false
[dependencies.ff]
git = "https://github.com/adityapk00/librustzcash.git"
rev = "188537ea025fcb7fbdfc11266f307a084a5451e4"
features = ["ff_derive"]
[build-dependencies]
tower-grpc-build = { git = "https://github.com/tower-rs/tower-grpc", features = ["tower-hyper"] }
zecwalletlitelib = { path = "./lib/" }
[profile.release]

75
lib/Cargo.toml

@ -0,0 +1,75 @@
[package]
name = "zecwalletlitelib"
version = "0.1.0"
edition = "2018"
[dependencies]
tower-grpc = { git = "https://github.com/tower-rs/tower-grpc" }
futures = "0.1"
bytes = "0.4"
base58 = "0.1.0"
log = "0.4"
log4rs = "0.8.3"
dirs = "2.0.2"
http = "0.1"
prost = "0.5"
tokio = "0.1"
tower-request-modifier = { git = "https://github.com/tower-rs/tower-http" }
tower-util = "0.1"
hex = "0.3"
protobuf = "2"
byteorder = "1"
rand = "0.5.6"
json = "0.12.0"
tiny-bip39 = "0.6.2"
secp256k1 = "=0.15.0"
sha2 = "0.8.0"
ripemd160 = "0.8.0"
ring = "0.14.0"
lazy_static = "1.2.0"
tower-service = "0.2"
tokio-rustls = "0.10.0-alpha.3"
webpki = "0.19.1"
webpki-roots = "0.16.0"
tower-h2 = { git = "https://github.com/tower-rs/tower-h2" }
rust-embed = "5.1.0"
[dependencies.bellman]
git = "https://github.com/adityapk00/librustzcash.git"
rev = "0743dadcd017b60a0ac7123d04f0d6e7ce1e8016"
default-features = false
features = ["groth16"]
[dependencies.pairing]
git = "https://github.com/adityapk00/librustzcash.git"
rev = "0743dadcd017b60a0ac7123d04f0d6e7ce1e8016"
[dependencies.zcash_client_backend]
git = "https://github.com/adityapk00/librustzcash.git"
rev = "0743dadcd017b60a0ac7123d04f0d6e7ce1e8016"
default-features = false
[dependencies.zcash_primitives]
git = "https://github.com/adityapk00/librustzcash.git"
rev = "0743dadcd017b60a0ac7123d04f0d6e7ce1e8016"
default-features = false
features = ["transparent-inputs"]
[dependencies.zcash_proofs]
git = "https://github.com/adityapk00/librustzcash.git"
rev = "0743dadcd017b60a0ac7123d04f0d6e7ce1e8016"
default-features = false
[dependencies.ff]
git = "https://github.com/adityapk00/librustzcash.git"
rev = "0743dadcd017b60a0ac7123d04f0d6e7ce1e8016"
features = ["ff_derive"]
[build-dependencies]
tower-grpc-build = { git = "https://github.com/tower-rs/tower-grpc", features = ["tower-hyper"] }
[dev-dependencies]
rand_core = "0.5.1"
[profile.release]
debug = false

0
build.rs → lib/build.rs

0
proto/compact_formats.proto → lib/proto/compact_formats.proto

0
proto/service.proto → lib/proto/service.proto

2
src/commands.rs → lib/src/commands.rs

@ -1,7 +1,7 @@
use std::collections::HashMap;
use json::{object};
use crate::LightClient;
use crate::lightclient::LightClient;
pub trait Command {
fn help(&self) -> String;

0
src/grpcconnector.rs → lib/src/grpcconnector.rs

19
lib/src/lib.rs

@ -0,0 +1,19 @@
#[macro_use]
extern crate rust_embed;
pub mod lightclient;
pub mod grpcconnector;
pub mod lightwallet;
pub mod commands;
#[derive(RustEmbed)]
#[folder = "zcash-params/"]
pub struct SaplingParams;
pub const ANCHOR_OFFSET: u32 = 4;
pub mod grpc_client {
include!(concat!(env!("OUT_DIR"), "/cash.z.wallet.sdk.rpc.rs"));
}

0
src/lightclient.rs → lib/src/lightclient.rs

4
src/lightwallet.rs → lib/src/lightwallet.rs

@ -40,7 +40,7 @@ use zcash_primitives::{
};
use crate::{LightClientConfig};
use crate::lightclient::{LightClientConfig};
mod data;
mod extended_key;
@ -1308,7 +1308,7 @@ pub mod tests {
use sha2::{Sha256, Digest};
use super::LightWallet;
use crate::LightClientConfig;
use super::LightClientConfig;
use secp256k1::{Secp256k1, key::PublicKey, key::SecretKey};
use crate::SaplingParams;

0
src/lightwallet/address.rs → lib/src/lightwallet/address.rs

0
src/lightwallet/data.rs → lib/src/lightwallet/data.rs

50
src/lightwallet/extended_key.rs → lib/src/lightwallet/extended_key.rs

@ -27,17 +27,6 @@ pub enum KeyIndex {
impl KeyIndex {
/// Check index range.
///
/// # Examples
///
/// ```rust
/// # extern crate hdwallet;
/// use hdwallet::KeyIndex;
///
/// assert!(KeyIndex::Normal(0).is_valid());
/// assert!(!KeyIndex::Normal(2_147_483_648).is_valid());
/// assert!(KeyIndex::Hardened(2_147_483_648).is_valid());
/// ```
pub fn is_valid(self) -> bool {
match self {
KeyIndex::Normal(i) => i < HARDENED_KEY_START_INDEX,
@ -46,20 +35,6 @@ impl KeyIndex {
}
/// Generate Hardened KeyIndex from normalize index value.
///
/// # Examples
///
/// ```rust
/// # extern crate hdwallet;
/// use hdwallet::KeyIndex;
///
/// // hardended key from zero
/// let hardened_index_zero = KeyIndex::hardened_from_normalize_index(0).unwrap();
/// assert_eq!(hardened_index_zero, KeyIndex::Hardened(2_147_483_648));
/// // also allow raw index for convernient
/// let hardened_index_zero = KeyIndex::hardened_from_normalize_index(2_147_483_648).unwrap();
/// assert_eq!(hardened_index_zero, KeyIndex::Hardened(2_147_483_648));
/// ```
pub fn hardened_from_normalize_index(i: u32) -> Result<KeyIndex, Error> {
if i < HARDENED_KEY_START_INDEX {
Ok(KeyIndex::Hardened(HARDENED_KEY_START_INDEX + i))
@ -69,18 +44,6 @@ impl KeyIndex {
}
/// Generate KeyIndex from raw index value.
///
/// # Examples
///
/// ```rust
/// # extern crate hdwallet;
/// use hdwallet::KeyIndex;
///
/// let normal_key = KeyIndex::from_index(0).unwrap();
/// assert_eq!(normal_key, KeyIndex::Normal(0));
/// let hardened_key = KeyIndex::from_index(2_147_483_648).unwrap();
/// assert_eq!(hardened_key, KeyIndex::Hardened(2_147_483_648));
/// ```
pub fn from_index(i: u32) -> Result<Self, Error> {
if i < HARDENED_KEY_START_INDEX {
Ok(KeyIndex::Normal(i))
@ -99,19 +62,6 @@ impl From<u32> for KeyIndex {
/// ExtendedPrivKey is used for child key derivation.
/// See [secp256k1 crate documentation](https://docs.rs/secp256k1) for SecretKey signatures usage.
///
/// # Examples
///
/// ```rust
/// # extern crate hdwallet;
/// use hdwallet::{ExtendedPrivKey, KeyIndex};
///
/// let master_key = ExtendedPrivKey::random().unwrap();
/// let hardened_key_index = KeyIndex::hardened_from_normalize_index(0).unwrap();
/// let hardended_child_priv_key = master_key.derive_private_key(hardened_key_index).unwrap();
/// let normal_key_index = KeyIndex::Normal(0);
/// let noamal_child_priv_key = master_key.derive_private_key(normal_key_index).unwrap();
/// ```
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ExtendedPrivKey {
pub private_key: SecretKey,

0
src/lightwallet/prover.rs → lib/src/lightwallet/prover.rs

0
src/lightwallet/utils.rs → lib/src/lightwallet/utils.rs

BIN
lib/zcash-params/sapling-output.params

Binary file not shown.

BIN
lib/zcash-params/sapling-spend.params

Binary file not shown.

22
src/main.rs

@ -1,17 +1,12 @@
#[macro_use]
extern crate rust_embed;
mod lightclient;
mod grpcconnector;
mod lightwallet;
mod commands;
use std::io::{Result, Error, ErrorKind};
use std::sync::{Arc};
use std::sync::mpsc::{channel, Sender, Receiver};
use std::time::Duration;
use lightclient::{LightClient, LightClientConfig};
use zecwalletlitelib::{grpcconnector, commands,
lightclient::{self, LightClient, LightClientConfig},
ANCHOR_OFFSET,
};
use log::{info, error, LevelFilter};
use log4rs::append::rolling_file::RollingFileAppender;
@ -29,15 +24,6 @@ use rustyline::Editor;
use clap::{Arg, App};
pub mod grpc_client {
include!(concat!(env!("OUT_DIR"), "/cash.z.wallet.sdk.rpc.rs"));
}
#[derive(RustEmbed)]
#[folder = "zcash-params/"]
pub struct SaplingParams;
const ANCHOR_OFFSET: u32 = 4;
/// Build the Logging config
fn get_log_config(config: &LightClientConfig) -> Result<Config> {

Loading…
Cancel
Save