mirror of
https://github.com/Qortal/pirate-librustzcash.git
synced 2025-02-11 17:55:46 +00:00
derive Debug for various structs
This commit is contained in:
parent
34ca75cceb
commit
012d43bc8c
@ -25,6 +25,7 @@ use std::io::{
|
||||
//
|
||||
// See "Twisted Edwards Curves Revisited"
|
||||
// Huseyin Hisil, Kenneth Koon-Ho Wong, Gary Carter, and Ed Dawson
|
||||
#[derive(Debug)]
|
||||
pub struct Point<E: JubjubEngine, Subgroup> {
|
||||
x: E::Fr,
|
||||
y: E::Fr,
|
||||
|
@ -43,6 +43,7 @@ pub mod fs;
|
||||
pub mod tests;
|
||||
|
||||
/// Point of unknown order.
|
||||
#[derive(Debug)]
|
||||
pub enum Unknown { }
|
||||
|
||||
/// 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)
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
pub struct Signature {
|
||||
rbar: [u8; 32],
|
||||
sbar: [u8; 32],
|
||||
@ -37,6 +37,7 @@ pub struct Signature {
|
||||
|
||||
pub struct PrivateKey<E: JubjubEngine>(pub E::Fs);
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct PublicKey<E: JubjubEngine>(pub Point<E, Unknown>);
|
||||
|
||||
impl Signature {
|
||||
|
@ -58,6 +58,7 @@ impl Amount {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Script(pub Vec<u8>);
|
||||
|
||||
impl Script {
|
||||
@ -71,6 +72,7 @@ impl Script {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct OutPoint {
|
||||
hash: [u8; 32],
|
||||
n: u32,
|
||||
@ -90,6 +92,7 @@ impl OutPoint {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct TxIn {
|
||||
pub prevout: OutPoint,
|
||||
script_sig: Script,
|
||||
@ -116,6 +119,7 @@ impl TxIn {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct TxOut {
|
||||
value: Amount,
|
||||
script_pubkey: Script,
|
||||
@ -147,6 +151,16 @@ pub struct SpendDescription {
|
||||
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 {
|
||||
pub fn read<R: Read>(mut reader: &mut R) -> io::Result<Self> {
|
||||
// Consensus rules (§4.4):
|
||||
@ -211,6 +225,16 @@ pub struct OutputDescription {
|
||||
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 {
|
||||
pub fn read<R: Read>(mut reader: &mut R) -> io::Result<Self> {
|
||||
// Consensus rules (§4.5):
|
||||
@ -268,6 +292,15 @@ enum SproutProof {
|
||||
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 {
|
||||
vpub_old: Amount,
|
||||
vpub_new: Amount,
|
||||
@ -281,6 +314,30 @@ pub struct JSDescription {
|
||||
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 {
|
||||
pub fn read<R: Read>(mut reader: R, use_groth: bool) -> io::Result<Self> {
|
||||
// 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;
|
||||
|
||||
/// A Zcash transaction.
|
||||
#[derive(Debug)]
|
||||
pub struct Transaction(TransactionData);
|
||||
|
||||
impl Deref for Transaction {
|
||||
@ -48,6 +49,41 @@ pub struct TransactionData {
|
||||
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 {
|
||||
pub fn new() -> Self {
|
||||
TransactionData {
|
||||
|
Loading…
x
Reference in New Issue
Block a user