Guest User

Untitled

a guest
May 28th, 2017
163
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/env python
  2.  
  3. import sys
  4. from binascii import unhexlify
  5. from pure25519.basic import Zero, L, bytes_to_unknown_group_element
  6. import urllib2
  7. import json
  8. from retrying import retry
  9.  
  10. ORDERS = {1: "1", 2: "2", 4: "4", 8: "8",
  11.           1*L: "1*L", 2*L: "2*L", 4*L: "4*L", 8*L: "8*L"}
  12.  
  13. def get_order(e):
  14.     for o in sorted(ORDERS):
  15.         if e.scalarmult(o) == Zero:
  16.             return o
  17.  
  18. @retry(stop_max_attempt_number=20, wait_fixed=2000)
  19. def get_block_transactions(height):
  20.     s = urllib2.urlopen("http://chainradar.com/api/v1/bcn/blocks/%s/full" % height)
  21.     block = json.loads(s.read())
  22.     transactions = block["transactions"]
  23.     return transactions
  24.  
  25. @retry(stop_max_attempt_number=20, wait_fixed=2000)
  26. def get_tx_inputs(tx_hash):
  27.     s = urllib2.urlopen("http://chainradar.com/api/v1/bcn/transactions/%s/full" % tx_hash)
  28.     tx = json.loads(s.read())
  29.     inputs = tx["inputs"]
  30.     return inputs
  31.  
  32. #change block height range as necessary
  33. for blockHeight in range(1267197, 1269965):
  34.     print "====  block height %s ====" % blockHeight
  35.     #print json.dumps(block, indent=4)
  36.     transactions = get_block_transactions(blockHeight)
  37.     tx_hashes = [tx["hash"] for tx in transactions]
  38.  
  39.     for tx_hash in tx_hashes:
  40.         print "tx:", tx_hash
  41.         inputs = get_tx_inputs(tx_hash)
  42.         #print inputs
  43.         keyimages = [str(i.get("kImage")) for i in inputs if i.get("kImage")]
  44.         print "key images: %s" % (keyimages,)
  45.         for ki in keyimages:
  46.             try:
  47.                 elem = bytes_to_unknown_group_element(unhexlify(ki))
  48.                 order = get_order(elem)
  49.                 if order != L:
  50.                     print "*** keyimage %s order %s" % (ki, ORDERS[order])
  51.                     with open("bad_keyimages", "a") as f:
  52.                         f.write("%s\n" % ki)
  53.             except Exception, e:
  54.                 print e
  55.                 print "Bad keyimage", ki
  56.                 with open("bad_keyimages", "a") as f:
  57.                     f.write("%s\n" % ki)
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×