Verify that the method ID and the recipient are one of the allowed combination, which for example is set by [from_eth::to_fvm_message]. The method ID is not part of the signature, so someone could modify it, which is why we have to check explicitly that there is nothing untowards going on.
(msg: &Message)
| 287 | /// The method ID is not part of the signature, so someone could modify it, which is |
| 288 | /// why we have to check explicitly that there is nothing untowards going on. |
| 289 | fn verify_eth_method(msg: &Message) -> Result<(), SignedMessageError> { |
| 290 | if msg.to == eam::EAM_ACTOR_ADDR { |
| 291 | if msg.method_num != eam::Method::CreateExternal as u64 { |
| 292 | return Err(SignedMessageError::Ethereum(anyhow!( |
| 293 | "The EAM actor can only be called with CreateExternal; got {}", |
| 294 | msg.method_num |
| 295 | ))); |
| 296 | } |
| 297 | } else if msg.method_num != evm::Method::InvokeContract as u64 { |
| 298 | return Err(SignedMessageError::Ethereum(anyhow!( |
| 299 | "An EVM actor can only be called with InvokeContract; got {} - {}", |
| 300 | msg.to, |
| 301 | msg.method_num |
| 302 | ))); |
| 303 | } |
| 304 | Ok(()) |
| 305 | } |
| 306 | |
| 307 | /// Sign a hash using the secret key. |
| 308 | pub fn sign_secp256k1(sk: &SecretKey, hash: &[u8; 32]) -> Signature { |