Respond to 1.1 A2 (also cited as 2 1)

`read_vec` was unbounded. It now accepts an optional bound. In some places, we
are able to define and provide a bound (Bulletproofs(+)' `L` and `R` vectors).
In others, we cannot (the amount of inputs within a transaction, which is not
subject to any rule in the current consensus other than the total transaction
size limit). Usage of `None` in those locations preserves the existing
behavior.
This commit is contained in:
Luke Parker
2025-07-23 08:58:02 -04:00
parent b426bfcfe8
commit 6b8cf6653a
8 changed files with 43 additions and 30 deletions

View File

@@ -213,7 +213,7 @@ impl Decoys {
pub fn write(&self, w: &mut impl io::Write) -> io::Result<()> {
write_vec(write_varint, &self.offsets, w)?;
w.write_all(&[self.signer_index])?;
write_vec(
write_raw_vec(
|pair, w| {
write_point(&pair[0], w)?;
write_point(&pair[1], w)
@@ -239,10 +239,12 @@ impl Decoys {
/// This is not a Monero protocol defined struct, and this is accordingly not a Monero protocol
/// defined serialization.
pub fn read(r: &mut impl io::Read) -> io::Result<Decoys> {
let offsets = read_vec(read_varint, None, r)?;
let len = offsets.len();
Decoys::new(
read_vec(read_varint, r)?,
offsets,
read_byte(r)?,
read_vec(|r| Ok([read_point(r)?, read_point(r)?]), r)?,
read_raw_vec(|r| Ok([read_point(r)?, read_point(r)?]), len, r)?,
)
.ok_or_else(|| io::Error::other("invalid Decoys"))
}