Is it possible to convert secp256k1 private key to valid sr25519 key?


1 Answer 1


Is it possible to convert secp256k1 private key to valid sr25519 key?

Yes. It's possible to convert any secret piece of data to private or secret key of any cryptosystem, by using that piece of data as seed of a deterministic key generator for said destination cryptosystem. And it's reasonable to do so when there is enough entropy in the source data, including in the case in point since a secp256k1 private key has nearly 256 bits of entropy, when sr25519 is content with a little above 252. Looking at it's spec, it looks like GenPrivKeyFromSecret would do, irrespective of the format of the source key.

Absent a stated purpose, it's hard to be more precise. And it's uncertain the whole endeavor serves a useful purpose. It goes against a common recommendation that I rephrase as:

one use, one key

where you can change use to usage, purpose, website, device… and key to secret, secret key, private key, passphrase, password, PIN…

  • $\begingroup$ I also included the description of bit clamping, the fact that the public key is not compatible and that you might want to use a KDF (although GenPrivKeyFromSecret already does that using SHA-512 basically: see here) in an answer that I was writing. Do you have any idea why SHA-512 is used instead of SHA-256 in that library? $\endgroup$
    – Maarten Bodewes
    Nov 25, 2021 at 15:30
  • $\begingroup$ @MaartenBodewes : Yes, I (now) see your nice deleted answer. I think using SHA-512 has to do with Ed25519 traditionally using SHA-512 as a PRF to generate pseudorandom scalars multiplying group elements, with optional reduction modulo prime $\ell=2^{252}+27742317777372353535851937790883648493$ or multiple thereof, in the interest of parameterizable resistance to side-channel attacks. $\endgroup$
    – fgrieu
    Nov 25, 2021 at 15:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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