Skip to content

Commit

Permalink
Use RedJubjub types in zebra-chain. (#142)
Browse files Browse the repository at this point in the history
  • Loading branch information
hdevalence authored and dconnolly committed Dec 12, 2019
1 parent c013895 commit 4315235
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 11 deletions.
68 changes: 68 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions zebra-chain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ byteorder = "1.3"
chrono = "0.4"
hex = "0.4"
sha2 = "0.8"
redjubjub = "0.1"

[dev-dependencies]
proptest = "0.9"
2 changes: 2 additions & 0 deletions zebra-chain/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ pub mod proofs;
pub mod serialization;
pub mod transaction;
pub mod types;

pub use redjubjub;
17 changes: 6 additions & 11 deletions zebra-chain/src/transaction/shielded_data.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// XXX this name seems too long?
use crate::note_commitment_tree::SaplingNoteTreeRootHash;

use crate::redjubjub::{self, Binding, SpendAuth};

/// A _Spend Description_, as described in [protocol specification §7.3][ps].
///
/// [ps]: https://zips.z.cash/protocol/protocol.pdf#spendencoding
Expand All @@ -17,19 +19,14 @@ pub struct SpendDescription {
/// XXX refine to a specific type.
pub nullifier: [u8; 32],
/// The randomized public key for `spend_auth_sig`.
///
/// XXX refine to a specific type.
pub rk: [u8; 32],
pub rk: redjubjub::PublicKeyBytes<SpendAuth>,
/// The ZK spend proof.
///
/// XXX add proof types.
/// XXX for now it's [u64; 24] instead of [u8; 192] to get trait impls
pub zkproof: [u64; 24],
/// A signature authorizing this spend.
///
/// XXX refine to a specific type: redjubjub signature?
/// XXX for now it's [u64; 8] instead of [u8; 64] to get trait impls
pub spend_auth_sig: [u64; 8],
pub spend_auth_sig: redjubjub::Signature<SpendAuth>,
}

/// A _Output Description_, as described in [protocol specification §7.4][ps].
Expand All @@ -47,7 +44,7 @@ pub struct OutputDescription {
pub cmu: [u8; 32],
/// An encoding of an ephemeral Jubjub public key.
///
/// XXX refine to a specific type.
/// XXX refine to a Jubjub key agreement type, not RedJubjub.
pub ephemeral_key: [u8; 32],
/// A ciphertext component for the encrypted output note.
///
Expand All @@ -74,7 +71,5 @@ pub struct ShieldedData {
/// A sequence of shielded outputs for this transaction.
pub shielded_outputs: Vec<OutputDescription>,
/// A signature on the transaction hash.
// XXX refine this type to a RedJubjub signature.
// for now it's [u64; 8] rather than [u8; 64] to get trait impls
pub binding_sig: [u64; 8],
pub binding_sig: redjubjub::Signature<Binding>,
}

0 comments on commit 4315235

Please sign in to comment.