>> (p.1)
    Author Topic: Timestamping a file into bitcoin's block chain  (Read 3030 times)
    grondilu (OP)
    Legendary
    *
    Offline Offline

    Activity: 1288
    Merit: 1080


    View Profile
    December 19, 2010, 03:58:47 AM
    Last edit: December 19, 2010, 05:22:19 AM by grondilu
     #1

    Here is a script to timestamp or search for a timestamp in the block chain.

    Code:
    #!/bin/bash
    #
    # timestamp.sh : Bitcoin timestamping script
    #
    # This script timestamps or search timestamps into bitcoin's block chain

    blockexplorer="http://blockexplorer.com"

    # reads data sent on stdin and hash it
    sha256=$(openssl dgst -sha256)

    # converts hash into a valid bitcoin address
    address=$(wget -O - $blockexplorer/q/hashtoaddress/${sha256::40})

    shopt -s extglob
    case "$@" in
        -s|--search)
            # just search the bitcoin address in the block chain
            w3m -dump "$blockexplorer/address/$address" ;;

        0.+([0-9])|"")
            fee=${1:-0.01}
            if bitcoind getinfo >dev/null
            then bitcoind sendtoaddress $address $fee
            else echo "Please check bitcoind is running"
            fi ;;
        *)
            echo "
            usage :  $0 [-s]  [amount]
            options :
            -s|--search : only search for a timestamp in bitcoin's block chain
            " ;;
    esac


    The first data I've timestamped using this code is this code itself (or more precisely my signature of it).

    You can check it by running :

    $ bash ./timestamp.sh -s < ./timestamp.sh.asc

    where timestamp.sh.asc is :

    -----BEGIN PGP MESSAGE-----
    Version: GnuPG v1.4.10 (GNU/Linux)

    owFtk7Fv00AUxkMLSD5RRPkLXh1LNIBjlwISroKAgQUQHdiiIJ3tS+7AuTO+c1LU
    dmDrgoRUsTFkQDCgMocBBlZ2xMKKBAtsDCw8J3GTILyc7/nd9/3e87tnS4uVheU3
    93//3Bye5EcOFmvhCSO6TBvaTeua31l60quueKGQXkg1J1VShdnvEMANYSIl5DQs
    ZAd0lInUjNLvcaEn+2mOBpWBZjSL+GxQSKMgHAue0RAmKnoIEadCEjLasK00URnL
    GjY3Jg08by5aj1TXJuiZMRpriKmhaCINKAnaxAhJZQwcCwFhiOb0wqXLDWdVpUxq
    nUDc0QbccbhWyERK9lhm9ORIAUehRxMRl5BA4zhjWpPJimr9DkOVu+CCMwfnPfIK
    GaMmqZ6zPbYKgov+LvpprtLCH9iW6SQqJBHVDGznmo3WBPBx9Y7rjrtWI1YVHuQI
    XHaRs3+hoPgrRXimjVZ/vQtunHdTVJ7nO+SavNgbG2Rk69fPrTZ990qrtmPbaNxm
    rOFsrwWuX/fXdokl2qVzDFi8kG0FV8GLWc+TeZIQCyHkNKXUBweFiMUSrJJFXIG9
    mbCi5Igz5D3Mx/HJcilxrAoiqy1GUGcRZHyKWLmmHYajCI4PTVe3AJq0q3JpWsTC
    ngolNQTEmmkfJiuZPC6b18ZppNNBLBr3/ym0bEAGpmlE9m4erSwvVI4fWyguSYVY
    p8pr9KteGbz+8eVz/8PXg5f7z1+8v/UnH5rTg8rgKd2Phu8+ffx+/TY5/yp7u7fy
    bf0v
    =ecN3
    -----END PGP MESSAGE-----


    PS.  An other version using rmd160 instead of sha256 (so that we don't have to truncate the hash) :

    Code:
    #!/bin/bash
    #
    # timestamp.sh : Bitcoin timestamping script
    #
    # This script timestamps or search timestamps into bitcoin's block chain

    blockexplorer="http://blockexplorer.com"

    # reads data sent on stdin, hash it, and converts hash into a valid bitcoin address
    address=$(wget -q -O - $blockexplorer/q/hashtoaddress/$(openssl dgst -rmd160))

    shopt -s extglob
    case "$@" in
        -s|--search)
            # just search the bitcoin address in the block chain
            wget -q -O - "$blockexplorer/address/$address" |
            if grep -q "First seen.*Never used in the network"
            then echo no timestamp found; exit 1
            else echo timestamp found : $blockexplorer/address/$address
            fi ;;

        0.+([0-9])|"")
            # timestamps data by sending a small amount to $address
            fee=${1:-0.01}
            if bitcoind getinfo >dev/null
            then bitcoind sendtoaddress $address $fee
            else echo "Please check bitcoind is running"
            fi ;;
        *)
            # usage information
            echo "
            usage :  $0 [-s]  [amount]
            options :
            -s|--search : only search for a timestamp in bitcoin's block chain
            " ;;
    esac

Page 1
Viewing Page: 1