cardano-crypto icon indicating copy to clipboard operation
cardano-crypto copied to clipboard

Cardano xPrv to Crypto.PubKey.Ed25519.SecretKey

Open volodyad opened this issue 3 years ago • 0 comments

Ib cardano we have next methods

Generate extended public key from private key
toXPub :: HasCallStack => XPrv -> XPub
toXPub (XPrv ekey) = XPub pub (ChainCode cc)
  where (_,r)     = B.splitAt 64 $ convert ekey
        (pub, cc) = B.splitAt 32 r

Return the Ed25519 public key associated with a XPub context
xPubGetPublicKey :: XPub -> Ed25519.PublicKey
xPubGetPublicKey (XPub pub _) =
    throwCryptoError $ Ed25519.publicKey pub

How can we get Ed25519.SecretKey from XPrv ? Ed25519.SecretKey expects 32 bytes, how to map first XPriv 64 bytes to Ed25519.SecretKey ?

volodyad avatar Oct 14 '21 15:10 volodyad