mirror of
https://github.com/serai-dex/serai.git
synced 2024-12-22 19:49:22 +00:00
Add PartialEq to structs
This commit is contained in:
parent
d10c6e16dc
commit
d67d6f2f98
13 changed files with 28 additions and 25 deletions
|
@ -3,7 +3,7 @@ use crate::{
|
|||
transaction::Transaction
|
||||
};
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
pub struct BlockHeader {
|
||||
pub major_version: u64,
|
||||
pub minor_version: u64,
|
||||
|
@ -34,7 +34,7 @@ impl BlockHeader {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
pub struct Block {
|
||||
pub header: BlockHeader,
|
||||
pub miner_tx: Transaction,
|
||||
|
|
|
@ -6,7 +6,7 @@ use curve25519_dalek::{scalar::Scalar, edwards::EdwardsPoint};
|
|||
|
||||
use crate::{Commitment, wallet::TransactionError, serialize::*};
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
pub struct Bulletproofs {
|
||||
pub A: EdwardsPoint,
|
||||
pub S: EdwardsPoint,
|
||||
|
|
|
@ -43,7 +43,7 @@ pub enum ClsagError {
|
|||
InvalidC1
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
pub struct ClsagInput {
|
||||
// The actual commitment for the true spend
|
||||
pub commitment: Commitment,
|
||||
|
@ -182,7 +182,7 @@ fn core(
|
|||
((D, c * mu_P, c * mu_C), c1.unwrap_or(c))
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
pub struct Clsag {
|
||||
pub D: EdwardsPoint,
|
||||
pub s: Vec<Scalar>,
|
||||
|
|
|
@ -47,10 +47,7 @@ impl ClsagInput {
|
|||
}
|
||||
}
|
||||
|
||||
// pub to enable testing
|
||||
// While we could move the CLSAG test inside this crate, that'd require duplicating the FROST test
|
||||
// helper, and isn't worth doing right now when this is harmless enough (semver? TODO)
|
||||
#[derive(Clone, Debug)]
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
pub struct ClsagDetails {
|
||||
input: ClsagInput,
|
||||
mask: Scalar
|
||||
|
@ -63,7 +60,7 @@ impl ClsagDetails {
|
|||
}
|
||||
|
||||
#[allow(non_snake_case)]
|
||||
#[derive(Clone, Debug)]
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
struct Interim {
|
||||
p: Scalar,
|
||||
c: Scalar,
|
||||
|
@ -73,7 +70,7 @@ struct Interim {
|
|||
}
|
||||
|
||||
#[allow(non_snake_case)]
|
||||
#[derive(Clone, Debug)]
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
pub struct ClsagMultisig {
|
||||
transcript: Transcript,
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ use crate::{
|
|||
ringct::{clsag::Clsag, bulletproofs::Bulletproofs}
|
||||
};
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
pub struct RctBase {
|
||||
pub fee: u64,
|
||||
pub ecdh_info: Vec<[u8; 8]>,
|
||||
|
@ -51,7 +51,7 @@ impl RctBase {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
pub enum RctPrunable {
|
||||
Null,
|
||||
Clsag {
|
||||
|
@ -107,7 +107,7 @@ impl RctPrunable {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
pub struct RctSignatures {
|
||||
pub base: RctBase,
|
||||
pub prunable: RctPrunable
|
||||
|
|
|
@ -2,7 +2,7 @@ use curve25519_dalek::edwards::EdwardsPoint;
|
|||
|
||||
use crate::{hash, serialize::*, ringct::{RctPrunable, RctSignatures}};
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
pub enum Input {
|
||||
Gen(u64),
|
||||
|
||||
|
@ -48,7 +48,7 @@ impl Input {
|
|||
}
|
||||
|
||||
// Doesn't bother moving to an enum for the unused Script classes
|
||||
#[derive(Clone, Debug)]
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
pub struct Output {
|
||||
pub amount: u64,
|
||||
pub key: EdwardsPoint,
|
||||
|
@ -84,7 +84,7 @@ impl Output {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
pub struct TransactionPrefix {
|
||||
pub version: u64,
|
||||
pub unlock_time: u64,
|
||||
|
@ -120,7 +120,7 @@ impl TransactionPrefix {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
pub struct Transaction {
|
||||
pub prefix: TransactionPrefix,
|
||||
pub rct_signatures: RctSignatures
|
||||
|
|
|
@ -88,7 +88,7 @@ fn offset(decoys: &[u64]) -> Vec<u64> {
|
|||
res
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
pub struct Decoys {
|
||||
pub i: u8,
|
||||
pub offsets: Vec<u64>,
|
||||
|
|
|
@ -15,7 +15,7 @@ use crate::{
|
|||
wallet::{uniqueness, shared_key, amount_decryption, commitment_mask}
|
||||
};
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
pub struct SpendableOutput {
|
||||
pub tx: [u8; 32],
|
||||
pub o: usize,
|
||||
|
|
|
@ -38,7 +38,7 @@ use crate::frost::MultisigError;
|
|||
mod multisig;
|
||||
|
||||
#[allow(non_snake_case)]
|
||||
#[derive(Clone, Debug)]
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
struct SendOutput {
|
||||
R: EdwardsPoint,
|
||||
dest: EdwardsPoint,
|
||||
|
@ -149,7 +149,7 @@ async fn prepare_inputs<R: RngCore + CryptoRng>(
|
|||
Ok(signable)
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
pub struct SignableTransaction {
|
||||
inputs: Vec<SpendableOutput>,
|
||||
payments: Vec<(Address, u64)>,
|
||||
|
|
|
@ -12,7 +12,7 @@ use crate::{Curve, FrostError, MultisigView};
|
|||
pub trait Algorithm<C: Curve>: Clone {
|
||||
type Transcript: Transcript + Clone + Debug;
|
||||
/// The resulting type of the signatures this algorithm will produce
|
||||
type Signature: Clone + Debug;
|
||||
type Signature: Clone + PartialEq + Debug;
|
||||
|
||||
fn transcript(&mut self) -> &mut Self::Transcript;
|
||||
|
||||
|
|
|
@ -255,7 +255,7 @@ impl fmt::Display for State {
|
|||
}
|
||||
|
||||
pub trait StateMachine {
|
||||
type Signature;
|
||||
type Signature: Clone + PartialEq + fmt::Debug;
|
||||
|
||||
/// Perform the preprocessing round required in order to sign
|
||||
/// Returns a byte vector which must be transmitted to all parties selected for this signing
|
||||
|
|
|
@ -17,6 +17,12 @@ pub trait Transcript {
|
|||
#[derive(Clone, Debug)]
|
||||
pub struct DigestTranscript<D: Digest>(Vec<u8>, PhantomData<D>);
|
||||
|
||||
impl<D: Digest> PartialEq for DigestTranscript<D> {
|
||||
fn eq(&self, other: &DigestTranscript<D>) -> bool {
|
||||
self.0 == other.0
|
||||
}
|
||||
}
|
||||
|
||||
impl<D: Digest> DigestTranscript<D> {
|
||||
pub fn new(label: Vec<u8>) -> Self {
|
||||
DigestTranscript(label, PhantomData)
|
||||
|
|
|
@ -2,7 +2,7 @@ use core::{marker::PhantomData, fmt::{Debug, Formatter}};
|
|||
|
||||
use digest::Digest;
|
||||
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, PartialEq)]
|
||||
pub struct MerlinTranscript(pub merlin::Transcript);
|
||||
// Merlin doesn't implement Debug so provide a stub which won't panic
|
||||
impl Debug for MerlinTranscript {
|
||||
|
|
Loading…
Reference in a new issue