diff --git a/CHANGELOG.md b/CHANGELOG.md index cb554a2cc0..de24c87117 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). #### Breaking - [#780](https://github.com/FuelLabs/fuel-vm/pull/780): Added `Blob` transaction, and `BSIZ` and `BLDD` instructions. Also allows `LDC` to load blobs. +- [#795](https://github.com/FuelLabs/fuel-vm/pull/795): Fixed `ed19` instruction to take variable length message instead of a fixed-length one. Changed the gas cost to be `DependentCost`. ## [Version 0.55.0] diff --git a/fuel-asm/src/lib.rs b/fuel-asm/src/lib.rs index 3ce1014b69..9c89930cc5 100644 --- a/fuel-asm/src/lib.rs +++ b/fuel-asm/src/lib.rs @@ -206,12 +206,12 @@ impl_instructions! { 0x3C TR tr [contract_id_addr: RegId amount: RegId asset_id_addr: RegId] "Transfer coins to a variable output." 0x3D TRO tro [contract_id_addr: RegId output_index: RegId amount: RegId asset_id_addr: RegId] - "The 64-byte public key (x, y) recovered from 64-byte signature on 32-byte message." + "The 64-byte public key (x, y) recovered from 64-byte signature on 32-byte message hash." 0x3E ECK1 eck1 [dst_addr: RegId sig_addr: RegId msg_hash_addr: RegId] - "The 64-byte Secp256r1 public key (x, y) recovered from 64-byte signature on 32-byte message." + "The 64-byte Secp256r1 public key (x, y) recovered from 64-byte signature on 32-byte message hash." 0x3F ECR1 ecr1 [dst_addr: RegId sig_addr: RegId msg_hash_addr: RegId] - "Verify ED25519 public key and signature match a 32-byte message." - 0x40 ED19 ed19 [pub_key_addr: RegId sig_addr: RegId msg_hash_addr: RegId] + "Verify ED25519 public key and signature match a message." + 0x40 ED19 ed19 [pub_key_addr: RegId sig_addr: RegId msg_addr: RegId msg_len: RegId] "The keccak-256 hash of a slice." 0x41 K256 k256 [dst_addr: RegId src_addr: RegId len: RegId] "The SHA-2-256 hash of a slice." diff --git a/fuel-crypto/src/ed25519.rs b/fuel-crypto/src/ed25519.rs index c6923ee486..5c41050ac2 100644 --- a/fuel-crypto/src/ed25519.rs +++ b/fuel-crypto/src/ed25519.rs @@ -6,23 +6,20 @@ use fuel_types::{ Bytes64, }; -use crate::{ - message::Message, - Error, -}; +use crate::Error; /// Verify a signature against a message digest and a public key. pub fn verify( pub_key: &Bytes32, signature: &Bytes64, - message: &Message, + message: &[u8], ) -> Result<(), Error> { let signature = Signature::from_bytes(signature); let pub_key = ed25519_dalek::VerifyingKey::from_bytes(pub_key) .map_err(|_| Error::InvalidPublicKey)?; - if pub_key.verify_strict(&**message, &signature).is_ok() { + if pub_key.verify_strict(message, &signature).is_ok() { Ok(()) } else { Err(Error::InvalidSignature) diff --git a/fuel-tx/src/transaction/consensus_parameters/gas.rs b/fuel-tx/src/transaction/consensus_parameters/gas.rs index 7cee63dd7a..d3b4c11d77 100644 --- a/fuel-tx/src/transaction/consensus_parameters/gas.rs +++ b/fuel-tx/src/transaction/consensus_parameters/gas.rs @@ -219,15 +219,6 @@ impl GasCostsValues { } } - pub fn ed19(&self) -> Word { - match self { - GasCostsValues::V1(v1) => v1.ed19, - GasCostsValues::V2(v2) => v2.ed19, - GasCostsValues::V3(v3) => v3.ed19, - GasCostsValues::V4(v4) => v4.ed19, - } - } - pub fn eq_(&self) -> Word { match self { GasCostsValues::V1(v1) => v1.eq, @@ -945,6 +936,24 @@ impl GasCostsValues { } } + pub fn ed19(&self) -> DependentCost { + match self { + GasCostsValues::V1(v1) => DependentCost::HeavyOperation { + base: v1.ed19, + gas_per_unit: 0, + }, + GasCostsValues::V2(v2) => DependentCost::HeavyOperation { + base: v2.ed19, + gas_per_unit: 0, + }, + GasCostsValues::V3(v3) => DependentCost::HeavyOperation { + base: v3.ed19, + gas_per_unit: 0, + }, + GasCostsValues::V4(v4) => v4.ed19, + } + } + pub fn k256(&self) -> DependentCost { match self { GasCostsValues::V1(v1) => v1.k256, @@ -1513,6 +1522,7 @@ pub struct GasCostsValuesV3 { /// Gas costs for every op. /// The difference with [`GasCostsValuesV3`]: /// - Added `bsiz`, `bldd` instructions +/// - Changed `ed19` to be `DependentCost` #[allow(missing_docs)] #[derive(Debug, Clone, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize)] #[serde(default = "GasCostsValuesV4::unit")] @@ -1531,7 +1541,6 @@ pub struct GasCostsValuesV4 { pub divi: Word, pub eck1: Word, pub ecr1: Word, - pub ed19: Word, pub eq: Word, pub exp: Word, pub expi: Word, @@ -1618,6 +1627,7 @@ pub struct GasCostsValuesV4 { pub ccp: DependentCost, pub croo: DependentCost, pub csiz: DependentCost, + pub ed19: DependentCost, pub k256: DependentCost, pub ldc: DependentCost, pub logd: DependentCost, @@ -2428,7 +2438,6 @@ impl GasCostsValuesV4 { divi: 0, eck1: 0, ecr1: 0, - ed19: 0, eq: 0, exp: 0, expi: 0, @@ -2509,6 +2518,7 @@ impl GasCostsValuesV4 { ccp: DependentCost::free(), croo: DependentCost::free(), csiz: DependentCost::free(), + ed19: DependentCost::free(), k256: DependentCost::free(), ldc: DependentCost::free(), logd: DependentCost::free(), @@ -2549,7 +2559,6 @@ impl GasCostsValuesV4 { divi: 1, eck1: 1, ecr1: 1, - ed19: 1, eq: 1, exp: 1, expi: 1, @@ -2630,6 +2639,7 @@ impl GasCostsValuesV4 { ccp: DependentCost::unit(), croo: DependentCost::unit(), csiz: DependentCost::unit(), + ed19: DependentCost::unit(), k256: DependentCost::unit(), ldc: DependentCost::unit(), logd: DependentCost::unit(), diff --git a/fuel-tx/src/transaction/consensus_parameters/gas/default_gas_costs.rs b/fuel-tx/src/transaction/consensus_parameters/gas/default_gas_costs.rs index 6f1b1bb913..7f1b19e380 100644 --- a/fuel-tx/src/transaction/consensus_parameters/gas/default_gas_costs.rs +++ b/fuel-tx/src/transaction/consensus_parameters/gas/default_gas_costs.rs @@ -19,7 +19,6 @@ pub fn default_gas_costs() -> GasCostsValues { divi: 1, eck1: 951, ecr1: 3000, - ed19: 3000, eq: 1, exp: 1, expi: 1, @@ -102,6 +101,10 @@ pub fn default_gas_costs() -> GasCostsValues { base: 2, units_per_gas: 214, }, + ed19: DependentCost::LightOperation { + base: 3000, + units_per_gas: 214, + }, k256: DependentCost::LightOperation { base: 11, units_per_gas: 214, diff --git a/fuel-vm/src/interpreter/crypto.rs b/fuel-vm/src/interpreter/crypto.rs index fa0ff807ab..e1ff2cf824 100644 --- a/fuel-vm/src/interpreter/crypto.rs +++ b/fuel-vm/src/interpreter/crypto.rs @@ -62,9 +62,10 @@ where a: Word, b: Word, c: Word, + len: Word, ) -> SimpleResult<()> { let (SystemRegisters { err, pc, .. }, _) = split_registers(&mut self.registers); - ed25519_verify(self.memory.as_mut(), err, pc, a, b, c) + ed25519_verify(self.memory.as_mut(), err, pc, a, b, c, len) } pub(crate) fn keccak256(&mut self, a: Word, b: Word, c: Word) -> SimpleResult<()> { @@ -155,13 +156,13 @@ pub(crate) fn ed25519_verify( a: Word, b: Word, c: Word, + len: Word, ) -> SimpleResult<()> { let pub_key = Bytes32::from(memory.read_bytes(a)?); let sig = Bytes64::from(memory.read_bytes(b)?); - let msg = Bytes32::from(memory.read_bytes(c)?); - let message = Message::from_bytes_ref(&msg); + let msg = memory.read(c, len)?; - if fuel_crypto::ed25519::verify(&pub_key, &sig, message).is_ok() { + if fuel_crypto::ed25519::verify(&pub_key, &sig, msg).is_ok() { clear_err(err); } else { set_err(err); diff --git a/fuel-vm/src/interpreter/crypto/tests.rs b/fuel-vm/src/interpreter/crypto/tests.rs index 282ef54905..c5634d62d8 100644 --- a/fuel-vm/src/interpreter/crypto/tests.rs +++ b/fuel-vm/src/interpreter/crypto/tests.rs @@ -4,6 +4,7 @@ use alloc::vec; use fuel_crypto::SecretKey; use rand::{ rngs::StdRng, + RngCore, SeedableRng, }; @@ -110,21 +111,22 @@ fn test_verify_ed25519() -> SimpleResult<()> { let mut err = 0; let mut pc = 4; - let sig_address = 0; - let msg_address = 64; - let pubkey_address = 64 + 32; + let pubkey_address = 0; + let sig_address = pubkey_address + 32; + let msg_address = sig_address + 64; let mut rng = rand::rngs::OsRng; let signing_key = ed25519_dalek::SigningKey::generate(&mut rng); - let message = Message::new([3u8; 100]); - let signature = signing_key.sign(&*message); + let mut message = [0u8; 100]; + rng.fill_bytes(&mut message); + let signature = signing_key.sign(&message); - memory[sig_address..sig_address + Signature::LEN] - .copy_from_slice(&signature.to_bytes()); - memory[msg_address..msg_address + Message::LEN].copy_from_slice(message.as_ref()); memory[pubkey_address..pubkey_address + Bytes32::LEN] .copy_from_slice(signing_key.verifying_key().as_ref()); + memory[sig_address..sig_address + Signature::LEN] + .copy_from_slice(&signature.to_bytes()); + memory[msg_address..msg_address + message.len()].copy_from_slice(message.as_ref()); ed25519_verify( &mut memory, @@ -133,6 +135,7 @@ fn test_verify_ed25519() -> SimpleResult<()> { pubkey_address as Word, sig_address as Word, msg_address as Word, + message.len() as Word, )?; assert_eq!(pc, 8); assert_eq!(err, 0); diff --git a/fuel-vm/src/interpreter/executors/instruction.rs b/fuel-vm/src/interpreter/executors/instruction.rs index 34d0c68d42..bc7c7b8cfa 100644 --- a/fuel-vm/src/interpreter/executors/instruction.rs +++ b/fuel-vm/src/interpreter/executors/instruction.rs @@ -845,9 +845,16 @@ where } Instruction::ED19(ed19) => { - self.gas_charge(self.gas_costs().ed19())?; - let (a, b, c) = ed19.unpack(); - self.ed25519_verify(r!(a), r!(b), r!(c))?; + let (a, b, c, len) = ed19.unpack(); + let mut len = r!(len); + + // Backwards compatibility with old contracts + if len == 0 { + len = 32; + } + + self.dependent_gas_charge(self.gas_costs().ed19(), len)?; + self.ed25519_verify(r!(a), r!(b), r!(c), len)?; } Instruction::K256(k256) => { diff --git a/fuel-vm/src/tests/crypto.rs b/fuel-vm/src/tests/crypto.rs index 2b052a40a9..2df366a5a4 100644 --- a/fuel-vm/src/tests/crypto.rs +++ b/fuel-vm/src/tests/crypto.rs @@ -1,4 +1,10 @@ -use alloc::vec; +#![allow(non_snake_case)] + +use alloc::{ + vec, + vec::Vec, +}; +use test_case::test_case; use fuel_asm::{ op, @@ -29,6 +35,7 @@ use sha3::{ use crate::{ prelude::*, + tests::test_helpers::set_full_word, util::test_helpers::check_expected_reason_for_instructions, }; @@ -278,13 +285,12 @@ fn secp256k1_recover_error() { } #[test] -fn secp256k1_recover_a_gt_vmaxram_sub_64() { +fn secp256k1_recover__register_a_overflows() { let reg_a = 0x20; let reg_b = 0x21; #[rustfmt::skip] let script = vec![ - op::xor(reg_b, reg_b, reg_b), op::not(reg_a, RegId::ZERO), op::subi(reg_a, reg_a, 63), op::eck1(reg_a, reg_b, reg_b), @@ -295,13 +301,12 @@ fn secp256k1_recover_a_gt_vmaxram_sub_64() { } #[test] -fn secp256k1_recover_b_gt_vmaxram_sub_64() { +fn secp256k1_recover__register_b_overflows() { let reg_a = 0x20; let reg_b = 0x21; #[rustfmt::skip] let script = vec![ - op::xor(reg_b, reg_b, reg_b), op::not(reg_a, RegId::ZERO), op::subi(reg_a, reg_a, 63), op::eck1(reg_b, reg_a, reg_b), @@ -312,13 +317,12 @@ fn secp256k1_recover_b_gt_vmaxram_sub_64() { } #[test] -fn secp256k1_recover_c_gt_vmaxram_sub_32() { +fn secp256k1_recover__register_c_overflows() { let reg_a = 0x20; let reg_b = 0x21; #[rustfmt::skip] let script = vec![ - op::xor(reg_b, reg_b, reg_b), op::not(reg_a, RegId::ZERO), op::subi(reg_a, reg_a, 31), op::eck1(reg_b, reg_b, reg_a), @@ -419,13 +423,12 @@ fn secp256r1_recover_error() { } #[test] -fn secp256r1_recover_a_gt_vmaxram_sub_64() { +fn secp256r1_recover__register_a_overflows() { let reg_a = 0x20; let reg_b = 0x21; #[rustfmt::skip] let script = vec![ - op::xor(reg_b, reg_b, reg_b), op::not(reg_a, RegId::ZERO), op::subi(reg_a, reg_a, 63), op::ecr1(reg_a, reg_b, reg_b), @@ -436,13 +439,12 @@ fn secp256r1_recover_a_gt_vmaxram_sub_64() { } #[test] -fn secp256r1_recover_b_gt_vmaxram_sub_64() { +fn secp256r1_recover__register_b_overflows() { let reg_a = 0x20; let reg_b = 0x21; #[rustfmt::skip] let script = vec![ - op::xor(reg_b, reg_b, reg_b), op::not(reg_a, RegId::ZERO), op::subi(reg_a, reg_a, 63), op::ecr1(reg_b, reg_a, reg_b), @@ -453,13 +455,12 @@ fn secp256r1_recover_b_gt_vmaxram_sub_64() { } #[test] -fn secp256r1_recover_c_gt_vmaxram_sub_32() { +fn secp256r1_recover__register_c_overflows() { let reg_a = 0x20; let reg_b = 0x21; #[rustfmt::skip] let script = vec![ - op::xor(reg_b, reg_b, reg_b), op::not(reg_a, RegId::ZERO), op::subi(reg_a, reg_a, 31), op::ecr1(reg_b, reg_b, reg_a), @@ -470,7 +471,7 @@ fn secp256r1_recover_c_gt_vmaxram_sub_32() { } #[test] -fn ed25519_verify() { +fn ed25519_verifies_message() { use ed25519_dalek::Signer; let mut client = MemoryClient::default(); @@ -483,22 +484,23 @@ fn ed25519_verify() { let signing_key = ed25519_dalek::SigningKey::generate(&mut rng); let message = b"The gift of words is the gift of deception and illusion."; - let message = Message::new(message); + let signature = signing_key.sign(&message[..]); - let signature = signing_key.sign(&*message); - - #[rustfmt::skip] - let script = vec![ + let mut script = set_full_word(0x23, message.len() as Word); + script.extend([ op::gtf_args(0x20, 0x00, GTFArgs::ScriptData), op::addi(0x21, 0x20, signature.to_bytes().len() as Immediate12), op::addi(0x22, 0x21, message.as_ref().len() as Immediate12), op::movi(0x10, PublicKey::LEN as Immediate18), op::aloc(0x10), - op::ed19(0x22, 0x20, 0x21), + op::ed19(0x22, 0x20, 0x21, 0x23), op::log(RegId::ERR, 0x00, 0x00, 0x00), op::ret(RegId::ONE), - ].into_iter().collect(); + ]); + + let script: Vec = script.into_iter().collect(); + // Success case let script_data = signature .to_bytes() .iter() @@ -507,7 +509,7 @@ fn ed25519_verify() { .chain(signing_key.verifying_key().as_ref().iter().copied()) .collect(); - let tx = TransactionBuilder::script(script, script_data) + let tx = TransactionBuilder::script(script.clone(), script_data) .script_gas_limit(gas_limit) .maturity(maturity) .add_random_fee_input() @@ -519,55 +521,120 @@ fn ed25519_verify() { .any(|r| matches!(r, Receipt::Log{ ra, .. } if *ra == 0)); assert!(success); + + // If we alter the message, the verification should fail + let altered_message = b"The gift of words is the gift of deception and illusion!"; + assert_eq!(message.len(), altered_message.len()); + + let script_data = signature + .to_bytes() + .iter() + .copied() + .chain(altered_message.as_ref().iter().copied()) + .chain(signing_key.verifying_key().as_ref().iter().copied()) + .collect(); + + let tx = TransactionBuilder::script(script.clone(), script_data) + .script_gas_limit(gas_limit) + .maturity(maturity) + .add_random_fee_input() + .finalize_checked(height); + + let receipts = client.transact(tx); + let errors = receipts + .iter() + .any(|r| matches!(r, Receipt::Log{ ra, .. } if *ra == 1)); + + assert!(errors); + + // And if we alter the signature, the verification should also fail + let altered_signature = signing_key.sign(&altered_message[..]); + + let script_data = altered_signature + .to_bytes() + .iter() + .copied() + .chain(message.as_ref().iter().copied()) + .chain(signing_key.verifying_key().as_ref().iter().copied()) + .collect(); + + let tx = TransactionBuilder::script(script, script_data) + .script_gas_limit(gas_limit) + .maturity(maturity) + .add_random_fee_input() + .finalize_checked(height); + + let receipts = client.transact(tx); + let errors = receipts + .iter() + .any(|r| matches!(r, Receipt::Log{ ra, .. } if *ra == 1)); + + assert!(errors); } #[test] -fn ed25519_verify_error() { - let rng = &mut StdRng::seed_from_u64(2322u64); +fn ed25519_zero_length_is_treated_as_32() { + use ed25519_dalek::Signer; - let secret = SecretKey::random(rng); + let mut client = MemoryClient::default(); - let message = b"The gift of words is the gift of deception and illusion."; - let message = Message::new(message); - let signature = Signature::sign(&secret, &message); + let gas_limit = 1_000_000; + let maturity = Default::default(); + let height = Default::default(); - let altered_message = b"The gift of words is the gift of deception and illusion!"; - let altered_message = Message::new(altered_message); + let mut rng = rand::rngs::OsRng; + let signing_key = ed25519_dalek::SigningKey::generate(&mut rng); + + let message = [1u8; 32]; + let signature = signing_key.sign(&message[..]); - #[rustfmt::skip] let script = vec![ op::gtf_args(0x20, 0x00, GTFArgs::ScriptData), - op::addi(0x21, 0x20, signature.as_ref().len() as Immediate12), - op::addi(0x22, 0x21, altered_message.as_ref().len() as Immediate12), + op::addi(0x21, 0x20, signature.to_bytes().len() as Immediate12), + op::addi(0x22, 0x21, message.as_ref().len() as Immediate12), op::movi(0x10, PublicKey::LEN as Immediate18), op::aloc(0x10), - op::move_(0x11, RegId::HP), - op::ed19(0x11, 0x20, 0x21), - op::log(RegId::ERR, RegId::ZERO, RegId::ZERO, RegId::ZERO), + op::ed19(0x22, 0x20, 0x21, 0), + op::log(RegId::ERR, 0x00, 0x00, 0x00), op::ret(RegId::ONE), ]; - let receipts = run_script(script); - assert_success(&receipts); + let script: Vec = script.into_iter().collect(); - let Some(Receipt::Log { ra, .. }) = receipts.first() else { - panic!("Expected log receipt"); - }; + let script_data = signature + .to_bytes() + .iter() + .copied() + .chain(message.as_ref().iter().copied()) + .chain(signing_key.verifying_key().as_ref().iter().copied()) + .collect(); - assert_eq!(*ra, 1, "Verification should have failed"); + let tx = TransactionBuilder::script(script.clone(), script_data) + .script_gas_limit(gas_limit) + .maturity(maturity) + .add_random_fee_input() + .finalize_checked(height); + + let receipts = client.transact(tx); + let success = receipts + .iter() + .any(|r| matches!(r, Receipt::Log{ ra, .. } if *ra == 0)); + + assert!(success); } #[test] -fn ed25519_verify_a_gt_vmaxram_sub_64() { +fn ed25519_verify__register_a_overflows() { let reg_a = 0x20; let reg_b = 0x21; + let reg_c = 0x22; #[rustfmt::skip] let script = vec![ - op::xor(reg_b, reg_b, reg_b), op::not(reg_a, RegId::ZERO), op::subi(reg_a, reg_a, 63), - op::ed19(reg_a, reg_b, reg_b), + op::movi(reg_c, 32), + op::ed19(reg_a, reg_b, reg_b, reg_c), op::ret(RegId::ONE), ]; @@ -575,33 +642,39 @@ fn ed25519_verify_a_gt_vmaxram_sub_64() { } #[test] -fn ed25519_verify_b_gt_vmaxram_sub_64() { +fn ed25519_verify__register_b_overflows() { let reg_a = 0x20; let reg_b = 0x21; + let reg_c = 0x22; #[rustfmt::skip] let script = vec![ - op::xor(reg_b, reg_b, reg_b), op::not(reg_a, RegId::ZERO), op::subi(reg_a, reg_a, 63), - op::ed19(reg_b, reg_a, reg_b), + op::movi(reg_c, 32), + op::ed19(reg_b, reg_a, reg_b, reg_c), op::ret(RegId::ONE), ]; check_expected_reason_for_instructions(script, MemoryOverflow); } -#[test] -fn ed25519_verify_c_gt_vmaxram_sub_32() { +#[test_case(31, 32 => (); "Just over the end with 32 bits")] +#[test_case(63, 64 => (); "Just over the end with 64 bits")] +#[test_case(31, 0 => (); "Zero defaults to 32")] +#[test_case(31, 100 => (); "Way over the end")] +#[test_case(0, 32 => (); "Empty range, goes over it")] +fn ed25519_verify__message_overflows_ram(offset: u16, len: u32) { let reg_a = 0x20; let reg_b = 0x21; + let reg_c = 0x22; #[rustfmt::skip] let script = vec![ - op::xor(reg_b, reg_b, reg_b), op::not(reg_a, RegId::ZERO), - op::subi(reg_a, reg_a, 31), - op::ed19(reg_b, reg_b, reg_a), + op::subi(reg_a, reg_a, offset), + op::movi(reg_c, len), + op::ed19(reg_b, reg_b, reg_a, reg_c), op::ret(RegId::ONE), ]; @@ -654,13 +727,12 @@ fn sha256() { } #[test] -fn s256_a_gt_vmaxram_sub_32() { +fn s256__register_a_overflows() { let reg_a = 0x20; let reg_b = 0x21; #[rustfmt::skip] let script = vec![ - op::xor(reg_b, reg_b, reg_b), op::not(reg_a, RegId::ZERO), op::s256(reg_a, reg_b, reg_b), ]; @@ -669,7 +741,7 @@ fn s256_a_gt_vmaxram_sub_32() { } #[test] -fn s256_c_gt_mem_max() { +fn s256__register_c_overflows() { let reg_a = 0x20; #[rustfmt::skip] @@ -682,13 +754,12 @@ fn s256_c_gt_mem_max() { } #[test] -fn s256_b_gt_vmaxram_sub_c() { +fn s256___register_b_overflows() { let reg_a = 0x20; let reg_b = 0x21; #[rustfmt::skip] let script = vec![ - op::xor(reg_b, reg_b, reg_b), op::not(reg_a, RegId::ZERO), op::s256(reg_b, reg_a, reg_b), ]; @@ -745,13 +816,12 @@ fn keccak256() { } #[test] -fn k256_a_gt_vmaxram_sub_32() { +fn k256__register_a_overflows() { let reg_a = 0x20; let reg_b = 0x21; #[rustfmt::skip] let script = vec![ - op::xor(reg_b, reg_b, reg_b), op::not(reg_a, RegId::ZERO), op::k256(reg_a, reg_b, reg_b), ]; @@ -766,7 +836,6 @@ fn k256_c_gt_mem_max() { #[rustfmt::skip] let script = vec![ - op::xor(reg_b, reg_b, reg_b), op::not(reg_a, RegId::ZERO), op::k256(reg_b, reg_b, reg_a), ]; @@ -775,13 +844,12 @@ fn k256_c_gt_mem_max() { } #[test] -fn k256_b_gt_vmaxram_sub_c() { +fn k256__register_b_overflows() { let reg_a = 0x20; let reg_b = 0x21; #[rustfmt::skip] let script = vec![ - op::xor(reg_b, reg_b, reg_b), op::not(reg_a, RegId::ZERO), op::k256(reg_b, reg_a, reg_b), ];