derive Debug for various structs
This commit is contained in:
@@ -25,6 +25,7 @@ use std::io::{
|
|||||||
//
|
//
|
||||||
// See "Twisted Edwards Curves Revisited"
|
// See "Twisted Edwards Curves Revisited"
|
||||||
// Huseyin Hisil, Kenneth Koon-Ho Wong, Gary Carter, and Ed Dawson
|
// Huseyin Hisil, Kenneth Koon-Ho Wong, Gary Carter, and Ed Dawson
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct Point<E: JubjubEngine, Subgroup> {
|
pub struct Point<E: JubjubEngine, Subgroup> {
|
||||||
x: E::Fr,
|
x: E::Fr,
|
||||||
y: E::Fr,
|
y: E::Fr,
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ pub mod fs;
|
|||||||
pub mod tests;
|
pub mod tests;
|
||||||
|
|
||||||
/// Point of unknown order.
|
/// Point of unknown order.
|
||||||
|
#[derive(Debug)]
|
||||||
pub enum Unknown { }
|
pub enum Unknown { }
|
||||||
|
|
||||||
/// Point of prime order.
|
/// Point of prime order.
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ fn h_star<E: JubjubEngine>(a: &[u8], b: &[u8]) -> E::Fs {
|
|||||||
hash_to_scalar::<E>(b"Zcash_RedJubjubH", a, b)
|
hash_to_scalar::<E>(b"Zcash_RedJubjubH", a, b)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone, Debug)]
|
||||||
pub struct Signature {
|
pub struct Signature {
|
||||||
rbar: [u8; 32],
|
rbar: [u8; 32],
|
||||||
sbar: [u8; 32],
|
sbar: [u8; 32],
|
||||||
@@ -37,6 +37,7 @@ pub struct Signature {
|
|||||||
|
|
||||||
pub struct PrivateKey<E: JubjubEngine>(pub E::Fs);
|
pub struct PrivateKey<E: JubjubEngine>(pub E::Fs);
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct PublicKey<E: JubjubEngine>(pub Point<E, Unknown>);
|
pub struct PublicKey<E: JubjubEngine>(pub Point<E, Unknown>);
|
||||||
|
|
||||||
impl Signature {
|
impl Signature {
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ impl Amount {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct Script(pub Vec<u8>);
|
pub struct Script(pub Vec<u8>);
|
||||||
|
|
||||||
impl Script {
|
impl Script {
|
||||||
@@ -71,6 +72,7 @@ impl Script {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct OutPoint {
|
pub struct OutPoint {
|
||||||
hash: [u8; 32],
|
hash: [u8; 32],
|
||||||
n: u32,
|
n: u32,
|
||||||
@@ -90,6 +92,7 @@ impl OutPoint {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct TxIn {
|
pub struct TxIn {
|
||||||
pub prevout: OutPoint,
|
pub prevout: OutPoint,
|
||||||
script_sig: Script,
|
script_sig: Script,
|
||||||
@@ -116,6 +119,7 @@ impl TxIn {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct TxOut {
|
pub struct TxOut {
|
||||||
value: Amount,
|
value: Amount,
|
||||||
script_pubkey: Script,
|
script_pubkey: Script,
|
||||||
@@ -147,6 +151,16 @@ pub struct SpendDescription {
|
|||||||
pub spend_auth_sig: Signature,
|
pub spend_auth_sig: Signature,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl std::fmt::Debug for SpendDescription {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
|
||||||
|
write!(
|
||||||
|
f,
|
||||||
|
"SpendDescription(cv = {:?}, anchor = {:?}, nullifier = {:?}, rk = {:?}, spend_auth_sig = {:?})",
|
||||||
|
self.cv, self.anchor, self.nullifier, self.rk, self.spend_auth_sig
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl SpendDescription {
|
impl SpendDescription {
|
||||||
pub fn read<R: Read>(mut reader: &mut R) -> io::Result<Self> {
|
pub fn read<R: Read>(mut reader: &mut R) -> io::Result<Self> {
|
||||||
// Consensus rules (§4.4):
|
// Consensus rules (§4.4):
|
||||||
@@ -211,6 +225,16 @@ pub struct OutputDescription {
|
|||||||
pub zkproof: [u8; GROTH_PROOF_SIZE],
|
pub zkproof: [u8; GROTH_PROOF_SIZE],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl std::fmt::Debug for OutputDescription {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
|
||||||
|
write!(
|
||||||
|
f,
|
||||||
|
"OutputDescription(cv = {:?}, cmu = {:?}, ephemeral_key = {:?})",
|
||||||
|
self.cv, self.cmu, self.ephemeral_key
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl OutputDescription {
|
impl OutputDescription {
|
||||||
pub fn read<R: Read>(mut reader: &mut R) -> io::Result<Self> {
|
pub fn read<R: Read>(mut reader: &mut R) -> io::Result<Self> {
|
||||||
// Consensus rules (§4.5):
|
// Consensus rules (§4.5):
|
||||||
@@ -268,6 +292,15 @@ enum SproutProof {
|
|||||||
PHGR([u8; PHGR_PROOF_SIZE]),
|
PHGR([u8; PHGR_PROOF_SIZE]),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl std::fmt::Debug for SproutProof {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
|
||||||
|
match self {
|
||||||
|
SproutProof::Groth(_) => write!(f, "SproutProof::Groth"),
|
||||||
|
SproutProof::PHGR(_) => write!(f, "SproutProof::PHGR"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub struct JSDescription {
|
pub struct JSDescription {
|
||||||
vpub_old: Amount,
|
vpub_old: Amount,
|
||||||
vpub_new: Amount,
|
vpub_new: Amount,
|
||||||
@@ -281,6 +314,30 @@ pub struct JSDescription {
|
|||||||
ciphertexts: [[u8; 601]; ZC_NUM_JS_OUTPUTS],
|
ciphertexts: [[u8; 601]; ZC_NUM_JS_OUTPUTS],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl std::fmt::Debug for JSDescription {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
|
||||||
|
write!(
|
||||||
|
f,
|
||||||
|
"JSDescription(
|
||||||
|
vpub_old = {:?}, vpub_new = {:?},
|
||||||
|
anchor = {:?},
|
||||||
|
nullifiers = {:?},
|
||||||
|
commitments = {:?},
|
||||||
|
ephemeral_key = {:?},
|
||||||
|
random_seed = {:?},
|
||||||
|
macs = {:?})",
|
||||||
|
self.vpub_old,
|
||||||
|
self.vpub_new,
|
||||||
|
self.anchor,
|
||||||
|
self.nullifiers,
|
||||||
|
self.commitments,
|
||||||
|
self.ephemeral_key,
|
||||||
|
self.random_seed,
|
||||||
|
self.macs
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl JSDescription {
|
impl JSDescription {
|
||||||
pub fn read<R: Read>(mut reader: R, use_groth: bool) -> io::Result<Self> {
|
pub fn read<R: Read>(mut reader: R, use_groth: bool) -> io::Result<Self> {
|
||||||
// Consensus rule (§4.3): Canonical encoding is enforced here
|
// Consensus rule (§4.3): Canonical encoding is enforced here
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ const SAPLING_VERSION_GROUP_ID: u32 = 0x892F2085;
|
|||||||
const SAPLING_TX_VERSION: u32 = 4;
|
const SAPLING_TX_VERSION: u32 = 4;
|
||||||
|
|
||||||
/// A Zcash transaction.
|
/// A Zcash transaction.
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct Transaction(TransactionData);
|
pub struct Transaction(TransactionData);
|
||||||
|
|
||||||
impl Deref for Transaction {
|
impl Deref for Transaction {
|
||||||
@@ -48,6 +49,41 @@ pub struct TransactionData {
|
|||||||
pub binding_sig: Option<Signature>,
|
pub binding_sig: Option<Signature>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl std::fmt::Debug for TransactionData {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
|
||||||
|
write!(
|
||||||
|
f,
|
||||||
|
"TransactionData(
|
||||||
|
overwintered = {:?},
|
||||||
|
version = {:?},
|
||||||
|
version_group_id = {:?},
|
||||||
|
vin = {:?},
|
||||||
|
vout = {:?},
|
||||||
|
lock_time = {:?},
|
||||||
|
expiry_height = {:?},
|
||||||
|
value_balance = {:?},
|
||||||
|
shielded_spends = {:?},
|
||||||
|
shielded_outputs = {:?},
|
||||||
|
joinsplits = {:?},
|
||||||
|
joinsplit_pubkey = {:?},
|
||||||
|
binding_sig = {:?})",
|
||||||
|
self.overwintered,
|
||||||
|
self.version,
|
||||||
|
self.version_group_id,
|
||||||
|
self.vin,
|
||||||
|
self.vout,
|
||||||
|
self.lock_time,
|
||||||
|
self.expiry_height,
|
||||||
|
self.value_balance,
|
||||||
|
self.shielded_spends,
|
||||||
|
self.shielded_outputs,
|
||||||
|
self.joinsplits,
|
||||||
|
self.joinsplit_pubkey,
|
||||||
|
self.binding_sig
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl TransactionData {
|
impl TransactionData {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
TransactionData {
|
TransactionData {
|
||||||
|
|||||||
Reference in New Issue
Block a user