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
|
transaction::Transaction
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, PartialEq, Debug)]
|
||||||
pub struct BlockHeader {
|
pub struct BlockHeader {
|
||||||
pub major_version: u64,
|
pub major_version: u64,
|
||||||
pub minor_version: u64,
|
pub minor_version: u64,
|
||||||
|
@ -34,7 +34,7 @@ impl BlockHeader {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, PartialEq, Debug)]
|
||||||
pub struct Block {
|
pub struct Block {
|
||||||
pub header: BlockHeader,
|
pub header: BlockHeader,
|
||||||
pub miner_tx: Transaction,
|
pub miner_tx: Transaction,
|
||||||
|
|
|
@ -6,7 +6,7 @@ use curve25519_dalek::{scalar::Scalar, edwards::EdwardsPoint};
|
||||||
|
|
||||||
use crate::{Commitment, wallet::TransactionError, serialize::*};
|
use crate::{Commitment, wallet::TransactionError, serialize::*};
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, PartialEq, Debug)]
|
||||||
pub struct Bulletproofs {
|
pub struct Bulletproofs {
|
||||||
pub A: EdwardsPoint,
|
pub A: EdwardsPoint,
|
||||||
pub S: EdwardsPoint,
|
pub S: EdwardsPoint,
|
||||||
|
|
|
@ -43,7 +43,7 @@ pub enum ClsagError {
|
||||||
InvalidC1
|
InvalidC1
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, PartialEq, Debug)]
|
||||||
pub struct ClsagInput {
|
pub struct ClsagInput {
|
||||||
// The actual commitment for the true spend
|
// The actual commitment for the true spend
|
||||||
pub commitment: Commitment,
|
pub commitment: Commitment,
|
||||||
|
@ -182,7 +182,7 @@ fn core(
|
||||||
((D, c * mu_P, c * mu_C), c1.unwrap_or(c))
|
((D, c * mu_P, c * mu_C), c1.unwrap_or(c))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, PartialEq, Debug)]
|
||||||
pub struct Clsag {
|
pub struct Clsag {
|
||||||
pub D: EdwardsPoint,
|
pub D: EdwardsPoint,
|
||||||
pub s: Vec<Scalar>,
|
pub s: Vec<Scalar>,
|
||||||
|
|
|
@ -47,10 +47,7 @@ impl ClsagInput {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// pub to enable testing
|
#[derive(Clone, PartialEq, Debug)]
|
||||||
// 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)]
|
|
||||||
pub struct ClsagDetails {
|
pub struct ClsagDetails {
|
||||||
input: ClsagInput,
|
input: ClsagInput,
|
||||||
mask: Scalar
|
mask: Scalar
|
||||||
|
@ -63,7 +60,7 @@ impl ClsagDetails {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, PartialEq, Debug)]
|
||||||
struct Interim {
|
struct Interim {
|
||||||
p: Scalar,
|
p: Scalar,
|
||||||
c: Scalar,
|
c: Scalar,
|
||||||
|
@ -73,7 +70,7 @@ struct Interim {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, PartialEq, Debug)]
|
||||||
pub struct ClsagMultisig {
|
pub struct ClsagMultisig {
|
||||||
transcript: Transcript,
|
transcript: Transcript,
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ use crate::{
|
||||||
ringct::{clsag::Clsag, bulletproofs::Bulletproofs}
|
ringct::{clsag::Clsag, bulletproofs::Bulletproofs}
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, PartialEq, Debug)]
|
||||||
pub struct RctBase {
|
pub struct RctBase {
|
||||||
pub fee: u64,
|
pub fee: u64,
|
||||||
pub ecdh_info: Vec<[u8; 8]>,
|
pub ecdh_info: Vec<[u8; 8]>,
|
||||||
|
@ -51,7 +51,7 @@ impl RctBase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, PartialEq, Debug)]
|
||||||
pub enum RctPrunable {
|
pub enum RctPrunable {
|
||||||
Null,
|
Null,
|
||||||
Clsag {
|
Clsag {
|
||||||
|
@ -107,7 +107,7 @@ impl RctPrunable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, PartialEq, Debug)]
|
||||||
pub struct RctSignatures {
|
pub struct RctSignatures {
|
||||||
pub base: RctBase,
|
pub base: RctBase,
|
||||||
pub prunable: RctPrunable
|
pub prunable: RctPrunable
|
||||||
|
|
|
@ -2,7 +2,7 @@ use curve25519_dalek::edwards::EdwardsPoint;
|
||||||
|
|
||||||
use crate::{hash, serialize::*, ringct::{RctPrunable, RctSignatures}};
|
use crate::{hash, serialize::*, ringct::{RctPrunable, RctSignatures}};
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, PartialEq, Debug)]
|
||||||
pub enum Input {
|
pub enum Input {
|
||||||
Gen(u64),
|
Gen(u64),
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ impl Input {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Doesn't bother moving to an enum for the unused Script classes
|
// Doesn't bother moving to an enum for the unused Script classes
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, PartialEq, Debug)]
|
||||||
pub struct Output {
|
pub struct Output {
|
||||||
pub amount: u64,
|
pub amount: u64,
|
||||||
pub key: EdwardsPoint,
|
pub key: EdwardsPoint,
|
||||||
|
@ -84,7 +84,7 @@ impl Output {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, PartialEq, Debug)]
|
||||||
pub struct TransactionPrefix {
|
pub struct TransactionPrefix {
|
||||||
pub version: u64,
|
pub version: u64,
|
||||||
pub unlock_time: u64,
|
pub unlock_time: u64,
|
||||||
|
@ -120,7 +120,7 @@ impl TransactionPrefix {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, PartialEq, Debug)]
|
||||||
pub struct Transaction {
|
pub struct Transaction {
|
||||||
pub prefix: TransactionPrefix,
|
pub prefix: TransactionPrefix,
|
||||||
pub rct_signatures: RctSignatures
|
pub rct_signatures: RctSignatures
|
||||||
|
|
|
@ -88,7 +88,7 @@ fn offset(decoys: &[u64]) -> Vec<u64> {
|
||||||
res
|
res
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, PartialEq, Debug)]
|
||||||
pub struct Decoys {
|
pub struct Decoys {
|
||||||
pub i: u8,
|
pub i: u8,
|
||||||
pub offsets: Vec<u64>,
|
pub offsets: Vec<u64>,
|
||||||
|
|
|
@ -15,7 +15,7 @@ use crate::{
|
||||||
wallet::{uniqueness, shared_key, amount_decryption, commitment_mask}
|
wallet::{uniqueness, shared_key, amount_decryption, commitment_mask}
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, PartialEq, Debug)]
|
||||||
pub struct SpendableOutput {
|
pub struct SpendableOutput {
|
||||||
pub tx: [u8; 32],
|
pub tx: [u8; 32],
|
||||||
pub o: usize,
|
pub o: usize,
|
||||||
|
|
|
@ -38,7 +38,7 @@ use crate::frost::MultisigError;
|
||||||
mod multisig;
|
mod multisig;
|
||||||
|
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, PartialEq, Debug)]
|
||||||
struct SendOutput {
|
struct SendOutput {
|
||||||
R: EdwardsPoint,
|
R: EdwardsPoint,
|
||||||
dest: EdwardsPoint,
|
dest: EdwardsPoint,
|
||||||
|
@ -149,7 +149,7 @@ async fn prepare_inputs<R: RngCore + CryptoRng>(
|
||||||
Ok(signable)
|
Ok(signable)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, PartialEq, Debug)]
|
||||||
pub struct SignableTransaction {
|
pub struct SignableTransaction {
|
||||||
inputs: Vec<SpendableOutput>,
|
inputs: Vec<SpendableOutput>,
|
||||||
payments: Vec<(Address, u64)>,
|
payments: Vec<(Address, u64)>,
|
||||||
|
|
|
@ -12,7 +12,7 @@ use crate::{Curve, FrostError, MultisigView};
|
||||||
pub trait Algorithm<C: Curve>: Clone {
|
pub trait Algorithm<C: Curve>: Clone {
|
||||||
type Transcript: Transcript + Clone + Debug;
|
type Transcript: Transcript + Clone + Debug;
|
||||||
/// The resulting type of the signatures this algorithm will produce
|
/// 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;
|
fn transcript(&mut self) -> &mut Self::Transcript;
|
||||||
|
|
||||||
|
|
|
@ -255,7 +255,7 @@ impl fmt::Display for State {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait StateMachine {
|
pub trait StateMachine {
|
||||||
type Signature;
|
type Signature: Clone + PartialEq + fmt::Debug;
|
||||||
|
|
||||||
/// Perform the preprocessing round required in order to sign
|
/// Perform the preprocessing round required in order to sign
|
||||||
/// Returns a byte vector which must be transmitted to all parties selected for this signing
|
/// 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)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct DigestTranscript<D: Digest>(Vec<u8>, PhantomData<D>);
|
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> {
|
impl<D: Digest> DigestTranscript<D> {
|
||||||
pub fn new(label: Vec<u8>) -> Self {
|
pub fn new(label: Vec<u8>) -> Self {
|
||||||
DigestTranscript(label, PhantomData)
|
DigestTranscript(label, PhantomData)
|
||||||
|
|
|
@ -2,7 +2,7 @@ use core::{marker::PhantomData, fmt::{Debug, Formatter}};
|
||||||
|
|
||||||
use digest::Digest;
|
use digest::Digest;
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone, PartialEq)]
|
||||||
pub struct MerlinTranscript(pub merlin::Transcript);
|
pub struct MerlinTranscript(pub merlin::Transcript);
|
||||||
// Merlin doesn't implement Debug so provide a stub which won't panic
|
// Merlin doesn't implement Debug so provide a stub which won't panic
|
||||||
impl Debug for MerlinTranscript {
|
impl Debug for MerlinTranscript {
|
||||||
|
|
Loading…
Reference in a new issue