pub fn build_p2pkh_circuit(
builder: &CircuitBuilder,
private_key: &BigUint,
expected_address: [Wire; 5],
)Expand description
Builds a circuit that proves knowledge of a Bitcoin private key corresponding to a P2PKH address.
This circuit implements the complete Bitcoin P2PKH address derivation: Private Key → [scalar_mul] → Curve Point → [compress] → Compressed PubKey → [sha256] → SHA256 Digest → [swap_bytes_32] → LE Format → [ripemd160] → Address
§Arguments
builder- Circuit builder for constructing constraintsprivate_key- Private key as BigUint (4 limbs, 256 bits)expected_address- Expected Bitcoin address as RIPEMD160 output (5 × 32-bit words)
§Circuit Flow
- Multiply private key by secp256k1 generator point
- Compress the resulting public key to 33-byte format
- Compute SHA256 hash of compressed public key
- Convert SHA256 output from big-endian to little-endian format
- Compute RIPEMD160 hash of the SHA256 digest
- Assert computed address equals expected address
§Panics
- If private_key doesn’t have exactly 4 limbs (256 bits)