I have signed the message, using ed25519
const msg = Buffer.from("hi");
const signerKeyPair = await keyStore.getKey(config.networkId, signerAccount);
const { signature } = signerKeyPair.sign(msg);
How to verify the signature in the smart contract if I have a signature and signer PublicKey?
I've found that near-core uses a near-crypto crate to do it, but I'm not sure that I can use it for the smart contracts.
an example using near-core
use near_crypto::{PublicKey, Signature, KeyType};
...
pub fn verify(&self, data: &[u8], public_key: String) -> bool {
let public_key = PublicKey::from_str(&public_key).unwrap();
let signature = Signature::empty(KeyType::SECP256K1);
signature.verify(data, &public_key)
}
...