mirror of
https://github.com/Qortal/pirate-librustzcash.git
synced 2025-02-14 10:45:47 +00:00
commit
3b7f4faa1b
40
Cargo.lock
generated
40
Cargo.lock
generated
@ -1,3 +1,5 @@
|
|||||||
|
# This file is automatically @generated by Cargo.
|
||||||
|
# It is not intended for manual editing.
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "aes"
|
name = "aes"
|
||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
@ -36,6 +38,11 @@ dependencies = [
|
|||||||
"nodrop 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)",
|
"nodrop 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bech32"
|
||||||
|
version = "0.6.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bellman"
|
name = "bellman"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
@ -295,7 +302,6 @@ dependencies = [
|
|||||||
"sapling-crypto 0.0.1",
|
"sapling-crypto 0.0.1",
|
||||||
"zcash_primitives 0.0.0",
|
"zcash_primitives 0.0.0",
|
||||||
"zcash_proofs 0.0.0",
|
"zcash_proofs 0.0.0",
|
||||||
"zip32 0.0.0",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -507,14 +513,27 @@ name = "winapi-x86_64-pc-windows-gnu"
|
|||||||
version = "0.4.0"
|
version = "0.4.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "zcash_client_backend"
|
||||||
|
version = "0.0.0"
|
||||||
|
dependencies = [
|
||||||
|
"bech32 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"pairing 0.14.2",
|
||||||
|
"rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"sapling-crypto 0.0.1",
|
||||||
|
"zcash_primitives 0.0.0",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "zcash_primitives"
|
name = "zcash_primitives"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
dependencies = [
|
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)",
|
"blake2-rfc 0.2.18 (git+https://github.com/gtank/blake2-rfc?rev=7a5b5fc99ae483a0043db7547fb79a6fa44b88a9)",
|
||||||
"byteorder 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"byteorder 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"crypto_api_chachapoly 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"crypto_api_chachapoly 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"ff 0.4.0",
|
"ff 0.4.0",
|
||||||
|
"fpe 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"pairing 0.14.2",
|
"pairing 0.14.2",
|
||||||
@ -536,29 +555,12 @@ dependencies = [
|
|||||||
"sapling-crypto 0.0.1",
|
"sapling-crypto 0.0.1",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "zcash_wallet"
|
|
||||||
version = "0.0.0"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "zip32"
|
|
||||||
version = "0.0.0"
|
|
||||||
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.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"ff 0.4.0",
|
|
||||||
"fpe 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"pairing 0.14.2",
|
|
||||||
"sapling-crypto 0.0.1",
|
|
||||||
"zcash_primitives 0.0.0",
|
|
||||||
]
|
|
||||||
|
|
||||||
[metadata]
|
[metadata]
|
||||||
"checksum aes 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e6fb1737cdc8da3db76e90ca817a194249a38fcb500c2e6ecec39b29448aa873"
|
"checksum aes 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e6fb1737cdc8da3db76e90ca817a194249a38fcb500c2e6ecec39b29448aa873"
|
||||||
"checksum aes-soft 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "67cc03b0a090a05cb01e96998a01905d7ceedce1bc23b756c0bb7faa0682ccb1"
|
"checksum aes-soft 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "67cc03b0a090a05cb01e96998a01905d7ceedce1bc23b756c0bb7faa0682ccb1"
|
||||||
"checksum aesni 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6810b7fb9f2bb4f76f05ac1c170b8dde285b6308955dc3afd89710268c958d9e"
|
"checksum aesni 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6810b7fb9f2bb4f76f05ac1c170b8dde285b6308955dc3afd89710268c958d9e"
|
||||||
"checksum arrayvec 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "a1e964f9e24d588183fcb43503abda40d288c8657dfc27311516ce2f05675aef"
|
"checksum arrayvec 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "a1e964f9e24d588183fcb43503abda40d288c8657dfc27311516ce2f05675aef"
|
||||||
|
"checksum bech32 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "58946044516aa9dc922182e0d6e9d124a31aafe6b421614654eb27cf90cec09c"
|
||||||
"checksum bit-vec 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "02b4ff8b16e6076c3e14220b39fbc1fabb6737522281a388998046859400895f"
|
"checksum bit-vec 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "02b4ff8b16e6076c3e14220b39fbc1fabb6737522281a388998046859400895f"
|
||||||
"checksum bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b3c30d3802dfb7281680d6285f2ccdaa8c2d8fee41f93805dba5c4cf50dc23cf"
|
"checksum bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b3c30d3802dfb7281680d6285f2ccdaa8c2d8fee41f93805dba5c4cf50dc23cf"
|
||||||
"checksum blake2-rfc 0.2.18 (git+https://github.com/gtank/blake2-rfc?rev=7a5b5fc99ae483a0043db7547fb79a6fa44b88a9)" = "<none>"
|
"checksum blake2-rfc 0.2.18 (git+https://github.com/gtank/blake2-rfc?rev=7a5b5fc99ae483a0043db7547fb79a6fa44b88a9)" = "<none>"
|
||||||
|
@ -6,10 +6,9 @@ members = [
|
|||||||
"librustzcash",
|
"librustzcash",
|
||||||
"pairing",
|
"pairing",
|
||||||
"sapling-crypto",
|
"sapling-crypto",
|
||||||
|
"zcash_client_backend",
|
||||||
"zcash_primitives",
|
"zcash_primitives",
|
||||||
"zcash_proofs",
|
"zcash_proofs",
|
||||||
"zcash_wallet",
|
|
||||||
"zip32",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
|
@ -24,7 +24,6 @@ rand = "0.4"
|
|||||||
sapling-crypto = { path = "../sapling-crypto" }
|
sapling-crypto = { path = "../sapling-crypto" }
|
||||||
zcash_primitives = { path = "../zcash_primitives" }
|
zcash_primitives = { path = "../zcash_primitives" }
|
||||||
zcash_proofs = { path = "../zcash_proofs" }
|
zcash_proofs = { path = "../zcash_proofs" }
|
||||||
zip32 = { path = "../zip32" }
|
|
||||||
|
|
||||||
[dependencies.blake2-rfc]
|
[dependencies.blake2-rfc]
|
||||||
git = "https://github.com/gtank/blake2-rfc"
|
git = "https://github.com/gtank/blake2-rfc"
|
||||||
|
@ -8,7 +8,6 @@ extern crate rand;
|
|||||||
extern crate sapling_crypto;
|
extern crate sapling_crypto;
|
||||||
extern crate zcash_primitives;
|
extern crate zcash_primitives;
|
||||||
extern crate zcash_proofs;
|
extern crate zcash_proofs;
|
||||||
extern crate zip32;
|
|
||||||
|
|
||||||
extern crate lazy_static;
|
extern crate lazy_static;
|
||||||
|
|
||||||
@ -58,7 +57,7 @@ use std::ffi::OsString;
|
|||||||
use std::os::windows::ffi::OsStringExt;
|
use std::os::windows::ffi::OsStringExt;
|
||||||
|
|
||||||
use sapling_crypto::primitives::{ProofGenerationKey, ViewingKey};
|
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::{
|
use zcash_proofs::{
|
||||||
load_parameters,
|
load_parameters,
|
||||||
sapling::{CommitmentTreeWitness, SaplingProvingContext, SaplingVerificationContext},
|
sapling::{CommitmentTreeWitness, SaplingProvingContext, SaplingVerificationContext},
|
||||||
|
16
zcash_client_backend/Cargo.toml
Normal file
16
zcash_client_backend/Cargo.toml
Normal file
@ -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"
|
@ -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
|
## License
|
||||||
|
|
4
zcash_client_backend/src/constants.rs
Normal file
4
zcash_client_backend/src/constants.rs
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
//! Zcash global and per-network constants.
|
||||||
|
|
||||||
|
pub mod mainnet;
|
||||||
|
pub mod testnet;
|
28
zcash_client_backend/src/constants/mainnet.rs
Normal file
28
zcash_client_backend/src/constants/mainnet.rs
Normal file
@ -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
zcash_client_backend/src/constants/testnet.rs
Normal file
28
zcash_client_backend/src/constants/testnet.rs
Normal file
@ -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";
|
257
zcash_client_backend/src/encoding.rs
Normal file
257
zcash_client_backend/src/encoding.rs
Normal file
@ -0,0 +1,257 @@
|
|||||||
|
//! Encoding and decoding functions for Zcash key and address structs.
|
||||||
|
//!
|
||||||
|
//! Human-Readable Prefixes (HRPs) for Bech32 encodings are located in the [`constants`]
|
||||||
|
//! module.
|
||||||
|
|
||||||
|
use bech32::{convert_bits, Bech32, Error};
|
||||||
|
use pairing::bls12_381::Bls12;
|
||||||
|
use sapling_crypto::{
|
||||||
|
jubjub::edwards,
|
||||||
|
primitives::{Diversifier, PaymentAddress},
|
||||||
|
};
|
||||||
|
use std::io::{self, Write};
|
||||||
|
use zcash_primitives::{
|
||||||
|
zip32::{ExtendedFullViewingKey, ExtendedSpendingKey},
|
||||||
|
JUBJUB,
|
||||||
|
};
|
||||||
|
|
||||||
|
fn bech32_encode<F>(hrp: &str, write: F) -> String
|
||||||
|
where
|
||||||
|
F: Fn(&mut dyn Write) -> io::Result<()>,
|
||||||
|
{
|
||||||
|
let mut data: Vec<u8> = vec![];
|
||||||
|
write(&mut data).expect("Should be able to write to a Vec");
|
||||||
|
|
||||||
|
let converted =
|
||||||
|
convert_bits(&data, 8, 5, true).expect("Should be able to convert Vec<u8> to Vec<u5>");
|
||||||
|
let encoded = Bech32::new_check_data(hrp.into(), converted).expect("hrp is not empty");
|
||||||
|
|
||||||
|
encoded.to_string()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn bech32_decode<T, F>(hrp: &str, s: &str, read: F) -> Result<Option<T>, Error>
|
||||||
|
where
|
||||||
|
F: Fn(Vec<u8>) -> Option<T>,
|
||||||
|
{
|
||||||
|
let decoded = s.parse::<Bech32>()?;
|
||||||
|
if decoded.hrp() == hrp {
|
||||||
|
convert_bits(decoded.data(), 5, 8, false).map(|data| read(data))
|
||||||
|
} else {
|
||||||
|
Ok(None)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Writes an [`ExtendedSpendingKey`] as a Bech32-encoded string.
|
||||||
|
///
|
||||||
|
/// # Examples
|
||||||
|
///
|
||||||
|
/// ```
|
||||||
|
/// use zcash_client_backend::{
|
||||||
|
/// constants::testnet::{COIN_TYPE, HRP_SAPLING_EXTENDED_SPENDING_KEY},
|
||||||
|
/// encoding::encode_extended_spending_key,
|
||||||
|
/// keys::spending_key,
|
||||||
|
/// };
|
||||||
|
///
|
||||||
|
/// let extsk = spending_key(&[0; 32][..], COIN_TYPE, 0);
|
||||||
|
/// let encoded = encode_extended_spending_key(HRP_SAPLING_EXTENDED_SPENDING_KEY, &extsk);
|
||||||
|
/// ```
|
||||||
|
pub fn encode_extended_spending_key(hrp: &str, extsk: &ExtendedSpendingKey) -> String {
|
||||||
|
bech32_encode(hrp, |w| extsk.write(w))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Decodes an [`ExtendedSpendingKey`] from a Bech32-encoded string.
|
||||||
|
pub fn decode_extended_spending_key(
|
||||||
|
hrp: &str,
|
||||||
|
s: &str,
|
||||||
|
) -> Result<Option<ExtendedSpendingKey>, Error> {
|
||||||
|
bech32_decode(hrp, s, |data| ExtendedSpendingKey::read(&data[..]).ok())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Writes an [`ExtendedFullViewingKey`] as a Bech32-encoded string.
|
||||||
|
///
|
||||||
|
/// # Examples
|
||||||
|
///
|
||||||
|
/// ```
|
||||||
|
/// use zcash_client_backend::{
|
||||||
|
/// constants::testnet::{COIN_TYPE, HRP_SAPLING_EXTENDED_FULL_VIEWING_KEY},
|
||||||
|
/// encoding::encode_extended_full_viewing_key,
|
||||||
|
/// keys::spending_key,
|
||||||
|
/// };
|
||||||
|
/// use zcash_primitives::zip32::ExtendedFullViewingKey;
|
||||||
|
///
|
||||||
|
/// let extsk = spending_key(&[0; 32][..], COIN_TYPE, 0);
|
||||||
|
/// let extfvk = ExtendedFullViewingKey::from(&extsk);
|
||||||
|
/// let encoded = encode_extended_full_viewing_key(HRP_SAPLING_EXTENDED_FULL_VIEWING_KEY, &extfvk);
|
||||||
|
/// ```
|
||||||
|
pub fn encode_extended_full_viewing_key(hrp: &str, extfvk: &ExtendedFullViewingKey) -> String {
|
||||||
|
bech32_encode(hrp, |w| extfvk.write(w))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Decodes an [`ExtendedFullViewingKey`] from a Bech32-encoded string.
|
||||||
|
pub fn decode_extended_full_viewing_key(
|
||||||
|
hrp: &str,
|
||||||
|
s: &str,
|
||||||
|
) -> Result<Option<ExtendedFullViewingKey>, Error> {
|
||||||
|
bech32_decode(hrp, s, |data| ExtendedFullViewingKey::read(&data[..]).ok())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Writes a [`PaymentAddress`] as a Bech32-encoded string.
|
||||||
|
///
|
||||||
|
/// # Examples
|
||||||
|
///
|
||||||
|
/// ```
|
||||||
|
/// use pairing::bls12_381::Bls12;
|
||||||
|
/// use rand::{SeedableRng, XorShiftRng};
|
||||||
|
/// use sapling_crypto::{
|
||||||
|
/// jubjub::edwards,
|
||||||
|
/// primitives::{Diversifier, PaymentAddress},
|
||||||
|
/// };
|
||||||
|
/// use zcash_client_backend::{
|
||||||
|
/// constants::testnet::HRP_SAPLING_PAYMENT_ADDRESS,
|
||||||
|
/// encoding::encode_payment_address,
|
||||||
|
/// };
|
||||||
|
/// use zcash_primitives::JUBJUB;
|
||||||
|
///
|
||||||
|
/// let rng = &mut XorShiftRng::from_seed([0x3dbe6259, 0x8d313d76, 0x3237db17, 0xe5bc0654]);
|
||||||
|
///
|
||||||
|
/// let pa = PaymentAddress {
|
||||||
|
/// diversifier: Diversifier([0u8; 11]),
|
||||||
|
/// pk_d: edwards::Point::<Bls12, _>::rand(rng, &JUBJUB).mul_by_cofactor(&JUBJUB),
|
||||||
|
/// };
|
||||||
|
///
|
||||||
|
/// assert_eq!(
|
||||||
|
/// encode_payment_address(HRP_SAPLING_PAYMENT_ADDRESS, &pa),
|
||||||
|
/// "ztestsapling1qqqqqqqqqqqqqqqqqqxrrfaccydp867g6zg7ne5ht37z38jtfyw0ygmp0ja6hhf07twjq6awtaj",
|
||||||
|
/// );
|
||||||
|
/// ```
|
||||||
|
pub fn encode_payment_address(hrp: &str, addr: &PaymentAddress<Bls12>) -> String {
|
||||||
|
bech32_encode(hrp, |w| {
|
||||||
|
w.write_all(&addr.diversifier.0)?;
|
||||||
|
addr.pk_d.write(w)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Decodes a [`PaymentAddress`] from a Bech32-encoded string.
|
||||||
|
///
|
||||||
|
/// # Examples
|
||||||
|
///
|
||||||
|
/// ```
|
||||||
|
/// use pairing::bls12_381::Bls12;
|
||||||
|
/// use rand::{SeedableRng, XorShiftRng};
|
||||||
|
/// use sapling_crypto::{
|
||||||
|
/// jubjub::edwards,
|
||||||
|
/// primitives::{Diversifier, PaymentAddress},
|
||||||
|
/// };
|
||||||
|
/// use zcash_client_backend::{
|
||||||
|
/// constants::testnet::HRP_SAPLING_PAYMENT_ADDRESS,
|
||||||
|
/// encoding::decode_payment_address,
|
||||||
|
/// };
|
||||||
|
/// use zcash_primitives::JUBJUB;
|
||||||
|
///
|
||||||
|
/// let rng = &mut XorShiftRng::from_seed([0x3dbe6259, 0x8d313d76, 0x3237db17, 0xe5bc0654]);
|
||||||
|
///
|
||||||
|
/// let pa = PaymentAddress {
|
||||||
|
/// diversifier: Diversifier([0u8; 11]),
|
||||||
|
/// pk_d: edwards::Point::<Bls12, _>::rand(rng, &JUBJUB).mul_by_cofactor(&JUBJUB),
|
||||||
|
/// };
|
||||||
|
///
|
||||||
|
/// assert_eq!(
|
||||||
|
/// decode_payment_address(
|
||||||
|
/// HRP_SAPLING_PAYMENT_ADDRESS,
|
||||||
|
/// "ztestsapling1qqqqqqqqqqqqqqqqqqxrrfaccydp867g6zg7ne5ht37z38jtfyw0ygmp0ja6hhf07twjq6awtaj",
|
||||||
|
/// ),
|
||||||
|
/// Ok(Some(pa)),
|
||||||
|
/// );
|
||||||
|
/// ```
|
||||||
|
pub fn decode_payment_address(hrp: &str, s: &str) -> Result<Option<PaymentAddress<Bls12>>, Error> {
|
||||||
|
bech32_decode(hrp, s, |data| {
|
||||||
|
let mut diversifier = Diversifier([0; 11]);
|
||||||
|
diversifier.0.copy_from_slice(&data[0..11]);
|
||||||
|
// Check that the diversifier is valid
|
||||||
|
if diversifier.g_d::<Bls12>(&JUBJUB).is_none() {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
|
||||||
|
edwards::Point::<Bls12, _>::read(&data[11..], &JUBJUB)
|
||||||
|
.ok()?
|
||||||
|
.as_prime_order(&JUBJUB)
|
||||||
|
.map(|pk_d| PaymentAddress { pk_d, diversifier })
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use pairing::bls12_381::Bls12;
|
||||||
|
use rand::{SeedableRng, XorShiftRng};
|
||||||
|
use sapling_crypto::{
|
||||||
|
jubjub::edwards,
|
||||||
|
primitives::{Diversifier, PaymentAddress},
|
||||||
|
};
|
||||||
|
use zcash_primitives::JUBJUB;
|
||||||
|
|
||||||
|
use super::{decode_payment_address, encode_payment_address};
|
||||||
|
use crate::constants;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn payment_address() {
|
||||||
|
let rng = &mut XorShiftRng::from_seed([0x3dbe6259, 0x8d313d76, 0x3237db17, 0xe5bc0654]);
|
||||||
|
|
||||||
|
let addr = PaymentAddress {
|
||||||
|
diversifier: Diversifier([0u8; 11]),
|
||||||
|
pk_d: edwards::Point::<Bls12, _>::rand(rng, &JUBJUB).mul_by_cofactor(&JUBJUB),
|
||||||
|
};
|
||||||
|
|
||||||
|
let encoded_main =
|
||||||
|
"zs1qqqqqqqqqqqqqqqqqqxrrfaccydp867g6zg7ne5ht37z38jtfyw0ygmp0ja6hhf07twjqj2ug6x";
|
||||||
|
let encoded_test =
|
||||||
|
"ztestsapling1qqqqqqqqqqqqqqqqqqxrrfaccydp867g6zg7ne5ht37z38jtfyw0ygmp0ja6hhf07twjq6awtaj";
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
encode_payment_address(constants::mainnet::HRP_SAPLING_PAYMENT_ADDRESS, &addr),
|
||||||
|
encoded_main
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
decode_payment_address(
|
||||||
|
constants::mainnet::HRP_SAPLING_PAYMENT_ADDRESS,
|
||||||
|
encoded_main
|
||||||
|
)
|
||||||
|
.unwrap(),
|
||||||
|
Some(addr.clone())
|
||||||
|
);
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
encode_payment_address(constants::testnet::HRP_SAPLING_PAYMENT_ADDRESS, &addr),
|
||||||
|
encoded_test
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
decode_payment_address(
|
||||||
|
constants::testnet::HRP_SAPLING_PAYMENT_ADDRESS,
|
||||||
|
encoded_test
|
||||||
|
)
|
||||||
|
.unwrap(),
|
||||||
|
Some(addr)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn invalid_diversifier() {
|
||||||
|
let rng = &mut XorShiftRng::from_seed([0x3dbe6259, 0x8d313d76, 0x3237db17, 0xe5bc0654]);
|
||||||
|
|
||||||
|
let addr = PaymentAddress {
|
||||||
|
diversifier: Diversifier([1u8; 11]),
|
||||||
|
pk_d: edwards::Point::<Bls12, _>::rand(rng, &JUBJUB).mul_by_cofactor(&JUBJUB),
|
||||||
|
};
|
||||||
|
|
||||||
|
let encoded_main =
|
||||||
|
encode_payment_address(constants::mainnet::HRP_SAPLING_PAYMENT_ADDRESS, &addr);
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
decode_payment_address(
|
||||||
|
constants::mainnet::HRP_SAPLING_PAYMENT_ADDRESS,
|
||||||
|
&encoded_main
|
||||||
|
)
|
||||||
|
.unwrap(),
|
||||||
|
None
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
24
zcash_client_backend/src/keys.rs
Normal file
24
zcash_client_backend/src/keys.rs
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
//! Helper functions for managing light client key material.
|
||||||
|
|
||||||
|
use zcash_primitives::zip32::{ChildIndex, ExtendedSpendingKey};
|
||||||
|
|
||||||
|
/// Derives the ZIP 32 [`ExtendedSpendingKey`] for a given coin type and account from the
|
||||||
|
/// given seed.
|
||||||
|
///
|
||||||
|
/// # Examples
|
||||||
|
///
|
||||||
|
/// ```
|
||||||
|
/// use zcash_client_backend::{constants::testnet::COIN_TYPE, keys::spending_key};
|
||||||
|
///
|
||||||
|
/// let extsk = spending_key(&[0; 32][..], COIN_TYPE, 0);
|
||||||
|
/// ```
|
||||||
|
pub fn spending_key(seed: &[u8], coin_type: u32, account: u32) -> ExtendedSpendingKey {
|
||||||
|
ExtendedSpendingKey::from_path(
|
||||||
|
&ExtendedSpendingKey::master(&seed),
|
||||||
|
&[
|
||||||
|
ChildIndex::Hardened(32),
|
||||||
|
ChildIndex::Hardened(coin_type),
|
||||||
|
ChildIndex::Hardened(account),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
}
|
8
zcash_client_backend/src/lib.rs
Normal file
8
zcash_client_backend/src/lib.rs
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
//! *A crate for implementing Zcash light clients.*
|
||||||
|
//!
|
||||||
|
//! `zcash_client_backend` contains Rust structs and traits for creating shielded Zcash
|
||||||
|
//! light clients.
|
||||||
|
|
||||||
|
pub mod constants;
|
||||||
|
pub mod encoding;
|
||||||
|
pub mod keys;
|
@ -6,9 +6,11 @@ authors = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
aes = "0.2"
|
||||||
byteorder = "1"
|
byteorder = "1"
|
||||||
crypto_api_chachapoly = "0.1"
|
crypto_api_chachapoly = "0.1"
|
||||||
ff = { path = "../ff" }
|
ff = { path = "../ff" }
|
||||||
|
fpe = "0.1"
|
||||||
hex = "0.3"
|
hex = "0.3"
|
||||||
lazy_static = "1"
|
lazy_static = "1"
|
||||||
pairing = { path = "../pairing" }
|
pairing = { path = "../pairing" }
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate lazy_static;
|
extern crate lazy_static;
|
||||||
|
|
||||||
|
extern crate aes;
|
||||||
extern crate blake2_rfc;
|
extern crate blake2_rfc;
|
||||||
extern crate byteorder;
|
extern crate byteorder;
|
||||||
extern crate crypto_api_chachapoly;
|
extern crate crypto_api_chachapoly;
|
||||||
extern crate ff;
|
extern crate ff;
|
||||||
|
extern crate fpe;
|
||||||
extern crate hex;
|
extern crate hex;
|
||||||
extern crate pairing;
|
extern crate pairing;
|
||||||
extern crate rand;
|
extern crate rand;
|
||||||
@ -19,6 +21,7 @@ pub mod note_encryption;
|
|||||||
pub mod sapling;
|
pub mod sapling;
|
||||||
mod serialize;
|
mod serialize;
|
||||||
pub mod transaction;
|
pub mod transaction;
|
||||||
|
pub mod zip32;
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test_vectors;
|
mod test_vectors;
|
||||||
|
@ -1,12 +1,3 @@
|
|||||||
extern crate aes;
|
|
||||||
extern crate blake2_rfc;
|
|
||||||
extern crate byteorder;
|
|
||||||
extern crate ff;
|
|
||||||
extern crate fpe;
|
|
||||||
extern crate pairing;
|
|
||||||
extern crate sapling_crypto;
|
|
||||||
extern crate zcash_primitives;
|
|
||||||
|
|
||||||
use aes::Aes256;
|
use aes::Aes256;
|
||||||
use blake2_rfc::blake2b::Blake2b;
|
use blake2_rfc::blake2b::Blake2b;
|
||||||
use byteorder::{ByteOrder, LittleEndian, ReadBytesExt, WriteBytesExt};
|
use byteorder::{ByteOrder, LittleEndian, ReadBytesExt, WriteBytesExt};
|
||||||
@ -18,7 +9,8 @@ use sapling_crypto::{
|
|||||||
primitives::{Diversifier, PaymentAddress, ViewingKey},
|
primitives::{Diversifier, PaymentAddress, ViewingKey},
|
||||||
};
|
};
|
||||||
use std::io::{self, Read, Write};
|
use std::io::{self, Read, Write};
|
||||||
use zcash_primitives::{
|
|
||||||
|
use crate::{
|
||||||
keys::{prf_expand, prf_expand_vec, ExpandedSpendingKey, FullViewingKey, OutgoingViewingKey},
|
keys::{prf_expand, prf_expand_vec, ExpandedSpendingKey, FullViewingKey, OutgoingViewingKey},
|
||||||
JUBJUB,
|
JUBJUB,
|
||||||
};
|
};
|
@ -1,8 +0,0 @@
|
|||||||
[package]
|
|
||||||
name = "zcash_wallet"
|
|
||||||
version = "0.0.0"
|
|
||||||
authors = [
|
|
||||||
"Jack Grigg <jack@z.cash>",
|
|
||||||
]
|
|
||||||
|
|
||||||
[dependencies]
|
|
@ -1,7 +0,0 @@
|
|||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
#[test]
|
|
||||||
fn it_works() {
|
|
||||||
assert_eq!(2 + 2, 4);
|
|
||||||
}
|
|
||||||
}
|
|
3
zip32/.gitignore
vendored
3
zip32/.gitignore
vendored
@ -1,3 +0,0 @@
|
|||||||
/target
|
|
||||||
**/*.rs.bk
|
|
||||||
Cargo.lock
|
|
@ -1,14 +0,0 @@
|
|||||||
Copyrights in the "zip32" library are retained by their contributors. No
|
|
||||||
copyright assignment is required to contribute to the "zip32" library.
|
|
||||||
|
|
||||||
The "zip32" library is licensed under either of
|
|
||||||
|
|
||||||
* Apache License, Version 2.0, (see ./LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
|
|
||||||
* MIT license (see ./LICENSE-MIT or http://opensource.org/licenses/MIT)
|
|
||||||
|
|
||||||
at your option.
|
|
||||||
|
|
||||||
Unless you explicitly state otherwise, any contribution intentionally
|
|
||||||
submitted for inclusion in the work by you, as defined in the Apache-2.0
|
|
||||||
license, shall be dual licensed as above, without any additional terms or
|
|
||||||
conditions.
|
|
@ -1,25 +0,0 @@
|
|||||||
[package]
|
|
||||||
name = "zip32"
|
|
||||||
version = "0.0.0"
|
|
||||||
authors = [
|
|
||||||
"Jack Grigg <jack@z.cash>",
|
|
||||||
]
|
|
||||||
license = "MIT/Apache-2.0"
|
|
||||||
|
|
||||||
description = "Library for implementing shielded hierarchical deterministic wallets"
|
|
||||||
documentation = "https://docs.rs/zip32/"
|
|
||||||
homepage = "https://github.com/zcash-hackworks/zip32"
|
|
||||||
repository = "https://github.com/zcash-hackworks/zip32"
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
aes = "0.2"
|
|
||||||
byteorder = "1"
|
|
||||||
ff = { path = "../ff" }
|
|
||||||
fpe = "0.1"
|
|
||||||
pairing = { path = "../pairing" }
|
|
||||||
sapling-crypto = { path = "../sapling-crypto" }
|
|
||||||
zcash_primitives = { path = "../zcash_primitives" }
|
|
||||||
|
|
||||||
[dependencies.blake2-rfc]
|
|
||||||
git = "https://github.com/gtank/blake2-rfc"
|
|
||||||
rev = "7a5b5fc99ae483a0043db7547fb79a6fa44b88a9"
|
|
@ -1,201 +0,0 @@
|
|||||||
Apache License
|
|
||||||
Version 2.0, January 2004
|
|
||||||
http://www.apache.org/licenses/
|
|
||||||
|
|
||||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
||||||
|
|
||||||
1. Definitions.
|
|
||||||
|
|
||||||
"License" shall mean the terms and conditions for use, reproduction,
|
|
||||||
and distribution as defined by Sections 1 through 9 of this document.
|
|
||||||
|
|
||||||
"Licensor" shall mean the copyright owner or entity authorized by
|
|
||||||
the copyright owner that is granting the License.
|
|
||||||
|
|
||||||
"Legal Entity" shall mean the union of the acting entity and all
|
|
||||||
other entities that control, are controlled by, or are under common
|
|
||||||
control with that entity. For the purposes of this definition,
|
|
||||||
"control" means (i) the power, direct or indirect, to cause the
|
|
||||||
direction or management of such entity, whether by contract or
|
|
||||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
||||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
||||||
|
|
||||||
"You" (or "Your") shall mean an individual or Legal Entity
|
|
||||||
exercising permissions granted by this License.
|
|
||||||
|
|
||||||
"Source" form shall mean the preferred form for making modifications,
|
|
||||||
including but not limited to software source code, documentation
|
|
||||||
source, and configuration files.
|
|
||||||
|
|
||||||
"Object" form shall mean any form resulting from mechanical
|
|
||||||
transformation or translation of a Source form, including but
|
|
||||||
not limited to compiled object code, generated documentation,
|
|
||||||
and conversions to other media types.
|
|
||||||
|
|
||||||
"Work" shall mean the work of authorship, whether in Source or
|
|
||||||
Object form, made available under the License, as indicated by a
|
|
||||||
copyright notice that is included in or attached to the work
|
|
||||||
(an example is provided in the Appendix below).
|
|
||||||
|
|
||||||
"Derivative Works" shall mean any work, whether in Source or Object
|
|
||||||
form, that is based on (or derived from) the Work and for which the
|
|
||||||
editorial revisions, annotations, elaborations, or other modifications
|
|
||||||
represent, as a whole, an original work of authorship. For the purposes
|
|
||||||
of this License, Derivative Works shall not include works that remain
|
|
||||||
separable from, or merely link (or bind by name) to the interfaces of,
|
|
||||||
the Work and Derivative Works thereof.
|
|
||||||
|
|
||||||
"Contribution" shall mean any work of authorship, including
|
|
||||||
the original version of the Work and any modifications or additions
|
|
||||||
to that Work or Derivative Works thereof, that is intentionally
|
|
||||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
||||||
or by an individual or Legal Entity authorized to submit on behalf of
|
|
||||||
the copyright owner. For the purposes of this definition, "submitted"
|
|
||||||
means any form of electronic, verbal, or written communication sent
|
|
||||||
to the Licensor or its representatives, including but not limited to
|
|
||||||
communication on electronic mailing lists, source code control systems,
|
|
||||||
and issue tracking systems that are managed by, or on behalf of, the
|
|
||||||
Licensor for the purpose of discussing and improving the Work, but
|
|
||||||
excluding communication that is conspicuously marked or otherwise
|
|
||||||
designated in writing by the copyright owner as "Not a Contribution."
|
|
||||||
|
|
||||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
||||||
on behalf of whom a Contribution has been received by Licensor and
|
|
||||||
subsequently incorporated within the Work.
|
|
||||||
|
|
||||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
||||||
this License, each Contributor hereby grants to You a perpetual,
|
|
||||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
||||||
copyright license to reproduce, prepare Derivative Works of,
|
|
||||||
publicly display, publicly perform, sublicense, and distribute the
|
|
||||||
Work and such Derivative Works in Source or Object form.
|
|
||||||
|
|
||||||
3. Grant of Patent License. Subject to the terms and conditions of
|
|
||||||
this License, each Contributor hereby grants to You a perpetual,
|
|
||||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
||||||
(except as stated in this section) patent license to make, have made,
|
|
||||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
||||||
where such license applies only to those patent claims licensable
|
|
||||||
by such Contributor that are necessarily infringed by their
|
|
||||||
Contribution(s) alone or by combination of their Contribution(s)
|
|
||||||
with the Work to which such Contribution(s) was submitted. If You
|
|
||||||
institute patent litigation against any entity (including a
|
|
||||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
||||||
or a Contribution incorporated within the Work constitutes direct
|
|
||||||
or contributory patent infringement, then any patent licenses
|
|
||||||
granted to You under this License for that Work shall terminate
|
|
||||||
as of the date such litigation is filed.
|
|
||||||
|
|
||||||
4. Redistribution. You may reproduce and distribute copies of the
|
|
||||||
Work or Derivative Works thereof in any medium, with or without
|
|
||||||
modifications, and in Source or Object form, provided that You
|
|
||||||
meet the following conditions:
|
|
||||||
|
|
||||||
(a) You must give any other recipients of the Work or
|
|
||||||
Derivative Works a copy of this License; and
|
|
||||||
|
|
||||||
(b) You must cause any modified files to carry prominent notices
|
|
||||||
stating that You changed the files; and
|
|
||||||
|
|
||||||
(c) You must retain, in the Source form of any Derivative Works
|
|
||||||
that You distribute, all copyright, patent, trademark, and
|
|
||||||
attribution notices from the Source form of the Work,
|
|
||||||
excluding those notices that do not pertain to any part of
|
|
||||||
the Derivative Works; and
|
|
||||||
|
|
||||||
(d) If the Work includes a "NOTICE" text file as part of its
|
|
||||||
distribution, then any Derivative Works that You distribute must
|
|
||||||
include a readable copy of the attribution notices contained
|
|
||||||
within such NOTICE file, excluding those notices that do not
|
|
||||||
pertain to any part of the Derivative Works, in at least one
|
|
||||||
of the following places: within a NOTICE text file distributed
|
|
||||||
as part of the Derivative Works; within the Source form or
|
|
||||||
documentation, if provided along with the Derivative Works; or,
|
|
||||||
within a display generated by the Derivative Works, if and
|
|
||||||
wherever such third-party notices normally appear. The contents
|
|
||||||
of the NOTICE file are for informational purposes only and
|
|
||||||
do not modify the License. You may add Your own attribution
|
|
||||||
notices within Derivative Works that You distribute, alongside
|
|
||||||
or as an addendum to the NOTICE text from the Work, provided
|
|
||||||
that such additional attribution notices cannot be construed
|
|
||||||
as modifying the License.
|
|
||||||
|
|
||||||
You may add Your own copyright statement to Your modifications and
|
|
||||||
may provide additional or different license terms and conditions
|
|
||||||
for use, reproduction, or distribution of Your modifications, or
|
|
||||||
for any such Derivative Works as a whole, provided Your use,
|
|
||||||
reproduction, and distribution of the Work otherwise complies with
|
|
||||||
the conditions stated in this License.
|
|
||||||
|
|
||||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
||||||
any Contribution intentionally submitted for inclusion in the Work
|
|
||||||
by You to the Licensor shall be under the terms and conditions of
|
|
||||||
this License, without any additional terms or conditions.
|
|
||||||
Notwithstanding the above, nothing herein shall supersede or modify
|
|
||||||
the terms of any separate license agreement you may have executed
|
|
||||||
with Licensor regarding such Contributions.
|
|
||||||
|
|
||||||
6. Trademarks. This License does not grant permission to use the trade
|
|
||||||
names, trademarks, service marks, or product names of the Licensor,
|
|
||||||
except as required for reasonable and customary use in describing the
|
|
||||||
origin of the Work and reproducing the content of the NOTICE file.
|
|
||||||
|
|
||||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
||||||
agreed to in writing, Licensor provides the Work (and each
|
|
||||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
||||||
implied, including, without limitation, any warranties or conditions
|
|
||||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
||||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
||||||
appropriateness of using or redistributing the Work and assume any
|
|
||||||
risks associated with Your exercise of permissions under this License.
|
|
||||||
|
|
||||||
8. Limitation of Liability. In no event and under no legal theory,
|
|
||||||
whether in tort (including negligence), contract, or otherwise,
|
|
||||||
unless required by applicable law (such as deliberate and grossly
|
|
||||||
negligent acts) or agreed to in writing, shall any Contributor be
|
|
||||||
liable to You for damages, including any direct, indirect, special,
|
|
||||||
incidental, or consequential damages of any character arising as a
|
|
||||||
result of this License or out of the use or inability to use the
|
|
||||||
Work (including but not limited to damages for loss of goodwill,
|
|
||||||
work stoppage, computer failure or malfunction, or any and all
|
|
||||||
other commercial damages or losses), even if such Contributor
|
|
||||||
has been advised of the possibility of such damages.
|
|
||||||
|
|
||||||
9. Accepting Warranty or Additional Liability. While redistributing
|
|
||||||
the Work or Derivative Works thereof, You may choose to offer,
|
|
||||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
||||||
or other liability obligations and/or rights consistent with this
|
|
||||||
License. However, in accepting such obligations, You may act only
|
|
||||||
on Your own behalf and on Your sole responsibility, not on behalf
|
|
||||||
of any other Contributor, and only if You agree to indemnify,
|
|
||||||
defend, and hold each Contributor harmless for any liability
|
|
||||||
incurred by, or claims asserted against, such Contributor by reason
|
|
||||||
of your accepting any such warranty or additional liability.
|
|
||||||
|
|
||||||
END OF TERMS AND CONDITIONS
|
|
||||||
|
|
||||||
APPENDIX: How to apply the Apache License to your work.
|
|
||||||
|
|
||||||
To apply the Apache License to your work, attach the following
|
|
||||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
||||||
replaced with your own identifying information. (Don't include
|
|
||||||
the brackets!) The text should be enclosed in the appropriate
|
|
||||||
comment syntax for the file format. We also recommend that a
|
|
||||||
file or class name and description of purpose be included on the
|
|
||||||
same "printed page" as the copyright notice for easier
|
|
||||||
identification within third-party archives.
|
|
||||||
|
|
||||||
Copyright [yyyy] [name of copyright owner]
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
@ -1,23 +0,0 @@
|
|||||||
Permission is hereby granted, free of charge, to any
|
|
||||||
person obtaining a copy of this software and associated
|
|
||||||
documentation files (the "Software"), to deal in the
|
|
||||||
Software without restriction, including without
|
|
||||||
limitation the rights to use, copy, modify, merge,
|
|
||||||
publish, distribute, sublicense, and/or sell copies of
|
|
||||||
the Software, and to permit persons to whom the Software
|
|
||||||
is furnished to do so, subject to the following
|
|
||||||
conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice
|
|
||||||
shall be included in all copies or substantial portions
|
|
||||||
of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
|
|
||||||
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
|
||||||
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
|
||||||
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
|
|
||||||
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
||||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
||||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
|
|
||||||
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
DEALINGS IN THE SOFTWARE.
|
|
@ -1,17 +0,0 @@
|
|||||||
# zip32 [![Crates.io](https://img.shields.io/crates/v/zip32.svg)](https://crates.io/crates/zip32) #
|
|
||||||
|
|
||||||
## License
|
|
||||||
|
|
||||||
Licensed under either of
|
|
||||||
|
|
||||||
* Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
|
|
||||||
* MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
|
|
||||||
|
|
||||||
at your option.
|
|
||||||
|
|
||||||
### Contribution
|
|
||||||
|
|
||||||
Unless you explicitly state otherwise, any contribution intentionally
|
|
||||||
submitted for inclusion in the work by you, as defined in the Apache-2.0
|
|
||||||
license, shall be dual licensed as above, without any additional terms or
|
|
||||||
conditions.
|
|
Loading…
x
Reference in New Issue
Block a user