test_ed25519 fails if we randomly select index 1

This commit is contained in:
Sean Young 2022-01-20 11:01:56 +00:00
parent 3ab75fc8de
commit c1b543c74d
1 changed files with 9 additions and 1 deletions

View File

@ -94,6 +94,7 @@ pub fn verify(
let expected_data_size = num_signatures
.saturating_mul(SIGNATURE_OFFSETS_SERIALIZED_SIZE)
.saturating_add(SIGNATURE_OFFSETS_START);
// We do not check or use the byte at data[1]
if data.len() < expected_data_size {
return Err(PrecompileError::InvalidInstructionDataSize);
}
@ -359,7 +360,14 @@ pub mod test {
assert!(tx.verify_precompiles(&feature_set).is_ok());
let index = thread_rng().gen_range(0, instruction.data.len());
let index = loop {
let index = thread_rng().gen_range(0, instruction.data.len());
// byte 1 is not used, so this would not cause the verify to fail
if index != 1 {
break index;
}
};
instruction.data[index] = instruction.data[index].wrapping_add(12);
let tx = Transaction::new_signed_with_payer(
&[instruction],