Function private_key_from_wif

Source
pub fn private_key_from_wif(
    wif: &str,
) -> Result<Secp256r1PrivateKey, CryptoError>
Expand description

Converts a WIF (Wallet Import Format) string into a Secp256r1PrivateKey.

This function decodes a WIF string, verifies its format and checksum, and then constructs a Secp256r1PrivateKey from it.

§Arguments

  • wif - A string slice representing the WIF to be converted.

§Returns

A Result which is Ok with Secp256r1PrivateKey if the WIF string is valid, or an Err with CryptoError if the WIF string is invalid.

§Errors

This function returns an error if:

  • The WIF string is not properly base58 encoded.
  • The decoded data does not have the correct length, prefix, or suffix expected for a WIF.
  • The checksum of the WIF does not match the expected value.