0

In my last question, I asked about how to generate key pair in substrate.But it seems that it is hard to do this.So I have to make a conclusion that I can't generate key pair in substrate sadly. But my intuition told me that I was wrong. So if somebody knows the truth about my question,please tell me.

In the course of struggling against the problem,I still puzzled why I can't use sp_core::Pair in my pallet code. Or who can tell me under what conditions I can import this item to my code.Is there some features or attributs that can help me to import sp_core::Pair into my code. I am not very clear with the condition compilation course of runtime especially the influence of cfg feature. Hope to learn this,anything about this is good for me.

Thanks!!!

0

1 Answer 1

1

It's not possible to use sp_core::Pair in your runtime.

By design, the Pair trait (as well as other traits with the full_crypto feature) don't support WASM runtimes.

This is because the WASM runtimes will be compiled for no_std environments too, which isn't a suitable environment for hash-based functions (like random seed generation).

2
  • Thanky you for explain this to me. But the substrate official website says “A secure, local entropy source for random number generation” in offchain worker. So how can I use this feature to generate randoms or even generate key pair?
    – kugool
    Aug 19, 2022 at 8:01
  • You can try again by asking what you are actually trying to archive. Creating a Pair seems like the solution that you came up with, but its not possible on-chain. Off-chain is something different. Aug 22, 2022 at 10:21

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.