If I sign with Ethereum’s private key and then send it to canister, how can I verify it with motoko.
Hi! There are at least two possible ways to do this:
-
The evm-txs.mo library implements a
Helper.getRecoveryId()
function as shown in this test case. This can be used to verify an ECDSA signature. Note that I would be wary of using this in production until this library undergoes a security audit. -
The ic-eth-starter project includes a Rust canister with a
verify_ecdsa
method (source code). This uses the secure and widely used ethers-core Rust package but requires some setup to be able to call this canister from your project.
Hopefully one of these solutions ends up working for you! I am currently also building a tool which makes it easier to use Rust libraries in Motoko, but it’s too early in development for me to recommend quite yet (as of February 2024).