From d3fa1fb0f5a1ff19f3aea7493c4d686cb2031f1b Mon Sep 17 00:00:00 2001 From: Alexander Gryaznov Date: Thu, 19 May 2022 18:37:05 +0300 Subject: [PATCH] make seal_ecdsa test cases differ from the one used in the pallet --- crates/env/src/api.rs | 27 ++++++++++++--------------- crates/lang/src/env_access.rs | 33 +++++++++++++++------------------ 2 files changed, 27 insertions(+), 33 deletions(-) diff --git a/crates/env/src/api.rs b/crates/env/src/api.rs index a39c348924c..581d7dabb4f 100644 --- a/crates/env/src/api.rs +++ b/crates/env/src/api.rs @@ -482,20 +482,18 @@ where /// /// ``` /// const signature: [u8; 65] = [ -/// 161, 234, 203, 74, 147, 96, 51, 212, 5, 174, 231, 9, 142, 48, 137, 201, -/// 162, 118, 192, 67, 239, 16, 71, 216, 125, 86, 167, 139, 70, 7, 86, 241, -/// 33, 87, 154, 251, 81, 29, 160, 4, 176, 239, 88, 211, 244, 232, 232, 52, -/// 211, 234, 100, 115, 230, 47, 80, 44, 152, 166, 62, 50, 8, 13, 86, 175, -/// 28, +/// 195, 218, 227, 165, 226, 17, 25, 160, 37, 92, 142, 238, 4, 41, 244, 211, 18, 94, +/// 131, 116, 231, 116, 255, 164, 252, 248, 85, 233, 173, 225, 26, 185, 119, 235, +/// 137, 35, 204, 251, 134, 131, 186, 215, 76, 112, 17, 192, 114, 243, 102, 166, 176, +/// 140, 180, 124, 213, 102, 117, 212, 89, 89, 92, 209, 116, 17, 28, /// ]; /// const message_hash: [u8; 32] = [ -/// 162, 28, 244, 179, 96, 76, 244, 178, 188, 83, 230, 248, 143, 106, 77, 117, -/// 239, 95, 244, 171, 65, 95, 62, 153, 174, 166, 182, 28, 130, 73, 196, 208 +/// 167, 124, 116, 195, 220, 156, 244, 20, 243, 69, 1, 98, 189, 205, 79, 108, 213, +/// 78, 65, 65, 230, 30, 17, 37, 184, 220, 237, 135, 1, 209, 101, 229, /// ]; /// const EXPECTED_COMPRESSED_PUBLIC_KEY: [u8; 33] = [ -/// 2, 121, 190, 102, 126, 249, 220, 187, 172, 85, 160, 98, 149, 206, 135, 11, -/// 7, 2, 155, 252, 219, 45, 206, 40, 217, 89, 242, 129, 91, 22, 248, 23, -/// 152, +/// 3, 110, 192, 35, 209, 24, 189, 55, 218, 250, 100, 89, 40, 76, 222, 208, 202, 127, +/// 31, 13, 58, 51, 242, 179, 13, 63, 19, 22, 252, 164, 226, 248, 98, /// ]; /// let mut output = [0; 33]; /// ink_env::ecdsa_recover(&signature, &message_hash, &mut output); @@ -517,13 +515,12 @@ pub fn ecdsa_recover( /// /// ``` /// let pub_key = [ -/// 2, 141, 181, 91, 5, 219, 134, 192, 177, 120, 108, 164, 159, 9, 93, 118, -/// 52, 76, 158, 96, 86, 178, 240, 39, 1, 167, 231, 243, 194, 10, 171, 253, -/// 145, +/// 3, 110, 192, 35, 209, 24, 189, 55, 218, 250, 100, 89, 40, 76, 222, 208, 202, 127, +/// 31, 13, 58, 51, 242, 179, 13, 63, 19, 22, 252, 164, 226, 248, 98, /// ]; /// let EXPECTED_ETH_ADDRESS = [ -/// 9, 35, 29, 167, 177, 154, 1, 111, 158, 87, 109, 35, 177, 98, 119, 6, 47, -/// 77, 70, 168, +/// 253, 240, 181, 194, 143, 66, 163, 109, 18, 211, 78, 49, 177, 94, 159, 79, 207, +/// 37, 21, 191, /// ]; /// let mut output = [0; 20]; /// ink_env::ecdsa_to_eth_address(&pub_key, &mut output); diff --git a/crates/lang/src/env_access.rs b/crates/lang/src/env_access.rs index cc01db9cb51..84e4cb02963 100644 --- a/crates/lang/src/env_access.rs +++ b/crates/lang/src/env_access.rs @@ -796,21 +796,19 @@ where /// #[ink(message)] /// pub fn ecdsa_recover(&self) { /// const signature: [u8; 65] = [ - /// 161, 234, 203, 74, 147, 96, 51, 212, 5, 174, 231, 9, 142, 48, 137, 201, - /// 162, 118, 192, 67, 239, 16, 71, 216, 125, 86, 167, 139, 70, 7, 86, 241, - /// 33, 87, 154, 251, 81, 29, 160, 4, 176, 239, 88, 211, 244, 232, 232, 52, - /// 211, 234, 100, 115, 230, 47, 80, 44, 152, 166, 62, 50, 8, 13, 86, 175, - /// 28, + /// 195, 218, 227, 165, 226, 17, 25, 160, 37, 92, 142, 238, 4, 41, 244, 211, 18, 94, + /// 131, 116, 231, 116, 255, 164, 252, 248, 85, 233, 173, 225, 26, 185, 119, 235, + /// 137, 35, 204, 251, 134, 131, 186, 215, 76, 112, 17, 192, 114, 243, 102, 166, 176, + /// 140, 180, 124, 213, 102, 117, 212, 89, 89, 92, 209, 116, 17, 28, /// ]; /// const message_hash: [u8; 32] = [ - /// 162, 28, 244, 179, 96, 76, 244, 178, 188, 83, 230, 248, 143, 106, 77, 117, - /// 239, 95, 244, 171, 65, 95, 62, 153, 174, 166, 182, 28, 130, 73, 196, 208 + /// 167, 124, 116, 195, 220, 156, 244, 20, 243, 69, 1, 98, 189, 205, 79, 108, 213, + /// 78, 65, 65, 230, 30, 17, 37, 184, 220, 237, 135, 1, 209, 101, 229, + /// ]; + /// const EXPECTED_COMPRESSED_PUBLIC_KEY: [u8; 33] = [ + /// 3, 110, 192, 35, 209, 24, 189, 55, 218, 250, 100, 89, 40, 76, 222, 208, 202, 127, + /// 31, 13, 58, 51, 242, 179, 13, 63, 19, 22, 252, 164, 226, 248, 98, /// ]; - /// let EXPECTED_COMPRESSED_PUBLIC_KEY: [u8; 33] = [ - /// 2, 121, 190, 102, 126, 249, 220, 187, 172, 85, 160, 98, 149, 206, 135, 11, - /// 7, 2, 155, 252, 219, 45, 206, 40, 217, 89, 242, 129, 91, 22, 248, 23, - /// 152, - /// ].into(); /// let result = self.env().ecdsa_recover(&signature, &message_hash); /// assert!(result.is_ok()); /// assert_eq!(result.unwrap().as_ref(), EXPECTED_COMPRESSED_PUBLIC_KEY.as_ref()); @@ -857,13 +855,12 @@ where /// #[ink(message)] /// pub fn ecdsa_to_eth_address(&self) { /// let pub_key = [ - /// 2, 141, 181, 91, 5, 219, 134, 192, 177, 120, 108, 164, 159, 9, 93, 118, - /// 52, 76, 158, 96, 86, 178, 240, 39, 1, 167, 231, 243, 194, 10, 171, 253, - /// 145, + /// 3, 110, 192, 35, 209, 24, 189, 55, 218, 250, 100, 89, 40, 76, 222, 208, 202, 127, + /// 31, 13, 58, 51, 242, 179, 13, 63, 19, 22, 252, 164, 226, 248, 98, /// ]; - /// let EXPECTED_ETH_ADDRESS = [ - /// 9, 35, 29, 167, 177, 154, 1, 111, 158, 87, 109, 35, 177, 98, 119, 6, 47, - /// 77, 70, 168, + /// let EXPECTED_ETH_ADDRESS = [ + /// 253, 240, 181, 194, 143, 66, 163, 109, 18, 211, 78, 49, 177, 94, 159, 79, 207, + /// 37, 21, 191, /// ]; /// let output = self /// .env()