Skip to content

Commit

Permalink
renaming IssuanceKey to IssuanceMasterKey
Browse files Browse the repository at this point in the history
  • Loading branch information
vivek-arte committed Oct 17, 2023
1 parent 64d4ed1 commit 6f6b59f
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 28 deletions.
6 changes: 3 additions & 3 deletions src/bundle/burn_validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ mod tests {
/// Creates an item of bundle burn list for a given asset description and value.
///
/// This function is deterministic and guarantees that each call with the same parameters
/// will return the same result. It achieves determinism by using a static `IssuanceKey`.
/// will return the same result. It achieves determinism by using a static `IssuanceMasterKey`.
///
/// # Arguments
///
Expand All @@ -81,9 +81,9 @@ mod tests {
/// A tuple `(AssetBase, Amount)` representing the burn list item.
///
pub fn get_burn_tuple(asset_desc: &str, value: i64) -> (AssetBase, i64) {
use crate::keys::{IssuanceAuthorizingKey, IssuanceKey, IssuanceValidatingKey};
use crate::keys::{IssuanceAuthorizingKey, IssuanceMasterKey, IssuanceValidatingKey};

let sk_iss = IssuanceKey::from_bytes([0u8; 32]).unwrap();
let sk_iss = IssuanceMasterKey::from_bytes([0u8; 32]).unwrap();
let isk: IssuanceAuthorizingKey = (&sk_iss).into();

(
Expand Down
10 changes: 5 additions & 5 deletions src/issuance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ mod tests {
};
use crate::issuance::{verify_issue_bundle, IssueAction, Signed, Unauthorized};
use crate::keys::{
FullViewingKey, IssuanceAuthorizingKey, IssuanceKey, IssuanceValidatingKey, Scope,
FullViewingKey, IssuanceAuthorizingKey, IssuanceMasterKey, IssuanceValidatingKey, Scope,
SpendingKey,
};
use crate::note::{AssetBase, Nullifier};
Expand All @@ -629,7 +629,7 @@ mod tests {
) {
let mut rng = OsRng;

let imk = IssuanceKey::random(&mut rng);
let imk = IssuanceMasterKey::random(&mut rng);
let isk: IssuanceAuthorizingKey = (&imk).into();
let ik: IssuanceValidatingKey = (&isk).into();

Expand Down Expand Up @@ -951,7 +951,7 @@ mod tests {
)
.unwrap();

let wrong_isk: IssuanceAuthorizingKey = (&IssuanceKey::random(&mut OsRng)).into();
let wrong_isk: IssuanceAuthorizingKey = (&IssuanceMasterKey::random(&mut OsRng)).into();

let err = bundle
.prepare([0; 32])
Expand Down Expand Up @@ -1183,7 +1183,7 @@ mod tests {
)
.unwrap();

let wrong_isk: IssuanceAuthorizingKey = (&IssuanceKey::random(&mut rng)).into();
let wrong_isk: IssuanceAuthorizingKey = (&IssuanceMasterKey::random(&mut rng)).into();

let mut signed = bundle.prepare(sighash).sign(rng, &isk).unwrap();

Expand Down Expand Up @@ -1278,7 +1278,7 @@ mod tests {

let mut signed = bundle.prepare(sighash).sign(rng, &isk).unwrap();

let incorrect_imk = IssuanceKey::random(&mut rng);
let incorrect_imk = IssuanceMasterKey::random(&mut rng);
let incorrect_isk: IssuanceAuthorizingKey = (&incorrect_imk).into();
let incorrect_ik: IssuanceValidatingKey = (&incorrect_isk).into();

Expand Down
28 changes: 14 additions & 14 deletions src/keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,21 +227,21 @@ type IssuanceAuth = SpendAuth;
///
/// [orchardkeycomponents]: https://zips.z.cash/protocol/nu5.pdf#orchardkeycomponents
#[derive(Debug, Copy, Clone)]
pub struct IssuanceKey([u8; 32]);
pub struct IssuanceMasterKey([u8; 32]);

impl From<SpendingKey> for IssuanceKey {
impl From<SpendingKey> for IssuanceMasterKey {
fn from(sk: SpendingKey) -> Self {
IssuanceKey(*sk.to_bytes())
IssuanceMasterKey(*sk.to_bytes())
}
}

impl ConstantTimeEq for IssuanceKey {
impl ConstantTimeEq for IssuanceMasterKey {
fn ct_eq(&self, other: &Self) -> Choice {
self.to_bytes().ct_eq(other.to_bytes())
}
}

impl IssuanceKey {
impl IssuanceMasterKey {
/// Generates a random issuance key.
///
/// This is only used when generating a random AssetBase.
Expand All @@ -256,7 +256,7 @@ impl IssuanceKey {
///
/// Returns `None` if the bytes do not correspond to a valid Orchard issuance key.
pub fn from_bytes(imk: [u8; 32]) -> CtOption<Self> {
let imk = IssuanceKey(imk);
let imk = IssuanceMasterKey(imk);
// If isk = 0 (A scalar value), discard this key.
let isk = IssuanceAuthorizingKey::derive_inner(&imk);
CtOption::new(imk, !isk.is_zero())
Expand Down Expand Up @@ -296,7 +296,7 @@ pub struct IssuanceAuthorizingKey(redpallas::SigningKey<IssuanceAuth>);

impl IssuanceAuthorizingKey {
/// Derives isk from imk. Internal use only, does not enforce all constraints.
fn derive_inner(imk: &IssuanceKey) -> pallas::Scalar {
fn derive_inner(imk: &IssuanceMasterKey) -> pallas::Scalar {
to_scalar(PrfExpand::ZsaIsk.expand(&imk.0))
}

Expand All @@ -310,8 +310,8 @@ impl IssuanceAuthorizingKey {
}
}

impl From<&IssuanceKey> for IssuanceAuthorizingKey {
fn from(imk: &IssuanceKey) -> Self {
impl From<&IssuanceMasterKey> for IssuanceAuthorizingKey {
fn from(imk: &IssuanceMasterKey) -> Self {
let isk = IssuanceAuthorizingKey::derive_inner(imk);
// IssuanceAuthorizingKey cannot be constructed such that this assertion would fail.
assert!(!bool::from(isk.is_zero()));
Expand Down Expand Up @@ -1116,7 +1116,7 @@ impl SharedSecret {
#[cfg_attr(docsrs, doc(cfg(feature = "test-dependencies")))]
pub mod testing {
use super::{
DiversifierIndex, DiversifierKey, EphemeralSecretKey, IssuanceAuthorizingKey, IssuanceKey,
DiversifierIndex, DiversifierKey, EphemeralSecretKey, IssuanceAuthorizingKey, IssuanceMasterKey,
IssuanceValidatingKey, SpendingKey,
};
use proptest::prelude::*;
Expand All @@ -1140,12 +1140,12 @@ pub mod testing {
/// Generate a uniformly distributed Orchard issuance key.
pub fn arb_issuance_key()(
key in prop::array::uniform32(prop::num::u8::ANY)
.prop_map(IssuanceKey::from_bytes)
.prop_map(IssuanceMasterKey::from_bytes)
.prop_filter(
"Values must correspond to valid Orchard issuance keys.",
|opt| bool::from(opt.is_some())
)
) -> IssuanceKey {
) -> IssuanceMasterKey {
key.unwrap()
}
}
Expand Down Expand Up @@ -1186,7 +1186,7 @@ pub mod testing {
/// Generate a uniformly distributed RedDSA issuance authorizing key.
pub fn arb_issuance_authorizing_key()(rng_seed in prop::array::uniform32(prop::num::u8::ANY)) -> IssuanceAuthorizingKey {
let mut rng = StdRng::from_seed(rng_seed);
IssuanceAuthorizingKey::from(&IssuanceKey::random(&mut rng))
IssuanceAuthorizingKey::from(&IssuanceMasterKey::random(&mut rng))
}
}

Expand Down Expand Up @@ -1267,7 +1267,7 @@ mod tests {
let ask: SpendAuthorizingKey = (&sk).into();
assert_eq!(<[u8; 32]>::from(&ask.0), tv.ask);

let imk = IssuanceKey::from_bytes(tv.sk).unwrap();
let imk = IssuanceMasterKey::from_bytes(tv.sk).unwrap();

let isk: IssuanceAuthorizingKey = (&imk).into();
assert_eq!(<[u8; 32]>::from(&isk.0), tv.isk);
Expand Down
4 changes: 2 additions & 2 deletions src/note/asset_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use subtle::{Choice, ConstantTimeEq, CtOption};
use crate::constants::fixed_bases::{
NATIVE_ASSET_BASE_V_BYTES, VALUE_COMMITMENT_PERSONALIZATION, ZSA_ASSET_BASE_PERSONALIZATION,
};
use crate::keys::{IssuanceAuthorizingKey, IssuanceKey, IssuanceValidatingKey};
use crate::keys::{IssuanceAuthorizingKey, IssuanceMasterKey, IssuanceValidatingKey};

/// Note type identifier.
#[derive(Clone, Copy, Debug, Eq)]
Expand Down Expand Up @@ -102,7 +102,7 @@ impl AssetBase {
///
/// This is only used in tests.
pub(crate) fn random(rng: &mut impl RngCore) -> Self {
let imk = IssuanceKey::random(rng);
let imk = IssuanceMasterKey::random(rng);
let isk = IssuanceAuthorizingKey::from(&imk);
let ik = IssuanceValidatingKey::from(&isk);
let asset_descr = "zsa_asset";
Expand Down
4 changes: 2 additions & 2 deletions src/supply_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ mod tests {
use super::*;

fn create_test_asset(asset_desc: &str) -> AssetBase {
use crate::keys::{IssuanceAuthorizingKey, IssuanceKey, IssuanceValidatingKey};
use crate::keys::{IssuanceAuthorizingKey, IssuanceMasterKey, IssuanceValidatingKey};

let imk = IssuanceKey::from_bytes([0u8; 32]).unwrap();
let imk = IssuanceMasterKey::from_bytes([0u8; 32]).unwrap();
let isk: IssuanceAuthorizingKey = (&imk).into();

AssetBase::derive(&IssuanceValidatingKey::from(&isk), asset_desc)
Expand Down
4 changes: 2 additions & 2 deletions tests/zsa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use orchard::{
bundle::Flags,
circuit::{ProvingKey, VerifyingKey},
keys::{
FullViewingKey, IssuanceKey, PreparedIncomingViewingKey, Scope, SpendAuthorizingKey,
FullViewingKey, IssuanceMasterKey, PreparedIncomingViewingKey, Scope, SpendAuthorizingKey,
SpendingKey,
},
value::NoteValue,
Expand Down Expand Up @@ -61,7 +61,7 @@ fn prepare_keys() -> Keychain {
let fvk = FullViewingKey::from(&sk);
let recipient = fvk.address_at(0u32, Scope::External);

let imk = IssuanceKey::from_bytes([0; 32]).unwrap();
let imk = IssuanceMasterKey::from_bytes([0; 32]).unwrap();
let isk = IssuanceAuthorizingKey::from(&imk);
let ik = IssuanceValidatingKey::from(&isk);
Keychain {
Expand Down

0 comments on commit 6f6b59f

Please sign in to comment.