Line data Source code
1 : #include "fd_keyguard_bls.h" 2 : #include "../../ballet/ed25519/fd_ed25519.h" 3 : 4 : void FD_FN_SENSITIVE 5 : fd_keyguard_bls_key_derive( fd_keyguard_bls_key_t * key, 6 : uchar const ed25519_public_key[ static 32 ], 7 : uchar const ed25519_private_key[ static 32 ], 8 0 : fd_sha512_t * sha ) { 9 0 : uchar check_public_key[ 32 ]; 10 0 : fd_ed25519_public_from_private( check_public_key, ed25519_private_key, sha ); 11 0 : if( FD_UNLIKELY( memcmp( check_public_key, ed25519_public_key, 32UL ) ) ) 12 0 : FD_LOG_EMERG(( "The public key in the key file does not match the public key derived from the private key. " 13 0 : "Firedancer will not use the key pair to sign as it might leak the private key." )); 14 : 15 0 : static char const derive_msg[] = "bls-key-derive-alpenglow"; 16 : 17 0 : uchar ikm[ FD_ED25519_SIG_SZ ]; 18 0 : fd_ed25519_sign( ikm, (uchar const *)derive_msg, sizeof(derive_msg)-1UL, ed25519_public_key, ed25519_private_key, sha ); 19 0 : fd_bls_sec_derive( &key->secret_key, ikm, sizeof(ikm) ); 20 0 : fd_memzero_explicit( ikm, sizeof(ikm) ); 21 : 22 0 : fd_bls_pub_t public_key[1]; 23 0 : fd_bls_sec_to_pub( &key->secret_key, public_key ); 24 0 : blst_p1_affine_compress( key->public_key, public_key ); 25 0 : }