Remove extraneous pub exports from the root.

This commit is contained in:
Kris Nuttycombe 2021-05-05 11:46:24 -06:00
parent 7ea8900a58
commit e72d74ccd6
6 changed files with 32 additions and 24 deletions

View File

@ -9,15 +9,16 @@ use pasta_curves::pallas;
use rand::RngCore; use rand::RngCore;
use crate::{ use crate::{
address::Address,
bundle::{Action, Authorization, Authorized, Bundle, Flags}, bundle::{Action, Authorization, Authorized, Bundle, Flags},
circuit::{Circuit, Proof, ProvingKey}, circuit::{Circuit, Proof, ProvingKey},
keys::{ keys::{
FullViewingKey, OutgoingViewingKey, SpendAuthorizingKey, SpendValidatingKey, SpendingKey, FullViewingKey, OutgoingViewingKey, SpendAuthorizingKey, SpendValidatingKey, SpendingKey,
}, },
note::{Note, TransmittedNoteCiphertext},
primitives::redpallas::{self, Binding, SpendAuth}, primitives::redpallas::{self, Binding, SpendAuth},
tree::{Anchor, MerklePath}, tree::{Anchor, MerklePath},
value::{self, NoteValue, OverflowError, ValueCommitTrapdoor, ValueCommitment, ValueSum}, value::{self, NoteValue, OverflowError, ValueCommitTrapdoor, ValueCommitment, ValueSum},
Address, Note, TransmittedNoteCiphertext,
}; };
const MIN_ACTIONS: usize = 2; const MIN_ACTIONS: usize = 2;

View File

