diff --git a/pallets/identity-management-mock/src/lib.rs b/pallets/identity-management-mock/src/lib.rs index 7752c75fae..afc961373e 100644 --- a/pallets/identity-management-mock/src/lib.rs +++ b/pallets/identity-management-mock/src/lib.rs @@ -546,7 +546,7 @@ pub mod pallet { ) -> DispatchResult { let code = Self::challenge_codes(who, identity).ok_or(Error::::ChallengeCodeNotExist)?; - let msg = Self::get_expected_web3_message(who, identity, &code)?; + let msg = Self::get_expected_payload(who, identity, &code)?; ensure!( msg.as_slice() == validation_data.message.as_slice(), @@ -599,7 +599,7 @@ pub mod pallet { ) -> DispatchResult { let code = Self::challenge_codes(who, identity).ok_or(Error::::ChallengeCodeNotExist)?; - let msg = Self::get_expected_web3_message(who, identity, &code)?; + let msg = Self::get_expected_payload(who, identity, &code)?; let digest = Self::compute_evm_msg_digest(&msg); if let IdentityMultiSignature::Ethereum(sig) = &validation_data.signature { let recovered_evm_address = Self::recover_evm_address(&digest, sig.as_ref()) @@ -621,10 +621,9 @@ pub mod pallet { Ok(()) } - // web3 message format: + + , where - // <> means SCALE-encoded - // Notice: actually we use the same format for web2 message too - pub fn get_expected_web3_message( + // Payload format: blake2_256( + + ), where + // <> means SCALE-encoded. It applies to both web2 and web3 message + pub fn get_expected_payload( who: &T::AccountId, identity: &Identity, code: &ChallengeCode, @@ -632,7 +631,7 @@ pub mod pallet { let mut msg = code.encode(); msg.append(&mut who.encode()); msg.append(&mut identity.encode()); - Ok(msg) + Ok(blake2_256(&msg).to_vec()) } // we use an EIP-191 message has computing diff --git a/pallets/identity-management-mock/src/mock.rs b/pallets/identity-management-mock/src/mock.rs index 8309b1218e..20cd46aa83 100644 --- a/pallets/identity-management-mock/src/mock.rs +++ b/pallets/identity-management-mock/src/mock.rs @@ -177,7 +177,7 @@ pub fn create_mock_polkadot_validation_data( code: ChallengeCode, ) -> ValidationData { let identity = create_mock_polkadot_identity(p.public().0); - let msg = IdentityManagementMock::get_expected_web3_message(&who, &identity, &code) + let msg = IdentityManagementMock::get_expected_payload(&who, &identity, &code) .expect("cannot calculate web3 message"); let sig = p.sign(&msg); @@ -194,7 +194,7 @@ pub fn create_mock_eth_validation_data( code: ChallengeCode, ) -> ValidationData { let identity = create_mock_eth_identity(p.address().0); - let msg = IdentityManagementMock::get_expected_web3_message(&who, &identity, &code) + let msg = IdentityManagementMock::get_expected_payload(&who, &identity, &code) .expect("cannot calculate web3 message"); let digest = IdentityManagementMock::compute_evm_msg_digest(&msg); let sig = sign(p.secret(), &Message::from(digest)).unwrap();