uma/jimmy

Programming Bitcoin library

Maintainers

Details

github.com/1ma/jimmy

Source

Issues

Installs: 13

Dependents: 0

Suggesters: 0

Security: 0

Stars: 4

Watchers: 1

Forks: 1

Open Issues: 0

Type:project

dev-master 2025-04-23 21:12 UTC

This package is auto-updated.

Last update: 2025-04-23 21:12:39 UTC


README

CI Coverage

This is 1ma's unfinished Bitcoin Cathedral of Doom.

cathedral of doom

Installation

composer require uma/jimmy:dev-master

Disclaimer

This project started as a PHP implementation of Jimmy Song's Programming Bitcoin library. However, since completing the book the library has kept evolving and turned into a sprawling testbed where I implement any other aspects of Bitcoin I find interesting.

This is toy grade code meant to learn concepts, not to be used in real projects that reach production.

It's not performant, it's not tested extensively, and it hasn't been reviewed. If you use it on mainnet you will possibly leak private keys, create transactions with invalid UTXOs that cannot be spent, etc.

To emphasize this I won't tag any release, and I don't promise any kind of backward compatibility. To further emphasize it the library assumes that it runs on testnet by default instead of mainnet.

Book Chapters Implemented

  • Chapter 1: Finite Fields
  • Chapter 2: Elliptic Curves
  • Chapter 3: Elliptic Curve Cryptography
  • Chapter 4: Serialization
  • Chapter 5: Transactions
  • Chapter 6: Script
  • Chapter 7: Transaction Creation and Validation
  • Chapter 8: Pay-to-Script Hash
  • Chapter 9: Blocks
  • Chapter 10: Networking
  • Chapter 11: Simplified Payment Verification
  • Chapter 12: Bloom Filters
  • Chapter 13: SegWit

Other Areas of Interest

  • BIP-0032: Hierarchical Deterministic Wallets
  • BIP-0039: Mnemonic code for generating deterministic keys
  • BIP-0043: Purpose Field for Deterministic Wallets
  • BIP-0044: Multi-Account Hierarchy for Deterministic Wallets
  • BIP-0066: Strict DER signatures
  • BIP-0067: Deterministic Pay-to-script-hash multi-signature addresses through public key sorting
  • BIP-0084: Derivation scheme for P2WPKH based accounts
  • BIP-0086: Key Derivation for Single Key P2TR Outputs
  • BIP-0173: Base32 address format for native v0-16 witness outputs
  • BIP-0322: Generic Signed Message Format
  • BIP-0325: Signet
  • BIP-0340: Schnorr Signatures for secp256k1
  • BIP-0341: Taproot
  • BIP-0342: Validation of Taproot Scripts
  • BIP-0350: Bech32m format for v1+ witness addresses
  • BIP-0370: Partially Signed Bitcoin Transaction Format Version 2
  • BIP-0371: Taproot Fields for PSBT
  • Wycheproof ECDSA compliance

How

Implementing the code related to ECC requires doing math operations on 256-bit integers, that's why the book uses Python.

PHP, like most programming languages, only has 32 or 64-bit integers that match the machine's word size. However, the language has a native binding to libgmp that provides support for representing and doing math on arbitrarily large integers with bearable (though not adequate) performance, just like Python.

To reiterate, this code is certainly vulnerable to timing side-channel attacks and other problems, do not use it in production.