# How to convert a nacl signing key to encryption key (NACL)

Because of the assumption of joint security, I want to use the same keypair for signing (ed22519) and encryption key exchange (x25519)

How can I share the same public key for my nacl.box.keyPair and nacl.sign.keyPair ?

As I understand it should be possible because both are on the same curve.

nacl seems to transform his ed22519 private key using this function:

  crypto_hash(d, sk, 32);
d[0] &= 248;
d[31] &= 127;
d[31] |= 64;


A failed attempt

const nacl = require('tweetnacl')

seed = nacl.randomBytes(32)

box_keypair = nacl.box.keyPair.fromSecretKey(seed)

k = new Uint8Array(Buffer.concat([box_keypair.publicKey, box_keypair.secretKey]))
sign_keypair = nacl.sign.keyPair.fromSecretKey(k)

msg = nacl.randomBytes(32)
signed_msg = nacl.sign(msg, sign_keypair.secretKey)
verif = nacl.sign.open(signed_msg, sign_keypair.publicKey)
console.log(msg, signed_msg, verif) // null
$$$$

• This is not a correct approach. Your signature key has a long lifetime, on the other hand, the x25519 key must be randomly generated per key exchange so that you can ephemeral-ephemeral key exchange that is mandated in TLS 1.3. If you really need, use k` in both Oct 14, 2021 at 21:23
• Oct 15, 2021 at 1:22