Skip to content

Commit 1ca9917

Browse files
authored
Merge pull request #2460 from oasisprotocol/peternose/trivial/revert-nonce-trim
runtime-sdk/modules/evm/src/precompile/confidential: Revert validation
2 parents 4fb9f2f + f5abfd8 commit 1ca9917

2 files changed

Lines changed: 4 additions & 32 deletions

File tree

runtime-sdk/modules/evm/fuzz/precompile_corpus.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ fn gen_test_vectors(fixture: &str) -> Box<dyn Iterator<Item = Vec<u8>>> {
1616

1717
fn gen_x25519() -> Box<dyn Iterator<Item = Vec<u8>>> {
1818
let key = b"this must be the excelentest key";
19-
let nonce = b"short nonce\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
19+
let nonce = b"complete noncence, and too long.";
2020
let plaintext = b"0123456789";
2121
let ad = b"additional data";
2222

runtime-sdk/modules/evm/src/precompile/confidential.rs

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,6 @@ fn decode_deoxysii_call_args(
185185
let text = text.to_vec();
186186
let ad = ad.to_vec();
187187

188-
if nonce_bytes[NONCE_SIZE..].iter().any(|&x| x != 0) {
189-
return Err(PrecompileFailure::Error {
190-
exit_status: ExitError::Other("invalid nonce size".into()),
191-
});
192-
}
193-
194188
let mut nonce = [0u8; NONCE_SIZE];
195189
nonce.copy_from_slice(&nonce_bytes[..NONCE_SIZE]);
196190
let mut key = [0u8; KEY_SIZE];
@@ -505,7 +499,7 @@ mod test {
505499
#[test]
506500
fn test_deoxysii() {
507501
let key = b"this must be the excelentest key";
508-
let nonce = b"short nonce\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
502+
let nonce = b"complete noncence, and too long.";
509503
let plaintext = b"0123456789";
510504
let ad = b"additional data";
511505
let ret_ct = call_contract(
@@ -541,28 +535,6 @@ mod test {
541535
assert_eq!(plaintext.as_slice(), ret_pt.output);
542536
}
543537

544-
#[test]
545-
fn test_deoxysii_invalid_nonce() {
546-
let key = b"this must be the excelentest key";
547-
let nonce = b"invalid nonce, which is too long";
548-
let plaintext = b"0123456789";
549-
let ad = b"additional data";
550-
let _ = call_contract(
551-
H160([
552-
0x01, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x03,
553-
]),
554-
&solabi::encode(&(
555-
solabi::Bytes::<[u8; 32]>(*key),
556-
solabi::Bytes::<[u8; 32]>(*nonce),
557-
solabi::Bytes(plaintext.to_vec()),
558-
solabi::Bytes(ad.to_vec()),
559-
)),
560-
10_000_000,
561-
)
562-
.expect("call should return something")
563-
.expect_err("call should fail");
564-
}
565-
566538
#[test]
567539
fn test_random_bytes() {
568540
let ret = call_contract(
@@ -579,7 +551,7 @@ mod test {
579551
#[bench]
580552
fn bench_deoxysii_short(b: &mut Bencher) {
581553
let key = b"this must be the excelentest key";
582-
let nonce = b"short nonce\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
554+
let nonce = b"complete noncence, and too long.";
583555
let plaintext = b"01234567890123456789";
584556
let ad = b"additional data";
585557
b.iter(|| {
@@ -603,7 +575,7 @@ mod test {
603575
#[bench]
604576
fn bench_deoxysii_long(b: &mut Bencher) {
605577
let key = b"this must be the excelentest key";
606-
let nonce = b"short nonce\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
578+
let nonce = b"complete noncence, and too long.";
607579
let plaintext = b"0123456789".repeat(200);
608580
let ad = b"additional data";
609581
b.iter(|| {

0 commit comments

Comments
 (0)