1. **`openssl` (⚠️ Limited for secp256k1)** **OpenSSL** is built-in on macOS, but it does **not support `secp256k1`** out of the box for ECC operations. It supports only NIST curves by default. * ✅ Great for `P-256`, `P-384`, etc. * ❌ **No native `secp256k1`** support unless you build OpenSSL from source with custom patches (not recommended for casual use). ---
2. **`libsecp256k1` CLI tools** (Recommended) The Bitcoin Core team maintains the **`libsecp256k1`** library — you can build this CLI on macOS to get full `secp256k1` support. #### 🔧 To install: ```bash # Clone the library git clone https://github.com/bitcoin-core/secp256k1.git cd secp256k1 # Build with command-line examples enabled ./autogen.sh ./configure --enable-experimental --enable-module-schnorrsig --enable-module-recovery make ``` After building, you'll have access to example binaries under `./examples/`, such as: * `ecdsa_sign` – Sign a message with a private key * `ecdsa_verify` – Verify a signature * `privkey` – Generate / parse private keys * `ecdh` – Perform key agreement (Elliptic Curve Diffie-Hellman) You can use these binaries directly, or write scripts around them.
3. **`btcli`, `bitcoin-cli`, or `bx` (Libbitcoin-explorer)** If you want a higher-level CLI tool: #### 🧰 **Libbitcoin Explorer (`bx`)** Install via `brew`: ```bash brew install libbitcoin/libbitcoin/bx ``` Now you can: * Generate a key: ```bash bx ec-new ``` * Get the public key: ```bash bx ec-to-public <private-key> ``` * Sign a message: ```bash bx sign --private-key=<key> <message> ``` * Verify: ```bash bx verify <address> <signature> <message> ``` ✅ `bx` uses `secp256k1` under the hood and is widely used for Bitcoin-related scripting.
4. **Node.js / Python CLIs** You can also write small one-liners with: * **Node.js** + `elliptic` library * **Python** + `coincurve` or `ecdsa` Example Node CLI: ```bash npm install -g elliptic ``` Create a script to generate and sign messages using `secp256k1`.
# TL;DR: Best CLI Tool on macOS If you want something ready-to-go: * 🔧 **`bx` (Libbitcoin Explorer)** is the easiest to install and use. * 🛠️ **Build `libsecp256k1`** if you want low-level CLI access to raw signing/verification.