1

I have defined an extrinsic function as follows

#[pallet::call_index(0)]
        #[pallet::weight(T::WeightInfo::create_record())]
        pub fn create_record(
            origin: OriginFor<T>,
            issuer_account: T::AccountId,
            input: Data<T::PublicKeySize, T::SignatureSize>,
        ) -> DispatchResult {
            let _who = ensure_signed(origin)?;
             
            let generated_public_key_from_bytes = Public::from_slice(&input.public_key)
                .map_err(|_| Error::<T>::InvalidPublicKey)?;

            let generated_signature_from_bytes = Signature::from_slice(&input.signature).ok_or(Error::<T>::InvalidSignature)?;

         

            let is_signature_valid = generated_public_key_from_bytes
                .verify(&input.public_key, &generated_signature_from_bytes)
                .is_ok();


                // more code here

                Ok(())
}

When I try to call verify function it says its not found. Im using polkadot version 0.9.42 This public key is an ED25519 Key ,

The errors which Im getting

error[E0599]: no method named verify found for struct sp_core::ecdsa::Public in the current scope

and gives this suggestion

help: the following trait is implemented but not in scope; perhaps add a `use` for it:
    |
32  +     use frame_support::sp_runtime::sp_application_crypto::RuntimePublic;

But its none existing path

Tried importing

 use sp_runtime::traits::Verify;

and

    use sp_runtime::RuntimeAppPublic;

separately, but there is no luck

Im getting the same error if I use use sp_core::ed25519

I have referred to this How to verify a signature in a Pallet? but it was not helpful in this scenario

How to call verify function to check the signature?

1 Answer 1

1

try importing sp_runtime::RuntimeAppPublic it has the verify method

2
  • Gets the same error .verify(&input.public_key, &generated_signature_from_bytes) | | -^^^^^^ method cannot be called on Public due to unsatisfied trait bounds
    – Kalanamith
    Sep 10, 2023 at 7:33
  • @not0x12 try adding also use sp_runtime::app_crypto::RuntimePublic; this should work
    – dadzerlaze
    Sep 11, 2023 at 8:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.