Keyboard shortcuts

Press or to navigate between chapters

Press ? to show this help

Press Esc to hide this help

create_private_key

Creates a Bitcoin private key from a u256 value with validation.

Validates that the provided key value is within the secp256k1 curve order and creates a properly formatted Bitcoin private key structure.

Arguments

  • key - The private key scalar value (must be 1 < key < curve_order)
  • network - The Bitcoin network this key will be used on
  • compressed - Whether the corresponding public key should use compressed format

Returns

  • BitcoinPrivateKey - Validated private key structure

Panics

Panics if key is zero or exceeds the secp256k1 curve order.

Fully qualified path: alexandria_btc::keys::create_private_key

pub fn create_private_key(key: u256, network: BitcoinNetwork, compressed: bool) -> BitcoinPrivateKey