>> (p.1)
    Author Topic: Bitcoin Message Tool - líneas de comando para firma y verificación  (Read 446 times)
    Porfirii (OP)
    Legendary
    *
    Offline Offline

    Activity: 2324
    Merit: 3188


    The Alliance Of Bitcointalk Translators - ENG>SPA


    View Profile WWW
    September 15, 2024, 12:57:04 PM
    Last edit: October 13, 2024, 09:32:31 AM by Porfirii
    Merited by witcher_sense (12), d5000 (5), DdmrDdmr (4), famososMuertos (1), rig4hodlers (1)
     #1

    Autor: witcher_sense
    Hilo en inglés: Bitcoin Message Tool - command-line signer & verifier



    Introducción

    Una herramienta CLI ligera y de código totalmente abierto para firmar y verificar mensajes con Bitcoin. Los mensajes con Bitcoin son la manera más directa y natural de probar tu propiedad sobre una dirección determinada sin revelar ningún tipo de información confidencial.

    Esta herramienta sigue las especificaciones descritas en BIP137:

    "...A pesar de que no existía una BIP sobre cómo firmar mensaje digitalmente para claves privadas de Bitcoin con direcciones P2PKH era un proceso bastante bien comprendido, sin embargo con la introducción de direcciones Segwit (tanto en la forma de P2SH y bech32) no está claro cómo diferenciar una dirección P2PKH, P2SH o bech32 unas de otras. Este BIP propone un formato de firma estándar que permitirá a los clientes distinguir diferentes formatos de direcciones."

    Por favor, ten en cuenta que:

    "dado que este formato incluye claves P2PKH, es retroactivamente compatible, pero recuerda que algunos programas tienen pruebas de rangos y encabezamientos que reportarán como errores los nuevos tipos de encabezamientos de segwit."

    Más información: https://github.com/bitcoin/bips/blob/master/bip-0137.mediawiki

    Carteras que soportan completamente firmas de tipo BIP137:

    1) Trezor
    2) Sparrow Wallet
    3) Coldcard?
    4) ...

    Esta herramienta es básicamente un intento de fomentar el uso de este estándar.

    Instalación

    1)Para instalar con pip, ejecuta:

    Code:
    pip install bitcoin-message-tool

    Puedes crear un entorno virtual para esta aplicación y ejecutarla desde él, por ejemplo usando Poetry.

    Crea una carpeta (bmt es la abreviatura de Bitcoin Message Tool o puedes elegir la que tú quieras):

    Code:
    poetry new bmt

    Code:
    cd ./bmt

    Crea un nuevo entorno virtual:

    Code:
    poetry install
    Code:
    poetry shell

    Descarga la aplicación de PyPi con este comando:
    Code:
    poetry add bitcoin-message-tool

    Para ejecutarla desde el terminal utiliza este comando:

    Code:
    python3 -m bitcoin_message_tool

    Cuando ejecutas la app sin argumentos, verás un mensaje de ayuda.

    2) Como alternativa, puedes descargar el código fuente directamente de GitHub con este comando:

    Code:
    git clone https://github.com/shadowy-pycoder/bitcoin_message_tool.git

    O puedes hacer un fork del repositorio y clonar la versión del fork

    Instala los requisitos con este comando:

    Code:
    pip install -rpath/to/requirements.txt

    Para ejecutar una aplicación del repositorio del fork o clonado, puedes simplemente usar el siguiente:

    Code:
    python3path/to/bmt.py -h

    Cómo usar la Herramienta de Mensajes Bitcoin

    El siguiente doctest debería ofrecerte una imagen clara sobre cómo firmar y verificar mensajes con esta herramienta CLI:

    Uso básico:

    Code:
    python -m bitcoin_message_tool -h

    or

    python bmt.py -h
    usage: python3 bmt.py [-h] {sign,verify} ...

    Bitcoin message signing/verification tool

    positional arguments:
    {sign,verify}

    options:
    -h, --help     show this help message and exit


    Firma de mensajes:

    Code:
    python bmt.py sign -h
    usage: python3 bmt.py sign [-h] -p -a {p2pkh,p2wpkh-p2sh,p2wpkh} -m [MESSAGE ...] [-d] [-v]

    options:
    -h, --help            show this help message and exit

    Sign messsage:
    -p, --privkey         private key in wallet import format (WIF)
    -a {p2pkh,p2wpkh-p2sh,p2wpkh}, --addr_type {p2pkh,p2wpkh-p2sh,p2wpkh}
                            type of bitcoin address
    -m [MESSAGE ...], --message [MESSAGE ...]
                            Message to sign
    -d, --deterministic   sign deterministtically (RFC6979)
    -v, --verbose         print prettified message

    Ejemplo: Firma no determinista para claves privadas comprimidas y direcciones p2pkh

    Code:
    $python bmt.py sign -p -a p2pkh -m ECDSA is the most fun I have ever experienced

    PrivateKey(WIF): <insert private key here>
    Por favor ten en cuenta que la clave privada no se mostrará en el terminal.

    Output:

    Code:
    Bitcoin address: 175A5YsPUdM71mnNCC3i8faxxYJgBonjWL
    Message: ECDSA is the most fun I have ever experienced
    Signature: IBuc5GXSJCr6m7KevsBAoCiX8ToOjW2CDZMr6PCEbiHwQJ237LZTj/REbDHI1/yelY6uBWEWXiOWoGnajlgvO/A=

    El mismo output con flag -v/--verbose:

    Code:
    -----BEGIN BITCOIN SIGNED MESSAGE-----
    ECDSA is the most fun I have ever experienced
    -----BEGIN BITCOIN SIGNATURE-----
    175A5YsPUdM71mnNCC3i8faxxYJgBonjWL

    IBuc5GXSJCr6m7KevsBAoCiX8ToOjW2CDZMr6PCEbiHwQJ237LZTj/REbDHI1/yelY6uBWEWXiOWoGnajlgvO/A=
    -----END BITCOIN SIGNATURE-----

    Verificación de mensajes:

    Code:
    python bmt.py verify -h
    usage: python3 bmt.py verify [-h] -a ADDRESS -m [MESSAGE ...] -s SIGNATURE [-v] [-r]

    options:
    -h, --help            show this help message and exit

    Verify messsage:
    -a ADDRESS, --address ADDRESS
                            specify bitcoin address
    -m [MESSAGE ...], --message [MESSAGE ...]
                            Message to verify
    -s SIGNATURE, --signature SIGNATURE
                            bitcoin signature in base64 format
    -v, --verbose         print full message
    -r, --recpub          recover public key

    Ejemplo: Verificación de mensaje en modo verbose

    Code:
    python bmt.py verify -a 175A5YsPUdM71mnNCC3i8faxxYJgBonjWL \
    > -m ECDSA is the most fun I have ever experienced \
    > -s HyiLDcQQ1p2bKmyqM0e5oIBQtKSZds4kJQ+VbZWpr0kYA6Qkam2MlUeTr+lm1teUGHuLapfa43JjyrRqdSA0pxs= \
    > -v

    Output:

    Code:
    True
    Message verified to be from 175A5YsPUdM71mnNCC3i8faxxYJgBonjWL

    Puedes encontrar más ejemplos y código fuente aquí: https://github.com/shadowy-pycoder/bitcoin_message_tool

    Pruebas con Sparrow Wallet

    Vamos a verificar una firma SegWit creada con una cartera real:



    Resultado:



    Verifiquemos una firma SegWit creada con esta herramienta:



    Resultado:







    Traducción ofrecida a iniciativa de:


    .
     betpanda.io 
     
    ANONYMOUS & INSTANT
    .......ONLINE CASINO.......
    ▄███████████████████████▄
    █████████████████████████
    █████████████████████████
    ████████▀▀▀▀▀▀███████████
    ████▀▀▀█░▀▀░░░░░░▄███████
    ████░▄▄█▄▄▀█▄░░░█▄░▄█████
    ████▀██▀░▄█▀░░░█▀░░██████
    ██████░░▄▀░░░░▐░░░▐█▄████
    ██████▄▄█░▀▀░░░█▄▄▄██████
    █████████████████████████
    █████████████████████████
    █████████████████████████
    ▀███████████████████████▀
    ▄███████████████████████▄
    █████████████████████████
    ██████████▀░░░▀██████████
    █████████░░░░░░░█████████
    ███████░░░░░░░░░███████
    ████████░░░░░░░░░████████
    █████████▄░░░░░▄█████████
    ███████▀▀▀█▄▄▄█▀▀▀███████
    ██████░░░░▄░▄░▄░░░░██████
    ██████░░░░█▀█▀█░░░░██████
    ██████░░░░░░░░░░░░░██████
    █████████████████████████
    ▀███████████████████████▀
    ▄███████████████████████▄
    █████████████████████████
    ██████████▀▀▀▀▀▀█████████
    ███████▀▀░░░░░░░░░███████
    ██████░░░░░░░░░░░░▀█████
    ██████░░░░░░░░░░░░░░▀████
    ██████▄░░░░░░▄▄░░░░░░████
    ████▀▀▀▀▀░░░█░░█░░░░░████
    ████░▀░▀░░░░░▀▀░░░░░█████
    ████░▀░▀▄░░░░░░▄▄▄▄██████
    █████░▀░█████████████████
    █████████████████████████
    ▀███████████████████████▀
    .
    SLOT GAMES
    ....SPORTS....
    LIVE CASINO
    ▄░░▄█▄░░▄
    ▀█▀░▄▀▄░▀█▀
    ▄▄▄▄▄▄▄▄▄▄▄   
    █████████████
    █░░░░░░░░░░░█
    █████████████

    ▄▀▄██▀▄▄▄▄▄███▄▀▄
    ▄▀▄█████▄██▄▀▄
    ▄▀▄▐▐▌▐▐▌▄▀▄
    ▄▀▄█▀██▀█▄▀▄
    ▄▀▄█████▀▄████▄▀▄
    ▀▄▀▄▀█████▀▄▀▄▀
    ▀▀▀▄█▀█▄▀▄▀▀

    Regional Sponsor of the
    Argentina National Team
Page 1
Viewing Page: 1