Skip to main content

Answer: CouldIt's not possible to directly compute the ed25519 public key from the private key. Instead, useduse the deterministic private key to create a seed, then useduse the seed to re-create the private key with its corresponding public key. The following code snippet assumes ed25519_skpked25519_skpk is already initialized:

char hex_ed_pk[65];
unsigned char seed[crypto_sign_SEEDBYTES];
unsigned char ed25519_skpk[crypto_sign_ed25519_SECRETKEYBYTES];
unsigned char ed25519_pk[crypto_sign_ed25519_PUBLICKEYBYTES];

// COMPUTE ED25519 PUBLIC KEY, REQUIRES ESTABLISHING A SEED (void)crypto_sign_ed25519_sk_to_seed( seed,ed25519_skpk);
(void)crypto_sign_seed_keypair( ed25519_pk, ed25519_skpk, seed );
(void)sodium_bin2hex( hex_ed_pk, 65, ed25519_pk, 32 );

char           hex_ed_pk[65];                                      
unsigned char  seed[crypto_sign_SEEDBYTES];                       
unsigned char  ed25519_skpk[crypto_sign_ed25519_SECRETKEYBYTES];        
unsigned char  ed25519_pk[crypto_sign_ed25519_PUBLICKEYBYTES];

// COMPUTE ED25519 PUBLIC KEY, REQUIRES ESTABLISHING A SEED
(void)crypto_sign_ed25519_sk_to_seed( seed,ed25519_skpk);                
(void)crypto_sign_seed_keypair( ed25519_pk, ed25519_skpk, seed );      
(void)sodium_bin2hex( hex_ed_pk, 65, ed25519_pk, 32 );

Answer: Could not directly compute the ed25519 public key from the private key. Instead, used the deterministic private key to create a seed, then used the seed to re-create the private key with its corresponding public key. The following code snippet assumes ed25519_skpk is already initialized:

char hex_ed_pk[65];
unsigned char seed[crypto_sign_SEEDBYTES];
unsigned char ed25519_skpk[crypto_sign_ed25519_SECRETKEYBYTES];
unsigned char ed25519_pk[crypto_sign_ed25519_PUBLICKEYBYTES];

// COMPUTE ED25519 PUBLIC KEY, REQUIRES ESTABLISHING A SEED (void)crypto_sign_ed25519_sk_to_seed( seed,ed25519_skpk);
(void)crypto_sign_seed_keypair( ed25519_pk, ed25519_skpk, seed );
(void)sodium_bin2hex( hex_ed_pk, 65, ed25519_pk, 32 );

It's not possible to directly compute the ed25519 public key from the private key. Instead, use the deterministic private key to create a seed, then use the seed to re-create the private key with its corresponding public key. The following code snippet assumes ed25519_skpk is already initialized:

char           hex_ed_pk[65];                                      
unsigned char  seed[crypto_sign_SEEDBYTES];                       
unsigned char  ed25519_skpk[crypto_sign_ed25519_SECRETKEYBYTES];        
unsigned char  ed25519_pk[crypto_sign_ed25519_PUBLICKEYBYTES];

// COMPUTE ED25519 PUBLIC KEY, REQUIRES ESTABLISHING A SEED
(void)crypto_sign_ed25519_sk_to_seed( seed,ed25519_skpk);                
(void)crypto_sign_seed_keypair( ed25519_pk, ed25519_skpk, seed );      
(void)sodium_bin2hex( hex_ed_pk, 65, ed25519_pk, 32 );
Source Link
skaht
  • 3.1k
  • 1
  • 14
  • 23

Answer: Could not directly compute the ed25519 public key from the private key. Instead, used the deterministic private key to create a seed, then used the seed to re-create the private key with its corresponding public key. The following code snippet assumes ed25519_skpk is already initialized:

char hex_ed_pk[65];
unsigned char seed[crypto_sign_SEEDBYTES];
unsigned char ed25519_skpk[crypto_sign_ed25519_SECRETKEYBYTES];
unsigned char ed25519_pk[crypto_sign_ed25519_PUBLICKEYBYTES];

// COMPUTE ED25519 PUBLIC KEY, REQUIRES ESTABLISHING A SEED (void)crypto_sign_ed25519_sk_to_seed( seed,ed25519_skpk);
(void)crypto_sign_seed_keypair( ed25519_pk, ed25519_skpk, seed );
(void)sodium_bin2hex( hex_ed_pk, 65, ed25519_pk, 32 );