Zebra: Finish refining all primitive types brought in by `Transaction` data.

Created on 28 Nov 2019  Â·  8Comments  Â·  Source: ZcashFoundation/zebra

Following from https://github.com/ZcashFoundation/zebra/pull/105#issue-342371155:

  1. Many of the types in the structures that make up a Transaction need to be refined to assign them semantic meaning. The complete list can be found by running rg 'XXX refine' -A 2 in zebra/zebra-chain/src. Fleshing out many of these types will require further work – for instance, the Zcash-flavored Ed25519 pubkey in the JoinSplit data requires #109.

This issue should be closed when there are no more refinements left to do. Once #105 is merged, I will replace this description with a checklist of types to refine.

  • [x] an Amount type (#126)
zebra-chain/src/transaction.rs
81:        // XXX refine this to an Amount type.
82-        value_balance: i64,
zebra-chain/src/transaction/joinsplit.rs
54:    /// XXX refine to an Amount
55-    vpub_old: u64,
--
59:    /// XXX refine to an Amount
60-    vpub_new: u64,
zebra-chain/src/transaction/transparent.rs
51:    // XXX refine to Amount ?
52-    pub value: u64,
53-
  • [x] a (Sprout?) (Sapling?) nullifier type (#287, #288)
zebra-chain/src/transaction/joinsplit.rs
16:    /// XXX refine type
17-    pub nullifier: [u8; 32],
zebra-chain/src/transaction/shielded_data.rs
17:    /// XXX refine to a specific type.
18-    pub nullifier: [u8; 32],

One of these is a nullifier for Sprout, while the other is for Sapling – should these be the same type or different types?

  • [x] a MAC type
zebra-chain/src/transaction/joinsplit.rs
20:    /// XXX refine type
21-    pub vmac: [u8; 32],
  • [x] note commitment type (sprout) (#36)
zebra-chain/src/transaction/joinsplit.rs
37:    /// XXX refine type
38-    pub commitment: [u8; 32],
  • [x] types related to note encryption (sprout):
zebra-chain/src/transaction/joinsplit.rs
41:    /// XXX refine type
42-    /// XXX this should be a [u8; 601] but we need trait impls.
43-    pub enc_ciphertext: Vec<u8>,
  • [x] a sprout commitment tree root (#36)
zebra-chain/src/transaction/joinsplit.rs
65:    /// XXX refine type
66-    anchor: [u8; 32],
  • [x] an X25519 key (#313):
zebra-chain/src/transaction/joinsplit.rs
69:    /// XXX refine to an x25519-dalek type?
70-    ephemeral_key: [u8; 32],
  • [x] an Ed25519 key (#109)
zebra-chain/src/transaction/joinsplit.rs
88:    // XXX refine to a Zcash-flavored Ed25519 pubkey.
89-    pub pub_key: [u8; 32],
90-    /// The JoinSplit signature.
91:    // XXX refine to a Zcash-flavored Ed25519 signature.
92-    // for now it's [u64; 8] rather than [u8; 64] to get trait impls
93-    pub sig: [u64; 8],
  • [x] a sapling value commitment type:
zebra-chain/src/transaction/shielded_data.rs
11:    /// XXX refine to a specific type.
12-    pub cv: [u8; 32],
  • [x] RedJubjub types (#125)
21:    /// XXX refine to a specific type.
22-    pub rk: [u8; 32],
23-    /// The ZK spend proof.
--
30:    /// XXX refine to a specific type: redjubjub signature?
31-    /// XXX for now it's [u64; 8] instead of [u8; 64] to get trait impls
32-    pub spend_auth_sig: [u64; 8],
--
77:    // XXX refine this type to a RedJubjub signature.
78-    // for now it's [u64; 8] rather than [u8; 64] to get trait impls
79-    pub binding_sig: [u64; 8],
  • [x] Jubjub key agreement types: #361
zebra-chain/src/transaction/shielded_data.rs
50:    /// XXX refine to a specific type.
51-    pub ephemeral_key: [u8; 32],
  • [x] note commitment type (sapling) (#36)
zebra-chain/src/transaction/shielded_data.rs
46:    /// XXX refine to a specific type.
47-    pub cmu: [u8; 32],
  • [x] note encryption (sapling):
zebra-chain/src/transaction/shielded_data.rs
54:    /// XXX refine to a specific type.
55-    /// XXX this is a Vec<u8> rather than a [u8; 580] to get trait impls
56-    pub enc_ciphertext: Vec<u8>,
--
59:    /// XXX refine to a specific type.
60-    /// XXX this is a [u64; 10] rather than a [u8; 80] to get trait impls
61-    pub out_ciphertext: [u64; 10],
--
A-dependencies A-rust

Most helpful comment

types related to note encryption (sprout):

This will be done better than existing when the proptest branch is merged in (they are basically dumb stub types for now but they are better than just Vec<u8>).

note encryption (sapling):

Same here.

All 8 comments

Requires #125.

Requires #126.

Updated the issue description to include a full list of types.

The ed25519-zebra crate will expose these types and can be refined when it is published: https://github.com/ZcashFoundation/ed25519-zebra

types related to note encryption (sprout):

This will be done better than existing when the proptest branch is merged in (they are basically dumb stub types for now but they are better than just Vec<u8>).

note encryption (sapling):

Same here.

Ticked the Ed25519 box; I think that the key agreement types should probably be part of the note encryption implementation.

As part of our Sprout key/address work, we're bringing in x25519_dalek and using *Secret and PublicKey types; the joinsplit ephemeral key type here should probably a x25519_dalek::PublicKey

Also taking over the rest of this issue @dconnolly

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hdevalence picture hdevalence  Â·  4Comments

dconnolly picture dconnolly  Â·  5Comments

hdevalence picture hdevalence  Â·  4Comments

yaahc picture yaahc  Â·  5Comments

dconnolly picture dconnolly  Â·  4Comments