fix(doc): Fix the syntax of links in comments (#4494)
* Fix the syntax of links in comments * Fix a mistake in the docs Co-authored-by: Alfredo Garcia <oxarbitrage@gmail.com> * Remove unnecessary angle brackets from a link * Revert the changes for links that serve as references * Revert "Revert the changes for links that serve as references" This reverts commit8b091aa9fa
. * Remove `<` `>` from links that serve as references This reverts commit046ef25620
. * Don't use `<` `>` in normal comments * Don't use `<` `>` for normal comments * Revert changes for comments starting with `//` Co-authored-by: Alfredo Garcia <oxarbitrage@gmail.com>
This commit is contained in:
parent
b4eb7b9509
commit
6f896ef5a5
|
@ -185,7 +185,7 @@ impl Block {
|
|||
/// Positive values are added to the corresponding chain value pool.
|
||||
/// Negative values are removed from the corresponding pool.
|
||||
///
|
||||
/// https://zebra.zfnd.org/dev/rfcs/0012-value-pools.html#definitions
|
||||
/// <https://zebra.zfnd.org/dev/rfcs/0012-value-pools.html#definitions>
|
||||
///
|
||||
/// `utxos` must contain the [`Utxo`]s of every input in this block,
|
||||
/// including UTXOs created by earlier transactions in this block.
|
||||
|
|
|
@ -85,7 +85,7 @@ pub struct Header {
|
|||
|
||||
/// TODO: Use this error as the source for zebra_consensus::error::BlockError::Time,
|
||||
/// and make `BlockError::Time` add additional context.
|
||||
/// See https://github.com/ZcashFoundation/zebra/issues/1021 for more details.
|
||||
/// See <https://github.com/ZcashFoundation/zebra/issues/1021> for more details.
|
||||
#[allow(missing_docs)]
|
||||
#[derive(Error, Debug)]
|
||||
pub enum BlockTimeError {
|
||||
|
@ -100,7 +100,7 @@ pub enum BlockTimeError {
|
|||
|
||||
impl Header {
|
||||
/// TODO: Inline this function into zebra_consensus::block::check::time_is_valid_at.
|
||||
/// See https://github.com/ZcashFoundation/zebra/issues/1021 for more details.
|
||||
/// See <https://github.com/ZcashFoundation/zebra/issues/1021> for more details.
|
||||
pub fn time_is_valid_at(
|
||||
&self,
|
||||
now: DateTime<Utc>,
|
||||
|
|
|
@ -26,7 +26,7 @@ use super::{
|
|||
|
||||
/// Generates a random scalar from the scalar field 𝔽_{q_P}.
|
||||
///
|
||||
/// https://zips.z.cash/protocol/nu5.pdf#pallasandvesta
|
||||
/// <https://zips.z.cash/protocol/nu5.pdf#pallasandvesta>
|
||||
pub fn generate_trapdoor<T>(csprng: &mut T) -> pallas::Scalar
|
||||
where
|
||||
T: RngCore + CryptoRng,
|
||||
|
@ -44,7 +44,7 @@ pub struct CommitmentRandomness(pallas::Scalar);
|
|||
impl From<SeedRandomness> for CommitmentRandomness {
|
||||
/// rcm = ToScalar^Orchard((PRF^expand_rseed ([5]))
|
||||
///
|
||||
/// https://zips.z.cash/protocol/nu5.pdf#orchardsend
|
||||
/// <https://zips.z.cash/protocol/nu5.pdf#orchardsend>
|
||||
fn from(rseed: SeedRandomness) -> Self {
|
||||
Self(pallas::Scalar::from_bytes_wide(&prf_expand(
|
||||
rseed.0,
|
||||
|
@ -111,7 +111,7 @@ impl NoteCommitment {
|
|||
///
|
||||
/// NoteCommit^Orchard_rcm(repr_P(gd),repr_P(pkd), v, ρ, ψ) :=
|
||||
///
|
||||
/// https://zips.z.cash/protocol/nu5.pdf#concretewindowedcommit
|
||||
/// <https://zips.z.cash/protocol/nu5.pdf#concretewindowedcommit>
|
||||
#[allow(non_snake_case)]
|
||||
pub fn new(note: Note) -> Option<Self> {
|
||||
// s as in the argument name for WindowedPedersenCommit_r(s)
|
||||
|
@ -156,7 +156,7 @@ impl NoteCommitment {
|
|||
/// A homomorphic Pedersen commitment to the net value of a _note_, used in
|
||||
/// Action descriptions.
|
||||
///
|
||||
/// https://zips.z.cash/protocol/nu5.pdf#concretehomomorphiccommit
|
||||
/// <https://zips.z.cash/protocol/nu5.pdf#concretehomomorphiccommit>
|
||||
#[derive(Clone, Copy, Deserialize, PartialEq, Eq, Serialize)]
|
||||
pub struct ValueCommitment(#[serde(with = "serde_helpers::Affine")] pub pallas::Affine);
|
||||
|
||||
|
@ -209,7 +209,7 @@ impl From<pallas::Point> for ValueCommitment {
|
|||
|
||||
/// LEBS2OSP256(repr_P(cv))
|
||||
///
|
||||
/// https://zips.z.cash/protocol/nu5.pdf#pallasandvesta
|
||||
/// <https://zips.z.cash/protocol/nu5.pdf#pallasandvesta>
|
||||
impl From<ValueCommitment> for [u8; 32] {
|
||||
fn from(cm: ValueCommitment) -> [u8; 32] {
|
||||
cm.0.to_bytes()
|
||||
|
@ -252,7 +252,7 @@ impl std::iter::Sum for ValueCommitment {
|
|||
|
||||
/// LEBS2OSP256(repr_P(cv))
|
||||
///
|
||||
/// https://zips.z.cash/protocol/nu5.pdf#pallasandvesta
|
||||
/// <https://zips.z.cash/protocol/nu5.pdf#pallasandvesta>
|
||||
impl TryFrom<[u8; 32]> for ValueCommitment {
|
||||
type Error = &'static str;
|
||||
|
||||
|
@ -283,7 +283,7 @@ impl ZcashDeserialize for ValueCommitment {
|
|||
impl ValueCommitment {
|
||||
/// Generate a new _ValueCommitment_.
|
||||
///
|
||||
/// https://zips.z.cash/protocol/nu5.pdf#concretehomomorphiccommit
|
||||
/// <https://zips.z.cash/protocol/nu5.pdf#concretehomomorphiccommit>
|
||||
pub fn randomized<T>(csprng: &mut T, value: Amount) -> Self
|
||||
where
|
||||
T: RngCore + CryptoRng,
|
||||
|
@ -297,7 +297,7 @@ impl ValueCommitment {
|
|||
///
|
||||
/// ValueCommit^Orchard(v) :=
|
||||
///
|
||||
/// https://zips.z.cash/protocol/nu5.pdf#concretehomomorphiccommit
|
||||
/// <https://zips.z.cash/protocol/nu5.pdf#concretehomomorphiccommit>
|
||||
#[allow(non_snake_case)]
|
||||
pub fn new(rcv: pallas::Scalar, value: Amount) -> Self {
|
||||
lazy_static! {
|
||||
|
|
|
@ -42,7 +42,7 @@ impl SeedRandomness {
|
|||
/// for the actual output note. When creating a dummy note, its _rho_ is chosen
|
||||
/// as a random Pallas point's x-coordinate.
|
||||
///
|
||||
/// https://zips.z.cash/protocol/nu5.pdf#orcharddummynotes
|
||||
/// <https://zips.z.cash/protocol/nu5.pdf#orcharddummynotes>
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Rho(pub(crate) pallas::Base);
|
||||
|
||||
|
|
|
@ -97,7 +97,7 @@ impl ShieldedData {
|
|||
/// of the value commitments in the Action descriptions of the transaction, and
|
||||
/// the balancing value.
|
||||
///
|
||||
/// https://zips.z.cash/protocol/protocol.pdf#orchardbalance
|
||||
/// <https://zips.z.cash/protocol/protocol.pdf#orchardbalance>
|
||||
pub fn binding_verification_key(&self) -> redpallas::VerificationKeyBytes<Binding> {
|
||||
let cv: ValueCommitment = self.actions().map(|action| action.cv).sum();
|
||||
let cv_balance: ValueCommitment =
|
||||
|
@ -162,7 +162,7 @@ impl AuthorizedAction {
|
|||
/// Actions are 5 * 32 + 580 + 80 bytes so the total size of each Action is 820 bytes.
|
||||
/// [7.5 Action Description Encoding and Consensus][ps]
|
||||
///
|
||||
/// [ps] https://zips.z.cash/protocol/nu5.pdf#actionencodingandconsensus
|
||||
/// [ps] <https://zips.z.cash/protocol/nu5.pdf#actionencodingandconsensus>
|
||||
pub const ACTION_SIZE: u64 = 5 * 32 + 580 + 80;
|
||||
|
||||
/// The size of a single Signature<SpendAuth>
|
||||
|
@ -170,7 +170,7 @@ pub const ACTION_SIZE: u64 = 5 * 32 + 580 + 80;
|
|||
/// Each Signature is 64 bytes.
|
||||
/// [7.1 Transaction Encoding and Consensus][ps]
|
||||
///
|
||||
/// [ps] https://zips.z.cash/protocol/nu5.pdf#actionencodingandconsensus
|
||||
/// [ps] <https://zips.z.cash/protocol/nu5.pdf#actionencodingandconsensus>
|
||||
pub const SPEND_AUTH_SIG_SIZE: u64 = 64;
|
||||
|
||||
/// The size of a single AuthorizedAction
|
||||
|
|
|
@ -167,7 +167,7 @@ pub fn sinsemilla_hash(D: &[u8], M: &BitVec<u8, Lsb0>) -> Option<pallas::Base> {
|
|||
///
|
||||
/// SinsemillaCommit_r(D, M) := SinsemillaHashToPoint(D || "-M", M) + [r]GroupHash^P(D || "-r", "")
|
||||
///
|
||||
/// https://zips.z.cash/protocol/nu5.pdf#concretesinsemillacommit
|
||||
/// <https://zips.z.cash/protocol/nu5.pdf#concretesinsemillacommit>
|
||||
#[allow(non_snake_case)]
|
||||
pub fn sinsemilla_commit(
|
||||
r: pallas::Scalar,
|
||||
|
@ -180,7 +180,7 @@ pub fn sinsemilla_commit(
|
|||
|
||||
/// SinsemillaShortCommit_r(D, M) := Extract⊥ P(SinsemillaCommit_r(D, M))
|
||||
///
|
||||
/// https://zips.z.cash/protocol/nu5.pdf#concretesinsemillacommit
|
||||
/// <https://zips.z.cash/protocol/nu5.pdf#concretesinsemillacommit>
|
||||
#[allow(non_snake_case)]
|
||||
pub fn sinsemilla_short_commit(
|
||||
r: pallas::Scalar,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//! Test vectors for generating Orchard keys, addresses, notes, note
|
||||
//! commitments, and nullifiers.
|
||||
//!
|
||||
//! Produced by https://github.com/zcash-hackworks/zcash-test-vectors/blob/ec5fe3abef5219d0f8c9edbc93bb4038f1729dfe/orchard_key_components.py
|
||||
//! Produced by <https://github.com/zcash-hackworks/zcash-test-vectors/blob/ec5fe3abef5219d0f8c9edbc93bb4038f1729dfe/orchard_key_components.py>
|
||||
|
||||
#![allow(dead_code)]
|
||||
|
||||
|
|
|
@ -48,8 +48,8 @@ pub(super) const MERKLE_DEPTH: usize = 32;
|
|||
/// l = I2LEBSP_10(MerkleDepth^Orchard − 1 − layer), and left, right, and
|
||||
/// the output are the x-coordinates of Pallas affine points.
|
||||
///
|
||||
/// https://zips.z.cash/protocol/protocol.pdf#orchardmerklecrh
|
||||
/// https://zips.z.cash/protocol/protocol.pdf#constants
|
||||
/// <https://zips.z.cash/protocol/protocol.pdf#orchardmerklecrh>
|
||||
/// <https://zips.z.cash/protocol/protocol.pdf#constants>
|
||||
fn merkle_crh_orchard(layer: u8, left: pallas::Base, right: pallas::Base) -> pallas::Base {
|
||||
let mut s = bitvec![u8, Lsb0;];
|
||||
|
||||
|
@ -70,7 +70,7 @@ lazy_static! {
|
|||
///
|
||||
/// The list is indexed by the layer number (0: root; MERKLE_DEPTH: leaf).
|
||||
///
|
||||
/// https://zips.z.cash/protocol/protocol.pdf#constants
|
||||
/// <https://zips.z.cash/protocol/protocol.pdf#constants>
|
||||
pub(super) static ref EMPTY_ROOTS: Vec<pallas::Base> = {
|
||||
// The empty leaf node. This is layer 32.
|
||||
let mut v = vec![NoteCommitmentTree::uncommitted()];
|
||||
|
|
|
@ -27,7 +27,7 @@ mod tests;
|
|||
/// > plaintext according to the preceding rule MUST have note plaintext lead byte equal to 0x02.
|
||||
/// > (This applies even during the “grace period” specified in [ZIP-212].)
|
||||
///
|
||||
/// https://zips.z.cash/protocol/protocol.pdf#txnencodingandconsensus
|
||||
/// <https://zips.z.cash/protocol/protocol.pdf#txnencodingandconsensus>
|
||||
///
|
||||
/// Wallets have a grace period of 32,256 blocks after Canopy's activation to validate those blocks,
|
||||
/// but nodes do not.
|
||||
|
@ -38,7 +38,7 @@ mod tests;
|
|||
/// > Let ActivationHeight be the activation height of this ZIP, and let GracePeriodEndHeight be
|
||||
/// > ActivationHeight + 32256.
|
||||
///
|
||||
/// https://zips.z.cash/zip-0212#changes-to-the-process-of-receiving-sapling-or-orchard-notes
|
||||
/// <https://zips.z.cash/zip-0212#changes-to-the-process-of-receiving-sapling-or-orchard-notes>
|
||||
///
|
||||
/// Zebra uses `librustzcash` to validate that rule, but it won't validate it during the grace
|
||||
/// period. Therefore Zebra must validate those blocks during the grace period using checkpoints.
|
||||
|
|
|
@ -207,18 +207,18 @@ pub const POW_AVERAGING_WINDOW: usize = 17;
|
|||
/// The multiplier used to derive the testnet minimum difficulty block time gap
|
||||
/// threshold.
|
||||
///
|
||||
/// Based on https://zips.z.cash/zip-0208#minimum-difficulty-blocks-on-the-test-network
|
||||
/// Based on <https://zips.z.cash/zip-0208#minimum-difficulty-blocks-on-the-test-network>
|
||||
const TESTNET_MINIMUM_DIFFICULTY_GAP_MULTIPLIER: i32 = 6;
|
||||
|
||||
/// The start height for the testnet minimum difficulty consensus rule.
|
||||
///
|
||||
/// Based on https://zips.z.cash/zip-0208#minimum-difficulty-blocks-on-the-test-network
|
||||
/// Based on <https://zips.z.cash/zip-0208#minimum-difficulty-blocks-on-the-test-network>
|
||||
const TESTNET_MINIMUM_DIFFICULTY_START_HEIGHT: block::Height = block::Height(299_188);
|
||||
|
||||
/// The activation height for the block maximum time rule on Testnet.
|
||||
///
|
||||
/// Part of the block header consensus rules in the Zcash specification at
|
||||
/// https://zips.z.cash/protocol/protocol.pdf#blockheader
|
||||
/// <https://zips.z.cash/protocol/protocol.pdf#blockheader>
|
||||
pub const TESTNET_MAX_TIME_START_HEIGHT: block::Height = block::Height(653_606);
|
||||
|
||||
impl NetworkUpgrade {
|
||||
|
@ -370,7 +370,7 @@ impl NetworkUpgrade {
|
|||
/// Returns the minimum difficulty block spacing for `network` and `height`.
|
||||
/// Returns `None` if the testnet minimum difficulty consensus rule is not active.
|
||||
///
|
||||
/// Based on https://zips.z.cash/zip-0208#minimum-difficulty-blocks-on-the-test-network
|
||||
/// Based on <https://zips.z.cash/zip-0208#minimum-difficulty-blocks-on-the-test-network>
|
||||
pub fn minimum_difficulty_spacing_for_height(
|
||||
network: Network,
|
||||
height: block::Height,
|
||||
|
@ -440,7 +440,7 @@ impl NetworkUpgrade {
|
|||
/// TESTNET_MAX_TIME_START_HEIGHT to return true.
|
||||
/// Returns false otherwise.
|
||||
///
|
||||
/// Part of the consensus rules at https://zips.z.cash/protocol/protocol.pdf#blockheader
|
||||
/// Part of the consensus rules at <https://zips.z.cash/protocol/protocol.pdf#blockheader>
|
||||
pub fn is_max_block_time_enforced(network: Network, height: block::Height) -> bool {
|
||||
match network {
|
||||
Network::Mainnet => true,
|
||||
|
|
|
@ -86,7 +86,7 @@ impl<T: SigType> SigningKey<T> {
|
|||
|
||||
/// Create a signature of type `T` on `msg` using this `SigningKey`.
|
||||
///
|
||||
/// https://zips.z.cash/protocol/nu5.pdf#concretereddsa
|
||||
/// <https://zips.z.cash/protocol/nu5.pdf#concretereddsa>
|
||||
// Similar to signature::Signer but without boxed errors.
|
||||
pub fn sign<R: RngCore + CryptoRng>(&self, mut rng: R, msg: &[u8]) -> Signature<T> {
|
||||
use super::HStar;
|
||||
|
|
|
@ -259,7 +259,7 @@ pub(crate) fn sighash(
|
|||
///
|
||||
/// If passed a pre-v5 transaction.
|
||||
///
|
||||
/// [ZIP-244]: https://zips.z.cash/zip-0244.
|
||||
/// [ZIP-244]: https://zips.z.cash/zip-0244
|
||||
pub(crate) fn auth_digest(trans: &Transaction) -> AuthDigest {
|
||||
let alt_tx: zp_tx::Transaction = trans
|
||||
.try_into()
|
||||
|
|
|
@ -32,7 +32,7 @@ use pedersen_hashes::*;
|
|||
/// the uniform distribution on 𝔽_{r_𝕁} needed for Sapling commitment schemes'
|
||||
/// trapdoor generators.
|
||||
///
|
||||
/// https://zips.z.cash/protocol/protocol.pdf#jubjub
|
||||
/// <https://zips.z.cash/protocol/protocol.pdf#jubjub>
|
||||
pub fn generate_trapdoor<T>(csprng: &mut T) -> jubjub::Fr
|
||||
where
|
||||
T: RngCore + CryptoRng,
|
||||
|
@ -96,7 +96,7 @@ impl NoteCommitment {
|
|||
/// NoteCommit^Sapling_rcm (g*_d , pk*_d , v) :=
|
||||
/// WindowedPedersenCommit_rcm([1; 6] || I2LEBSP_64(v) || g*_d || pk*_d)
|
||||
///
|
||||
/// https://zips.z.cash/protocol/protocol.pdf#concretewindowedcommit
|
||||
/// <https://zips.z.cash/protocol/protocol.pdf#concretewindowedcommit>
|
||||
#[allow(non_snake_case)]
|
||||
pub fn new<T>(
|
||||
csprng: &mut T,
|
||||
|
@ -142,7 +142,7 @@ impl NoteCommitment {
|
|||
|
||||
/// Hash Extractor for Jubjub (?)
|
||||
///
|
||||
/// https://zips.z.cash/protocol/protocol.pdf#concreteextractorjubjub
|
||||
/// <https://zips.z.cash/protocol/protocol.pdf#concreteextractorjubjub>
|
||||
pub fn extract_u(&self) -> jubjub::Fq {
|
||||
self.0.get_u()
|
||||
}
|
||||
|
@ -154,7 +154,7 @@ impl NoteCommitment {
|
|||
/// type actually stored in Spend and Output descriptions, see
|
||||
/// [`NotSmallOrderValueCommitment`].
|
||||
///
|
||||
/// https://zips.z.cash/protocol/protocol.pdf#concretehomomorphiccommit
|
||||
/// <https://zips.z.cash/protocol/protocol.pdf#concretehomomorphiccommit>
|
||||
#[derive(Clone, Copy, Deserialize, PartialEq, Eq, Serialize)]
|
||||
pub struct ValueCommitment(#[serde(with = "serde_helpers::AffinePoint")] jubjub::AffinePoint);
|
||||
|
||||
|
@ -199,8 +199,8 @@ impl From<jubjub::ExtendedPoint> for ValueCommitment {
|
|||
|
||||
/// LEBS2OSP256(repr_J(cv))
|
||||
///
|
||||
/// https://zips.z.cash/protocol/protocol.pdf#spendencoding
|
||||
/// https://zips.z.cash/protocol/protocol.pdf#jubjub
|
||||
/// <https://zips.z.cash/protocol/protocol.pdf#spendencoding>
|
||||
/// <https://zips.z.cash/protocol/protocol.pdf#jubjub>
|
||||
impl From<ValueCommitment> for [u8; 32] {
|
||||
fn from(cm: ValueCommitment) -> [u8; 32] {
|
||||
cm.0.to_bytes()
|
||||
|
@ -243,8 +243,8 @@ impl std::iter::Sum for ValueCommitment {
|
|||
|
||||
/// LEBS2OSP256(repr_J(cv))
|
||||
///
|
||||
/// https://zips.z.cash/protocol/protocol.pdf#spendencoding
|
||||
/// https://zips.z.cash/protocol/protocol.pdf#jubjub
|
||||
/// <https://zips.z.cash/protocol/protocol.pdf#spendencoding>
|
||||
/// <https://zips.z.cash/protocol/protocol.pdf#jubjub>
|
||||
impl TryFrom<[u8; 32]> for ValueCommitment {
|
||||
type Error = &'static str;
|
||||
|
||||
|
@ -263,7 +263,7 @@ impl TryFrom<[u8; 32]> for ValueCommitment {
|
|||
impl ValueCommitment {
|
||||
/// Generate a new _ValueCommitment_.
|
||||
///
|
||||
/// https://zips.z.cash/protocol/protocol.pdf#concretehomomorphiccommit
|
||||
/// <https://zips.z.cash/protocol/protocol.pdf#concretehomomorphiccommit>
|
||||
pub fn randomized<T>(csprng: &mut T, value: Amount) -> Self
|
||||
where
|
||||
T: RngCore + CryptoRng,
|
||||
|
@ -275,7 +275,7 @@ impl ValueCommitment {
|
|||
|
||||
/// Generate a new _ValueCommitment_ from an existing _rcv_ on a _value_.
|
||||
///
|
||||
/// https://zips.z.cash/protocol/protocol.pdf#concretehomomorphiccommit
|
||||
/// <https://zips.z.cash/protocol/protocol.pdf#concretehomomorphiccommit>
|
||||
#[allow(non_snake_case)]
|
||||
pub fn new(rcv: jubjub::Fr, value: Amount) -> Self {
|
||||
let v = jubjub::Fr::from(value);
|
||||
|
@ -298,8 +298,8 @@ impl ValueCommitment {
|
|||
///
|
||||
/// This is denoted by `cv` in the specification.
|
||||
///
|
||||
/// https://zips.z.cash/protocol/protocol.pdf#spenddesc
|
||||
/// https://zips.z.cash/protocol/protocol.pdf#outputdesc
|
||||
/// <https://zips.z.cash/protocol/protocol.pdf#spenddesc>
|
||||
/// <https://zips.z.cash/protocol/protocol.pdf#outputdesc>
|
||||
#[derive(Debug, Clone, Copy, Deserialize, PartialEq, Eq, Serialize)]
|
||||
pub struct NotSmallOrderValueCommitment(ValueCommitment);
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ use super::super::keys::find_group_hash;
|
|||
///
|
||||
/// Expects i to be 1-indexed from the loop it's called in.
|
||||
///
|
||||
/// https://zips.z.cash/protocol/protocol.pdf#concretepedersenhash
|
||||
/// <https://zips.z.cash/protocol/protocol.pdf#concretepedersenhash>
|
||||
#[allow(non_snake_case)]
|
||||
fn I_i(domain: [u8; 8], i: u32) -> jubjub::ExtendedPoint {
|
||||
find_group_hash(domain, &(i - 1).to_le_bytes())
|
||||
|
@ -18,7 +18,7 @@ fn I_i(domain: [u8; 8], i: u32) -> jubjub::ExtendedPoint {
|
|||
///
|
||||
/// Σ j={0,k-1}: (1 - 2x₂)⋅(1 + x₀ + 2x₁)⋅2^(4⋅j)
|
||||
///
|
||||
/// https://zips.z.cash/protocol/protocol.pdf#concretepedersenhash
|
||||
/// <https://zips.z.cash/protocol/protocol.pdf#concretepedersenhash>
|
||||
#[allow(non_snake_case)]
|
||||
fn M_i(segment: &BitSlice<u8, Lsb0>) -> jubjub::Fr {
|
||||
let mut m_i = jubjub::Fr::zero();
|
||||
|
@ -66,7 +66,7 @@ fn M_i(segment: &BitSlice<u8, Lsb0>) -> jubjub::Fr {
|
|||
/// Sapling incremental Merkle tree (§ 5.4.1.3 'MerkleCRH^Sapling Hash
|
||||
/// Function').
|
||||
///
|
||||
/// https://zips.z.cash/protocol/protocol.pdf#concretepedersenhash
|
||||
/// <https://zips.z.cash/protocol/protocol.pdf#concretepedersenhash>
|
||||
#[allow(non_snake_case)]
|
||||
pub fn pedersen_hash_to_point(domain: [u8; 8], M: &BitVec<u8, Lsb0>) -> jubjub::ExtendedPoint {
|
||||
let mut result = jubjub::ExtendedPoint::identity();
|
||||
|
@ -92,7 +92,7 @@ pub fn pedersen_hash_to_point(domain: [u8; 8], M: &BitVec<u8, Lsb0>) -> jubjub::
|
|||
///
|
||||
/// This is technically returning 255 (l_MerkleSapling) bits, not 256.
|
||||
///
|
||||
/// https://zips.z.cash/protocol/protocol.pdf#concretepedersenhash
|
||||
/// <https://zips.z.cash/protocol/protocol.pdf#concretepedersenhash>
|
||||
#[allow(non_snake_case)]
|
||||
pub fn pedersen_hash(domain: [u8; 8], M: &BitVec<u8, Lsb0>) -> jubjub::Fq {
|
||||
jubjub::AffinePoint::from(pedersen_hash_to_point(domain, M)).get_u()
|
||||
|
@ -106,7 +106,7 @@ pub fn pedersen_hash(domain: [u8; 8], M: &BitVec<u8, Lsb0>) -> jubjub::Fq {
|
|||
///
|
||||
/// MixingPedersenHash(P, x) := P + [x]FindGroupHash^J^(r)("Zcash_J_", "")
|
||||
///
|
||||
/// https://zips.z.cash/protocol/protocol.pdf#concretemixinghash
|
||||
/// <https://zips.z.cash/protocol/protocol.pdf#concretemixinghash>
|
||||
#[allow(non_snake_case)]
|
||||
pub fn mixing_pedersen_hash(P: jubjub::ExtendedPoint, x: jubjub::Fr) -> jubjub::ExtendedPoint {
|
||||
const J: [u8; 8] = *b"Zcash_J_";
|
||||
|
@ -120,7 +120,7 @@ pub fn mixing_pedersen_hash(P: jubjub::ExtendedPoint, x: jubjub::Fr) -> jubjub::
|
|||
/// WindowedPedersenCommit_r (s) := \
|
||||
/// PedersenHashToPoint("Zcash_PH", s) + [r]FindGroupHash^J^(r)("Zcash_PH", "r")
|
||||
///
|
||||
/// https://zips.z.cash/protocol/protocol.pdf#concretewindowedcommit
|
||||
/// <https://zips.z.cash/protocol/protocol.pdf#concretewindowedcommit>
|
||||
pub fn windowed_pedersen_commitment(r: jubjub::Fr, s: &BitVec<u8, Lsb0>) -> jubjub::ExtendedPoint {
|
||||
const D: [u8; 8] = *b"Zcash_PH";
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ pub(super) const RANDOMNESS_BEACON_URS: &[u8; 64] =
|
|||
///
|
||||
/// PRF^expand(sk, t) := BLAKE2b-512("Zcash_ExpandSeed", sk || t)
|
||||
///
|
||||
/// https://zips.z.cash/protocol/protocol.pdf#concreteprfs
|
||||
/// <https://zips.z.cash/protocol/protocol.pdf#concreteprfs>
|
||||
fn prf_expand(sk: [u8; 32], t: &[u8]) -> [u8; 64] {
|
||||
let hash = blake2b_simd::Params::new()
|
||||
.hash_length(64)
|
||||
|
@ -69,7 +69,7 @@ fn prf_expand(sk: [u8; 32], t: &[u8]) -> [u8; 64] {
|
|||
///
|
||||
/// PRF^ock(ovk, cv, cm_u, ephemeralKey) := BLAKE2b-256(“Zcash_Derive_ock”, ovk || cv || cm_u || ephemeralKey)
|
||||
///
|
||||
/// https://zips.z.cash/protocol/nu5.pdf#concreteprfs
|
||||
/// <https://zips.z.cash/protocol/nu5.pdf#concreteprfs>
|
||||
fn prf_ock(ovk: [u8; 32], cv: [u8; 32], cm_u: [u8; 32], ephemeral_key: [u8; 32]) -> [u8; 32] {
|
||||
let hash = blake2b_simd::Params::new()
|
||||
.hash_length(32)
|
||||
|
@ -89,7 +89,7 @@ fn prf_ock(ovk: [u8; 32], cv: [u8; 32], cm_u: [u8; 32], ephemeral_key: [u8; 32])
|
|||
///
|
||||
/// _CRH^ivk(ak, nk) := BLAKE2s-256("Zcashivk", ak || nk)_
|
||||
///
|
||||
/// https://zips.z.cash/protocol/protocol.pdf#concretecrhivk
|
||||
/// <https://zips.z.cash/protocol/protocol.pdf#concretecrhivk>
|
||||
fn crh_ivk(ak: [u8; 32], nk: [u8; 32]) -> [u8; 32] {
|
||||
let hash = blake2s_simd::Params::new()
|
||||
.hash_length(32)
|
||||
|
@ -112,7 +112,7 @@ fn crh_ivk(ak: [u8; 32], nk: [u8; 32]) -> [u8; 32] {
|
|||
/// input.
|
||||
///
|
||||
/// [0]: https://github.com/zcash/librustzcash/blob/master/zcash_primitives/src/group_hash.rs#L15
|
||||
/// https://zips.z.cash/protocol/protocol.pdf#concretegrouphashjubjub
|
||||
/// <https://zips.z.cash/protocol/protocol.pdf#concretegrouphashjubjub>
|
||||
fn jubjub_group_hash(d: [u8; 8], m: &[u8]) -> Option<jubjub::ExtendedPoint> {
|
||||
let hash = blake2s_simd::Params::new()
|
||||
.hash_length(32)
|
||||
|
@ -143,7 +143,7 @@ fn jubjub_group_hash(d: [u8; 8], m: &[u8]) -> Option<jubjub::ExtendedPoint> {
|
|||
/// input.
|
||||
///
|
||||
/// [0]: https://github.com/zcash/librustzcash/blob/master/zcash_primitives/src/jubjub/mod.rs#L409
|
||||
/// https://zips.z.cash/protocol/protocol.pdf#concretegrouphashjubjub
|
||||
/// <https://zips.z.cash/protocol/protocol.pdf#concretegrouphashjubjub>
|
||||
// TODO: move common functions like these out of the keys module into
|
||||
// a more appropriate location
|
||||
pub(super) fn find_group_hash(d: [u8; 8], m: &[u8]) -> jubjub::ExtendedPoint {
|
||||
|
@ -167,14 +167,14 @@ pub(super) fn find_group_hash(d: [u8; 8], m: &[u8]) -> jubjub::ExtendedPoint {
|
|||
/// Instance of FindGroupHash for JubJub, using personalized by
|
||||
/// BLAKE2s for picking the proof generation key base point.
|
||||
///
|
||||
/// https://zips.z.cash/protocol/protocol.pdf#saplingkeycomponents
|
||||
/// <https://zips.z.cash/protocol/protocol.pdf#saplingkeycomponents>
|
||||
fn zcash_h() -> jubjub::ExtendedPoint {
|
||||
find_group_hash(*b"Zcash_H_", b"")
|
||||
}
|
||||
|
||||
/// Used to derive a diversified base point from a diversifier value.
|
||||
///
|
||||
/// https://zips.z.cash/protocol/protocol.pdf#concretediversifyhash
|
||||
/// <https://zips.z.cash/protocol/protocol.pdf#concretediversifyhash>
|
||||
fn diversify_hash(d: [u8; 11]) -> Option<jubjub::ExtendedPoint> {
|
||||
jubjub_group_hash(*b"Zcash_gd", &d)
|
||||
}
|
||||
|
@ -331,8 +331,8 @@ impl From<SpendingKey> for SpendAuthorizingKey {
|
|||
/// Invokes Blake2b-512 as _PRF^expand_, t=0, to derive a
|
||||
/// SpendAuthorizingKey from a SpendingKey.
|
||||
///
|
||||
/// https://zips.z.cash/protocol/protocol.pdf#saplingkeycomponents
|
||||
/// https://zips.z.cash/protocol/protocol.pdf#concreteprfs
|
||||
/// <https://zips.z.cash/protocol/protocol.pdf#saplingkeycomponents>
|
||||
/// <https://zips.z.cash/protocol/protocol.pdf#concreteprfs>
|
||||
fn from(spending_key: SpendingKey) -> SpendAuthorizingKey {
|
||||
let hash_bytes = prf_expand(spending_key.bytes, &[0]);
|
||||
|
||||
|
@ -388,8 +388,8 @@ impl From<ProofAuthorizingKey> for [u8; 32] {
|
|||
impl From<SpendingKey> for ProofAuthorizingKey {
|
||||
/// For this invocation of Blake2b-512 as _PRF^expand_, t=1.
|
||||
///
|
||||
/// https://zips.z.cash/protocol/protocol.pdf#saplingkeycomponents
|
||||
/// https://zips.z.cash/protocol/protocol.pdf#concreteprfs
|
||||
/// <https://zips.z.cash/protocol/protocol.pdf#saplingkeycomponents>
|
||||
/// <https://zips.z.cash/protocol/protocol.pdf#concreteprfs>
|
||||
fn from(spending_key: SpendingKey) -> ProofAuthorizingKey {
|
||||
let hash_bytes = prf_expand(spending_key.bytes, &[1]);
|
||||
|
||||
|
@ -442,8 +442,8 @@ impl From<OutgoingViewingKey> for [u8; 32] {
|
|||
impl From<SpendingKey> for OutgoingViewingKey {
|
||||
/// For this invocation of Blake2b-512 as _PRF^expand_, t=2.
|
||||
///
|
||||
/// https://zips.z.cash/protocol/protocol.pdf#saplingkeycomponents
|
||||
/// https://zips.z.cash/protocol/protocol.pdf#concreteprfs
|
||||
/// <https://zips.z.cash/protocol/protocol.pdf#saplingkeycomponents>
|
||||
/// <https://zips.z.cash/protocol/protocol.pdf#concreteprfs>
|
||||
fn from(spending_key: SpendingKey) -> OutgoingViewingKey {
|
||||
let hash_bytes = prf_expand(spending_key.bytes, &[2]);
|
||||
|
||||
|
@ -575,9 +575,9 @@ impl From<ProofAuthorizingKey> for NullifierDerivingKey {
|
|||
/// the resulting generator point to scalar multiply the
|
||||
/// ProofAuthorizingKey into the new NullifierDerivingKey
|
||||
///
|
||||
/// https://github.com/zcash/librustzcash/blob/master/zcash_primitives/src/group_hash.rs
|
||||
/// https://zips.z.cash/protocol/protocol.pdf#saplingkeycomponents
|
||||
/// https://zips.z.cash/protocol/protocol.pdf#concretegrouphashjubjub
|
||||
/// <https://github.com/zcash/librustzcash/blob/master/zcash_primitives/src/group_hash.rs>
|
||||
/// <https://zips.z.cash/protocol/protocol.pdf#saplingkeycomponents>
|
||||
/// <https://zips.z.cash/protocol/protocol.pdf#concretegrouphashjubjub>
|
||||
fn from(nsk: ProofAuthorizingKey) -> Self {
|
||||
// Should this point, when generated, be fixed for the rest of
|
||||
// the protocol instance? Since this is kind of hash-and-pray, it
|
||||
|
@ -668,9 +668,9 @@ impl From<[u8; 32]> for IncomingViewingKey {
|
|||
impl From<(AuthorizingKey, NullifierDerivingKey)> for IncomingViewingKey {
|
||||
/// For this invocation of Blake2s-256 as _CRH^ivk_.
|
||||
///
|
||||
/// https://zips.z.cash/protocol/protocol.pdf#saplingkeycomponents
|
||||
/// https://zips.z.cash/protocol/protocol.pdf#concreteprfs
|
||||
/// https://zips.z.cash/protocol/protocol.pdf#jubjub
|
||||
/// <https://zips.z.cash/protocol/protocol.pdf#saplingkeycomponents>
|
||||
/// <https://zips.z.cash/protocol/protocol.pdf#concreteprfs>
|
||||
/// <https://zips.z.cash/protocol/protocol.pdf#jubjub>
|
||||
// TODO: return None if ivk = 0
|
||||
//
|
||||
// "If ivk = 0, discard this key and start over with a new
|
||||
|
@ -815,8 +815,8 @@ impl Diversifier {
|
|||
/// as a preimage to a valid diversified base point when used to
|
||||
/// derive a diversified payment address.
|
||||
///
|
||||
/// https://zips.z.cash/protocol/protocol.pdf#saplingkeycomponents
|
||||
/// https://zips.z.cash/protocol/protocol.pdf#concretediversifyhash
|
||||
/// <https://zips.z.cash/protocol/protocol.pdf#saplingkeycomponents>
|
||||
/// <https://zips.z.cash/protocol/protocol.pdf#concretediversifyhash>
|
||||
pub fn new<T>(csprng: &mut T) -> Self
|
||||
where
|
||||
T: RngCore + CryptoRng,
|
||||
|
@ -870,8 +870,8 @@ impl TryFrom<[u8; 32]> for TransmissionKey {
|
|||
/// Attempts to interpret a byte representation of an affine Jubjub point, failing if the
|
||||
/// element is not on the curve, non-canonical, or not in the prime-order subgroup.
|
||||
///
|
||||
/// https://github.com/zkcrypto/jubjub/blob/master/src/lib.rs#L411
|
||||
/// https://zips.z.cash/zip-0216
|
||||
/// <https://github.com/zkcrypto/jubjub/blob/master/src/lib.rs#L411>
|
||||
/// <https://zips.z.cash/zip-0216>
|
||||
fn try_from(bytes: [u8; 32]) -> Result<Self, Self::Error> {
|
||||
let affine_point = jubjub::AffinePoint::from_bytes(bytes).unwrap();
|
||||
// Check if it's identity or has prime order (i.e. is in the prime-order subgroup).
|
||||
|
@ -895,8 +895,8 @@ impl TryFrom<(IncomingViewingKey, Diversifier)> for TransmissionKey {
|
|||
/// This includes _KA^Sapling.DerivePublic(ivk, G_d)_, which is just a
|
||||
/// scalar mult _\[ivk\]G_d_.
|
||||
///
|
||||
/// https://zips.z.cash/protocol/protocol.pdf#saplingkeycomponents
|
||||
/// https://zips.z.cash/protocol/protocol.pdf#concretesaplingkeyagreement
|
||||
/// <https://zips.z.cash/protocol/protocol.pdf#saplingkeycomponents>
|
||||
/// <https://zips.z.cash/protocol/protocol.pdf#concretesaplingkeyagreement>
|
||||
fn try_from((ivk, d): (IncomingViewingKey, Diversifier)) -> Result<Self, Self::Error> {
|
||||
let affine_point = jubjub::AffinePoint::from(
|
||||
diversify_hash(d.0).ok_or("invalid diversifier")? * ivk.scalar,
|
||||
|
@ -932,7 +932,7 @@ mod fvk_hrp {
|
|||
/// Human-Readable Part is "zviews". For incoming viewing keys on the
|
||||
/// test network, the Human-Readable Part is "zviewtestsapling".
|
||||
///
|
||||
/// https://zips.z.cash/protocol/protocol.pdf#saplingfullviewingkeyencoding
|
||||
/// <https://zips.z.cash/protocol/protocol.pdf#saplingfullviewingkeyencoding>
|
||||
#[derive(Copy, Clone, Eq, PartialEq)]
|
||||
pub struct FullViewingKey {
|
||||
network: Network,
|
||||
|
|
|
@ -12,7 +12,7 @@ use super::super::{
|
|||
///
|
||||
/// PRF^nfSapling(ρ*) := BLAKE2s-256("Zcash_nf", nk* || ρ*)
|
||||
///
|
||||
/// https://zips.z.cash/protocol/protocol.pdf#concreteprfs
|
||||
/// <https://zips.z.cash/protocol/protocol.pdf#concreteprfs>
|
||||
fn prf_nf(nk: [u8; 32], rho: [u8; 32]) -> [u8; 32] {
|
||||
let hash = blake2s_simd::Params::new()
|
||||
.hash_length(32)
|
||||
|
@ -56,7 +56,7 @@ impl From<Nullifier> for [u8; 32] {
|
|||
impl From<Nullifier> for [jubjub::Fq; 2] {
|
||||
/// Add the nullifier through multiscalar packing
|
||||
///
|
||||
/// Informed by https://github.com/zkcrypto/bellman/blob/main/src/gadgets/multipack.rs
|
||||
/// Informed by <https://github.com/zkcrypto/bellman/blob/main/src/gadgets/multipack.rs>
|
||||
fn from(n: Nullifier) -> Self {
|
||||
use std::ops::AddAssign;
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ pub struct Output {
|
|||
|
||||
/// Wrapper for `Output` serialization in a `V4` transaction.
|
||||
///
|
||||
/// https://zips.z.cash/protocol/protocol.pdf#outputencoding
|
||||
/// <https://zips.z.cash/protocol/protocol.pdf#outputencoding>
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct OutputInTransactionV4(pub Output);
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ pub(super) const MERKLE_DEPTH: usize = 32;
|
|||
/// where l = I2LEBSP_6(MerkleDepth^Sapling − 1 − layer) and
|
||||
/// left, right, and the output are all technically 255 bits (l_MerkleSapling), not 256.
|
||||
///
|
||||
/// https://zips.z.cash/protocol/protocol.pdf#merklecrh
|
||||
/// <https://zips.z.cash/protocol/protocol.pdf#merklecrh>
|
||||
fn merkle_crh_sapling(layer: u8, left: [u8; 32], right: [u8; 32]) -> [u8; 32] {
|
||||
let mut s = bitvec![u8, Lsb0;];
|
||||
|
||||
|
@ -66,7 +66,7 @@ lazy_static! {
|
|||
///
|
||||
/// The list is indexed by the layer number (0: root; MERKLE_DEPTH: leaf).
|
||||
///
|
||||
/// https://zips.z.cash/protocol/protocol.pdf#constants
|
||||
/// <https://zips.z.cash/protocol/protocol.pdf#constants>
|
||||
pub(super) static ref EMPTY_ROOTS: Vec<[u8; 32]> = {
|
||||
// The empty leaf node. This is layer 32.
|
||||
let mut v = vec![NoteCommitmentTree::uncommitted()];
|
||||
|
@ -88,7 +88,7 @@ lazy_static! {
|
|||
/// The index of a note's commitment at the leafmost layer of its Note
|
||||
/// Commitment Tree.
|
||||
///
|
||||
/// https://zips.z.cash/protocol/protocol.pdf#merkletree
|
||||
/// <https://zips.z.cash/protocol/protocol.pdf#merkletree>
|
||||
pub struct Position(pub(crate) u64);
|
||||
|
||||
/// Sapling note commitment tree root node hash.
|
||||
|
|
|
@ -21,7 +21,7 @@ mod magics {
|
|||
|
||||
/// Sprout Shielded Payment Addresses
|
||||
///
|
||||
/// https://zips.z.cash/protocol/protocol.pdf#sproutpaymentaddrencoding
|
||||
/// <https://zips.z.cash/protocol/protocol.pdf#sproutpaymentaddrencoding>
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct SproutShieldedAddress {
|
||||
network: Network,
|
||||
|
|
|
@ -35,7 +35,7 @@ impl From<[u8; 32]> for NoteCommitment {
|
|||
impl From<Note> for NoteCommitment {
|
||||
/// NoteCommit_rcm^Sprout(a_pk, v, rho)
|
||||
///
|
||||
/// https://zips.z.cash/protocol/protocol.pdf#concretesproutnotecommit
|
||||
/// <https://zips.z.cash/protocol/protocol.pdf#concretesproutnotecommit>
|
||||
fn from(note: Note) -> NoteCommitment {
|
||||
let leading_byte: u8 = 0xB0;
|
||||
let mut hasher = Sha256::default();
|
||||
|
|
|
@ -102,7 +102,7 @@ impl<P: ZkSnarkProof> JoinSplit<P> {
|
|||
/// Return the sprout value balance,
|
||||
/// the change in the transaction value pool due to this sprout [`JoinSplit`].
|
||||
///
|
||||
/// https://zebra.zfnd.org/dev/rfcs/0012-value-pools.html#definitions
|
||||
/// <https://zebra.zfnd.org/dev/rfcs/0012-value-pools.html#definitions>
|
||||
///
|
||||
/// See [`Transaction::sprout_value_balance`] for details.
|
||||
pub fn value_balance(&self) -> Amount<NegativeAllowed> {
|
||||
|
|
|
@ -34,8 +34,8 @@ mod sk_magics {
|
|||
/// a spending key, and instantiated using the SHA-256 compression
|
||||
/// function.
|
||||
///
|
||||
/// https://zips.z.cash/protocol/protocol.pdf#abstractprfs
|
||||
/// https://zips.z.cash/protocol/protocol.pdf#sproutkeycomponents
|
||||
/// <https://zips.z.cash/protocol/protocol.pdf#abstractprfs>
|
||||
/// <https://zips.z.cash/protocol/protocol.pdf#sproutkeycomponents>
|
||||
fn prf_addr(x: [u8; 32], t: u8) -> [u8; 32] {
|
||||
let mut state = [0u32; 8];
|
||||
let mut block = GenericArray::<u8, U64>::default();
|
||||
|
@ -170,8 +170,8 @@ impl From<SpendingKey> for ReceivingKey {
|
|||
/// is populated by default in an empty block of all zeros to
|
||||
/// start.
|
||||
///
|
||||
/// https://zips.z.cash/protocol/protocol.pdf#sproutkeycomponents
|
||||
/// https://zips.z.cash/protocol/protocol.pdf#concreteprfs
|
||||
/// <https://zips.z.cash/protocol/protocol.pdf#sproutkeycomponents>
|
||||
/// <https://zips.z.cash/protocol/protocol.pdf#concreteprfs>
|
||||
fn from(spending_key: SpendingKey) -> ReceivingKey {
|
||||
let derived_bytes = prf_addr(spending_key.bytes, 0);
|
||||
|
||||
|
@ -204,8 +204,8 @@ impl fmt::Debug for PayingKey {
|
|||
impl From<SpendingKey> for PayingKey {
|
||||
/// For this invocation of SHA256Compress as PRF^addr, t=1.
|
||||
///
|
||||
/// https://zips.z.cash/protocol/protocol.pdf#sproutkeycomponents
|
||||
/// https://zips.z.cash/protocol/protocol.pdf#concreteprfs
|
||||
/// <https://zips.z.cash/protocol/protocol.pdf#sproutkeycomponents>
|
||||
/// <https://zips.z.cash/protocol/protocol.pdf#concreteprfs>
|
||||
fn from(spending_key: SpendingKey) -> PayingKey {
|
||||
let derived_bytes = prf_addr(spending_key.bytes, 1);
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ pub use nullifiers::{Nullifier, NullifierSeed};
|
|||
/// holds the spending key corresponding to a given shielded payment
|
||||
/// address.
|
||||
///
|
||||
/// https://zips.z.cash/protocol/protocol.pdf#notes
|
||||
/// <https://zips.z.cash/protocol/protocol.pdf#notes>
|
||||
#[derive(Clone, Debug)]
|
||||
#[cfg_attr(
|
||||
any(test, feature = "proptest-impl"),
|
||||
|
|
|
@ -10,8 +10,8 @@ use super::super::keys::SpendingKey;
|
|||
/// spending key a_sk and a nullifier seed ρ, instantiated using the
|
||||
/// SHA-256 compression function.
|
||||
///
|
||||
/// https://zips.z.cash/protocol/protocol.pdf#abstractprfs
|
||||
/// https://zips.z.cash/protocol/protocol.pdf#commitmentsandnullifiers
|
||||
/// <https://zips.z.cash/protocol/protocol.pdf#abstractprfs>
|
||||
/// <https://zips.z.cash/protocol/protocol.pdf#commitmentsandnullifiers>
|
||||
fn prf_nf(a_sk: [u8; 32], rho: [u8; 32]) -> [u8; 32] {
|
||||
let mut state = [0u32; 8];
|
||||
let mut block = GenericArray::<u8, U64>::default();
|
||||
|
|
|
@ -37,7 +37,7 @@ pub(super) const MERKLE_DEPTH: usize = 29;
|
|||
/// Note: the implementation of MerkleCRH^Sprout does not use the `layer`
|
||||
/// argument from the definition above since the argument does not affect the output.
|
||||
///
|
||||
/// [MerkleCRH^Sprout]: https://zips.z.cash/protocol/protocol.pdf#merklecrh.
|
||||
/// [MerkleCRH^Sprout]: https://zips.z.cash/protocol/protocol.pdf#merklecrh
|
||||
fn merkle_crh_sprout(left: [u8; 32], right: [u8; 32]) -> [u8; 32] {
|
||||
let mut other_block = [0u8; 64];
|
||||
other_block[..32].copy_from_slice(&left[..]);
|
||||
|
@ -83,7 +83,7 @@ lazy_static! {
|
|||
/// The index of a note's commitment at the leafmost layer of its Note
|
||||
/// Commitment Tree.
|
||||
///
|
||||
/// https://zips.z.cash/protocol/protocol.pdf#merkletree
|
||||
/// <https://zips.z.cash/protocol/protocol.pdf#merkletree>
|
||||
pub struct Position(pub(crate) u64);
|
||||
|
||||
/// Sprout note commitment tree root node hash.
|
||||
|
|
|
@ -984,7 +984,7 @@ impl Transaction {
|
|||
/// Negative values are removed from the transparent chain value pool,
|
||||
/// and added to this transaction.
|
||||
///
|
||||
/// https://zebra.zfnd.org/dev/rfcs/0012-value-pools.html#definitions
|
||||
/// <https://zebra.zfnd.org/dev/rfcs/0012-value-pools.html#definitions>
|
||||
///
|
||||
/// `utxos` must contain the utxos of every input in the transaction,
|
||||
/// including UTXOs created by earlier transactions in this block.
|
||||
|
@ -1247,7 +1247,7 @@ impl Transaction {
|
|||
/// Negative values are removed from this transaction,
|
||||
/// and added to the sprout pool.
|
||||
///
|
||||
/// https://zebra.zfnd.org/dev/rfcs/0012-value-pools.html#definitions
|
||||
/// <https://zebra.zfnd.org/dev/rfcs/0012-value-pools.html#definitions>
|
||||
fn sprout_value_balance(&self) -> Result<ValueBalance<NegativeAllowed>, ValueBalanceError> {
|
||||
self.sprout_joinsplit_value_balances().sum()
|
||||
}
|
||||
|
@ -1262,7 +1262,7 @@ impl Transaction {
|
|||
/// Negative values are removed from this transaction,
|
||||
/// and added to sapling pool.
|
||||
///
|
||||
/// https://zebra.zfnd.org/dev/rfcs/0012-value-pools.html#definitions
|
||||
/// <https://zebra.zfnd.org/dev/rfcs/0012-value-pools.html#definitions>
|
||||
pub fn sapling_value_balance(&self) -> ValueBalance<NegativeAllowed> {
|
||||
let sapling_value_balance = match self {
|
||||
Transaction::V4 {
|
||||
|
@ -1329,7 +1329,7 @@ impl Transaction {
|
|||
/// Negative values are removed from this transaction,
|
||||
/// and added to orchard pool.
|
||||
///
|
||||
/// https://zebra.zfnd.org/dev/rfcs/0012-value-pools.html#definitions
|
||||
/// <https://zebra.zfnd.org/dev/rfcs/0012-value-pools.html#definitions>
|
||||
pub fn orchard_value_balance(&self) -> ValueBalance<NegativeAllowed> {
|
||||
let orchard_value_balance = self
|
||||
.orchard_shielded_data()
|
||||
|
@ -1375,7 +1375,7 @@ impl Transaction {
|
|||
/// Negative values are removed from this transaction,
|
||||
/// and added to the corresponding pool.
|
||||
///
|
||||
/// https://zebra.zfnd.org/dev/rfcs/0012-value-pools.html#definitions
|
||||
/// <https://zebra.zfnd.org/dev/rfcs/0012-value-pools.html#definitions>
|
||||
///
|
||||
/// `utxos` must contain the utxos of every input in the transaction,
|
||||
/// including UTXOs created by earlier transactions in this block.
|
||||
|
|
|
@ -83,7 +83,7 @@ impl<P: ZkSnarkProof> JoinSplitData<P> {
|
|||
/// Return the sprout value balance,
|
||||
/// the change in the transaction value pool due to sprout [`JoinSplit`]s.
|
||||
///
|
||||
/// https://zebra.zfnd.org/dev/rfcs/0012-value-pools.html#definitions
|
||||
/// <https://zebra.zfnd.org/dev/rfcs/0012-value-pools.html#definitions>
|
||||
///
|
||||
/// See [`Transaction::sprout_value_balance`] for details.
|
||||
pub fn value_balance(&self) -> Result<Amount<NegativeAllowed>, amount::Error> {
|
||||
|
|
|
@ -9,7 +9,7 @@ use crate::primitives::zcash_primitives::sighash;
|
|||
static ZIP143_EXPLANATION: &str = "Invalid transaction version: after Overwinter activation transaction versions 1 and 2 are rejected";
|
||||
|
||||
bitflags::bitflags! {
|
||||
/// The different SigHash types, as defined in https://zips.z.cash/zip-0143
|
||||
/// The different SigHash types, as defined in <https://zips.z.cash/zip-0143>
|
||||
pub struct HashType: u32 {
|
||||
/// Sign all the outputs
|
||||
const ALL = 0b0000_0001;
|
||||
|
@ -23,7 +23,7 @@ bitflags::bitflags! {
|
|||
}
|
||||
|
||||
/// A Signature Hash (or SIGHASH) as specified in
|
||||
/// https://zips.z.cash/protocol/protocol.pdf#sighash
|
||||
/// <https://zips.z.cash/protocol/protocol.pdf#sighash>
|
||||
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
|
||||
pub struct SigHash(pub [u8; 32]);
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ mod magics {
|
|||
/// imply that a transparent Zcash address can be parsed identically
|
||||
/// to a Bitcoin address just by removing the "t".)
|
||||
///
|
||||
/// https://zips.z.cash/protocol/protocol.pdf#transparentaddrencoding
|
||||
/// <https://zips.z.cash/protocol/protocol.pdf#transparentaddrencoding>
|
||||
#[derive(
|
||||
Copy, Clone, Eq, PartialEq, Hash, serde_with::SerializeDisplay, serde_with::DeserializeFromStr,
|
||||
)]
|
||||
|
@ -241,7 +241,7 @@ impl Address {
|
|||
///
|
||||
/// The resulting hash in both of these cases is always exactly 20
|
||||
/// bytes.
|
||||
/// https://en.bitcoin.it/Base58Check_encoding#Encoding_a_Bitcoin_address
|
||||
/// <https://en.bitcoin.it/Base58Check_encoding#Encoding_a_Bitcoin_address>
|
||||
fn hash_payload(bytes: &[u8]) -> [u8; 20] {
|
||||
let sha_hash = Sha256::digest(bytes);
|
||||
let ripe_hash = Ripemd160::digest(&sha_hash);
|
||||
|
|
|
@ -217,7 +217,7 @@ fn compact_extremes() {
|
|||
|
||||
/// Bitcoin test vectors for CompactDifficulty, and their corresponding
|
||||
/// ExpandedDifficulty and Work values.
|
||||
/// See https://developer.bitcoin.org/reference/block_chain.html#target-nbits
|
||||
/// See <https://developer.bitcoin.org/reference/block_chain.html#target-nbits>
|
||||
static COMPACT_DIFFICULTY_CASES: &[(u32, Option<u128>, Option<u128>)] = &[
|
||||
// These Work values will never happen in practice, because the corresponding
|
||||
// difficulties are extremely high. So it is ok for us to reject them.
|
||||
|
|
|
@ -83,7 +83,7 @@ pub enum VerifyBlockError {
|
|||
/// We re-use some `zcashd` C++ script code via `zebra-script` and `zcash_script`.
|
||||
///
|
||||
/// See:
|
||||
/// https://github.com/zcash/zcash/blob/bad7f7eadbbb3466bebe3354266c7f69f607fcfd/src/consensus/consensus.h#L30
|
||||
/// <https://github.com/zcash/zcash/blob/bad7f7eadbbb3466bebe3354266c7f69f607fcfd/src/consensus/consensus.h#L30>
|
||||
pub const MAX_BLOCK_SIGOPS: u64 = 20_000;
|
||||
|
||||
impl<S, V> BlockVerifier<S, V>
|
||||
|
|
|
@ -122,7 +122,7 @@ pub fn funding_stream_address(
|
|||
/// Given a funding stream address, create a script and check if it is the same
|
||||
/// as the given lock_script as described in [protocol specification §7.10][7.10]
|
||||
///
|
||||
/// [7.10]: https://zips.z.cash/protocol/protocol.pdf#fundingstreams.
|
||||
/// [7.10]: https://zips.z.cash/protocol/protocol.pdf#fundingstreams
|
||||
pub fn check_script_form(lock_script: &Script, address: Address) -> bool {
|
||||
let mut address_hash = address
|
||||
.zcash_serialize_to_vec()
|
||||
|
|
|
@ -112,7 +112,7 @@ pub static OUTPUT_VERIFIER: Lazy<
|
|||
/// Global batch verification context for Groth16 proofs of JoinSplit statements.
|
||||
///
|
||||
/// This service does not yet batch verifications, see
|
||||
/// https://github.com/ZcashFoundation/zebra/issues/3127
|
||||
/// <https://github.com/ZcashFoundation/zebra/issues/3127>
|
||||
///
|
||||
/// Note that making a `Service` call requires mutable access to the service, so
|
||||
/// you should call `.clone()` on the global handle to create a local, mutable
|
||||
|
@ -249,7 +249,7 @@ impl Description for (&JoinSplit<Groth16Proof>, &ed25519::VerificationKeyBytes)
|
|||
/// the transaction. (All JoinSplits in a transaction share the same validation key.)
|
||||
///
|
||||
/// This is not yet officially documented; see the reference implementation:
|
||||
/// https://github.com/zcash/librustzcash/blob/0ec7f97c976d55e1a194a37b27f247e8887fca1d/zcash_proofs/src/sprout.rs#L152-L166
|
||||
/// <https://github.com/zcash/librustzcash/blob/0ec7f97c976d55e1a194a37b27f247e8887fca1d/zcash_proofs/src/sprout.rs#L152-L166>
|
||||
/// <https://zips.z.cash/protocol/protocol.pdf#joinsplitdesc>
|
||||
fn primary_inputs(&self) -> Vec<jubjub::Fq> {
|
||||
let (joinsplit, joinsplit_pub_key) = self;
|
||||
|
@ -299,7 +299,7 @@ pub type Item = batch::Item<Bls12>;
|
|||
|
||||
/// A wrapper to allow a TryFrom blanket implementation of the [`Description`]
|
||||
/// trait for the [`Item`] struct.
|
||||
/// See https://github.com/rust-lang/rust/issues/50133 for more details.
|
||||
/// See <https://github.com/rust-lang/rust/issues/50133> for more details.
|
||||
pub struct DescriptionWrapper<T>(pub T);
|
||||
|
||||
impl<T> TryFrom<DescriptionWrapper<&T>> for Item
|
||||
|
|
|
@ -135,7 +135,7 @@ pub enum Response {
|
|||
/// > The remaining value in the transparent transaction value pool
|
||||
/// > of a coinbase transaction is destroyed.
|
||||
///
|
||||
/// https://zips.z.cash/protocol/protocol.pdf#transactions
|
||||
/// <https://zips.z.cash/protocol/protocol.pdf#transactions>
|
||||
miner_fee: Option<Amount<NonNegative>>,
|
||||
|
||||
/// The number of legacy signature operations in this transaction's
|
||||
|
|
|
@ -169,8 +169,8 @@ pub fn joinsplit_has_vpub_zero(tx: &Transaction) -> Result<(), TransactionError>
|
|||
/// Check if a transaction is adding to the sprout pool after Canopy
|
||||
/// network upgrade given a block height and a network.
|
||||
///
|
||||
/// https://zips.z.cash/zip-0211
|
||||
/// https://zips.z.cash/protocol/protocol.pdf#joinsplitdesc
|
||||
/// <https://zips.z.cash/zip-0211>
|
||||
/// <https://zips.z.cash/protocol/protocol.pdf#joinsplitdesc>
|
||||
pub fn disabled_add_to_sprout_pool(
|
||||
tx: &Transaction,
|
||||
height: Height,
|
||||
|
@ -211,13 +211,13 @@ pub fn disabled_add_to_sprout_pool(
|
|||
/// Any subsequent reference is a forbidden double spend-
|
||||
/// an attempt to spend the same satoshis twice."
|
||||
///
|
||||
/// https://developer.bitcoin.org/devguide/block_chain.html#introduction
|
||||
/// <https://developer.bitcoin.org/devguide/block_chain.html#introduction>
|
||||
///
|
||||
/// A _nullifier_ *MUST NOT* repeat either within a _transaction_, or across _transactions_ in a
|
||||
/// _valid blockchain_ . *Sprout* and *Sapling* and *Orchard* _nulliers_ are considered disjoint,
|
||||
/// even if they have the same bit pattern.
|
||||
///
|
||||
/// https://zips.z.cash/protocol/protocol.pdf#nullifierset
|
||||
/// <https://zips.z.cash/protocol/protocol.pdf#nullifierset>
|
||||
pub fn spend_conflicts(transaction: &Transaction) -> Result<(), TransactionError> {
|
||||
use crate::error::TransactionError::*;
|
||||
|
||||
|
@ -284,7 +284,7 @@ where
|
|||
///
|
||||
/// TODO: Currently, a 0x01 lead byte is allowed in the "grace period" mentioned since we're
|
||||
/// using `librustzcash` to implement this and it doesn't currently allow changing that behavior.
|
||||
/// https://github.com/ZcashFoundation/zebra/issues/3027
|
||||
/// <https://github.com/ZcashFoundation/zebra/issues/3027>
|
||||
pub fn coinbase_outputs_are_decryptable(
|
||||
transaction: &Transaction,
|
||||
network: Network,
|
||||
|
@ -309,8 +309,8 @@ pub fn coinbase_outputs_are_decryptable(
|
|||
/// Returns `Ok(())` if the expiry height for the coinbase transaction is valid
|
||||
/// according to specifications [7.1] and [ZIP-203].
|
||||
///
|
||||
/// [7.1]: <https://zips.z.cash/protocol/protocol.pdf#txnencodingandconsensus>
|
||||
/// [ZIP-203]: <https://zips.z.cash/zip-0203>
|
||||
/// [7.1]: https://zips.z.cash/protocol/protocol.pdf#txnencodingandconsensus
|
||||
/// [ZIP-203]: https://zips.z.cash/zip-0203
|
||||
pub fn coinbase_expiry_height(
|
||||
block_height: &Height,
|
||||
coinbase: &Transaction,
|
||||
|
@ -351,8 +351,8 @@ pub fn coinbase_expiry_height(
|
|||
/// Returns `Ok(())` if the expiry height for a non coinbase transaction is
|
||||
/// valid according to specifications [7.1] and [ZIP-203].
|
||||
///
|
||||
/// [7.1]: <https://zips.z.cash/protocol/protocol.pdf#txnencodingandconsensus>
|
||||
/// [ZIP-203]: <https://zips.z.cash/zip-0203>
|
||||
/// [7.1]: https://zips.z.cash/protocol/protocol.pdf#txnencodingandconsensus
|
||||
/// [ZIP-203]: https://zips.z.cash/zip-0203
|
||||
pub fn non_coinbase_expiry_height(
|
||||
block_height: &Height,
|
||||
transaction: &Transaction,
|
||||
|
|
|
@ -194,13 +194,13 @@ pub const GET_ADDR_FANOUT: usize = 1;
|
|||
/// `addr`:
|
||||
/// > The number of IP address entries up to a maximum of 1,000.
|
||||
///
|
||||
/// https://developer.bitcoin.org/reference/p2p_networking.html#addr
|
||||
/// <https://developer.bitcoin.org/reference/p2p_networking.html#addr>
|
||||
///
|
||||
/// `addrv2`:
|
||||
/// > One message can contain up to 1,000 addresses.
|
||||
/// > Clients MUST reject messages with more addresses.
|
||||
///
|
||||
/// https://zips.z.cash/zip-0155#specification
|
||||
/// <https://zips.z.cash/zip-0155#specification>
|
||||
pub const MAX_ADDRS_IN_MESSAGE: usize = 1000;
|
||||
|
||||
/// The fraction of addresses Zebra sends in response to a `Peers` request.
|
||||
|
@ -316,8 +316,8 @@ lazy_static! {
|
|||
/// [6.1.3.3 Efficient Resource Usage] from [RFC 1123: Requirements for Internet Hosts]
|
||||
/// suggest no less than 5 seconds for resolving timeout.
|
||||
///
|
||||
/// [RFC 1123: Requirements for Internet Hosts] https://tools.ietf.org/rfcmarkup?doc=1123
|
||||
/// [6.1.3.3 Efficient Resource Usage] https://tools.ietf.org/rfcmarkup?doc=1123#page-77
|
||||
/// [RFC 1123: Requirements for Internet Hosts] <https://tools.ietf.org/rfcmarkup?doc=1123>
|
||||
/// [6.1.3.3 Efficient Resource Usage] <https://tools.ietf.org/rfcmarkup?doc=1123#page-77>
|
||||
pub const DNS_LOOKUP_TIMEOUT: Duration = Duration::from_secs(5);
|
||||
|
||||
/// Magic numbers used to identify different Zcash networks.
|
||||
|
|
|
@ -154,7 +154,7 @@ impl PeerError {
|
|||
/// > that provides non-async methods for performing operations on the data within,
|
||||
/// > and only lock the mutex inside these methods
|
||||
///
|
||||
/// https://docs.rs/tokio/1.15.0/tokio/sync/struct.Mutex.html#which-kind-of-mutex-should-you-use
|
||||
/// <https://docs.rs/tokio/1.15.0/tokio/sync/struct.Mutex.html#which-kind-of-mutex-should-you-use>
|
||||
#[derive(Default, Clone)]
|
||||
pub struct ErrorSlot(Arc<std::sync::Mutex<Option<SharedPeerError>>>);
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ use tower::retry::Policy;
|
|||
|
||||
/// A very basic retry policy with a limited number of retry attempts.
|
||||
///
|
||||
/// XXX Remove this when https://github.com/tower-rs/tower/pull/414 lands.
|
||||
/// XXX Remove this when <https://github.com/tower-rs/tower/pull/414> lands.
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
|
||||
pub struct RetryLimit {
|
||||
remaining_tries: usize,
|
||||
|
|
|
@ -39,31 +39,31 @@ use zebra_chain::serialization::{zcash_serialize_bytes, ZcashSerialize};
|
|||
/// > Field addr has a variable length, with a maximum of 512 bytes (4096 bits).
|
||||
/// > Clients MUST reject messages with a longer addr field, irrespective of the network ID.
|
||||
///
|
||||
/// https://zips.z.cash/zip-0155#specification
|
||||
/// <https://zips.z.cash/zip-0155#specification>
|
||||
pub const MAX_ADDR_V2_ADDR_SIZE: usize = 512;
|
||||
|
||||
/// The network ID of [`Ipv4Addr`]s in `addrv2` messages.
|
||||
///
|
||||
/// > 0x01 IPV4 4 IPv4 address (globally routed internet)
|
||||
///
|
||||
/// https://zips.z.cash/zip-0155#specification
|
||||
/// <https://zips.z.cash/zip-0155#specification>
|
||||
pub const ADDR_V2_IPV4_NETWORK_ID: u8 = 0x01;
|
||||
|
||||
/// The size of [`Ipv4Addr`]s in `addrv2` messages.
|
||||
///
|
||||
/// https://zips.z.cash/zip-0155#specification
|
||||
/// <https://zips.z.cash/zip-0155#specification>
|
||||
pub const ADDR_V2_IPV4_ADDR_SIZE: usize = 4;
|
||||
|
||||
/// The network ID of [`Ipv6Addr`]s in `addrv2` messages.
|
||||
///
|
||||
/// > 0x02 IPV6 16 IPv6 address (globally routed internet)
|
||||
///
|
||||
/// https://zips.z.cash/zip-0155#specification
|
||||
/// <https://zips.z.cash/zip-0155#specification>
|
||||
pub const ADDR_V2_IPV6_NETWORK_ID: u8 = 0x02;
|
||||
|
||||
/// The size of [`Ipv6Addr`]s in `addrv2` messages.
|
||||
///
|
||||
/// https://zips.z.cash/zip-0155#specification
|
||||
/// <https://zips.z.cash/zip-0155#specification>
|
||||
pub const ADDR_V2_IPV6_ADDR_SIZE: usize = 16;
|
||||
|
||||
/// The second format used for Bitcoin node addresses.
|
||||
|
@ -253,7 +253,7 @@ impl ZcashSerialize for AddrV2 {
|
|||
}
|
||||
|
||||
/// Deserialize an `addrv2` entry according to:
|
||||
/// https://zips.z.cash/zip-0155#specification
|
||||
/// <https://zips.z.cash/zip-0155#specification>
|
||||
///
|
||||
/// Unimplemented and unrecognised addresses are deserialized as [`AddrV2::Unsupported`].
|
||||
/// (Deserialization consumes the correct number of bytes for unsupported addresses.)
|
||||
|
|
|
@ -208,7 +208,7 @@ pub trait Rpc {
|
|||
/// # Notes
|
||||
///
|
||||
/// Only the multi-argument format is used by lightwalletd and this is what we currently support:
|
||||
/// https://github.com/zcash/lightwalletd/blob/631bb16404e3d8b045e74a7c5489db626790b2f6/common/common.go#L97-L102
|
||||
/// <https://github.com/zcash/lightwalletd/blob/631bb16404e3d8b045e74a7c5489db626790b2f6/common/common.go#L97-L102>
|
||||
#[rpc(name = "getaddresstxids")]
|
||||
fn get_address_tx_ids(&self, request: GetAddressTxIdsRequest)
|
||||
-> BoxFuture<Result<Vec<String>>>;
|
||||
|
@ -224,7 +224,7 @@ pub trait Rpc {
|
|||
/// # Notes
|
||||
///
|
||||
/// lightwalletd always uses the multi-address request, without chaininfo:
|
||||
/// https://github.com/zcash/lightwalletd/blob/master/frontend/service.go#L402
|
||||
/// <https://github.com/zcash/lightwalletd/blob/master/frontend/service.go#L402>
|
||||
#[rpc(name = "getaddressutxos")]
|
||||
fn get_address_utxos(
|
||||
&self,
|
||||
|
|
|
@ -399,7 +399,7 @@ pub enum Request {
|
|||
/// Returns
|
||||
///
|
||||
/// [`Response::BlockHashes(Vec<block::Hash>)`](Response::BlockHashes).
|
||||
/// See https://en.bitcoin.it/wiki/Protocol_documentation#getblocks
|
||||
/// See <https://en.bitcoin.it/wiki/Protocol_documentation#getblocks>
|
||||
FindBlockHashes {
|
||||
/// Hashes of known blocks, ordered from highest height to lowest height.
|
||||
known_blocks: Vec<block::Hash>,
|
||||
|
@ -422,7 +422,7 @@ pub enum Request {
|
|||
/// Returns
|
||||
///
|
||||
/// [`Response::BlockHeaders(Vec<block::Header>)`](Response::BlockHeaders).
|
||||
/// See https://en.bitcoin.it/wiki/Protocol_documentation#getheaders
|
||||
/// See <https://en.bitcoin.it/wiki/Protocol_documentation#getheaders>
|
||||
FindBlockHeaders {
|
||||
/// Hashes of known blocks, ordered from highest height to lowest height.
|
||||
known_blocks: Vec<block::Hash>,
|
||||
|
|
|
@ -22,7 +22,7 @@ use crate::{
|
|||
/// > Sprout and Sapling and Orchard nullifiers are considered disjoint,
|
||||
/// > even if they have the same bit pattern.
|
||||
///
|
||||
/// https://zips.z.cash/protocol/protocol.pdf#nullifierset
|
||||
/// <https://zips.z.cash/protocol/protocol.pdf#nullifierset>
|
||||
#[tracing::instrument(skip(prepared, finalized_state))]
|
||||
pub(crate) fn no_duplicates_in_finalized_chain(
|
||||
prepared: &PreparedBlock,
|
||||
|
@ -67,7 +67,7 @@ pub(crate) fn no_duplicates_in_finalized_chain(
|
|||
/// > Sprout and Sapling and Orchard nullifiers are considered disjoint,
|
||||
/// > even if they have the same bit pattern.
|
||||
///
|
||||
/// https://zips.z.cash/protocol/protocol.pdf#nullifierset
|
||||
/// <https://zips.z.cash/protocol/protocol.pdf#nullifierset>
|
||||
///
|
||||
/// We comply with the "disjoint" rule by storing the nullifiers for each
|
||||
/// pool in separate sets (also with different types), so that even if
|
||||
|
@ -104,7 +104,7 @@ where
|
|||
/// to a different best valid block chain that does not contain
|
||||
/// the transaction in which a note was output"
|
||||
///
|
||||
/// https://zips.z.cash/protocol/nu5.pdf#decryptivk
|
||||
/// <https://zips.z.cash/protocol/nu5.pdf#decryptivk>
|
||||
///
|
||||
/// Note: reorganizations can also change the best chain to one
|
||||
/// where a note was unspent, rather than spent.
|
||||
|
|
|
@ -103,14 +103,14 @@ pub fn transparent_spend(
|
|||
/// This ensures that any program parsing block chain transactions linearly
|
||||
/// will encounter each output before it is used as an input."
|
||||
///
|
||||
/// https://developer.bitcoin.org/reference/block_chain.html#merkle-trees
|
||||
/// <https://developer.bitcoin.org/reference/block_chain.html#merkle-trees>
|
||||
///
|
||||
/// "each output of a particular transaction
|
||||
/// can only be used as an input once in the block chain.
|
||||
/// Any subsequent reference is a forbidden double spend-
|
||||
/// an attempt to spend the same satoshis twice."
|
||||
///
|
||||
/// https://developer.bitcoin.org/devguide/block_chain.html#introduction
|
||||
/// <https://developer.bitcoin.org/devguide/block_chain.html#introduction>
|
||||
///
|
||||
/// # Consensus
|
||||
///
|
||||
|
@ -229,7 +229,7 @@ pub fn transparent_coinbase_spend(
|
|||
/// Consensus rule: The remaining value in the transparent transaction value pool
|
||||
/// MUST be nonnegative."
|
||||
///
|
||||
/// https://zips.z.cash/protocol/protocol.pdf#transactions
|
||||
/// <https://zips.z.cash/protocol/protocol.pdf#transactions>
|
||||
pub fn remaining_transaction_value(
|
||||
prepared: &PreparedBlock,
|
||||
utxos: &HashMap<transparent::OutPoint, transparent::OrderedUtxo>,
|
||||
|
|
|
@ -345,7 +345,7 @@ impl DiskDb {
|
|||
///
|
||||
/// On Windows, the default limit is 512 high-level I/O files, and 8192
|
||||
/// low-level I/O files:
|
||||
/// https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/setmaxstdio?view=msvc-160#remarks
|
||||
/// <https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/setmaxstdio?view=msvc-160#remarks>
|
||||
const MIN_OPEN_FILE_LIMIT: u64 = 512;
|
||||
|
||||
/// The number of files used internally by Zebra.
|
||||
|
@ -356,7 +356,7 @@ impl DiskDb {
|
|||
|
||||
/// The size of the database memtable RAM cache in megabytes.
|
||||
///
|
||||
/// https://github.com/facebook/rocksdb/wiki/RocksDB-FAQ#configuration-and-tuning
|
||||
/// <https://github.com/facebook/rocksdb/wiki/RocksDB-FAQ#configuration-and-tuning>
|
||||
const MEMTABLE_RAM_CACHE_MEGABYTES: usize = 128;
|
||||
|
||||
/// Opens or creates the database at `config.path` for `network`,
|
||||
|
|
|
@ -548,7 +548,7 @@ fn snapshot_transparent_address_data(state: &FinalizedState, height: u32) {
|
|||
/// Return true if `list` is sorted in ascending order.
|
||||
///
|
||||
/// TODO: replace with Vec::is_sorted when it stabilises
|
||||
/// https://github.com/rust-lang/rust/issues/53485
|
||||
/// <https://github.com/rust-lang/rust/issues/53485>
|
||||
pub fn is_sorted<T: Ord + Clone>(list: &[T]) -> bool {
|
||||
// This could perform badly, but it is only used in tests, and the test vectors are small.
|
||||
let mut sorted_list = list.to_owned();
|
||||
|
|
|
@ -1403,7 +1403,7 @@ impl Ord for Chain {
|
|||
/// the vast majority of nodes should eventually agree on their best valid block chain
|
||||
/// up to that height."
|
||||
///
|
||||
/// https://zips.z.cash/protocol/protocol.pdf#blockchain
|
||||
/// <https://zips.z.cash/protocol/protocol.pdf#blockchain>
|
||||
///
|
||||
/// # Correctness
|
||||
///
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -33,7 +33,7 @@ pub struct TestVector {
|
|||
|
||||
lazy_static! {
|
||||
/// Array of ZIP-244 test vectors.
|
||||
/// From https://github.com/zcash-hackworks/zcash-test-vectors/blob/master/zip_0244.py
|
||||
/// From <https://github.com/zcash-hackworks/zcash-test-vectors/blob/master/zip_0244.py>
|
||||
pub static ref TEST_VECTORS: Vec<TestVector> = vec![
|
||||
TestVector {
|
||||
tx: vec![
|
||||
|
|
|
@ -41,7 +41,7 @@ pub fn app_config() -> config::Reader<ZebradApp> {
|
|||
/// Includes the git commit and the number of commits since the last version
|
||||
/// tag, if available.
|
||||
///
|
||||
/// For details, see https://semver.org/
|
||||
/// For details, see <https://semver.org/>
|
||||
pub fn app_version() -> Version {
|
||||
const CARGO_PKG_VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||
let vergen_git_semver: Option<&str> = option_env!("VERGEN_GIT_SEMVER_LIGHTWEIGHT");
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
//!
|
||||
//! This module uses the legacy directory structure,
|
||||
//! to avoid compiling an empty "common" test binary:
|
||||
//! https://doc.rust-lang.org/book/ch11-03-test-organization.html#submodules-in-integration-tests
|
||||
//! <https://doc.rust-lang.org/book/ch11-03-test-organization.html#submodules-in-integration-tests>
|
||||
|
||||
pub mod cached_state;
|
||||
pub mod check;
|
||||
|
|
Loading…
Reference in New Issue