diff --git a/substrate/frame/contracts/COMPLEXITY.md b/substrate/frame/contracts/COMPLEXITY.md index 482cb45baf993cf6ad26c912e41323d49aaa13f9..7e8c2903c79b9348d2441b46e181a0c59a6562d0 100644 --- a/substrate/frame/contracts/COMPLEXITY.md +++ b/substrate/frame/contracts/COMPLEXITY.md @@ -480,7 +480,6 @@ This paragraph concerns the following supported built-in hash functions: - `SHA2` with 256-bit width - `KECCAK` with 256-bit width - `BLAKE2` with 128-bit and 256-bit widths -- `TWOX` with 64-bit, 128-bit and 256-bit widths These functions compute a cryptographic hash on the given inputs and copy the resulting hash directly back into the sandboxed Wasm contract output buffer. diff --git a/substrate/frame/contracts/src/tests.rs b/substrate/frame/contracts/src/tests.rs index 3f01096b883970fc50c6cb6ede5c1179658fd08b..2fcd2e58fba91cac996297cd8240d04a27c0bd1a 100644 --- a/substrate/frame/contracts/src/tests.rs +++ b/substrate/frame/contracts/src/tests.rs @@ -2747,9 +2747,6 @@ const CODE_CRYPTO_HASHES: &str = r#" (import "env" "ext_hash_keccak_256" (func $ext_hash_keccak_256 (param i32 i32 i32))) (import "env" "ext_hash_blake2_256" (func $ext_hash_blake2_256 (param i32 i32 i32))) (import "env" "ext_hash_blake2_128" (func $ext_hash_blake2_128 (param i32 i32 i32))) - (import "env" "ext_hash_twox_256" (func $ext_hash_twox_256 (param i32 i32 i32))) - (import "env" "ext_hash_twox_128" (func $ext_hash_twox_128 (param i32 i32 i32))) - (import "env" "ext_hash_twox_64" (func $ext_hash_twox_64 (param i32 i32 i32))) (import "env" "memory" (memory 1 1)) @@ -2760,9 +2757,6 @@ const CODE_CRYPTO_HASHES: &str = r#" $ext_hash_keccak_256 $ext_hash_blake2_256 $ext_hash_blake2_128 - $ext_hash_twox_256 - $ext_hash_twox_128 - $ext_hash_twox_64 ) (data (i32.const 1) "20202010201008") ;; Output sizes of the hashes in order in hex. @@ -2793,9 +2787,6 @@ const CODE_CRYPTO_HASHES: &str = r#" ;; | 1 | KECCAK | 256 | ;; | 2 | BLAKE2 | 256 | ;; | 3 | BLAKE2 | 128 | - ;; | 4 | TWOX | 256 | - ;; | 5 | TWOX | 128 | - ;; | 6 | TWOX | 64 | ;; --------------------------------- (func (export "call") (result i32) (local $chosen_hash_fn i32) @@ -2860,9 +2851,6 @@ fn crypto_hashes() { (dyn_hash_fn!(keccak_256), 32), (dyn_hash_fn!(blake2_256), 32), (dyn_hash_fn!(blake2_128), 16), - (dyn_hash_fn!(twox_256), 32), - (dyn_hash_fn!(twox_128), 16), - (dyn_hash_fn!(twox_64), 8), ]; // Test the given hash functions for the input: "_DEAD_BEEF" for (n, (hash_fn, expected_size)) in test_cases.iter().enumerate() { diff --git a/substrate/frame/contracts/src/wasm/runtime.rs b/substrate/frame/contracts/src/wasm/runtime.rs index 92f2ff782b22cdd0824ec9b2541057a123bc5df3..7cede5542fc6f8bde389f6b99fc960b7b3512e24 100644 --- a/substrate/frame/contracts/src/wasm/runtime.rs +++ b/substrate/frame/contracts/src/wasm/runtime.rs @@ -30,9 +30,6 @@ use sp_io::hashing::{ keccak_256, blake2_256, blake2_128, - twox_256, - twox_128, - twox_64, sha2_256, }; @@ -1118,78 +1115,6 @@ define_env!(Env, <E: Ext>, ext_hash_blake2_128(ctx, input_ptr: u32, input_len: u32, output_ptr: u32) => { compute_hash_on_intermediate_buffer(ctx, blake2_128, input_ptr, input_len, output_ptr) }, - - // Computes the TWOX 256-bit hash on the given input buffer. - // - // Returns the result directly into the given output buffer. - // - // # Note - // - // - The `input` and `output` buffer may overlap. - // - The output buffer is expected to hold at least 32 bytes (256 bits). - // - It is the callers responsibility to provide an output buffer that - // is large enough to hold the expected amount of bytes returned by the - // chosen hash function. - // - // # Parameters - // - // - `input_ptr`: the pointer into the linear memory where the input - // data is placed. - // - `input_len`: the length of the input data in bytes. - // - `output_ptr`: the pointer into the linear memory where the output - // data is placed. The function will write the result - // directly into this buffer. - ext_hash_twox_256(ctx, input_ptr: u32, input_len: u32, output_ptr: u32) => { - compute_hash_on_intermediate_buffer(ctx, twox_256, input_ptr, input_len, output_ptr) - }, - - // Computes the TWOX 128-bit hash on the given input buffer. - // - // Returns the result directly into the given output buffer. - // - // # Note - // - // - The `input` and `output` buffer may overlap. - // - The output buffer is expected to hold at least 16 bytes (128 bits). - // - It is the callers responsibility to provide an output buffer that - // is large enough to hold the expected amount of bytes returned by the - // chosen hash function. - // - // # Parameters - // - // - `input_ptr`: the pointer into the linear memory where the input - // data is placed. - // - `input_len`: the length of the input data in bytes. - // - `output_ptr`: the pointer into the linear memory where the output - // data is placed. The function will write the result - // directly into this buffer. - ext_hash_twox_128(ctx, input_ptr: u32, input_len: u32, output_ptr: u32) => { - compute_hash_on_intermediate_buffer(ctx, twox_128, input_ptr, input_len, output_ptr) - }, - - // Computes the TWOX 64-bit hash on the given input buffer. - // - // Returns the result directly into the given output buffer. - // - // # Note - // - // - The `input` and `output` buffer may overlap. - // - The output buffer is expected to hold at least 8 bytes (64 bits). - // - It is the callers responsibility to provide an output buffer that - // is large enough to hold the expected amount of bytes returned by the - // chosen hash function. - // - // # Parameters - // - // - `input_ptr`: the pointer into the linear memory where the input - // data is placed. - // - `input_len`: the length of the input data in bytes. - // - `output_ptr`: the pointer into the linear memory where the output - // data is placed. The function will write the result - // directly into this buffer. - ext_hash_twox_64(ctx, input_ptr: u32, input_len: u32, output_ptr: u32) => { - compute_hash_on_intermediate_buffer(ctx, twox_64, input_ptr, input_len, output_ptr) - }, ); /// Computes the given hash function on the scratch buffer.