mirror of
https://github.com/serai-dex/serai.git
synced 2025-02-02 11:16:41 +00:00
Only deserialize RctSignatures where's there at least one input
This is only enforced by the Monero protocol due to a single check the mixRing isn't empty in get_pre_mlsag_hash. The value in ensuring there's a least one input is to ensure the safety of our rct_type functions, which determines the RctType based off structural analysis (specifically, input data if MlsagBorromean). rct_type was technically safe without this. A 0-input transaction would be mis-classified as RctFull/MlsagAggregate, which would then make the RctSignatures invalid for being RctFull (requiring exactly one input) yet not having inputs, meaning an invalid RctSignatures would be mis-classified yet still invalid. This just removes the risk of mis-classification in the first place, tightening the library's safety.
This commit is contained in:
parent
5d9067b84d
commit
b54548b13a
1 changed files with 11 additions and 0 deletions
|
@ -255,6 +255,17 @@ impl RctPrunable {
|
|||
outputs: usize,
|
||||
r: &mut R,
|
||||
) -> io::Result<RctPrunable> {
|
||||
// While we generally don't bother with misc consensus checks, this affects the safety of
|
||||
// the below defined rct_type function
|
||||
// The exact line preventing zero-input transactions is:
|
||||
// https://github.com/monero-project/monero/blob/00fd416a99686f0956361d1cd0337fe56e58d4a7/
|
||||
// src/ringct/rctSigs.cpp#L609
|
||||
// And then for RctNull, that's only allowed for miner TXs which require one input of
|
||||
// Input::Gen
|
||||
if decoys.is_empty() {
|
||||
Err(io::Error::new(io::ErrorKind::Other, "transaction had no inputs"))?;
|
||||
}
|
||||
|
||||
Ok(match rct_type {
|
||||
RctType::Null => RctPrunable::Null,
|
||||
RctType::MlsagAggregate | RctType::MlsagIndividual => RctPrunable::MlsagBorromean {
|
||||
|
|
Loading…
Reference in a new issue