Apply suggestions from code review

Co-authored-by: str4d <jack@electriccoin.co>
This commit is contained in:
Kris Nuttycombe 2022-01-27 08:54:27 -07:00 committed by Kris Nuttycombe
parent 132df78a31
commit 3a20176092
15 changed files with 28 additions and 20 deletions

View File

@ -352,10 +352,10 @@ pub trait ShieldedOutput<D: Domain, const CIPHERTEXT_SIZE: usize> {
/// use ff::Field;
/// use rand_core::OsRng;
/// use zcash_primitives::{
/// keys::{OutgoingViewingKey, prf_expand},
/// consensus::{TEST_NETWORK, TestNetwork, NetworkUpgrade, Parameters},
/// memo::MemoBytes,
/// sapling::{
/// keys::{OutgoingViewingKey, prf_expand},
/// note_encryption::sapling_note_encryption,
/// util::generate_random_rseed,
/// Diversifier, PaymentAddress, Rseed, ValueCommitment

View File

@ -25,8 +25,8 @@ and this library adheres to Rust's notion of
to support handling of errors in transparent address decoding.
- The `Builder::add_sapling_output` method now takes its `MemoBytes` argument
as a required field rather than an optional one. If the empty memo is desired, use
MemoBytes::from(Memo::Empty) explicitly.
- The `SaplingBuiilder::add_output` method has now similarly been changed to take
`MemoBytes::from(Memo::Empty)` explicitly.
- The `SaplingBuilder::add_output` method has now similarly been changed to take
its `MemoBytes` argument as a required field.
## [0.5.0] - 2021-03-26
### Added

View File

@ -72,7 +72,7 @@ pub trait WalletRead {
heights.map(|(min_height, max_height)| {
let target_height = max_height + 1;
// Select an anchor ANCHOR_OFFSET back from the target block,
// Select an anchor min_confirmations back from the target block,
// unless that would be before the earliest block we have.
let anchor_height = BlockHeight::from(cmp::max(
u32::from(target_height).saturating_sub(min_confirmations),

View File

@ -28,7 +28,7 @@ pub struct DecryptedOutput {
/// True if this output was recovered using an [`OutgoingViewingKey`], meaning that
/// this is a logical output of the transaction.
///
/// [`OutgoingViewingKey`]: zcash_primitives::sapling::keys::OutgoingViewingKey
/// [`OutgoingViewingKey`]: zcash_primitives::keys::OutgoingViewingKey
pub outgoing: bool,
}

View File

@ -3,9 +3,10 @@
use zcash_note_encryption::EphemeralKeyBytes;
use zcash_primitives::{
keys::OutgoingViewingKey,
merkle_tree::IncrementalWitness,
sapling::{
keys::OutgoingViewingKey, Diversifier, Node, Note, Nullifier, PaymentAddress, Rseed,
Diversifier, Node, Note, Nullifier, PaymentAddress, Rseed,
},
transaction::{components::Amount, TxId},
zip32::AccountId,

View File

@ -24,8 +24,8 @@ rusqlite = { version = "0.24", features = ["bundled", "time"] }
secp256k1 = { version = "0.20" }
time = "0.2"
zcash_address = { version = "0.0", path = "../components/zcash_address"}
zcash_client_backend = { version = "0.5", path = "../zcash_client_backend"}
zcash_primitives = { version = "0.5", path = "../zcash_primitives"}
zcash_client_backend = { version = "0.5", path = "../zcash_client_backend" }
zcash_primitives = { version = "0.5", path = "../zcash_primitives" }
[dev-dependencies]
tempfile = "3"
@ -34,7 +34,7 @@ zcash_proofs = { version = "0.5", path = "../zcash_proofs" }
[features]
mainnet = []
test-dependencies = ["zcash_client_backend/test-dependencies"]
transparent-inputs = ["zcash_client_backend/transparent-inputs", "zcash_primitives/transparent-inputs"]
transparent-inputs = ["zcash_client_backend/transparent-inputs"]
[lib]
bench = false

View File

@ -44,7 +44,6 @@ ripemd160 = { version = "0.9", optional = true }
secp256k1 = { version = "0.20", optional = true }
sha2 = "0.9"
subtle = "2.2.3"
zcash_address = { version = "0.0", path = "../components/zcash_address" }
zcash_encoding = { version = "0.0", path = "../components/zcash_encoding" }
[dependencies.zcash_note_encryption]

View File

@ -5,9 +5,11 @@
/// [SLIP 44]: https://github.com/satoshilabs/slips/blob/master/slip-0044.md
pub const COIN_TYPE: u32 = 133;
/// The mainnet Wallet Import Format (WIF) lead byte.
/// The mainnet Wallet Import Format ([WIF]) lead byte, as defined by [section 5.6.1.2] of
/// the Zcash protocol spec.
///
/// [WIF]: https://en.bitcoin.it/wiki/Wallet_import_format
/// [section 5.6.1.2]: https://zips.z.cash/protocol/protocol.pdf#transparentkeyencoding
pub const WIF_LEAD_BYTE: u8 = 0x80;
/// The HRP for a Bech32-encoded mainnet [`ExtendedSpendingKey`].

View File

@ -5,9 +5,11 @@
/// [SLIP 44]: https://github.com/satoshilabs/slips/blob/master/slip-0044.md
pub const COIN_TYPE: u32 = 1;
/// The mainnet Wallet Import Format (WIF) lead byte.
/// The mainnet Wallet Import Format ([WIF]) lead byte, as defined by [section 5.6.1.2] of
/// the Zcash protocol spec.
///
/// [WIF]: https://en.bitcoin.it/wiki/Wallet_import_format
/// [section 5.6.1.2]: https://zips.z.cash/protocol/protocol.pdf#transparentkeyencoding
pub const WIF_LEAD_BYTE: u8 = 0xEF;
/// The HRP for a Bech32-encoded testnet [`ExtendedSpendingKey`].

View File

@ -23,13 +23,13 @@ use subtle::{Choice, ConstantTimeEq};
use crate::{
constants::{self, SPENDING_KEY_GENERATOR},
keys::prf_expand,
merkle_tree::{HashSer, Hashable},
transaction::components::amount::MAX_MONEY,
};
use self::{
group_hash::group_hash,
keys::prf_expand,
pedersen_hash::{pedersen_hash, Personalization},
redjubjub::{PrivateKey, PublicKey, Signature},
};

View File

@ -6,6 +6,7 @@
use crate::{
constants::{PROOF_GENERATION_KEY_GENERATOR, SPENDING_KEY_GENERATOR},
keys::{prf_expand, OutgoingViewingKey},
sapling::{ProofGenerationKey, ViewingKey},
};
use ff::PrimeField;
@ -13,7 +14,6 @@ use group::{Group, GroupEncoding};
use std::io::{self, Read, Write};
use subtle::CtOption;
pub use crate::keys::{prf_expand, prf_expand_vec, OutgoingViewingKey};
/// A Sapling expanded spending key
#[derive(Clone)]

View File

@ -16,8 +16,9 @@ use zcash_note_encryption::{
use crate::{
consensus::{self, BlockHeight, NetworkUpgrade::Canopy, ZIP212_GRACE_PERIOD},
keys::OutgoingViewingKey,
memo::MemoBytes,
sapling::{keys::OutgoingViewingKey, Diversifier, Note, PaymentAddress, Rseed, SaplingIvk},
sapling::{Diversifier, Note, PaymentAddress, Rseed, SaplingIvk},
transaction::components::{
amount::Amount,
sapling::{self, OutputDescription},
@ -492,10 +493,11 @@ mod tests {
NetworkUpgrade::{Canopy, Sapling},
Parameters, TestNetwork, TEST_NETWORK, ZIP212_GRACE_PERIOD,
},
keys::OutgoingViewingKey,
memo::MemoBytes,
sapling::util::generate_random_rseed,
sapling::{
keys::OutgoingViewingKey, Diversifier, PaymentAddress, Rseed, SaplingIvk,
Diversifier, PaymentAddress, Rseed, SaplingIvk,
ValueCommitment,
},
transaction::components::{

View File

@ -12,11 +12,12 @@ use rand::{rngs::OsRng, CryptoRng, RngCore};
use crate::{
consensus::{self, BlockHeight, BranchId},
keys::OutgoingViewingKey,
legacy::TransparentAddress,
memo::MemoBytes,
merkle_tree::MerklePath,
sapling::{
keys::OutgoingViewingKey, prover::TxProver, Diversifier, Node, Note, PaymentAddress,
prover::TxProver, Diversifier, Node, Note, PaymentAddress,
},
transaction::{
components::{

View File

@ -9,10 +9,10 @@ use rand::{seq::SliceRandom, RngCore};
use crate::{
consensus::{self, BlockHeight},
keys::OutgoingViewingKey,
memo::MemoBytes,
merkle_tree::MerklePath,
sapling::{
keys::OutgoingViewingKey,
note_encryption::sapling_note_encryption,
prover::TxProver,
redjubjub::{PrivateKey, Signature},

View File

@ -16,8 +16,9 @@ use crate::{
};
use std::io::{self, Read, Write};
use crate::sapling::keys::{
prf_expand, prf_expand_vec, ExpandedSpendingKey, FullViewingKey, OutgoingViewingKey,
use crate::{
keys::{prf_expand, prf_expand_vec, OutgoingViewingKey},
sapling::keys::{ExpandedSpendingKey, FullViewingKey},
};
pub const ZIP32_SAPLING_MASTER_PERSONALIZATION: &[u8; 16] = b"ZcashIP32Sapling";