Skip to content
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

Use RedJubjub types in zebra-chain. #142

Merged
merged 1 commit into from
Dec 12, 2019
Merged
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
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>,
Copy link
Contributor

Choose a reason for hiding this comment

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

❤️

/// 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>,
Copy link
Contributor

Choose a reason for hiding this comment

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

❤️

}

/// 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>,
Copy link
Contributor

Choose a reason for hiding this comment

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

❤️

}