Properly calculate uniqueness when creating change outputs

It was missing sorting its inputs by their key images.
This commit is contained in:
Luke Parker 2022-05-21 21:44:57 -04:00
parent 23d9d81bdb
commit e1fd462a50
No known key found for this signature in database
GPG key ID: F9F1386DB1E119B6

View file

@ -289,14 +289,20 @@ impl SignableTransaction {
rpc: &Rpc, rpc: &Rpc,
spend: &Scalar spend: &Scalar
) -> Result<Transaction, TransactionError> { ) -> Result<Transaction, TransactionError> {
let mut images = Vec::with_capacity(self.inputs.len());
for input in &self.inputs {
images.push(generate_key_image(&(spend + input.key_offset)));
}
images.sort_by(|x, y| x.compress().to_bytes().cmp(&y.compress().to_bytes()).reverse());
let (commitments, mask_sum) = self.prepare_outputs( let (commitments, mask_sum) = self.prepare_outputs(
rng, rng,
Some( Some(
uniqueness( uniqueness(
&self.inputs.iter().map(|input| Input::ToKey { &images.iter().map(|image| Input::ToKey {
amount: 0, amount: 0,
key_offsets: vec![], key_offsets: vec![],
key_image: generate_key_image(&(spend + input.key_offset)) key_image: *image
}).collect::<Vec<_>>() }).collect::<Vec<_>>()
) )
) )