Skip to content

Commit

Permalink
rename 1
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulLaux committed Oct 27, 2022
1 parent 88d2a4e commit ce1443c
Show file tree
Hide file tree
Showing 16 changed files with 139 additions and 140 deletions.
4 changes: 2 additions & 2 deletions benches/circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use criterion::{BenchmarkId, Criterion};
#[cfg(unix)]
use pprof::criterion::{Output, PProfProfiler};

use orchard::note::NoteType;
use orchard::note::AssetId;
use orchard::{
builder::Builder,
bundle::Flags,
Expand Down Expand Up @@ -37,7 +37,7 @@ fn criterion_benchmark(c: &mut Criterion) {
None,
recipient,
NoteValue::from_raw(10),
NoteType::native(),
AssetId::native(),
None,
)
.unwrap();
Expand Down
6 changes: 3 additions & 3 deletions benches/note_decryption.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use orchard::{
bundle::Flags,
circuit::ProvingKey,
keys::{FullViewingKey, Scope, SpendingKey},
note::NoteType,
note::AssetId,
note_encryption::{CompactAction, OrchardDomain},
value::NoteValue,
Anchor, Bundle,
Expand Down Expand Up @@ -56,7 +56,7 @@ fn bench_note_decryption(c: &mut Criterion) {
None,
recipient,
NoteValue::from_raw(10),
NoteType::native(),
AssetId::native(),
None,
)
.unwrap();
Expand All @@ -65,7 +65,7 @@ fn bench_note_decryption(c: &mut Criterion) {
None,
recipient,
NoteValue::from_raw(10),
NoteType::native(),
AssetId::native(),
None,
)
.unwrap();
Expand Down
6 changes: 3 additions & 3 deletions src/action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ pub(crate) mod testing {

use proptest::prelude::*;

use crate::note::note_type::testing::arb_note_type;
use crate::note::note_type::testing::arb_asset_id;
use crate::{
note::{
commitment::ExtractedNoteCommitment, nullifier::testing::arb_nullifier,
Expand All @@ -147,7 +147,7 @@ pub(crate) mod testing {
nf in arb_nullifier(),
rk in arb_spendauth_verification_key(),
note in arb_note(output_value),
note_type in arb_note_type()
note_type in arb_asset_id()
) -> Action<()> {
let cmx = ExtractedNoteCommitment::from(note.commitment());
let cv_net = ValueCommitment::derive(
Expand Down Expand Up @@ -180,7 +180,7 @@ pub(crate) mod testing {
note in arb_note(output_value),
rng_seed in prop::array::uniform32(prop::num::u8::ANY),
fake_sighash in prop::array::uniform32(prop::num::u8::ANY),
note_type in arb_note_type()
note_type in arb_asset_id()
) -> Action<redpallas::Signature<SpendAuth>> {
let cmx = ExtractedNoteCommitment::from(note.commitment());
let cv_net = ValueCommitment::derive(
Expand Down
32 changes: 16 additions & 16 deletions src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use nonempty::NonEmpty;
use pasta_curves::pallas;
use rand::{prelude::SliceRandom, CryptoRng, RngCore};

use crate::note::NoteType;
use crate::note::AssetId;
use crate::{
action::Action,
address::Address,
Expand Down Expand Up @@ -74,7 +74,7 @@ impl SpendInfo {
/// Defined in [Zcash Protocol Spec § 4.8.3: Dummy Notes (Orchard)][orcharddummynotes].
///
/// [orcharddummynotes]: https://zips.z.cash/protocol/nu5.pdf#orcharddummynotes
fn dummy(note_type: NoteType, rng: &mut impl RngCore) -> Self {
fn dummy(note_type: AssetId, rng: &mut impl RngCore) -> Self {
let (sk, fvk, note) = Note::dummy(rng, None, note_type);
let merkle_path = MerklePath::dummy(rng);

Expand Down Expand Up @@ -104,15 +104,15 @@ struct RecipientInfo {
ovk: Option<OutgoingViewingKey>,
recipient: Address,
value: NoteValue,
note_type: NoteType,
note_type: AssetId,
memo: Option<[u8; 512]>,
}

impl RecipientInfo {
/// Defined in [Zcash Protocol Spec § 4.8.3: Dummy Notes (Orchard)][orcharddummynotes].
///
/// [orcharddummynotes]: https://zips.z.cash/protocol/nu5.pdf#orcharddummynotes
fn dummy(rng: &mut impl RngCore, note_type: NoteType) -> Self {
fn dummy(rng: &mut impl RngCore, note_type: AssetId) -> Self {
let fvk: FullViewingKey = (&SpendingKey::random(rng)).into();
let recipient = fvk.address_at(0u32, Scope::External);

Expand Down Expand Up @@ -166,7 +166,7 @@ impl ActionInfo {
/// Panics if the asset types of the spent and output notes do not match.
fn build(self, mut rng: impl RngCore) -> (Action<SigningMetadata>, Circuit) {
assert_eq!(
self.spend.note.note_type(),
self.spend.note.asset(),
self.output.note_type,
"spend and recipient note types must be equal"
);
Expand Down Expand Up @@ -326,7 +326,7 @@ impl Builder {
ovk: Option<OutgoingViewingKey>,
recipient: Address,
value: NoteValue,
note_type: NoteType,
note_type: AssetId,
memo: Option<[u8; 512]>,
) -> Result<(), &'static str> {
if !self.flags.outputs_enabled() {
Expand Down Expand Up @@ -426,9 +426,9 @@ impl Builder {
// Verify that bsk and bvk are consistent.
let bvk = (actions.iter().map(|a| a.cv_net()).sum::<ValueCommitment>()
- ValueCommitment::derive(
value_balance,
ValueCommitTrapdoor::zero(),
NoteType::native(),
value_balance,
ValueCommitTrapdoor::zero(),
AssetId::native(),
))
.into_bvk();
assert_eq!(redpallas::VerificationKey::from(&bsk), bvk);
Expand All @@ -450,11 +450,11 @@ impl Builder {
fn partition_by_asset(
spends: &[SpendInfo],
recipients: &[RecipientInfo],
) -> HashMap<NoteType, (Vec<SpendInfo>, Vec<RecipientInfo>)> {
) -> HashMap<AssetId, (Vec<SpendInfo>, Vec<RecipientInfo>)> {
let mut hm = HashMap::new();

for s in spends {
hm.entry(s.note.note_type())
hm.entry(s.note.asset())
.or_insert((vec![], vec![]))
.0
.push(s.clone());
Expand Down Expand Up @@ -734,7 +734,7 @@ pub mod testing {
use proptest::collection::vec;
use proptest::prelude::*;

use crate::note::NoteType;
use crate::note::AssetId;
use crate::{
address::testing::arb_address,
bundle::{Authorized, Bundle, Flags},
Expand Down Expand Up @@ -762,7 +762,7 @@ pub mod testing {
sk: SpendingKey,
anchor: Anchor,
notes: Vec<(Note, MerklePath)>,
recipient_amounts: Vec<(Address, NoteValue, NoteType)>,
recipient_amounts: Vec<(Address, NoteValue, AssetId)>,
}

impl<R: RngCore + CryptoRng> ArbitraryBundleInputs<R> {
Expand Down Expand Up @@ -816,7 +816,7 @@ pub mod testing {
arb_address().prop_flat_map(move |a| {
arb_positive_note_value(MAX_NOTE_VALUE / n_recipients as u64)
.prop_map(move |v| {
(a,v, NoteType::native())
(a,v, AssetId::native())
})
}),
n_recipients as usize,
Expand Down Expand Up @@ -867,7 +867,7 @@ mod tests {
use rand::rngs::OsRng;

use super::Builder;
use crate::note::NoteType;
use crate::note::AssetId;
use crate::{
bundle::{Authorized, Bundle, Flags},
circuit::ProvingKey,
Expand Down Expand Up @@ -896,7 +896,7 @@ mod tests {
None,
recipient,
NoteValue::from_raw(5000),
NoteType::native(),
AssetId::native(),
None,
)
.unwrap();
Expand Down
8 changes: 4 additions & 4 deletions src/bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use memuse::DynamicUsage;
use nonempty::NonEmpty;
use zcash_note_encryption::{try_note_decryption, try_output_recovery_with_ovk};

use crate::note::NoteType;
use crate::note::AssetId;
use crate::{
action::Action,
address::Address,
Expand Down Expand Up @@ -378,9 +378,9 @@ impl<T: Authorization, V: Copy + Into<i64>> Bundle<T, V> {
.map(|a| a.cv_net())
.sum::<ValueCommitment>()
- ValueCommitment::derive(
ValueSum::from_raw(self.value_balance.into()),
ValueCommitTrapdoor::zero(),
NoteType::native(),
ValueSum::from_raw(self.value_balance.into()),
ValueCommitTrapdoor::zero(),
AssetId::native(),
))
.into_bvk()
}
Expand Down
2 changes: 1 addition & 1 deletion src/bundle/commitments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ pub(crate) fn hash_issue_bundle_txid_data<A: IssueAuth>(bundle: &IssueBundle<A>)
for note in action.notes().iter() {
h.update(&note.recipient().to_raw_address_bytes());
h.update(&note.value().to_bytes());
h.update(&note.note_type().to_bytes());
h.update(&note.asset().to_bytes());
h.update(&note.rho().to_bytes());
h.update(note.rseed().as_bytes());
}
Expand Down
8 changes: 4 additions & 4 deletions src/circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -900,7 +900,7 @@ mod tests {
use rand::{rngs::OsRng, RngCore};

use super::{Circuit, Instance, Proof, ProvingKey, VerifyingKey, K};
use crate::note::NoteType;
use crate::note::AssetId;
use crate::{
keys::SpendValidatingKey,
note::Note,
Expand All @@ -909,7 +909,7 @@ mod tests {
};

fn generate_circuit_instance<R: RngCore>(mut rng: R) -> (Circuit, Instance) {
let (_, fvk, spent_note) = Note::dummy(&mut rng, None, NoteType::native());
let (_, fvk, spent_note) = Note::dummy(&mut rng, None, AssetId::native());

let sender_address = spent_note.recipient();
let nk = *fvk.nk();
Expand All @@ -919,12 +919,12 @@ mod tests {
let alpha = pallas::Scalar::random(&mut rng);
let rk = ak.randomize(&alpha);

let (_, _, output_note) = Note::dummy(&mut rng, Some(nf_old), NoteType::native());
let (_, _, output_note) = Note::dummy(&mut rng, Some(nf_old), AssetId::native());
let cmx = output_note.commitment().into();

let value = spent_note.value() - output_note.value();
let rcv = ValueCommitTrapdoor::random(&mut rng);
let cv_net = ValueCommitment::derive(value, rcv, NoteType::native());
let cv_net = ValueCommitment::derive(value, rcv, AssetId::native());

let path = MerklePath::dummy(&mut rng);
let anchor = path.root(spent_note.commitment().into());
Expand Down
Loading

0 comments on commit ce1443c

Please sign in to comment.