mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-10 05:09:22 +00:00
MLSAG (de)serialisation fix
ss_2_elements will not always be 2 as rct type 1 transactions are not enforced to have one input
This commit is contained in:
@@ -13,7 +13,7 @@ use crate::{hash_to_scalar, ringct::hash_to_point};
|
|||||||
|
|
||||||
#[derive(Clone, PartialEq, Eq, Debug)]
|
#[derive(Clone, PartialEq, Eq, Debug)]
|
||||||
pub struct Mlsag {
|
pub struct Mlsag {
|
||||||
pub ss: Vec<[Scalar; 2]>,
|
pub ss: Vec<Vec<Scalar>>,
|
||||||
pub cc: Scalar,
|
pub cc: Scalar,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -25,9 +25,11 @@ impl Mlsag {
|
|||||||
write_scalar(&self.cc, w)
|
write_scalar(&self.cc, w)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn read<R: Read>(mixins: usize, r: &mut R) -> io::Result<Mlsag> {
|
pub fn read<R: Read>(mixins: usize, ss_2_elements: usize, r: &mut R) -> io::Result<Mlsag> {
|
||||||
Ok(Mlsag {
|
Ok(Mlsag {
|
||||||
ss: (0 .. mixins).map(|_| read_array(read_scalar, r)).collect::<Result<_, _>>()?,
|
ss: (0 .. mixins)
|
||||||
|
.map(|_| read_raw_vec(read_scalar, ss_2_elements, r))
|
||||||
|
.collect::<Result<_, _>>()?,
|
||||||
cc: read_scalar(r)?,
|
cc: read_scalar(r)?,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -257,9 +257,13 @@ impl RctPrunable {
|
|||||||
) -> io::Result<RctPrunable> {
|
) -> io::Result<RctPrunable> {
|
||||||
Ok(match rct_type {
|
Ok(match rct_type {
|
||||||
RctType::Null => RctPrunable::Null,
|
RctType::Null => RctPrunable::Null,
|
||||||
RctType::MlsagAggregate | RctType::MlsagIndividual => RctPrunable::MlsagBorromean {
|
RctType::MlsagAggregate => RctPrunable::MlsagBorromean {
|
||||||
borromean: read_raw_vec(BorromeanRange::read, outputs, r)?,
|
borromean: read_raw_vec(BorromeanRange::read, outputs, r)?,
|
||||||
mlsags: decoys.iter().map(|d| Mlsag::read(*d, r)).collect::<Result<_, _>>()?,
|
mlsags: vec![Mlsag::read(decoys[0], decoys.len() + 1, r)?],
|
||||||
|
},
|
||||||
|
RctType::MlsagIndividual => RctPrunable::MlsagBorromean {
|
||||||
|
borromean: read_raw_vec(BorromeanRange::read, outputs, r)?,
|
||||||
|
mlsags: decoys.iter().map(|d| Mlsag::read(*d, 2, r)).collect::<Result<_, _>>()?,
|
||||||
},
|
},
|
||||||
RctType::Bulletproofs | RctType::BulletproofsCompactAmount => {
|
RctType::Bulletproofs | RctType::BulletproofsCompactAmount => {
|
||||||
RctPrunable::MlsagBulletproofs {
|
RctPrunable::MlsagBulletproofs {
|
||||||
@@ -274,7 +278,7 @@ impl RctPrunable {
|
|||||||
}
|
}
|
||||||
Bulletproofs::read(r)?
|
Bulletproofs::read(r)?
|
||||||
},
|
},
|
||||||
mlsags: decoys.iter().map(|d| Mlsag::read(*d, r)).collect::<Result<_, _>>()?,
|
mlsags: decoys.iter().map(|d| Mlsag::read(*d, 2, r)).collect::<Result<_, _>>()?,
|
||||||
pseudo_outs: read_raw_vec(read_point, decoys.len(), r)?,
|
pseudo_outs: read_raw_vec(read_point, decoys.len(), r)?,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user