Skip to content

Commit

Permalink
Merge pull request #88 from str4d/address-encodings
Browse files Browse the repository at this point in the history
Sapling address encodings
  • Loading branch information
str4d authored Jul 10, 2019
2 parents 3b6f5e3 + a3a9ee2 commit 91c6b0b
Show file tree
Hide file tree
Showing 25 changed files with 397 additions and 334 deletions.
40 changes: 21 additions & 19 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ members = [
"librustzcash",
"pairing",
"sapling-crypto",
"zcash_client_backend",
"zcash_primitives",
"zcash_proofs",
"zcash_wallet",
"zip32",
]

[profile.release]
Expand Down
1 change: 0 additions & 1 deletion librustzcash/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ rand = "0.4"
sapling-crypto = { path = "../sapling-crypto" }
zcash_primitives = { path = "../zcash_primitives" }
zcash_proofs = { path = "../zcash_proofs" }
zip32 = { path = "../zip32" }

[dependencies.blake2-rfc]
git = "https://github.com/gtank/blake2-rfc"
Expand Down
3 changes: 1 addition & 2 deletions librustzcash/src/rustzcash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ extern crate rand;
extern crate sapling_crypto;
extern crate zcash_primitives;
extern crate zcash_proofs;
extern crate zip32;

extern crate lazy_static;

Expand Down Expand Up @@ -58,7 +57,7 @@ use std::ffi::OsString;
use std::os::windows::ffi::OsStringExt;

use sapling_crypto::primitives::{ProofGenerationKey, ViewingKey};
use zcash_primitives::{note_encryption::sapling_ka_agree, sapling::spend_sig, JUBJUB};
use zcash_primitives::{note_encryption::sapling_ka_agree, sapling::spend_sig, zip32, JUBJUB};
use zcash_proofs::{
load_parameters,
sapling::{CommitmentTreeWitness, SaplingProvingContext, SaplingVerificationContext},
Expand Down
16 changes: 16 additions & 0 deletions zcash_client_backend/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[package]
name = "zcash_client_backend"
version = "0.0.0"
authors = [
"Jack Grigg <jack@z.cash>",
]
edition = "2018"

[dependencies]
bech32 = "0.6"
pairing = { path = "../pairing" }
sapling-crypto = { path = "../sapling-crypto" }
zcash_primitives = { path = "../zcash_primitives" }

[dev-dependencies]
rand = "0.4"
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions zcash_wallet/README.md → zcash_client_backend/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# zcash_wallet
# zcash_client_backend

This library contains Rust structs and traits for creating shielded Zcash wallets.
This library contains Rust structs and traits for creating shielded Zcash light clients.

## License

Expand Down
4 changes: 4 additions & 0 deletions zcash_client_backend/src/constants.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
//! Zcash global and per-network constants.

pub mod mainnet;
pub mod testnet;
28 changes: 28 additions & 0 deletions zcash_client_backend/src/constants/mainnet.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/// The mainnet coin type for ZEC, as defined by [SLIP 44].
///
/// [SLIP 44]: https://github.com/satoshilabs/slips/blob/master/slip-0044.md
pub const COIN_TYPE: u32 = 133;

/// The HRP for a Bech32-encoded mainnet [`ExtendedSpendingKey`].
///
/// Defined in [ZIP 32].
///
/// [`ExtendedSpendingKey`]: zcash_primitives::zip32::ExtendedSpendingKey
/// [ZIP 32]: https://github.com/zcash/zips/blob/master/zip-0032.rst
pub const HRP_SAPLING_EXTENDED_SPENDING_KEY: &str = "secret-extended-key-main";

/// The HRP for a Bech32-encoded mainnet [`ExtendedFullViewingKey`].
///
/// Defined in [ZIP 32].
///
/// [`ExtendedFullViewingKey`]: zcash_primitives::zip32::ExtendedFullViewingKey
/// [ZIP 32]: https://github.com/zcash/zips/blob/master/zip-0032.rst
pub const HRP_SAPLING_EXTENDED_FULL_VIEWING_KEY: &str = "zxviews";

/// The HRP for a Bech32-encoded mainnet [`PaymentAddress`].
///
/// Defined in section 5.6.4 of the [Zcash Protocol Specification].
///
/// [`PaymentAddress`]: sapling_crypto::primitives::PaymentAddress
/// [Zcash Protocol Specification]: https://github.com/zcash/zips/blob/master/protocol/protocol.pdf
pub const HRP_SAPLING_PAYMENT_ADDRESS: &str = "zs";
28 changes: 28 additions & 0 deletions zcash_client_backend/src/constants/testnet.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/// The testnet coin type for ZEC, as defined by [SLIP 44].
///
/// [SLIP 44]: https://github.com/satoshilabs/slips/blob/master/slip-0044.md
pub const COIN_TYPE: u32 = 1;

/// The HRP for a Bech32-encoded testnet [`ExtendedSpendingKey`].
///
/// Defined in [ZIP 32].
///
/// [`ExtendedSpendingKey`]: zcash_primitives::zip32::ExtendedSpendingKey
/// [ZIP 32]: https://github.com/zcash/zips/blob/master/zip-0032.rst
pub const HRP_SAPLING_EXTENDED_SPENDING_KEY: &str = "secret-extended-key-test";

/// The HRP for a Bech32-encoded testnet [`ExtendedFullViewingKey`].
///
/// Defined in [ZIP 32].
///
/// [`ExtendedFullViewingKey`]: zcash_primitives::zip32::ExtendedFullViewingKey
/// [ZIP 32]: https://github.com/zcash/zips/blob/master/zip-0032.rst
pub const HRP_SAPLING_EXTENDED_FULL_VIEWING_KEY: &str = "zxviewtestsapling";

/// The HRP for a Bech32-encoded testnet [`PaymentAddress`].
///
/// Defined in section 5.6.4 of the [Zcash Protocol Specification].
///
/// [`PaymentAddress`]: sapling_crypto::primitives::PaymentAddress
/// [Zcash Protocol Specification]: https://github.com/zcash/zips/blob/master/protocol/protocol.pdf
pub const HRP_SAPLING_PAYMENT_ADDRESS: &str = "ztestsapling";
Loading

0 comments on commit 91c6b0b

Please sign in to comment.