From 6ca2f9e747ebdb6f1c3685407837883c69e3d1fc Mon Sep 17 00:00:00 2001 From: Paul Date: Thu, 28 Apr 2022 14:47:05 +0300 Subject: [PATCH 01/16] Added NoteType to Notes --- src/builder.rs | 3 +- src/constants/fixed_bases.rs | 3 ++ src/keys.rs | 2 + src/note.rs | 17 ++++++++ src/note/note_type.rs | 78 ++++++++++++++++++++++++++++++++++++ src/note_encryption.rs | 8 +++- 6 files changed, 108 insertions(+), 3 deletions(-) create mode 100644 src/note/note_type.rs diff --git a/src/builder.rs b/src/builder.rs index c1a45b76c..ed2cb2f97 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -150,8 +150,9 @@ impl ActionInfo { let ak: SpendValidatingKey = self.spend.fvk.clone().into(); let alpha = pallas::Scalar::random(&mut rng); let rk = ak.randomize(&alpha); + let note_type = self.spend.note.note_type(); - let note = Note::new(self.output.recipient, self.output.value, nf_old, &mut rng); + let note = Note::new(self.output.recipient, self.output.value, note_type, nf_old, &mut rng); let cm_new = note.commitment(); let cmx = cm_new.into(); diff --git a/src/constants/fixed_bases.rs b/src/constants/fixed_bases.rs index af11e335f..40df1a2de 100644 --- a/src/constants/fixed_bases.rs +++ b/src/constants/fixed_bases.rs @@ -21,6 +21,9 @@ 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 NOTE_TYPE_PERSONALIZATION: &str = "z.cash:Orchard-NoteType"; + /// SWU hash-to-curve value for the value commitment generator pub const VALUE_COMMITMENT_V_BYTES: [u8; 1] = *b"v"; diff --git a/src/keys.rs b/src/keys.rs index 3f5b4bd8a..2c8a27ad5 100644 --- a/src/keys.rs +++ b/src/keys.rs @@ -1050,6 +1050,7 @@ mod tests { value::NoteValue, Note, }; + use crate::note::NoteType; #[test] fn spend_validating_key_from_bytes() { @@ -1136,6 +1137,7 @@ mod tests { let note = Note::from_parts( addr, NoteValue::from_raw(tv.note_v), + NoteType::native(), rho, RandomSeed::from_bytes(tv.note_rseed, &rho).unwrap(), ); diff --git a/src/note.rs b/src/note.rs index 6bd3f7783..7e586c558 100644 --- a/src/note.rs +++ b/src/note.rs @@ -19,6 +19,9 @@ pub use self::commitment::{ExtractedNoteCommitment, NoteCommitment}; pub(crate) mod nullifier; pub use self::nullifier::Nullifier; +pub(crate) mod note_type; +pub use self::note_type::NoteType; + /// The ZIP 212 seed randomness for a note. #[derive(Copy, Clone, Debug)] pub(crate) struct RandomSeed([u8; 32]); @@ -86,6 +89,8 @@ pub struct Note { recipient: Address, /// The value of this note. value: NoteValue, + /// The type of this note. + note_type: NoteType, /// A unique creation ID for this note. /// /// This is set to the nullifier of the note that was spent in the [`Action`] that @@ -111,12 +116,14 @@ impl Note { pub(crate) fn from_parts( recipient: Address, value: NoteValue, + note_type: NoteType, rho: Nullifier, rseed: RandomSeed, ) -> Self { Note { recipient, value, + note_type, rho, rseed, } @@ -130,6 +137,7 @@ impl Note { pub(crate) fn new( recipient: Address, value: NoteValue, + note_type: NoteType, rho: Nullifier, mut rng: impl RngCore, ) -> Self { @@ -137,6 +145,7 @@ impl Note { let note = Note { recipient, value, + note_type, rho, rseed: RandomSeed::random(&mut rng, &rho), }; @@ -162,6 +171,7 @@ impl Note { let note = Note::new( recipient, NoteValue::zero(), + NoteType::native(), rho.unwrap_or_else(|| Nullifier::dummy(rng)), rng, ); @@ -179,6 +189,11 @@ impl Note { self.value } + /// Returns the note type + pub fn note_type(&self) -> NoteType { + self.note_type + } + /// Returns the rseed value of this note. pub(crate) fn rseed(&self) -> &RandomSeed { &self.rseed @@ -268,6 +283,7 @@ pub mod testing { use crate::{ address::testing::arb_address, note::nullifier::testing::arb_nullifier, value::NoteValue, }; + use crate::note::NoteType; use super::{Note, RandomSeed}; @@ -288,6 +304,7 @@ pub mod testing { Note { recipient, value, + note_type: NoteType::native(), rho, rseed, } diff --git a/src/note/note_type.rs b/src/note/note_type.rs new file mode 100644 index 000000000..2bab59a00 --- /dev/null +++ b/src/note/note_type.rs @@ -0,0 +1,78 @@ +use group::{ff::PrimeField}; +use halo2_proofs::arithmetic::CurveExt; +use pasta_curves::pallas; +use subtle::CtOption; + +use crate:: spec::{extract_p}; +use crate::constants::fixed_bases::{VALUE_COMMITMENT_PERSONALIZATION, VALUE_COMMITMENT_V_BYTES}; +// use crate::keys::SpendValidatingKey; + +/// Note type identifier. +#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)] +pub struct NoteType(pub(crate) pallas::Base); + +impl NoteType { + /* + /// Generates a dummy note type for use as $\rho$ in dummy spent notes. + pub(crate) fn dummy(rng: &mut impl RngCore) -> Self { + NoteType(extract_p(&pallas::Point::random(rng))) + } + */ + + /// Deserialize the note_type from a byte array. + pub fn from_bytes(bytes: &[u8; 32]) -> CtOption { + pallas::Base::from_repr(*bytes).map(NoteType) + } + + /// Serialize the note_type to its canonical byte representation. + pub fn to_bytes(self) -> [u8; 32] { + self.0.to_repr() + } + + /// $DeriveNoteType$. + /// + /// Defined in [Zcash Protocol Spec ยง TBD: Note Types][notetypes]. + /// + /// [notetypes]: https://zips.z.cash/protocol/nu5.pdf#notetypes + #[allow(non_snake_case)] + pub(super) fn derive( + asset_idx: u64 + ) -> Self { + let hasher = pallas::Point::hash_to_curve(VALUE_COMMITMENT_PERSONALIZATION); + let V = hasher(&VALUE_COMMITMENT_V_BYTES); + + let value = pallas::Scalar::from(asset_idx); + + NoteType(extract_p(&(V * value))) + } + + /// note type for the "native" token (zec) + pub fn native() -> Self { + Self::derive(1) + } + +} + +/// Generators for property testing. +#[cfg(any(test, feature = "test-dependencies"))] +#[cfg_attr(docsrs, doc(cfg(feature = "test-dependencies")))] +pub mod testing { + use group::Group; + use pasta_curves::{arithmetic::FieldExt, pallas}; + use proptest::collection::vec; + use proptest::prelude::*; + use std::convert::TryFrom; + + use super::NoteType; + use crate::spec::extract_p; + + prop_compose! { + /// Generate a uniformly distributed note type + pub fn arb_nullifier()( + bytes in vec(any::(), 64) + ) -> NoteType { + let point = pallas::Point::generator() * pallas::Scalar::from_bytes_wide(&<[u8; 64]>::try_from(bytes).unwrap()); + NoteType(extract_p(&point)) + } + } +} diff --git a/src/note_encryption.rs b/src/note_encryption.rs index 7aed1831e..474eefd17 100644 --- a/src/note_encryption.rs +++ b/src/note_encryption.rs @@ -21,6 +21,7 @@ use crate::{ value::{NoteValue, ValueCommitment}, Address, Note, }; +use crate::note::NoteType; const PRF_OCK_ORCHARD_PERSONALIZATION: &[u8; 16] = b"Zcash_Orchardock"; @@ -75,7 +76,8 @@ where let pk_d = get_validated_pk_d(&diversifier)?; let recipient = Address::from_parts(diversifier, pk_d); - let note = Note::from_parts(recipient, value, domain.rho, rseed); + // TODO: add note_type + let note = Note::from_parts(recipient, value, NoteType::native(), domain.rho, rseed); Some((note, recipient)) } @@ -151,6 +153,7 @@ impl Domain for OrchardDomain { np[0] = 0x02; np[1..12].copy_from_slice(note.recipient().diversifier().as_array()); np[12..20].copy_from_slice(¬e.value().to_bytes()); + // todo: add note_type np[20..52].copy_from_slice(note.rseed().as_bytes()); np[52..].copy_from_slice(memo); NotePlaintextBytes(np) @@ -327,6 +330,7 @@ mod tests { value::{NoteValue, ValueCommitment}, Address, Note, }; + use crate::note::NoteType; #[test] fn test_vectors() { @@ -369,7 +373,7 @@ mod tests { assert_eq!(ock.as_ref(), tv.ock); let recipient = Address::from_parts(d, pk_d); - let note = Note::from_parts(recipient, value, rho, rseed); + let note = Note::from_parts(recipient, value, NoteType::native(), rho, rseed); assert_eq!(ExtractedNoteCommitment::from(note.commitment()), cmx); let action = Action::from_parts( From 49cedd8eccef489c1f75c5d2d985ef21fffacf99 Mon Sep 17 00:00:00 2001 From: Paul Date: Thu, 12 May 2022 12:49:30 +0300 Subject: [PATCH 02/16] reformated file --- src/builder.rs | 8 +++++++- src/keys.rs | 2 +- src/note.rs | 2 +- src/note/note_type.rs | 9 +++------ src/note_encryption.rs | 4 ++-- 5 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/builder.rs b/src/builder.rs index ed2cb2f97..cc5d056c7 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -152,7 +152,13 @@ impl ActionInfo { let rk = ak.randomize(&alpha); let note_type = self.spend.note.note_type(); - let note = Note::new(self.output.recipient, self.output.value, note_type, nf_old, &mut rng); + let note = Note::new( + self.output.recipient, + self.output.value, + note_type, + nf_old, + &mut rng, + ); let cm_new = note.commitment(); let cmx = cm_new.into(); diff --git a/src/keys.rs b/src/keys.rs index 2c8a27ad5..811e86b36 100644 --- a/src/keys.rs +++ b/src/keys.rs @@ -1045,12 +1045,12 @@ mod tests { testing::{arb_diversifier_index, arb_diversifier_key, arb_esk, arb_spending_key}, *, }; + use crate::note::NoteType; use crate::{ note::{ExtractedNoteCommitment, Nullifier, RandomSeed}, value::NoteValue, Note, }; - use crate::note::NoteType; #[test] fn spend_validating_key_from_bytes() { diff --git a/src/note.rs b/src/note.rs index 7e586c558..2c953c314 100644 --- a/src/note.rs +++ b/src/note.rs @@ -280,10 +280,10 @@ impl fmt::Debug for TransmittedNoteCiphertext { pub mod testing { use proptest::prelude::*; + use crate::note::NoteType; use crate::{ address::testing::arb_address, note::nullifier::testing::arb_nullifier, value::NoteValue, }; - use crate::note::NoteType; use super::{Note, RandomSeed}; diff --git a/src/note/note_type.rs b/src/note/note_type.rs index 2bab59a00..dff7d330f 100644 --- a/src/note/note_type.rs +++ b/src/note/note_type.rs @@ -1,10 +1,10 @@ -use group::{ff::PrimeField}; +use group::ff::PrimeField; use halo2_proofs::arithmetic::CurveExt; use pasta_curves::pallas; use subtle::CtOption; -use crate:: spec::{extract_p}; use crate::constants::fixed_bases::{VALUE_COMMITMENT_PERSONALIZATION, VALUE_COMMITMENT_V_BYTES}; +use crate::spec::extract_p; // use crate::keys::SpendValidatingKey; /// Note type identifier. @@ -35,9 +35,7 @@ impl NoteType { /// /// [notetypes]: https://zips.z.cash/protocol/nu5.pdf#notetypes #[allow(non_snake_case)] - pub(super) fn derive( - asset_idx: u64 - ) -> Self { + pub(super) fn derive(asset_idx: u64) -> Self { let hasher = pallas::Point::hash_to_curve(VALUE_COMMITMENT_PERSONALIZATION); let V = hasher(&VALUE_COMMITMENT_V_BYTES); @@ -50,7 +48,6 @@ impl NoteType { pub fn native() -> Self { Self::derive(1) } - } /// Generators for property testing. diff --git a/src/note_encryption.rs b/src/note_encryption.rs index 474eefd17..c9cef0837 100644 --- a/src/note_encryption.rs +++ b/src/note_encryption.rs @@ -10,6 +10,7 @@ use zcash_note_encryption::{ OUT_PLAINTEXT_SIZE, }; +use crate::note::NoteType; use crate::{ action::Action, keys::{ @@ -21,7 +22,6 @@ use crate::{ value::{NoteValue, ValueCommitment}, Address, Note, }; -use crate::note::NoteType; const PRF_OCK_ORCHARD_PERSONALIZATION: &[u8; 16] = b"Zcash_Orchardock"; @@ -319,6 +319,7 @@ mod tests { }; use super::{prf_ock_orchard, CompactAction, OrchardDomain, OrchardNoteEncryption}; + use crate::note::NoteType; use crate::{ action::Action, keys::{ @@ -330,7 +331,6 @@ mod tests { value::{NoteValue, ValueCommitment}, Address, Note, }; - use crate::note::NoteType; #[test] fn test_vectors() { From da3c4342e4b4586d97cf9468354a05f64253b63e Mon Sep 17 00:00:00 2001 From: Paul Date: Thu, 19 May 2022 15:30:40 +0300 Subject: [PATCH 03/16] updated `derive` for NoteType --- src/constants/fixed_bases.rs | 1 + src/note/note_type.rs | 32 +++++++++++++++++--------------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/constants/fixed_bases.rs b/src/constants/fixed_bases.rs index 40df1a2de..7a86487d3 100644 --- a/src/constants/fixed_bases.rs +++ b/src/constants/fixed_bases.rs @@ -19,6 +19,7 @@ pub mod value_commit_v; pub const ORCHARD_PERSONALIZATION: &str = "z.cash:Orchard"; /// SWU hash-to-curve personalization for the value commitment generator +/// TODO: should we change to "NOTE_TYPE_PERSONALIZATION"? pub const VALUE_COMMITMENT_PERSONALIZATION: &str = "z.cash:Orchard-cv"; /// SWU hash-to-curve personalization for the note type generator diff --git a/src/note/note_type.rs b/src/note/note_type.rs index dff7d330f..935308fa4 100644 --- a/src/note/note_type.rs +++ b/src/note/note_type.rs @@ -1,23 +1,24 @@ use group::ff::PrimeField; use halo2_proofs::arithmetic::CurveExt; -use pasta_curves::pallas; +use pasta_curves::{pallas}; use subtle::CtOption; use crate::constants::fixed_bases::{VALUE_COMMITMENT_PERSONALIZATION, VALUE_COMMITMENT_V_BYTES}; +use crate::keys::SpendValidatingKey; use crate::spec::extract_p; -// use crate::keys::SpendValidatingKey; /// Note type identifier. #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)] pub struct NoteType(pub(crate) pallas::Base); +// the hasher used to derive the assetID +#[allow(non_snake_case)] +fn assetID_hasher(msg: Vec) -> pallas::Base { + let hasher = pallas::Point::hash_to_curve(VALUE_COMMITMENT_PERSONALIZATION); + extract_p(&hasher(msg.as_bytes()))) +} + impl NoteType { - /* - /// Generates a dummy note type for use as $\rho$ in dummy spent notes. - pub(crate) fn dummy(rng: &mut impl RngCore) -> Self { - NoteType(extract_p(&pallas::Point::random(rng))) - } - */ /// Deserialize the note_type from a byte array. pub fn from_bytes(bytes: &[u8; 32]) -> CtOption { @@ -35,18 +36,19 @@ impl NoteType { /// /// [notetypes]: https://zips.z.cash/protocol/nu5.pdf#notetypes #[allow(non_snake_case)] - pub(super) fn derive(asset_idx: u64) -> Self { - let hasher = pallas::Point::hash_to_curve(VALUE_COMMITMENT_PERSONALIZATION); - let V = hasher(&VALUE_COMMITMENT_V_BYTES); + pub(super) fn derive(ak: &SpendValidatingKey, assetDesc: &[u8; 64]) -> Self { + let mut s = vec![]; - let value = pallas::Scalar::from(asset_idx); + s.extend_from_slice(&ak.to_bytes()); + s.extend_from_slice(assetDesc); - NoteType(extract_p(&(V * value))) + NoteType(assetID_hasher(s)) } - /// note type for the "native" token (zec) + /// Note type for the "native" currency (zec), maintains backward compatibility with Orchard untyped notes. + #[allow(non_snake_case)] pub fn native() -> Self { - Self::derive(1) + NoteType(assetID_hasher(VALUE_COMMITMENT_V_BYTES.to_vec())) } } From 69183ac578c18bc94634314feeefd0081ad4a03d Mon Sep 17 00:00:00 2001 From: Paul Date: Fri, 20 May 2022 21:42:14 +0300 Subject: [PATCH 04/16] added note_type to value commit derivation --- src/action.rs | 7 +++++-- src/builder.rs | 5 +++-- src/bundle.rs | 8 +++++--- src/circuit.rs | 3 ++- src/note/note_type.rs | 23 ++++++++++------------- src/value.rs | 15 +++++++++------ 6 files changed, 34 insertions(+), 27 deletions(-) diff --git a/src/action.rs b/src/action.rs index d0b73f23e..2b1a329e4 100644 --- a/src/action.rs +++ b/src/action.rs @@ -137,6 +137,7 @@ pub(crate) mod testing { }, value::{NoteValue, ValueCommitTrapdoor, ValueCommitment}, }; + use crate::note::NoteType; use super::Action; @@ -150,7 +151,8 @@ pub(crate) mod testing { let cmx = ExtractedNoteCommitment::from(note.commitment()); let cv_net = ValueCommitment::derive( spend_value - output_value, - ValueCommitTrapdoor::zero() + ValueCommitTrapdoor::zero(), + NoteType::native() ); // FIXME: make a real one from the note. let encrypted_note = TransmittedNoteCiphertext { @@ -181,7 +183,8 @@ pub(crate) mod testing { let cmx = ExtractedNoteCommitment::from(note.commitment()); let cv_net = ValueCommitment::derive( spend_value - output_value, - ValueCommitTrapdoor::zero() + ValueCommitTrapdoor::zero(), + NoteType::native() ); // FIXME: make a real one from the note. diff --git a/src/builder.rs b/src/builder.rs index cc5d056c7..47541e7dd 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -23,6 +23,7 @@ use crate::{ tree::{Anchor, MerklePath}, value::{self, NoteValue, OverflowError, ValueCommitTrapdoor, ValueCommitment, ValueSum}, }; +use crate::note::NoteType; const MIN_ACTIONS: usize = 2; @@ -140,7 +141,7 @@ impl ActionInfo { /// [orchardsend]: https://zips.z.cash/protocol/nu5.pdf#orchardsend fn build(self, mut rng: impl RngCore) -> (Action, Circuit) { let v_net = self.value_sum(); - let cv_net = ValueCommitment::derive(v_net, self.rcv.clone()); + let cv_net = ValueCommitment::derive(v_net, self.rcv.clone(), NoteType::native()); let nf_old = self.spend.note.nullifier(&self.spend.fvk); let sender_address = self.spend.note.recipient(); @@ -368,7 +369,7 @@ impl Builder { // Verify that bsk and bvk are consistent. let bvk = (actions.iter().map(|a| a.cv_net()).sum::() - - ValueCommitment::derive(value_balance, ValueCommitTrapdoor::zero())) + - ValueCommitment::derive(value_balance, ValueCommitTrapdoor::zero(), NoteType::native())) .into_bvk(); assert_eq!(redpallas::VerificationKey::from(&bsk), bvk); diff --git a/src/bundle.rs b/src/bundle.rs index 5421dadc3..b2dc96fba 100644 --- a/src/bundle.rs +++ b/src/bundle.rs @@ -21,6 +21,7 @@ use crate::{ tree::Anchor, value::{ValueCommitTrapdoor, ValueCommitment, ValueSum}, }; +use crate::note::NoteType; impl Action { /// Prepares the public instance for this action, for creating and verifying the @@ -374,9 +375,10 @@ impl> Bundle { .map(|a| a.cv_net()) .sum::() - ValueCommitment::derive( - ValueSum::from_raw(self.value_balance.into()), - ValueCommitTrapdoor::zero(), - )) + ValueSum::from_raw(self.value_balance.into()), + ValueCommitTrapdoor::zero(), + NoteType::native(), + )) .into_bvk() } } diff --git a/src/circuit.rs b/src/circuit.rs index f1742a8db..ea4ad2f8b 100644 --- a/src/circuit.rs +++ b/src/circuit.rs @@ -888,6 +888,7 @@ mod tests { tree::MerklePath, value::{ValueCommitTrapdoor, ValueCommitment}, }; + use crate::note::NoteType; fn generate_circuit_instance(mut rng: R) -> (Circuit, Instance) { let (_, fvk, spent_note) = Note::dummy(&mut rng, None); @@ -905,7 +906,7 @@ mod tests { let value = spent_note.value() - output_note.value(); let rcv = ValueCommitTrapdoor::random(&mut rng); - let cv_net = ValueCommitment::derive(value, rcv.clone()); + let cv_net = ValueCommitment::derive(value, rcv.clone(), NoteType::native()); let path = MerklePath::dummy(&mut rng); let anchor = path.root(spent_note.commitment().into()); diff --git a/src/note/note_type.rs b/src/note/note_type.rs index 935308fa4..65dab29cc 100644 --- a/src/note/note_type.rs +++ b/src/note/note_type.rs @@ -1,33 +1,31 @@ -use group::ff::PrimeField; +use group::GroupEncoding; use halo2_proofs::arithmetic::CurveExt; -use pasta_curves::{pallas}; +use pasta_curves::pallas; use subtle::CtOption; use crate::constants::fixed_bases::{VALUE_COMMITMENT_PERSONALIZATION, VALUE_COMMITMENT_V_BYTES}; use crate::keys::SpendValidatingKey; -use crate::spec::extract_p; /// Note type identifier. -#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)] -pub struct NoteType(pub(crate) pallas::Base); +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub struct NoteType(pub(crate) pallas::Point); // the hasher used to derive the assetID #[allow(non_snake_case)] -fn assetID_hasher(msg: Vec) -> pallas::Base { - let hasher = pallas::Point::hash_to_curve(VALUE_COMMITMENT_PERSONALIZATION); - extract_p(&hasher(msg.as_bytes()))) +fn assetID_hasher(msg: Vec) -> pallas::Point { + // TODO(zsa) replace personalization, will require circuit change. + pallas::Point::hash_to_curve(VALUE_COMMITMENT_PERSONALIZATION)(&msg) } impl NoteType { - /// Deserialize the note_type from a byte array. pub fn from_bytes(bytes: &[u8; 32]) -> CtOption { - pallas::Base::from_repr(*bytes).map(NoteType) + pallas::Point::from_bytes(bytes).map(NoteType) } /// Serialize the note_type to its canonical byte representation. pub fn to_bytes(self) -> [u8; 32] { - self.0.to_repr() + self.0.to_bytes() } /// $DeriveNoteType$. @@ -63,7 +61,6 @@ pub mod testing { use std::convert::TryFrom; use super::NoteType; - use crate::spec::extract_p; prop_compose! { /// Generate a uniformly distributed note type @@ -71,7 +68,7 @@ pub mod testing { bytes in vec(any::(), 64) ) -> NoteType { let point = pallas::Point::generator() * pallas::Scalar::from_bytes_wide(&<[u8; 64]>::try_from(bytes).unwrap()); - NoteType(extract_p(&point)) + NoteType(point) } } } diff --git a/src/value.rs b/src/value.rs index a760e77b3..94fe47442 100644 --- a/src/value.rs +++ b/src/value.rs @@ -50,9 +50,10 @@ use pasta_curves::{ use rand::RngCore; use subtle::CtOption; +use crate::note::NoteType; use crate::{ constants::fixed_bases::{ - VALUE_COMMITMENT_PERSONALIZATION, VALUE_COMMITMENT_R_BYTES, VALUE_COMMITMENT_V_BYTES, + VALUE_COMMITMENT_PERSONALIZATION, VALUE_COMMITMENT_R_BYTES, }, primitives::redpallas::{self, Binding}, }; @@ -292,9 +293,8 @@ impl ValueCommitment { /// /// [concretehomomorphiccommit]: https://zips.z.cash/protocol/nu5.pdf#concretehomomorphiccommit #[allow(non_snake_case)] - pub(crate) fn derive(value: ValueSum, rcv: ValueCommitTrapdoor) -> Self { + pub(crate) fn derive(value: ValueSum, rcv: ValueCommitTrapdoor, note_type: NoteType) -> Self { let hasher = pallas::Point::hash_to_curve(VALUE_COMMITMENT_PERSONALIZATION); - let V = hasher(&VALUE_COMMITMENT_V_BYTES); let R = hasher(&VALUE_COMMITMENT_R_BYTES); let abs_value = u64::try_from(value.0.abs()).expect("value must be in valid range"); @@ -304,7 +304,9 @@ impl ValueCommitment { pallas::Scalar::from(abs_value) }; - ValueCommitment(V * value + R * rcv.0) + let V_zsa = note_type.0; + + ValueCommitment(V_zsa * value + R * rcv.0) } pub(crate) fn into_bvk(self) -> redpallas::VerificationKey { @@ -407,6 +409,7 @@ pub mod testing { #[cfg(test)] mod tests { + use crate::note::NoteType; use proptest::prelude::*; use super::{ @@ -438,9 +441,9 @@ mod tests { let bvk = (values .into_iter() - .map(|(value, rcv)| ValueCommitment::derive(value, rcv)) + .map(|(value, rcv)| ValueCommitment::derive(value, rcv, NoteType::native())) .sum::() - - ValueCommitment::derive(value_balance, ValueCommitTrapdoor::zero())) + - ValueCommitment::derive(value_balance, ValueCommitTrapdoor::zero(), NoteType::native())) .into_bvk(); assert_eq!(redpallas::VerificationKey::from(&bsk), bvk); From 56994a939830ea6bab5483ac4745095ab38e890b Mon Sep 17 00:00:00 2001 From: Paul Date: Sun, 22 May 2022 11:28:56 +0300 Subject: [PATCH 05/16] rustfmt --- src/action.rs | 2 +- src/builder.rs | 8 ++++++-- src/bundle.rs | 10 +++++----- src/circuit.rs | 2 +- src/value.rs | 4 +--- 5 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/action.rs b/src/action.rs index 2b1a329e4..b6396ed91 100644 --- a/src/action.rs +++ b/src/action.rs @@ -126,6 +126,7 @@ pub(crate) mod testing { use proptest::prelude::*; + use crate::note::NoteType; use crate::{ note::{ commitment::ExtractedNoteCommitment, nullifier::testing::arb_nullifier, @@ -137,7 +138,6 @@ pub(crate) mod testing { }, value::{NoteValue, ValueCommitTrapdoor, ValueCommitment}, }; - use crate::note::NoteType; use super::Action; diff --git a/src/builder.rs b/src/builder.rs index 47541e7dd..b2f894c47 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -8,6 +8,7 @@ use nonempty::NonEmpty; use pasta_curves::pallas; use rand::{prelude::SliceRandom, CryptoRng, RngCore}; +use crate::note::NoteType; use crate::{ action::Action, address::Address, @@ -23,7 +24,6 @@ use crate::{ tree::{Anchor, MerklePath}, value::{self, NoteValue, OverflowError, ValueCommitTrapdoor, ValueCommitment, ValueSum}, }; -use crate::note::NoteType; const MIN_ACTIONS: usize = 2; @@ -369,7 +369,11 @@ impl Builder { // Verify that bsk and bvk are consistent. let bvk = (actions.iter().map(|a| a.cv_net()).sum::() - - ValueCommitment::derive(value_balance, ValueCommitTrapdoor::zero(), NoteType::native())) + - ValueCommitment::derive( + value_balance, + ValueCommitTrapdoor::zero(), + NoteType::native(), + )) .into_bvk(); assert_eq!(redpallas::VerificationKey::from(&bsk), bvk); diff --git a/src/bundle.rs b/src/bundle.rs index b2dc96fba..e0c928f0d 100644 --- a/src/bundle.rs +++ b/src/bundle.rs @@ -9,6 +9,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::{ action::Action, address::Address, @@ -21,7 +22,6 @@ use crate::{ tree::Anchor, value::{ValueCommitTrapdoor, ValueCommitment, ValueSum}, }; -use crate::note::NoteType; impl Action { /// Prepares the public instance for this action, for creating and verifying the @@ -375,10 +375,10 @@ impl> Bundle { .map(|a| a.cv_net()) .sum::() - ValueCommitment::derive( - ValueSum::from_raw(self.value_balance.into()), - ValueCommitTrapdoor::zero(), - NoteType::native(), - )) + ValueSum::from_raw(self.value_balance.into()), + ValueCommitTrapdoor::zero(), + NoteType::native(), + )) .into_bvk() } } diff --git a/src/circuit.rs b/src/circuit.rs index ea4ad2f8b..e3e2e55fe 100644 --- a/src/circuit.rs +++ b/src/circuit.rs @@ -882,13 +882,13 @@ mod tests { use rand::{rngs::OsRng, RngCore}; use super::{Circuit, Instance, Proof, ProvingKey, VerifyingKey, K}; + use crate::note::NoteType; use crate::{ keys::SpendValidatingKey, note::Note, tree::MerklePath, value::{ValueCommitTrapdoor, ValueCommitment}, }; - use crate::note::NoteType; fn generate_circuit_instance(mut rng: R) -> (Circuit, Instance) { let (_, fvk, spent_note) = Note::dummy(&mut rng, None); diff --git a/src/value.rs b/src/value.rs index 94fe47442..1a79fcc86 100644 --- a/src/value.rs +++ b/src/value.rs @@ -52,9 +52,7 @@ use subtle::CtOption; use crate::note::NoteType; use crate::{ - constants::fixed_bases::{ - VALUE_COMMITMENT_PERSONALIZATION, VALUE_COMMITMENT_R_BYTES, - }, + constants::fixed_bases::{VALUE_COMMITMENT_PERSONALIZATION, VALUE_COMMITMENT_R_BYTES}, primitives::redpallas::{self, Binding}, }; From 393a60a265fd7ebd1cc7c5da43966701544010ae Mon Sep 17 00:00:00 2001 From: Paul Date: Sun, 22 May 2022 13:15:01 +0300 Subject: [PATCH 06/16] updated ci config --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 153b55131..85d731849 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -18,7 +18,7 @@ jobs: name: "cargo test" command: | cargo version; - cargo test; + cargo test --all --all-features; # Invoke jobs via workflows From 6a82e1a7281551d25a37a9205913702826d150f7 Mon Sep 17 00:00:00 2001 From: Paul Date: Sun, 22 May 2022 13:42:03 +0300 Subject: [PATCH 07/16] updated ci config --- .circleci/config.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 85d731849..d2184d7c4 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -2,6 +2,9 @@ # See: https://circleci.com/docs/2.0/configuration-reference version: 2.1 +orbs: + slack: circleci/slack@4.1 + # Define a job to be invoked later in a workflow. # See: https://circleci.com/docs/2.0/configuration-reference/#jobs jobs: @@ -19,6 +22,12 @@ jobs: command: | cargo version; cargo test --all --all-features; + - slack/notify: + event: fail + template: basic_fail_1 + - slack/notify: + event: pass + template: basic_success_1 # Invoke jobs via workflows @@ -26,4 +35,5 @@ jobs: workflows: build-and-test: jobs: - - cargo-test + - cargo-test: + context: CI-Orchard-slack From 0c5fe00db9df925b6e20488633b58db400eed6c8 Mon Sep 17 00:00:00 2001 From: Paul Date: Sun, 22 May 2022 14:02:16 +0300 Subject: [PATCH 08/16] updated ci config --- .circleci/config.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index d2184d7c4..ba37a7890 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -20,6 +20,7 @@ jobs: - run: name: "cargo test" command: | + sudo apt update && sudo apt-get install libfontconfig libfontconfig1-dev libfreetype6-dev; cargo version; cargo test --all --all-features; - slack/notify: From 44851584a26afb106a962cf9ee9e9cb37773947a Mon Sep 17 00:00:00 2001 From: Paul Date: Sun, 22 May 2022 14:23:43 +0300 Subject: [PATCH 09/16] updated derive for note_type --- src/note/note_type.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/note/note_type.rs b/src/note/note_type.rs index 65dab29cc..3ecc6f398 100644 --- a/src/note/note_type.rs +++ b/src/note/note_type.rs @@ -37,8 +37,8 @@ impl NoteType { pub(super) fn derive(ak: &SpendValidatingKey, assetDesc: &[u8; 64]) -> Self { let mut s = vec![]; - s.extend_from_slice(&ak.to_bytes()); - s.extend_from_slice(assetDesc); + s.extend(&ak.to_bytes()); + s.extend(assetDesc); NoteType(assetID_hasher(s)) } From b25189e19fe239cb7d66b6e26a02f187c993ac86 Mon Sep 17 00:00:00 2001 From: Paul Date: Mon, 23 May 2022 13:09:33 +0300 Subject: [PATCH 10/16] added test for arb note_type --- src/note.rs | 5 +++-- src/note/note_type.rs | 20 ++++++++++---------- src/value.rs | 9 +++++---- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/note.rs b/src/note.rs index 2c953c314..7c59e0360 100644 --- a/src/note.rs +++ b/src/note.rs @@ -280,7 +280,7 @@ impl fmt::Debug for TransmittedNoteCiphertext { pub mod testing { use proptest::prelude::*; - use crate::note::NoteType; + use crate::note::note_type::testing::arb_note_type; use crate::{ address::testing::arb_address, note::nullifier::testing::arb_nullifier, value::NoteValue, }; @@ -300,11 +300,12 @@ pub mod testing { recipient in arb_address(), rho in arb_nullifier(), rseed in arb_rseed(), + note_type in arb_note_type(), ) -> Note { Note { recipient, value, - note_type: NoteType::native(), + note_type, rho, rseed, } diff --git a/src/note/note_type.rs b/src/note/note_type.rs index 3ecc6f398..c26150fde 100644 --- a/src/note/note_type.rs +++ b/src/note/note_type.rs @@ -37,14 +37,13 @@ impl NoteType { pub(super) fn derive(ak: &SpendValidatingKey, assetDesc: &[u8; 64]) -> Self { let mut s = vec![]; - s.extend(&ak.to_bytes()); + s.extend(ak.to_bytes()); s.extend(assetDesc); NoteType(assetID_hasher(s)) } /// Note type for the "native" currency (zec), maintains backward compatibility with Orchard untyped notes. - #[allow(non_snake_case)] pub fn native() -> Self { NoteType(assetID_hasher(VALUE_COMMITMENT_V_BYTES.to_vec())) } @@ -54,21 +53,22 @@ impl NoteType { #[cfg(any(test, feature = "test-dependencies"))] #[cfg_attr(docsrs, doc(cfg(feature = "test-dependencies")))] pub mod testing { - use group::Group; - use pasta_curves::{arithmetic::FieldExt, pallas}; - use proptest::collection::vec; use proptest::prelude::*; - use std::convert::TryFrom; use super::NoteType; + use crate::keys::{testing::arb_spending_key, FullViewingKey}; + prop_compose! { /// Generate a uniformly distributed note type - pub fn arb_nullifier()( - bytes in vec(any::(), 64) + pub fn arb_note_type()( + sk in arb_spending_key(), + bytes32a in prop::array::uniform32(prop::num::u8::ANY), + bytes32b in prop::array::uniform32(prop::num::u8::ANY), ) -> NoteType { - let point = pallas::Point::generator() * pallas::Scalar::from_bytes_wide(&<[u8; 64]>::try_from(bytes).unwrap()); - NoteType(point) + let bytes64 = [bytes32a, bytes32b].concat(); + let fvk = FullViewingKey::from(&sk); + NoteType::derive(&fvk.into(), &bytes64.try_into().unwrap()) } } } diff --git a/src/value.rs b/src/value.rs index 1a79fcc86..26ac695ff 100644 --- a/src/value.rs +++ b/src/value.rs @@ -407,7 +407,7 @@ pub mod testing { #[cfg(test)] mod tests { - use crate::note::NoteType; + use crate::note::note_type::testing::arb_note_type; use proptest::prelude::*; use super::{ @@ -423,7 +423,8 @@ mod tests { arb_note_value_bounded(MAX_NOTE_VALUE / n_values as u64).prop_flat_map(move |bound| prop::collection::vec((arb_value_sum_bounded(bound), arb_trapdoor()), n_values) ) - ) + ), + arb_note_type in arb_note_type(), ) { let value_balance = values .iter() @@ -439,9 +440,9 @@ mod tests { let bvk = (values .into_iter() - .map(|(value, rcv)| ValueCommitment::derive(value, rcv, NoteType::native())) + .map(|(value, rcv)| ValueCommitment::derive(value, rcv, arb_note_type)) .sum::() - - ValueCommitment::derive(value_balance, ValueCommitTrapdoor::zero(), NoteType::native())) + - ValueCommitment::derive(value_balance, ValueCommitTrapdoor::zero(), arb_note_type)) .into_bvk(); assert_eq!(redpallas::VerificationKey::from(&bsk), bvk); From ca693fee318f271ae14a22cba1eb892cd8e14f2b Mon Sep 17 00:00:00 2001 From: Paul Date: Mon, 23 May 2022 14:20:04 +0300 Subject: [PATCH 11/16] added test for `native` note type --- src/note/note_type.rs | 2 +- src/value.rs | 51 ++++++++++++++++++++++++++----------------- 2 files changed, 32 insertions(+), 21 deletions(-) diff --git a/src/note/note_type.rs b/src/note/note_type.rs index c26150fde..3d5ae2a39 100644 --- a/src/note/note_type.rs +++ b/src/note/note_type.rs @@ -13,7 +13,7 @@ pub struct NoteType(pub(crate) pallas::Point); // the hasher used to derive the assetID #[allow(non_snake_case)] fn assetID_hasher(msg: Vec) -> pallas::Point { - // TODO(zsa) replace personalization, will require circuit change. + // TODO(zsa) replace personalization, will require circuit change? pallas::Point::hash_to_curve(VALUE_COMMITMENT_PERSONALIZATION)(&msg) } diff --git a/src/value.rs b/src/value.rs index 26ac695ff..24deb4a95 100644 --- a/src/value.rs +++ b/src/value.rs @@ -408,6 +408,7 @@ pub mod testing { #[cfg(test)] mod tests { use crate::note::note_type::testing::arb_note_type; + use crate::note::NoteType; use proptest::prelude::*; use super::{ @@ -416,6 +417,32 @@ mod tests { }; use crate::primitives::redpallas; + fn _bsk_consistent_with_bvk( + values: &Vec<(ValueSum, ValueCommitTrapdoor)>, + note_type: NoteType, + ) { + let value_balance = values + .iter() + .map(|(value, _)| value) + .sum::>() + .expect("we generate values that won't overflow"); + + let bsk = values + .iter() + .map(|(_, rcv)| rcv) + .sum::() + .into_bsk(); + + let bvk = (values + .into_iter() + .map(|(value, rcv)| ValueCommitment::derive(value.clone(), rcv.clone(), note_type)) + .sum::() + - ValueCommitment::derive(value_balance, ValueCommitTrapdoor::zero(), note_type)) + .into_bvk(); + + assert_eq!(redpallas::VerificationKey::from(&bsk), bvk); + } + proptest! { #[test] fn bsk_consistent_with_bvk( @@ -426,26 +453,10 @@ mod tests { ), arb_note_type in arb_note_type(), ) { - let value_balance = values - .iter() - .map(|(value, _)| value) - .sum::>() - .expect("we generate values that won't overflow"); - - let bsk = values - .iter() - .map(|(_, rcv)| rcv) - .sum::() - .into_bsk(); - - let bvk = (values - .into_iter() - .map(|(value, rcv)| ValueCommitment::derive(value, rcv, arb_note_type)) - .sum::() - - ValueCommitment::derive(value_balance, ValueCommitTrapdoor::zero(), arb_note_type)) - .into_bvk(); - - assert_eq!(redpallas::VerificationKey::from(&bsk), bvk); + // Test with native note type (zec) + _bsk_consistent_with_bvk(&values, NoteType::native()); + // Test with arbitrary note type + _bsk_consistent_with_bvk(&values, arb_note_type); } } } From 4b4b6602793f8267ee37ff272cf4e96225f8659c Mon Sep 17 00:00:00 2001 From: Paul Date: Tue, 24 May 2022 20:23:50 +0300 Subject: [PATCH 12/16] fixed clippy warrnings --- src/builder.rs | 2 +- src/circuit.rs | 2 +- src/value.rs | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/builder.rs b/src/builder.rs index b2f894c47..e07e31f1c 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -141,7 +141,7 @@ impl ActionInfo { /// [orchardsend]: https://zips.z.cash/protocol/nu5.pdf#orchardsend fn build(self, mut rng: impl RngCore) -> (Action, Circuit) { let v_net = self.value_sum(); - let cv_net = ValueCommitment::derive(v_net, self.rcv.clone(), NoteType::native()); + let cv_net = ValueCommitment::derive(v_net, self.rcv, NoteType::native()); let nf_old = self.spend.note.nullifier(&self.spend.fvk); let sender_address = self.spend.note.recipient(); diff --git a/src/circuit.rs b/src/circuit.rs index e3e2e55fe..9e5634e7f 100644 --- a/src/circuit.rs +++ b/src/circuit.rs @@ -906,7 +906,7 @@ mod tests { let value = spent_note.value() - output_note.value(); let rcv = ValueCommitTrapdoor::random(&mut rng); - let cv_net = ValueCommitment::derive(value, rcv.clone(), NoteType::native()); + let cv_net = ValueCommitment::derive(value, rcv, NoteType::native()); let path = MerklePath::dummy(&mut rng); let anchor = path.root(spent_note.commitment().into()); diff --git a/src/value.rs b/src/value.rs index 24deb4a95..84f376c22 100644 --- a/src/value.rs +++ b/src/value.rs @@ -208,7 +208,7 @@ impl TryFrom for i64 { } /// The blinding factor for a [`ValueCommitment`]. -#[derive(Clone, Debug)] +#[derive(Clone, Copy, Debug)] pub struct ValueCommitTrapdoor(pallas::Scalar); impl ValueCommitTrapdoor { @@ -418,7 +418,7 @@ mod tests { use crate::primitives::redpallas; fn _bsk_consistent_with_bvk( - values: &Vec<(ValueSum, ValueCommitTrapdoor)>, + values: &[(ValueSum, ValueCommitTrapdoor)], note_type: NoteType, ) { let value_balance = values @@ -434,8 +434,8 @@ mod tests { .into_bsk(); let bvk = (values - .into_iter() - .map(|(value, rcv)| ValueCommitment::derive(value.clone(), rcv.clone(), note_type)) + .iter() + .map(|(value, rcv)| ValueCommitment::derive(*value, *rcv, note_type)) .sum::() - ValueCommitment::derive(value_balance, ValueCommitTrapdoor::zero(), note_type)) .into_bvk(); From 3e1020e13d49b40699c4562d97a9039787c5fa3a Mon Sep 17 00:00:00 2001 From: Paul Date: Tue, 24 May 2022 21:01:56 +0300 Subject: [PATCH 13/16] rustfmt --- src/value.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/value.rs b/src/value.rs index 84f376c22..abb287bcc 100644 --- a/src/value.rs +++ b/src/value.rs @@ -417,10 +417,7 @@ mod tests { }; use crate::primitives::redpallas; - fn _bsk_consistent_with_bvk( - values: &[(ValueSum, ValueCommitTrapdoor)], - note_type: NoteType, - ) { + fn _bsk_consistent_with_bvk(values: &[(ValueSum, ValueCommitTrapdoor)], note_type: NoteType) { let value_balance = values .iter() .map(|(value, _)| value) From 12497afcd453988ca541779902718e0c92ec03bb Mon Sep 17 00:00:00 2001 From: Paul Date: Tue, 14 Jun 2022 19:30:03 +0300 Subject: [PATCH 14/16] updated note type derivation --- src/note/note_type.rs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/note/note_type.rs b/src/note/note_type.rs index 3d5ae2a39..eebfc20db 100644 --- a/src/note/note_type.rs +++ b/src/note/note_type.rs @@ -4,12 +4,14 @@ use pasta_curves::pallas; use subtle::CtOption; use crate::constants::fixed_bases::{VALUE_COMMITMENT_PERSONALIZATION, VALUE_COMMITMENT_V_BYTES}; -use crate::keys::SpendValidatingKey; +use crate::keys::{IssuerValidatingKey}; /// Note type identifier. #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub struct NoteType(pub(crate) pallas::Point); +const MAX_ASSET_DESCRIPTION_SIZE: usize = 512; + // the hasher used to derive the assetID #[allow(non_snake_case)] fn assetID_hasher(msg: Vec) -> pallas::Point { @@ -34,10 +36,11 @@ impl NoteType { /// /// [notetypes]: https://zips.z.cash/protocol/nu5.pdf#notetypes #[allow(non_snake_case)] - pub(super) fn derive(ak: &SpendValidatingKey, assetDesc: &[u8; 64]) -> Self { - let mut s = vec![]; + pub fn derive(ik: &IssuerValidatingKey, assetDesc: Vec) -> Self { + assert!(assetDesc.len() < MAX_ASSET_DESCRIPTION_SIZE); - s.extend(ak.to_bytes()); + let mut s = vec![]; + s.extend(ik.to_bytes()); s.extend(assetDesc); NoteType(assetID_hasher(s)) @@ -57,7 +60,7 @@ pub mod testing { use super::NoteType; - use crate::keys::{testing::arb_spending_key, FullViewingKey}; + use crate::keys::{testing::arb_spending_key, IssuerAuthorizingKey, IssuerValidatingKey}; prop_compose! { /// Generate a uniformly distributed note type @@ -67,8 +70,8 @@ pub mod testing { bytes32b in prop::array::uniform32(prop::num::u8::ANY), ) -> NoteType { let bytes64 = [bytes32a, bytes32b].concat(); - let fvk = FullViewingKey::from(&sk); - NoteType::derive(&fvk.into(), &bytes64.try_into().unwrap()) + let isk = IssuerAuthorizingKey::from(&sk); + NoteType::derive(&IssuerValidatingKey::from(&isk), &bytes64.try_into().unwrap()) } } } From 25d3c81b3d6be85585eac9e86746d5b2ce9978e2 Mon Sep 17 00:00:00 2001 From: Paul Date: Tue, 14 Jun 2022 19:32:28 +0300 Subject: [PATCH 15/16] rustfmt --- src/note/note_type.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/note/note_type.rs b/src/note/note_type.rs index eebfc20db..ff1ace330 100644 --- a/src/note/note_type.rs +++ b/src/note/note_type.rs @@ -4,7 +4,7 @@ use pasta_curves::pallas; use subtle::CtOption; use crate::constants::fixed_bases::{VALUE_COMMITMENT_PERSONALIZATION, VALUE_COMMITMENT_V_BYTES}; -use crate::keys::{IssuerValidatingKey}; +use crate::keys::IssuerValidatingKey; /// Note type identifier. #[derive(Clone, Copy, Debug, PartialEq, Eq)] From 99bd12d274cdafea35d839c0b4ad02a46bad5645 Mon Sep 17 00:00:00 2001 From: Paul Date: Tue, 14 Jun 2022 19:36:12 +0300 Subject: [PATCH 16/16] fixed test --- src/note/note_type.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/note/note_type.rs b/src/note/note_type.rs index ff1ace330..d0857d61a 100644 --- a/src/note/note_type.rs +++ b/src/note/note_type.rs @@ -71,7 +71,7 @@ pub mod testing { ) -> NoteType { let bytes64 = [bytes32a, bytes32b].concat(); let isk = IssuerAuthorizingKey::from(&sk); - NoteType::derive(&IssuerValidatingKey::from(&isk), &bytes64.try_into().unwrap()) + NoteType::derive(&IssuerValidatingKey::from(&isk), bytes64) } } }