pub fn key_recover_bls(
    private_key: &PrivateKey,
    testnet: bool,
) -> Result<ExtendedKey, SignerError> {
    let sk = bls_signatures::PrivateKey::from_bytes(&private_key.0)?;

    let mut address = Address::new_bls(&sk.public_key().as_bytes())?;

    if testnet {
        address.set_network(Network::Testnet);
    } else {
        address.set_network(Network::Mainnet);
    }

    let mut secret_key = PrivateKey([0; SECRET_KEY_SIZE]);
    secret_key.0.copy_from_slice(&sk.as_bytes());

    Ok(ExtendedKey {
        private_key: secret_key,
        public_key: PublicKey::BLSPublicKey(sk.public_key()),
        address: address.to_string(),
    })
}
/// Get extended key from BLS private key
///
/// # Arguments
///
/// * `private_key` - A `bls_signatures::PrivateKey`
/// * `testnet` - specify the network, `true` if testnet else `false` for mainnet
///
Get extended key from BLS private key
Get extended key from BLS private key
pub fn key_recover_bls(
    private_key: &PrivateKey,
    testnet: bool,
) -> Result<ExtendedKey, SignerError> {
    let sk = bls_signatures::PrivateKey::from_bytes(&private_key.0)?;
    let mut address = Address::new_bls(&sk.public_key().as_bytes())?;
    if testnet {
        address.set_network(Network::Testnet);
    } else {
        address.set_network(Network::Mainnet);
    }
    let mut secret_key = PrivateKey([0; SECRET_KEY_SIZE]);
    secret_key.0.copy_from_slice(&sk.as_bytes());
    Ok(ExtendedKey {
        private_key: secret_key,
        public_key: PublicKey::BLSPublicKey(sk.public_key()),
        address: address.to_string(),
    })
}
pub fn key_recover_bls ( private_key : & PrivateKey , testnet : bool , ) -> Result < ExtendedKey , SignerError > { let sk = bls_signatures :: PrivateKey :: from_bytes ( & private_key . 0 ) ? ; let mut address = Address :: new_bls ( & sk . public_key ( ) . as_bytes ( ) ) ? ; if testnet { address . set_network ( Network :: Testnet ) ; } else { address . set_network ( Network :: Mainnet ) ; } let mut secret_key = PrivateKey ( [ 0 ; SECRET_KEY_SIZE ] ) ; secret_key . 0 . copy_from_slice ( & sk . as_bytes ( ) ) ; Ok ( ExtendedKey { private_key : secret_key , public_key : PublicKey :: BLSPublicKey ( sk . public_key ( ) ) , address : address . to_string ( ) , } ) }
Get extended key from BLS private key
Get extended key from BLS private key
private_key
&PrivateKey
testnet
bool
private_key
&PrivateKey
testnet
bool