From 9514a43ad5366526522e137b524580c312387f45 Mon Sep 17 00:00:00 2001 From: Frederic Heem Date: Sun, 9 Mar 2014 15:11:38 +0100 Subject: [PATCH 1/2] add asset-proof.py --- extras/asset-proof.py | 103 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100755 extras/asset-proof.py diff --git a/extras/asset-proof.py b/extras/asset-proof.py new file mode 100755 index 000000000..f2e0c3928 --- /dev/null +++ b/extras/asset-proof.py @@ -0,0 +1,103 @@ +#! /usr/bin/python + +# This script signs all addresses with a given message and write a json file containing a list of public addresses alonside the signature. The file can be given to auditors to verify the signatures and get the balance for this wallet. +# For more information, see https://github.com/olalonde/bitcoin-asset-proof +# +# Usage: +# asset-proof.py armory_CACABEA_.wallet "EmptyGox Btc Assets" emptygox-btc-assets.json +# more emptygox-btc-assets.json +#{ +# "signatures": [ +# { +# "signature": "HP0ehv2bUm8tSDJwFNiHzlN+Nyk0NP6ZyKsPm/emoAX4Ntyg/KRtPEFTieY3Yth3/7RbeZhVhEP52TdXi4QOY5c=", +# "address": "1ErNyayp5CdX7qBmmYjLuN2cFVpQJhf4t9" +# }, +# { +# "signature": "HKIwUnCadn+YUFzrcqtlnxdkkYqAOcT1n8/2fCWxNp1xObCFXEKPtd1Yr0N2th2tvRvHdCLgWsE81nAvLjxWHWk=", +# "address": "1PLvZNm1gZ7n32HHtgmVGgj8Zh5a3DxVbg" +# } +# ], +# "type": "BTC", +# "id": "EmptyGox Btc Assets" +#} + +import sys +sys.path.append('..') +sys.path.append('.') + +from armoryengine import * +from jasvet import ASv0 +import getpass +from sys import argv +import os +import json + +# Do not ever access the same wallet file from two different processes at the same time +print '\n' +#raw_input('PLEASE CLOSE ARMORY BEFORE RUNNING THIS SCRIPT! (press enter to continue)\n') + +if len(argv)<4: + print 'USAGE: %s ' % argv[0] + print 'USAGE: %s armory_CACABEA_.wallet "EmptyGox Btc Asset" emptygox-btc-assets.json' % argv[0] + exit(0) + +wltfile = argv[1] +messageToSign = argv[2] +outfilename = argv[3] + +signatures = [] + +if not os.path.exists(wltfile): + print 'Wallet file was not found: %s' % wltfile + +wlt = PyBtcWallet().readWalletFile(wltfile) + +# If the wallet is encrypted, get the passphrase +if wlt.useEncryption: + print 'Please enter your passphrase to unlock your wallet: ' + for ntries in range(3): + passwd = SecureBinaryData(getpass.getpass('Wallet Passphrase: ')) + #passwd = SecureBinaryData("you pasphrase") + if wlt.verifyPassphrase(passwd): + break; + + print 'Passphrase was incorrect!' + if ntries==2: + print 'Wallet could not be unlocked. Aborting.' + exit(0) + + print 'Correct Passphrase. Unlocking wallet...' + wlt.unlock(securePassphrase=passwd) + passwd.destroy() + + +try: + addrList = wlt.getAddrList() + print 'Addresses in this wallet:%s' % len(addrList) + + for addr in addrList: + privateKey = addr.binPrivKey32_Plain.toBinStr() + signature = ASv0(privateKey, messageToSign) + signatureb64 = signature['b64-signature'] + pair = {"address" : addr.getAddrStr(), "signature": signatureb64} + signatures.append(pair) + print '\t%s, %s' % (addr.getAddrStr(), signatureb64) + +except WalletLockError: + print 'Error signing transaction. Wallet is somehow still locked' + raise +except: + print 'Error signing transsaction. Unknown reason.' + raise + +out = {'id':messageToSign, 'signatures':signatures, 'type':'BTC'} + +outDump = json.dumps(out, sort_keys = False, indent = 4) + +outfile = open(outfilename, 'w') +outfile.write(outDump) +outfile.close() + +print '\nAssets written to :' +print '\t', outfilename, '\n' + From 55e9e275cbc6831f0b38d916456258ccdd870920 Mon Sep 17 00:00:00 2001 From: Frederic Heem Date: Tue, 12 Aug 2014 23:02:30 +0200 Subject: [PATCH 2/2] update to the latest spec: hash --- extras/asset-proof.py | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/extras/asset-proof.py b/extras/asset-proof.py index f2e0c3928..d1315be90 100755 --- a/extras/asset-proof.py +++ b/extras/asset-proof.py @@ -4,8 +4,8 @@ # For more information, see https://github.com/olalonde/bitcoin-asset-proof # # Usage: -# asset-proof.py armory_CACABEA_.wallet "EmptyGox Btc Assets" emptygox-btc-assets.json -# more emptygox-btc-assets.json +# asset-proof.py armory_ABCDEF_.wallet "Airbex Btc Assets" airbex-btc-assets.json +# more airbex-btc-assets.json #{ # "signatures": [ # { @@ -17,15 +17,16 @@ # "address": "1PLvZNm1gZ7n32HHtgmVGgj8Zh5a3DxVbg" # } # ], -# "type": "BTC", -# "id": "EmptyGox Btc Assets" +# "blockhash": "00000000000000000a94cd53c34e2cdfd2b7eab95e7b2d948e5ad200d863bcd4" +# "currency": "BTC", +# "message": "Airbex Btc Assets" #} import sys sys.path.append('..') sys.path.append('.') -from armoryengine import * +from armoryengine.ALL import * from jasvet import ASv0 import getpass from sys import argv @@ -36,15 +37,16 @@ print '\n' #raw_input('PLEASE CLOSE ARMORY BEFORE RUNNING THIS SCRIPT! (press enter to continue)\n') -if len(argv)<4: - print 'USAGE: %s ' % argv[0] - print 'USAGE: %s armory_CACABEA_.wallet "EmptyGox Btc Asset" emptygox-btc-assets.json' % argv[0] +if len(argv)<5: + print 'USAGE: %s ' % argv[0] + print 'USAGE: %s armory_ABCDEF_.wallet "Airbex Btc Asset" airbex-btc-assets.json 00000000000000000a94cd53c34e2cdfd2b7eab95e7b2d948e5ad200d863bcd4' % argv[0] exit(0) -wltfile = argv[1] -messageToSign = argv[2] +wltfile = argv[1] +message = argv[2] outfilename = argv[3] - +blockhash = argv[4] +messageToSign = blockhash + '|' + message signatures = [] if not os.path.exists(wltfile): @@ -57,7 +59,6 @@ print 'Please enter your passphrase to unlock your wallet: ' for ntries in range(3): passwd = SecureBinaryData(getpass.getpass('Wallet Passphrase: ')) - #passwd = SecureBinaryData("you pasphrase") if wlt.verifyPassphrase(passwd): break; @@ -72,10 +73,10 @@ try: - addrList = wlt.getAddrList() + addrList = wlt.getLinearAddrList() print 'Addresses in this wallet:%s' % len(addrList) - for addr in addrList: + for addr in addrList[0:100]: privateKey = addr.binPrivKey32_Plain.toBinStr() signature = ASv0(privateKey, messageToSign) signatureb64 = signature['b64-signature'] @@ -90,7 +91,7 @@ print 'Error signing transsaction. Unknown reason.' raise -out = {'id':messageToSign, 'signatures':signatures, 'type':'BTC'} +out = {'blockhash': blockhash, 'message':message, 'currency':'BTC', 'signatures':signatures} outDump = json.dumps(out, sort_keys = False, indent = 4)