mirror of https://github.com/zcash/orchard.git
Add `memuse::DynamicUsage` impls for types used for batch scanning
This commit is contained in:
parent
0b4d7bc9c6
commit
050b2f231e
|
@ -16,6 +16,9 @@ and this project adheres to Rust's notion of
|
||||||
- `orchard::note`:
|
- `orchard::note`:
|
||||||
- `RandomSeed`
|
- `RandomSeed`
|
||||||
- `Note::{from_parts, rseed}`
|
- `Note::{from_parts, rseed}`
|
||||||
|
- `impl memuse::DynamicUsage for Nullifier`
|
||||||
|
- `orchard::note_encryption`:
|
||||||
|
- `impl memuse::DynamicUsage for OrchardDomain`
|
||||||
- `orchard::builder::SpendInfo::new`
|
- `orchard::builder::SpendInfo::new`
|
||||||
- `orchard::circuit::Circuit::from_action_context`
|
- `orchard::circuit::Circuit::from_action_context`
|
||||||
|
|
||||||
|
|
|
@ -28,12 +28,12 @@ bitvec = "1"
|
||||||
blake2b_simd = "1"
|
blake2b_simd = "1"
|
||||||
ff = "0.12"
|
ff = "0.12"
|
||||||
fpe = "0.5"
|
fpe = "0.5"
|
||||||
group = "0.12.1"
|
group = { version = "0.12.1", features = ["wnaf-memuse"] }
|
||||||
halo2_gadgets = "0.2"
|
halo2_gadgets = "0.2"
|
||||||
halo2_proofs = "0.2"
|
halo2_proofs = "0.2"
|
||||||
hex = "0.4"
|
hex = "0.4"
|
||||||
lazy_static = "1"
|
lazy_static = "1"
|
||||||
memuse = { version = "0.2", features = ["nonempty"] }
|
memuse = { version = "0.2.1", features = ["nonempty"] }
|
||||||
pasta_curves = "0.4"
|
pasta_curves = "0.4"
|
||||||
proptest = { version = "1.0.0", optional = true }
|
proptest = { version = "1.0.0", optional = true }
|
||||||
rand = "0.8"
|
rand = "0.8"
|
||||||
|
|
10
src/keys.rs
10
src/keys.rs
|
@ -710,6 +710,16 @@ impl IncomingViewingKey {
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct PreparedIncomingViewingKey(PreparedNonZeroScalar);
|
pub struct PreparedIncomingViewingKey(PreparedNonZeroScalar);
|
||||||
|
|
||||||
|
impl memuse::DynamicUsage for PreparedIncomingViewingKey {
|
||||||
|
fn dynamic_usage(&self) -> usize {
|
||||||
|
self.0.dynamic_usage()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn dynamic_usage_bounds(&self) -> (usize, Option<usize>) {
|
||||||
|
self.0.dynamic_usage_bounds()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl PreparedIncomingViewingKey {
|
impl PreparedIncomingViewingKey {
|
||||||
/// Performs the necessary precomputations to use an `IncomingViewingKey` for note
|
/// Performs the necessary precomputations to use an `IncomingViewingKey` for note
|
||||||
/// decryption.
|
/// decryption.
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
use group::{ff::PrimeField, Group};
|
use group::{ff::PrimeField, Group};
|
||||||
use halo2_proofs::arithmetic::CurveExt;
|
use halo2_proofs::arithmetic::CurveExt;
|
||||||
|
use memuse::DynamicUsage;
|
||||||
use pasta_curves::pallas;
|
use pasta_curves::pallas;
|
||||||
use rand::RngCore;
|
use rand::RngCore;
|
||||||
use subtle::CtOption;
|
use subtle::CtOption;
|
||||||
|
@ -14,6 +15,9 @@ use crate::{
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)]
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)]
|
||||||
pub struct Nullifier(pub(crate) pallas::Base);
|
pub struct Nullifier(pub(crate) pallas::Base);
|
||||||
|
|
||||||
|
// We know that `pallas::Base` doesn't allocate internally.
|
||||||
|
memuse::impl_no_dynamic_usage!(Nullifier);
|
||||||
|
|
||||||
impl Nullifier {
|
impl Nullifier {
|
||||||
/// Generates a dummy nullifier for use as $\rho$ in dummy spent notes.
|
/// Generates a dummy nullifier for use as $\rho$ in dummy spent notes.
|
||||||
///
|
///
|
||||||
|
|
|
@ -85,6 +85,16 @@ pub struct OrchardDomain {
|
||||||
rho: Nullifier,
|
rho: Nullifier,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl memuse::DynamicUsage for OrchardDomain {
|
||||||
|
fn dynamic_usage(&self) -> usize {
|
||||||
|
self.rho.dynamic_usage()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn dynamic_usage_bounds(&self) -> (usize, Option<usize>) {
|
||||||
|
self.rho.dynamic_usage_bounds()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl OrchardDomain {
|
impl OrchardDomain {
|
||||||
/// Constructs a domain that can be used to trial-decrypt this action's output note.
|
/// Constructs a domain that can be used to trial-decrypt this action's output note.
|
||||||
pub fn for_action<T>(act: &Action<T>) -> Self {
|
pub fn for_action<T>(act: &Action<T>) -> Self {
|
||||||
|
|
11
src/spec.rs
11
src/spec.rs
|
@ -7,6 +7,7 @@ use ff::{Field, PrimeField, PrimeFieldBits};
|
||||||
use group::{Curve, Group, GroupEncoding, WnafBase, WnafScalar};
|
use group::{Curve, Group, GroupEncoding, WnafBase, WnafScalar};
|
||||||
use halo2_gadgets::{poseidon::primitives as poseidon, sinsemilla::primitives as sinsemilla};
|
use halo2_gadgets::{poseidon::primitives as poseidon, sinsemilla::primitives as sinsemilla};
|
||||||
use halo2_proofs::arithmetic::{CurveAffine, CurveExt, FieldExt};
|
use halo2_proofs::arithmetic::{CurveAffine, CurveExt, FieldExt};
|
||||||
|
use memuse::DynamicUsage;
|
||||||
use pasta_curves::pallas;
|
use pasta_curves::pallas;
|
||||||
use subtle::{ConditionallySelectable, CtOption};
|
use subtle::{ConditionallySelectable, CtOption};
|
||||||
|
|
||||||
|
@ -153,6 +154,16 @@ impl PreparedNonIdentityBase {
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub(crate) struct PreparedNonZeroScalar(WnafScalar<pallas::Scalar, PREPARED_WINDOW_SIZE>);
|
pub(crate) struct PreparedNonZeroScalar(WnafScalar<pallas::Scalar, PREPARED_WINDOW_SIZE>);
|
||||||
|
|
||||||
|
impl DynamicUsage for PreparedNonZeroScalar {
|
||||||
|
fn dynamic_usage(&self) -> usize {
|
||||||
|
self.0.dynamic_usage()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn dynamic_usage_bounds(&self) -> (usize, Option<usize>) {
|
||||||
|
self.0.dynamic_usage_bounds()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl PreparedNonZeroScalar {
|
impl PreparedNonZeroScalar {
|
||||||
pub(crate) fn new(scalar: &NonZeroPallasScalar) -> Self {
|
pub(crate) fn new(scalar: &NonZeroPallasScalar) -> Self {
|
||||||
PreparedNonZeroScalar(WnafScalar::new(scalar))
|
PreparedNonZeroScalar(WnafScalar::new(scalar))
|
||||||
|
|
Loading…
Reference in New Issue