Skip to content
Closed
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
11 changes: 6 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -221,4 +221,4 @@ unexpected_cfgs = { level = "warn", check-cfg = [
[patch.crates-io]
zcash_note_encryption = { version = "0.4.1", git = "https://github.com/zcash/zcash_note_encryption", rev = "668ea44cf59a226715a5f3cb1bf88710a8c188a3" }
sapling = { package = "sapling-crypto", version = "0.5", git = "https://github.com/QED-it/sapling-crypto", rev = "b0d2e4c1139f23fb7e9e410f2e5d986d5662ee03" }
orchard = { version = "0.11.0", git = "https://github.com/QED-it/orchard", rev = "0982ff66e15e3e1e0566e4c9cd688d9d0e5d4f81" }
orchard = { version = "0.11.0", git = "https://github.com/QED-it/orchard", branch = "fixes_for_librustzcash" }
7 changes: 4 additions & 3 deletions pczt/tests/end_to_end.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ use nonempty::NonEmpty;
#[cfg(zcash_unstable = "nu7")]
use orchard::{
issuance::compute_asset_desc_hash,
keys::{IssuanceAuthorizingKey, IssuanceValidatingKey},
issuance_auth::{IssueAuthKey, IssueValidatingKey},
note::{RandomSeed, Rho},
orchard_flavor::OrchardZSA,
value::NoteValue,
Expand All @@ -45,6 +45,7 @@ use orchard::{
use zcash_protocol::consensus::Network::RegtestNetwork;

static ORCHARD_PROVING_KEY: OnceLock<orchard::circuit::ProvingKey> = OnceLock::new();
#[allow(dead_code)]
static ORCHARD_ZSA_PROVING_KEY: OnceLock<orchard::circuit::ProvingKey> = OnceLock::new();

fn orchard_proving_key() -> &'static orchard::circuit::ProvingKey {
Expand Down Expand Up @@ -495,8 +496,8 @@ fn zsa_to_zsa() {
note
};

let isk = IssuanceAuthorizingKey::from_bytes([1; 32]).unwrap();
let ik = IssuanceValidatingKey::from(&isk);
let isk = IssueAuthKey::from_bytes(&[1u8; 32]).unwrap();
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer to specify that it is a ZSASchnorr validating key to avoid any ambiguity.

Suggested change
let isk = IssueAuthKey::from_bytes(&[1u8; 32]).unwrap();
let isk = IssueAuthKey::<ZSASchnorr>::from_bytes(&[1u8; 32]).unwrap();

let ik = IssueValidatingKey::from(&isk);
let value = orchard::value::NoteValue::from_raw(1_000_000);
let asset = AssetBase::derive(
&ik,
Expand Down
20 changes: 11 additions & 9 deletions zcash_primitives/src/transaction/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,12 @@ use {
},
};

use orchard::builder::BundleType;
use orchard::note::AssetBase;
use orchard::orchard_flavor::OrchardVanilla;
use orchard::Address;
use orchard::{
builder::{BuildError::BundleTypeNotSatisfiable, BundleType},
note::AssetBase,
orchard_flavor::OrchardVanilla,
Address,
};

#[cfg(feature = "transparent-inputs")]
use ::transparent::builder::TransparentInputInfo;
Expand All @@ -62,13 +64,13 @@ use crate::{
fees::FutureFeeRule,
},
};
use orchard::builder::BuildError::BundleTypeNotSatisfiable;

#[cfg(zcash_unstable = "nu7")]
use orchard::{
bundle::Authorization,
issuance,
issuance::{IssueBundle, IssueInfo},
keys::{IssuanceAuthorizingKey, IssuanceValidatingKey},
issuance_auth::{IssueAuthKey, IssueValidatingKey, ZSASchnorr},
note::Nullifier,
orchard_flavor::OrchardZSA,
};
Expand Down Expand Up @@ -380,7 +382,7 @@ pub struct Builder<'a, P, U: sapling::builder::ProverProgress> {
#[cfg(zcash_unstable = "nu7")]
issuance_builder: Option<IssueBundle<issuance::AwaitingNullifier>>,
#[cfg(zcash_unstable = "nu7")]
issuance_isk: Option<orchard::keys::IssuanceAuthorizingKey>,
issuance_isk: Option<orchard::issuance_auth::IssueAuthKey<ZSASchnorr>>,
#[cfg(zcash_unstable = "zfuture")]
tze_builder: TzeBuilder<'a, TransactionData<Unauthorized>>,
#[cfg(not(zcash_unstable = "zfuture"))]
Expand Down Expand Up @@ -508,7 +510,7 @@ impl<'a, P: consensus::Parameters> Builder<'a, P, ()> {
#[cfg(zcash_unstable = "nu7")]
pub fn init_issuance_bundle<FE>(
&mut self,
ik: IssuanceAuthorizingKey,
ik: IssueAuthKey<ZSASchnorr>,
asset_desc_hash: [u8; 32],
issue_info: Option<IssueInfo>,
first_issuance: bool,
Expand All @@ -522,7 +524,7 @@ impl<'a, P: consensus::Parameters> Builder<'a, P, ()> {
}

let (bundle, _) = IssueBundle::new(
IssuanceValidatingKey::from(&ik),
IssueValidatingKey::from(&ik),
asset_desc_hash,
issue_info,
first_issuance,
Expand Down
32 changes: 19 additions & 13 deletions zcash_primitives/src/transaction/components/issuance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::encoding::{ReadBytesExt, WriteBytesExt};
use core2::io::{self, Error, ErrorKind, Read, Write};
use nonempty::NonEmpty;
use orchard::issuance::{IssueAction, IssueAuth, IssueBundle, Signed};
use orchard::keys::IssuanceValidatingKey;
use orchard::issuance_auth::{IssueAuthSig, IssueValidatingKey, ZSASchnorr};
use orchard::note::{AssetBase, RandomSeed, Rho};
use orchard::value::NoteValue;
use orchard::{Address, Note};
Expand All @@ -26,24 +26,26 @@ pub fn read_v6_bundle<R: Read>(mut reader: R) -> io::Result<Option<IssueBundle<S
}
}

fn read_ik<R: Read>(mut reader: R) -> io::Result<IssuanceValidatingKey> {
let mut bytes = [0u8; 32];
reader.read_exact(&mut bytes)?;
IssuanceValidatingKey::from_bytes(&bytes).ok_or(Error::new(
ErrorKind::InvalidData,
"Invalid Pallas point for IssuanceValidatingKey",
))
fn read_ik<R: Read>(mut reader: R) -> io::Result<IssueValidatingKey<ZSASchnorr>> {
// Vector::read(&mut reader, |r| r.read_u8())?;
let ik_bytes = Vector::read(&mut reader, |r| r.read_u8())?;
IssueValidatingKey::<ZSASchnorr>::decode(&ik_bytes).map_err(|_| {
Error::new(
ErrorKind::InvalidData,
"Invalid Pallas point for IssueValidatingKey",
)
})
}

fn read_authorization<R: Read>(mut reader: R) -> io::Result<Signed> {
let mut bytes = [0u8; 64];
reader.read_exact(&mut bytes).map_err(|_| {
let sig_bytes = Vector::read(&mut reader, |r| r.read_u8())?;
let sig = IssueAuthSig::<ZSASchnorr>::decode(&sig_bytes).map_err(|_| {
Error::new(
ErrorKind::InvalidData,
"Invalid signature for IssuanceAuthorization",
)
})?;
Ok(Signed::from_data(bytes))
Ok(Signed::from_sig(sig))
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer to call this function new rather than from_sig.

}

fn read_action<R: Read>(mut reader: R) -> io::Result<IssueAction> {
Expand Down Expand Up @@ -125,8 +127,12 @@ pub fn write_v6_bundle<W: Write>(
) -> io::Result<()> {
if let Some(bundle) = bundle {
Vector::write_nonempty(&mut writer, bundle.actions(), write_action)?;
writer.write_all(&bundle.ik().to_bytes())?;
writer.write_all(&<[u8; 64]>::from(bundle.authorization().signature()))?;
Vector::write(&mut writer, &bundle.ik().encode(), |w, b| w.write_u8(*b))?;
Vector::write(
&mut writer,
&bundle.authorization().signature().encode(),
|w, b| w.write_u8(*b),
)?;
} else {
CompactSize::write(&mut writer, 0)?;
}
Expand Down
Loading
Loading