Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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::AssetId;
use orchard::note::AssetBase;
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),
AssetId::native(),
AssetBase::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, PreparedIncomingViewingKey, Scope, SpendingKey},
note::AssetId,
note::AssetBase,
note_encryption_v3::{CompactAction, OrchardDomainV3},
value::NoteValue,
Anchor, Bundle,
Expand Down Expand Up @@ -57,7 +57,7 @@ fn bench_note_decryption(c: &mut Criterion) {
None,
recipient,
NoteValue::from_raw(10),
AssetId::native(),
AssetBase::native(),
None,
)
.unwrap();
Expand All @@ -66,7 +66,7 @@ fn bench_note_decryption(c: &mut Criterion) {
None,
recipient,
NoteValue::from_raw(10),
AssetId::native(),
AssetBase::native(),
None,
)
.unwrap();
Expand Down
2 changes: 1 addition & 1 deletion 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::asset_id::testing::arb_asset_id;
use crate::note::asset_base::testing::arb_asset_id;
use crate::{
note::{
commitment::ExtractedNoteCommitment, nullifier::testing::arb_nullifier,
Expand Down
28 changes: 14 additions & 14 deletions src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use nonempty::NonEmpty;
use pasta_curves::pallas;
use rand::{prelude::SliceRandom, CryptoRng, RngCore};

use crate::note::AssetId;
use crate::note::AssetBase;
use crate::{
action::Action,
address::Address,
Expand Down Expand Up @@ -99,7 +99,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(asset: AssetId, rng: &mut impl RngCore) -> Self {
fn dummy(asset: AssetBase, rng: &mut impl RngCore) -> Self {
let (sk, fvk, note) = Note::dummy(rng, None, asset);
let merkle_path = MerklePath::dummy(rng);

Expand Down Expand Up @@ -127,15 +127,15 @@ struct RecipientInfo {
ovk: Option<OutgoingViewingKey>,
recipient: Address,
value: NoteValue,
asset: AssetId,
asset: AssetBase,
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, asset: AssetId) -> Self {
fn dummy(rng: &mut impl RngCore, asset: AssetBase) -> Self {
let fvk: FullViewingKey = (&SpendingKey::random(rng)).into();
let recipient = fvk.address_at(0u32, Scope::External);

Expand Down Expand Up @@ -253,7 +253,7 @@ impl ActionInfo {
pub struct Builder {
spends: Vec<SpendInfo>,
recipients: Vec<RecipientInfo>,
burn: HashMap<AssetId, ValueSum>,
burn: HashMap<AssetBase, ValueSum>,
flags: Flags,
anchor: Anchor,
}
Expand Down Expand Up @@ -323,7 +323,7 @@ impl Builder {
ovk: Option<OutgoingViewingKey>,
recipient: Address,
value: NoteValue,
asset: AssetId,
asset: AssetBase,
memo: Option<[u8; 512]>,
) -> Result<(), &'static str> {
if !self.flags.outputs_enabled() {
Expand All @@ -342,7 +342,7 @@ impl Builder {
}

/// Add an instruction to burn a given amount of a specific asset.
pub fn add_burn(&mut self, asset: AssetId, value: NoteValue) -> Result<(), &'static str> {
pub fn add_burn(&mut self, asset: AssetBase, value: NoteValue) -> Result<(), &'static str> {
if asset.is_native().into() {
return Err("Burning is only possible for non-native assets");
}
Expand Down Expand Up @@ -481,7 +481,7 @@ fn partition_by_asset(
spends: &[SpendInfo],
recipients: &[RecipientInfo],
rng: &mut impl RngCore,
) -> HashMap<AssetId, (Vec<SpendInfo>, Vec<RecipientInfo>)> {
) -> HashMap<AssetBase, (Vec<SpendInfo>, Vec<RecipientInfo>)> {
let mut hm = HashMap::new();

for s in spends {
Expand All @@ -499,7 +499,7 @@ fn partition_by_asset(
}

if hm.is_empty() {
let dummy_spend = SpendInfo::dummy(AssetId::native(), rng);
let dummy_spend = SpendInfo::dummy(AssetBase::native(), rng);
hm.insert(dummy_spend.note.asset(), (vec![dummy_spend], vec![]));
}

Expand Down Expand Up @@ -770,7 +770,7 @@ pub mod testing {
use proptest::collection::vec;
use proptest::prelude::*;

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

impl<R: RngCore + CryptoRng> ArbitraryBundleInputs<R> {
Expand Down Expand Up @@ -852,7 +852,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, AssetId::native())
(a,v, AssetBase::native())
})
}),
n_recipients as usize,
Expand Down Expand Up @@ -904,7 +904,7 @@ mod tests {
use rand::rngs::OsRng;

use super::Builder;
use crate::note::AssetId;
use crate::note::AssetBase;
use crate::{
bundle::{Authorized, Bundle, Flags},
circuit::ProvingKey,
Expand Down Expand Up @@ -933,7 +933,7 @@ mod tests {
None,
recipient,
NoteValue::from_raw(5000),
AssetId::native(),
AssetBase::native(),
None,
)
.unwrap();
Expand Down
16 changes: 8 additions & 8 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::AssetId;
use crate::note::AssetBase;
use crate::{
action::Action,
address::Address,
Expand Down Expand Up @@ -142,7 +142,7 @@ pub struct Bundle<T: Authorization, V> {
value_balance: V,
/// Assets intended for burning
/// TODO We need to add a consensus check to make sure that it is impossible to burn ZEC.
burn: Vec<(AssetId, V)>,
burn: Vec<(AssetBase, V)>,
/// The root of the Orchard commitment tree that this bundle commits to.
anchor: Anchor,
/// The authorization for this bundle.
Expand Down Expand Up @@ -175,7 +175,7 @@ impl<T: Authorization, V> Bundle<T, V> {
actions: NonEmpty<Action<T::SpendAuth>>,
flags: Flags,
value_balance: V,
burn: Vec<(AssetId, V)>,
burn: Vec<(AssetBase, V)>,
anchor: Anchor,
authorization: T,
) -> Self {
Expand Down Expand Up @@ -232,7 +232,7 @@ impl<T: Authorization, V> Bundle<T, V> {
.burn
.into_iter()
.map(|(asset, value)| Ok((asset, f(value)?)))
.collect::<Result<Vec<(AssetId, V0)>, E>>()?,
.collect::<Result<Vec<(AssetBase, V0)>, E>>()?,
anchor: self.anchor,
authorization: self.authorization,
})
Expand Down Expand Up @@ -397,7 +397,7 @@ impl<T: Authorization, V: Copy + Into<i64>> Bundle<T, V> {
- ValueCommitment::derive(
ValueSum::from_raw(self.value_balance.into()),
ValueCommitTrapdoor::zero(),
AssetId::native(),
AssetBase::native(),
)
- self
.burn
Expand Down Expand Up @@ -527,8 +527,8 @@ pub mod testing {
use super::{Action, Authorization, Authorized, Bundle, Flags};

pub use crate::action::testing::{arb_action, arb_unauthorized_action};
use crate::note::asset_id::testing::arb_zsa_asset_id;
use crate::note::AssetId;
use crate::note::asset_base::testing::arb_zsa_asset_id;
use crate::note::AssetBase;
use crate::value::testing::arb_value_sum;

/// Marker for an unauthorized bundle with no proofs or signatures.
Expand Down Expand Up @@ -595,7 +595,7 @@ pub mod testing {
(
asset_id in arb_zsa_asset_id(),
value in arb_value_sum()
) -> (AssetId, ValueSum) {
) -> (AssetBase, ValueSum) {
(asset_id, value)
}
}
Expand Down
16 changes: 8 additions & 8 deletions src/circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ use crate::{
note::{
commitment::{NoteCommitTrapdoor, NoteCommitment},
nullifier::Nullifier,
AssetId, ExtractedNoteCommitment, Note,
AssetBase, ExtractedNoteCommitment, Note,
},
primitives::redpallas::{SpendAuth, VerificationKey},
spec::NonIdentityPallasPoint,
Expand Down Expand Up @@ -109,7 +109,7 @@ pub struct Circuit {
pub(crate) psi_old: Value<pallas::Base>,
pub(crate) rcm_old: Value<NoteCommitTrapdoor>,
pub(crate) cm_old: Value<NoteCommitment>,
pub(crate) asset_old: Value<AssetId>,
pub(crate) asset_old: Value<AssetBase>,
pub(crate) alpha: Value<pallas::Scalar>,
pub(crate) ak: Value<SpendValidatingKey>,
pub(crate) nk: Value<NullifierDerivingKey>,
Expand All @@ -119,7 +119,7 @@ pub struct Circuit {
pub(crate) v_new: Value<NoteValue>,
pub(crate) psi_new: Value<pallas::Base>,
pub(crate) rcm_new: Value<NoteCommitTrapdoor>,
pub(crate) asset_new: Value<AssetId>,
pub(crate) asset_new: Value<AssetBase>,
pub(crate) rcv: Value<ValueCommitTrapdoor>,
pub(crate) split_flag: Value<bool>,
}
Expand Down Expand Up @@ -1034,7 +1034,7 @@ mod tests {

use super::{Circuit, Instance, Proof, ProvingKey, VerifyingKey, K};
use crate::keys::{IssuanceAuthorizingKey, IssuanceValidatingKey, SpendingKey};
use crate::note::AssetId;
use crate::note::AssetBase;
use crate::{
keys::SpendValidatingKey,
note::Note,
Expand All @@ -1043,7 +1043,7 @@ mod tests {
};

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

let sender_address = spent_note.recipient();
let nk = *fvk.nk();
Expand All @@ -1053,12 +1053,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), AssetId::native());
let (_, _, output_note) = Note::dummy(&mut rng, Some(nf_old), AssetBase::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, AssetId::native());
let cv_net = ValueCommitment::derive(value, rcv, AssetBase::native());

let path = MerklePath::dummy(&mut rng);
let anchor = path.root(spent_note.commitment().into());
Expand Down Expand Up @@ -1175,7 +1175,7 @@ mod tests {
let isk = IssuanceAuthorizingKey::from(&sk);
let ik = IssuanceValidatingKey::from(&isk);
let asset_descr = "zsa_asset";
AssetId::derive(&ik, asset_descr)
AssetBase::derive(&ik, asset_descr)
};
circuit.asset_new = Value::known(random_asset_id);

Expand Down
6 changes: 3 additions & 3 deletions src/constants/fixed_bases.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ pub const ORCHARD_PERSONALIZATION: &str = "z.cash:Orchard";
/// SWU hash-to-curve personalization for the value commitment generator
pub const VALUE_COMMITMENT_PERSONALIZATION: &str = "z.cash:Orchard-cv";

/// SWU hash-to-curve personalization for the note type generator
// pub const ASSET_ID_PERSONALIZATION: &str = "z.cash:Orchard-NoteType";
/// SWU hash-to-curve personalization for the ZSA asset base generator
pub const ZSA_ASSET_BASE_PERSONALIZATION: &str = "z.cash:OrchardZSA";

/// SWU hash-to-curve value for the value commitment generator
pub const VALUE_COMMITMENT_V_BYTES: [u8; 1] = *b"v";
pub const NATIVE_ASSET_BASE_V_BYTES: [u8; 1] = *b"v";

/// SWU hash-to-curve value for the value commitment generator
pub const VALUE_COMMITMENT_R_BYTES: [u8; 1] = *b"r";
Expand Down
Loading