Conversation
* Added .circleci/config.yml
Implements the issuer keys as
IssuerAuthorizingKey -> isk
IssuerVerifyingKey -> ik
Test vectors generated with zcash_test_vectors repo
* Added NoteType to Notes * Added NoteType to value commitment derivation
* Circleci project setup (#1) * Added .circleci/config.yml * Added NoteType to Notes * reformated file * updated `derive` for NoteType * added note_type to value commit derivation * rustfmt * updated ci config * updated ci config * updated ci config * updated derive for note_type * added test for arb note_type * added test for `native` note type * zsa-note-encryption: introduce AssetType and encode and decode it in note plaintexts * zsa-note-encryption: extend the size of compact notes to include asset_type * fixed clippy warrnings * rustfmt * zsa-note-encryption: document parsing requirement * zsa-note-encryption: revert support of ZSA compact action * zsa_value: add NoteType method is_native * zsa-note-encryption: remove dependency on changes in the other crate * zsa-note-encryption: extract memo of ZSA notes * zsa-note-encryption: tests (zcash_test_vectors 77c73492) * zsa-note-encryption: simplify roundtrip test * zsa-note-encryption: more test vectors (zcash_test_vectors c10da464) * Circleci project setup (#1) * Added .circleci/config.yml * issuer keys implementation (#5) Implements the issuer keys as IssuerAuthorizingKey -> isk IssuerVerifyingKey -> ik Test vectors generated with zcash_test_vectors repo * Added NoteType to Notes (#2) * Added NoteType to Notes * Added NoteType to value commitment derivation * zsa-note-encryption: use both native and ZSA in proptests * zsa-note-encryption: test vector commit 51398c93 * zsa-note-encryption: fix after merge Co-authored-by: Paul <3682187+PaulLaux@users.noreply.github.com> Co-authored-by: Paul <lauxpaul@protonmail.com> Co-authored-by: Aurélien Nicolas <info@nau.re> Co-authored-by: Daniel Benarroch <danielbenarroch92@gmail.com>
+ Updated test bsk_consistent_with_bvk to verify mixed note types. + Added NoteType support to the builder and the bundle. + added split_flag to SpentInfo and as input to the Circuit (currently commented out) + added conditional cv_sum calculation (currently commented out) + added padding to actions
- added IssueBundle and IssueAction - added a builder for IssueBundle - added verify_issue_bundle() for consensus verification. - unit tests.
added tests in `tests/zsa.rs`
* disabled split notes and proof check for zsa transfer
* fixes and suggestions * changed "issuer" to "issuance" as per zcash#356 (comment) * terminology fixes * updated naming
* rename 2 note_type -> asset as per zcash#356 (comment) * added a dedicated type for "IssuanceAuth" * disabled codecov github action due to bad behavior. * extracted "is_asset_desc_of_valid_size()" into asset_id.rs
* improved `verify_issue_bundle()`
PaulLaux
left a comment
There was a problem hiding this comment.
Good first run, added the comments. In addition:
- Avoid the term
burntsince it is past tense. Useburnorfor_burnorto_burn.
src/builder.rs
Outdated
| recipients: Vec<RecipientInfo>, | ||
| flags: Flags, | ||
| anchor: Anchor, | ||
| assets_burnt: Vec<(AssetId, i64)>, |
There was a problem hiding this comment.
Vec seems inappropriate since we can have multiple burns for the same asset. I would go with:
pub struct Builder {
spends: Vec<SpendInfo>,
recipients: Vec<RecipientInfo>,
burn: HashMap<AssetId, ValueSum>,
flags: Flags,
anchor: Anchor,
}Order is also important, let's have flags and anchor at the end.
There was a problem hiding this comment.
I was thinking its more of a feature that you can burn different amounts separately, but I agree that use case for that will be pretty artificial
Regarding ValueSum - yeah, actually first I implemented with it and then decided to simplify
src/bundle.rs
Outdated
| value_balance: V, | ||
| anchor: Anchor, | ||
| authorization: T, | ||
| assets_burnt: Vec<(AssetId, i64)>, |
There was a problem hiding this comment.
Let's keep similar terminology and order:
/// A bundle of actions to be applied to the ledger.
#[derive(Clone)]
pub struct Bundle<T: Authorization, V> {
/// The list of actions that make up this bundle.
actions: NonEmpty<Action<T::SpendAuth>>,
/// Orchard-specific transaction-level flags for this bundle.
flags: Flags,
/// The net value moved out of the Orchard shielded pool.
///
/// This is the sum of Orchard spends minus the sum of Orchard outputs.
value_balance: V,
/// Assets intended for burning.
burn: Vec<(AssetId, V)>,
/// The root of the Orchard commitment tree that this bundle commits to.
anchor: Anchor,
/// The authorization for this bundle.
authorization: T,
}
tests/zsa.rs
Outdated
| ) | ||
| }); | ||
| assets_to_burn | ||
| .iter() |
There was a problem hiding this comment.
try into_iter() to avoid dereferance.
PaulLaux
left a comment
There was a problem hiding this comment.
This is better, we are getting there.
src/builder.rs
Outdated
|
|
||
| /// 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> { | ||
| if asset == AssetId::native() { |
There was a problem hiding this comment.
if asset.is_native().into()
src/builder.rs
Outdated
| let sum = (*self.burn.get(&asset).unwrap_or(&ValueSum::zero()) + value) | ||
| .ok_or("Orchard value operation overflowed")?; |
There was a problem hiding this comment.
Let's have
let cur = *self.burn.get(&asset).unwrap_or(&ValueSum::zero());
let sum = (cur + value).ok_or("Orchard ValueSum operation overflowed")?;for clarity.
src/builder.rs
Outdated
| let value_balance = pre_actions | ||
| let native_value_balance = pre_actions | ||
| .iter() | ||
| .filter(|action| action.spend.note.asset() == AssetId::native()) |
There was a problem hiding this comment.
asset().is_native().into()
src/builder.rs
Outdated
| .and_then(|i| { | ||
| V::try_from(i).map_err(|_| Error::ValueSum(value::OverflowError)) | ||
| }) | ||
| .unwrap(); |
There was a problem hiding this comment.
unwrap() might panic, you should check and propagate with ? or similar.
src/builder.rs
Outdated
| let v_value: V = i64::try_from(value) | ||
| .map_err(Error::ValueSum) | ||
| .and_then(|i| { | ||
| V::try_from(i).map_err(|_| Error::ValueSum(value::OverflowError)) | ||
| }) |
There was a problem hiding this comment.
extract functionality here and in result_native_value_balance into somthing like
fn into<V: TryFrom<V>>(v: ValueSum) -> Result<V, Error> {
i64::try_from(v)
.map_err(Error::ValueSum)
.and_then(|i| V::try_from(i).map_err(Error::ValueSum(OverflowError)))
}Located as part of the ValueSum functionality.
src/value.rs
Outdated
| AssetId::native(), | ||
| )) | ||
| ) | ||
| - arb_values_burnt |
There was a problem hiding this comment.
Replace burnt into to_burn across the entire PR.
|
|
||
| proptest! { | ||
| #[test] | ||
| fn bsk_consistent_with_bvk_native_with_zsa_transfer_and_burning( |
There was a problem hiding this comment.
Let's unify everything into one test that include 4 calls
_bsk_consistent_with_bvk(&native_values, &[], &[], &[]);
_bsk_consistent_with_bvk(&native_values, &[], &[], &assets_burnt);
_bsk_consistent_with_bvk(&native_values, &arb_values, &neg_trapdoors, &[]);
_bsk_consistent_with_bvk(&native_values, &arb_values, &neg_trapdoors, &assets_burnt);There was a problem hiding this comment.
Please rename:
_bsk_consistent_with_bvk into check_binding_signature()
arb_values into asset_values
assets_burnt into burn_values
| .unwrap(); | ||
| }); | ||
| assert!(result.is_err()); | ||
|
|
There was a problem hiding this comment.
use consistent style: zsa_note1 or zsa_spend_1 not both.
tests/zsa.rs
Outdated
| let value_to_burn: u64 = 3; | ||
| let value_to_transfer: u64 = zsa_spend_1.note.value().inner() - value_to_burn; |
There was a problem hiding this comment.
redundant :u64 (all occurrences)
tests/zsa.rs
Outdated
| ) | ||
| .unwrap(); | ||
|
|
||
| // 10. Burn a part of ZSA assets |
There was a problem hiding this comment.
Burn a partial amount of the ZSA assets
5ec6aee to
9405f80
Compare
# Conflicts: # .circleci/config.yml # .github/workflows/bench.yml # .github/workflows/ci.yml # .github/workflows/lints-stable.yml # Cargo.toml # README.md # benches/note_decryption.rs # rust-toolchain # src/builder.rs # src/bundle.rs # src/note_encryption.rs # src/value.rs # tests/zsa.rs
|
Closed in favor of #35 |
Added a method to add assets to burn to the Builder
bvkcomputation now includes the burnt assetsAdded Tests for
bsk/bvkconsistency for burningAdded E2E tests for assets burning