@ -429,8 +429,16 @@ pub mod testing {
move |spend_value| { move |spend_value| {
arb_nonnegative_note_value(MAX_NOTE_VALUE / n_actions as u64).prop_flat_map( arb_nonnegative_note_value(MAX_NOTE_VALUE / n_actions as u64).prop_flat_map(
move |output_value| { move |output_value| {
let spend_value = if flags.spends_enabled { spend_value } else { NoteValue::zero() }; let spend_value = if flags.spends_enabled {
let output_value = if flags.outputs_enabled { output_value } else { NoteValue::zero() }; spend_value
} else {
NoteValue::zero()
};
let output_value = if flags.outputs_enabled {
output_value
} else {
NoteValue::zero()
};
arb_unauthorized_action(spend_value, output_value) arb_unauthorized_action(spend_value, output_value)
.prop_map(move |a| ((spend_value - output_value).unwrap(), a)) .prop_map(move |a| ((spend_value - output_value).unwrap(), a))
}, },
@ -483,8 +491,16 @@ pub mod testing {
move |spend_value| { move |spend_value| {
arb_nonnegative_note_value(MAX_NOTE_VALUE / n_actions as u64).prop_flat_map( arb_nonnegative_note_value(MAX_NOTE_VALUE / n_actions as u64).prop_flat_map(
move |output_value| { move |output_value| {
let spend_value = if flags.spends_enabled { spend_value } else { NoteValue::zero() }; let spend_value = if flags.spends_enabled {
let output_value = if flags.outputs_enabled { output_value } else { NoteValue::zero() }; spend_value
} else {
NoteValue::zero()
};
let output_value = if flags.outputs_enabled {
output_value
} else {
NoteValue::zero()
};
arb_action(spend_value, output_value) arb_action(spend_value, output_value)
.prop_map(move |a| ((spend_value - output_value).unwrap(), a)) .prop_map(move |a| ((spend_value - output_value).unwrap(), a))
}, },
@ -505,7 +521,7 @@ pub mod testing {
/// necessarily respect consensus rules; for that use /// necessarily respect consensus rules; for that use
/// [`crate::builder::testing::arb_bundle`] /// [`crate::builder::testing::arb_bundle`]
pub fn arb_unauthorized_bundle() pub fn arb_unauthorized_bundle()
( (
n_actions in 1usize..100, n_actions in 1usize..100,
flags in arb_flags(), flags in arb_flags(),
) )
@ -531,7 +547,7 @@ pub mod testing {
/// necessarily respect consensus rules; for that use /// necessarily respect consensus rules; for that use
/// [`crate::builder::testing::arb_bundle`] /// [`crate::builder::testing::arb_bundle`]
pub fn arb_bundle() pub fn arb_bundle()
( (
n_actions in 1usize..100, n_actions in 1usize..100,
flags in arb_flags(), flags in arb_flags(),
) )
@ -553,7 +569,7 @@ pub mod testing {
balances.into_iter().sum::<Result<ValueSum, _>>().unwrap(), balances.into_iter().sum::<Result<ValueSum, _>>().unwrap(),
anchor, anchor,
Authorized { Authorized {
proof: Proof(fake_proof), proof: Proof::new(fake_proof),
binding_signature: sk.sign(rng, &fake_sighash), binding_signature: sk.sign(rng, &fake_sighash),
} }
) )

View File

@ -7,11 +7,10 @@ use halo2::{
use pasta_curves::{pallas, vesta}; use pasta_curves::{pallas, vesta};
use crate::{ use crate::{
note::ExtractedNoteCommitment, note::{nullifier::Nullifier, ExtractedNoteCommitment},
primitives::redpallas::{SpendAuth, VerificationKey}, primitives::redpallas::{SpendAuth, VerificationKey},
tree::Anchor, tree::Anchor,
value::ValueCommitment, value::ValueCommitment,
Nullifier,
}; };
pub(crate) mod gadget; pub(crate) mod gadget;
@ -118,7 +117,7 @@ impl Instance {
/// ///
/// [`Bundle`]: crate::bundle::Bundle /// [`Bundle`]: crate::bundle::Bundle
#[derive(Debug)] #[derive(Debug)]
pub struct Proof(pub(crate) Vec<u8>); pub struct Proof(Vec<u8>);
impl AsRef<[u8]> for Proof { impl AsRef<[u8]> for Proof {
fn as_ref(&self) -> &[u8] { fn as_ref(&self) -> &[u8] {

View File

@ -385,9 +385,9 @@ pub mod testing {
prop_compose! { prop_compose! {
/// Generate a uniformly distributed fake note commitment value. /// Generate a uniformly distributed fake note commitment value.
pub fn arb_spending_key()( pub fn arb_spending_key()(
key in prop::array::uniform32(prop::num::u8::ANY). key in prop::array::uniform32(prop::num::u8::ANY)
prop_map(SpendingKey::from_bytes). .prop_map(SpendingKey::from_bytes)
prop_filter( .prop_filter(
"Values must correspond to valid Orchard spending keys.", "Values must correspond to valid Orchard spending keys.",
|opt| bool::from(opt.is_some()) |opt| bool::from(opt.is_some())
) )

View File

@ -29,9 +29,7 @@ mod tree;
pub mod value; pub mod value;
pub use address::Address; pub use address::Address;
pub use bundle::{Action, Authorization, Authorized, Bundle}; pub use bundle::Bundle;
pub use circuit::Proof; pub use circuit::Proof;
pub use note::{ pub use note::Note;
ExtractedNoteCommitment, Note, NoteCommitment, Nullifier, TransmittedNoteCiphertext,
};
pub use tree::Anchor; pub use tree::Anchor;

View File

@ -139,12 +139,6 @@ impl TryFrom<ValueSum> for i64 {
} }
} }
impl From<NoteValue> for ValueSum {
fn from(v: NoteValue) -> Self {
ValueSum(v.0 as i128)
}
}
/// The blinding factor for a [`ValueCommitment`]. /// The blinding factor for a [`ValueCommitment`].
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub struct ValueCommitTrapdoor(pallas::Scalar); pub struct ValueCommitTrapdoor(pallas::Scalar);