Title: Bitcoin Message Tool - command-line signer & verifier Post by: Mia Chloe on September 03, 2024, 03:31:16 AM ORIGINAL TOPIC: Bitcoin Message Tool - command-line signer & verifier (https://bitcointalk.org/index.php?topic=5437423.msg61684922#msg61684922)
AUTHOR: witcher_sense D Introduction Fully open-source CLI tool way De light weight to take sign and verify bitcoin messages. Bitcoin message na the most straightforward and natural way to take prove say na you get a particular bitcoin address without say you go need to reveal any of your information way De important well well. This tool go follow particular things way dem describe for BIP137: "...While dem no write BIP for how to take sign digital messages with Bitcoin private keys with P2PKH address , Na somehow simple process to understand , however as dem come introduce Segwit (both the one way De in the form of P2SH and bech32) addresses, E nor come clear how to take know if address na P2PKH, P2SH, or bech32 address . This BIP go propose standard signature format way go allow clients to fit differentiate all these address format from each other. Abeg Keep am for mind say: "because say this format get P2PKH keys, E de backwards compatible, but keep am for mind say some software get checks for dem header range and go report the new new segwit header type as error." More info: https://github.com/bitcoin/bips/blob/master/bip-0137.mediawiki Wallets way dey fully support BIP137 type of signature: 1) Trezor 2) Sparrow Wallet 3) Coldcard? 4) ... This tool normally na just attempt to take understand how we dey use this standard. D Installation matter 1)To take install with pip u go run: Code: pip install bitcoin-message-tool You fit create virtual environment for this application then you go run am from there, for example make we use Poetry. You go Create new folder (bmt na shorthand for Bitcoin Message Tool or you fit choose watin you like ): Code: poetry new bmt Code: cd ./bmt You go Create new virtual environment: Code: poetry install Code: poetry shell You go use this command Download the application from PyPi: Code: poetry add bitcoin-message-tool To take run am from the terminal you go use this command: Code: python3 -m bitcoin_message_tool When you don run the app without say wahala no de d arguments, you go see something like help message. 2) And, you go fit use dis command download the source code direct from GitHub: Code: git clone https://github.com/shadowy-pycoder/bitcoin_message_tool.git or you fit fork the repo or you go down clone the forked version You go Install requirements with this command: Code: pip install -r /path/to/requirements.txt To take run application from the repo way dem fork or clone , you fit still use this code for under: Code: python3 /path/to/bmt.py -h How to take use Bitcoin Message Tool The doctest way we wan do so suppose give better idea about how to take sign and verify messages with this CLI tool: Basic on how to take use am: Code: python -m bitcoin_message_tool -h Message signing: Code: python bmt.py sign -h Example na : Non-deterministic signature for private key and p2pkh address way dem compress Code: $python bmt.py sign -p -a p2pkh -m ECDSA is the most fun I have ever experienced Output: Code: Bitcoin address: 175A5YsPUdM71mnNCC3i8faxxYJgBonjWL The same output with -v/--verbose flag: Code: -----BEGIN BITCOIN SIGNED MESSAGE----- Message verification: Code: python bmt.py verify -h Example: Message verification in verbose mode Code: python bmt.py verify -a 175A5YsPUdM71mnNCC3i8faxxYJgBonjWL \ Output: Code: True More examples and source code can be found here: https://github.com/shadowy-pycoder/bitcoin_message_tool Tests with Sparrow Wallet Let's verify a SegWit signature created with real wallet: https://i.ibb.co/hHxnG0V/IMG-20230131-081915-189.png Result: https://i.ibb.co/MC5knZ3/Screenshot-2023-01-31-08-28-49-549-edit-com-termux.jpg Make we verify one SegWit signature way dem Create with this tool: https://i.ibb.co/D1CKJ5G/Screenshot-2023-01-31-08-43-47-964-edit-com-termux.jpg D Result: https://i.ibb.co/t2syZsH/IMG-20230131-084712-671.png |