-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nu7 implementation #65
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added some minor comments but I have the felling the the diff is incorrect, maybe because all the upstream commits that should not be there.
# run: rustup target add ${{ matrix.target }} | ||
# - name: Build for target | ||
# working-directory: ./ci-build | ||
# run: cargo build --verbose --target ${{ matrix.target }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why comment out?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We decided not to touch zcah_client_xxx crates for now and this target requires them
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so let's remove just the relevant lines:
name: Add zcash_client_backend as a dependency of the synthetic crate
working-directory: ./ci-build
run: cargo add --features lightwalletd-tonic --path ../crates/zcash_client_backend
Seems that it can work
…te (which supports Vanilla and ZSA) - but for now zcash_primitives is not generalised itself and pinned to Vanilla only
…te (which supports Vanilla and ZSA) - but for now zcash_primitives is not generalised itself and pinned to Vanilla only
This PR updates `librustzcash` to accommodate the recent refactoring changes in the `orchard` crate. The specific changes include: - Renamed all references from `orchard_flavors` to `orchard_flavor` to match the new module name. - Updated the `OrchardDomain` trait references to `OrchardDomainCommon` to reflect the trait renaming. - Adjusted the `Bundle` structure to use the fixed `NoteValue` type for the `burn` field, replacing the previous generic argument. - Refactored associated code to align with the new structure and naming conventions in the `orchard` crate. - Switched from the `orchardzsa-backward-compatibility-0.8.0-ak` to `orchardzsa-backward-compatibility-0.8.0` branch in `Cargo.toml` to use the latest version of the `orchard` crate. --------- Co-authored-by: Dmitry Demin <[email protected]>
) This PR makes the following changes: - reordering of the component fields in `read_action` and `write_action` in issuance in order to make them spec compliant. - It sets some of the constant values for NU7 in a way that is consistent with the generated test vectors from the Python reference implementation (See QED-it/zcash-test-vectors#22 for the changes to the Python reference implementation). - Some changes are made to function names to reflect the shift from preparing ZSAs for V7 rather than V6. - There are changes to the tests to use the `zcash_unstable` flag in order to cover both ZSA and vanilla Orchard behavior. - The test vectors are also expanded to include both the V5 vectors, and the V7 vectors (behind a `zcash_unstable` flag).
04ecb20
to
f160f25
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good start, added some comments, mostly around builder.
In addition:
- fix diff and redundant commits in the list
- rename
txv7
andv7
totxv6
andv6
respectively.
"Sprout components cannot be present when serializing to the V7 transaction format.", | ||
)); | ||
} | ||
self.write_v5_header(&mut writer)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename to write_header()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's their naming, shall we change it anyway?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well yes, the functionality is now extended to v6
} | ||
self.write_v5_header(&mut writer)?; | ||
self.write_transparent(&mut writer)?; | ||
self.write_v5_sapling(&mut writer)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename to write_sapling()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well yes, the functionality is now extended to v6
_orchard_zsa_bundle in orchard_testing::arb_zsa_bundle_for_version(version), | ||
_issue_bundle in issuance::testing::arb_bundle_for_version(version), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why the _
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in these proptests I'm not sure its possible to hide it behind feature flag, so I want avoid clippy bitching at unused arguments for non-nu6 builds
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added some comments. Most impotently try to stick to orchard::issuance
api
#[allow(unused_mut)] | ||
let mut upper = None; | ||
#[cfg(zcash_unstable = "nu6")] | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure we need the scope? (x3)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, looks ugly af, but I'm not sure how to do it better. Open to ideas...
use super::components::amount::NonNegativeAmount; | ||
use super::components::sapling::zip212_enforcement; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's try to avoid moving (to line 41) if not needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Found them a better place
@@ -345,7 +403,13 @@ impl<A: Authorization> TransactionData<A> { | |||
transparent_bundle: Option<transparent::Bundle<A::TransparentAuth>>, | |||
sprout_bundle: Option<sprout::Bundle>, | |||
sapling_bundle: Option<sapling::Bundle<A::SaplingAuth, Amount>>, | |||
orchard_bundle: Option<orchard::Bundle<A::OrchardAuth, Amount>>, | |||
orchard_bundle: Option<orchard::Bundle<A::OrchardAuth, Amount, OrchardVanilla>>, | |||
#[cfg(zcash_unstable = "nu6" /* TODO nu7 */ )] orchard_zsa_bundle: Option< |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please make sure a new line after the flag (all occurrences )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd be happy but cargo fmt disagrees
#[cfg(zcash_unstable = "nu6")] | ||
/* TODO nu7 */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please be consistent about the flag syntax
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup, weird, fixed
A::OrchardZsaAuth, | ||
B::OrchardZsaAuth, | ||
>, | ||
#[cfg(zcash_unstable = "nu6" /* TODO nu7 */ )] f_issue: impl issuance::MapIssueAuth< |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cargo fmt
let (bundle, meta) = builder | ||
.build(&mut rng) | ||
.map_err(Error::OrchardBuild)? | ||
.unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be outside of if
(before)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we do that Rust will infer OrchardVanilla for the bundle
let flags = read_flags(&mut reader)?; | ||
let value_balance = Transaction::read_amount(&mut reader)?; | ||
let anchor = read_anchor(&mut reader)?; | ||
let proof_bytes = Vector::read(&mut reader, |r| r.read_u8())?; | ||
let actions = NonEmpty::from_vec( | ||
actions_without_auth | ||
.into_iter() | ||
.map(|act| act.try_map(|_| read_signature::<_, redpallas::SpendAuth>(&mut reader))) | ||
.collect::<Result<Vec<_>, _>>()?, | ||
) | ||
.expect("A nonzero number of actions was read from the transaction data."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure I understand the question (replay to previous comment)
@@ -134,21 +181,43 @@ pub fn read_cmx<R: Read>(mut reader: R) -> io::Result<ExtractedNoteCommitment> { | |||
}) | |||
} | |||
|
|||
pub fn read_note_ciphertext<R: Read>(mut reader: R) -> io::Result<TransmittedNoteCiphertext> { | |||
let mut tnc = TransmittedNoteCiphertext { | |||
pub fn read_note_ciphertext<R: Read>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pub fn read_note_ciphertext<R: Read, D: OrchardDomainCommon>(
mut reader: R,
) -> io::Result<TransmittedNoteCiphertext<D>> {
let mut epk = [0; 32];
let mut enc = vec![0u8; D::ENC_CIPHERTEXT_SIZE];
let mut out = [0;80];
reader.read_exact(&mut epk)?;
reader.read_exact(&mut enc)?;
reader.read_exact(&mut out)?;
Ok(TransmittedNoteCiphertext::<D> {
epk_bytes: epk,
enc_ciphertext: <D>::NoteCiphertextBytes::from_slice(&enc).unwrap(),
out_ciphertext: out,
})
}
Ok(tnc) | ||
} | ||
|
||
pub fn read_action_without_auth<R: Read>(mut reader: R) -> io::Result<Action<(), OrchardVanilla>> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pub fn read_action<R: Read, D: OrchardDomainCommon>(mut reader: R) -> io::Result<Action<(), D>> {
let cv_net = read_value_commitment(&mut reader)?;
let nf_old = read_nullifier(&mut reader)?;
let rk = read_verification_key(&mut reader)?;
let cmx = read_cmx(&mut reader)?;
let encrypted_note = read_note_ciphertext(&mut reader)?; // the generic function
Ok(...)
}
This PR updates the `zcash_primitives` crate to align with the recent changes in the `sapling-crypto` crate, which was updated to sync with the latest changes in `zcash_note_encryption`. ### Changes: - Updated the usage of `enc_ciphertext` to call `.as_ref()` to match the new return type. - Adjusted the import of the `ENC_CIPHERTEXT_SIZE` constant to use the definition from `sapling-crypto` instead of `zcash_note_encryption`, as the constant has been moved to `sapling-crypto`. Co-authored-by: Dmitry Demin <[email protected]>
This updates the test vectors to be of version 6 (as opposed to version 7). It also provides a new file for the V6 test vectors, an improvement to having them in the same file but behind feature flags. It provides a error for when the asset description string is not a UTF8 encoding.
Closed in favor of #73 |
ZSA is implemented across all the codebase, including:
TransactionData
now contains 2 extra components -OrchardZsaBundle
andIssueBundle
Serialization/deserialization of the new components
Digests of the new components are taken into account during calculation of
sighash
/txid
.TODO: we are waiting for test vectors and small ordering fixes to be merged to be able to check txid calculation
Nu7 network upgrade is introduced, although currently "nu6" zcash_unstable flag is used to separate ZSA from regular build. All nu7-related "nu6" flags are annotated with /* TODO nu7 */ comment
Builder methods for ZSAs
Wallet-related functionality (
zcash_client_backend
,zcash_client_sqlite
) are disabled since they do not support ZSAs