I've seen some Substrate repo's where the SessionKeys (Aura, Babe, Grandpa, etc) are used with unchecked_into() .While the stash/controller keys are only used with into(). These are some examples:

Can someone please explain the actual reasoning behind this?

1 Answer 1


Because AccountId was implemented From<[u8; 32]>. And the KeyId(aura, babe, grandpa...) was implemented UncheckedFrom<[u8; 32]> instead of From<[u8; 32]>.

Read more: https://paritytech.github.io/substrate/master/sp_core/crypto/trait.UncheckedFrom.html

  • But, is there a specific reason behind these implementations? like, why isn't From<[u8; 32]> is implemented for KeyId?
    – Discardo
    Commented Jun 7, 2023 at 10:00
  • I think there is no specific reason. Those key types are generated by the macro. Maybe they want to make the macro more generic. And chose not to provide an infallible method.
    – AurevoirXavier
    Commented Jun 8, 2023 at 6:55

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.