Guest User

Untitled

a guest
May 18th, 2017
140
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/env python
  2. import sys
  3. from binascii import unhexlify
  4. from pure25519.basic import Zero, L, bytes_to_unknown_group_element
  5.  
  6. ORDERS = {1: "1", 2: "2", 4: "4", 8: "8",
  7.           1*L: "1*L", 2*L: "2*L", 4*L: "4*L", 8*L: "8*L"}
  8. def get_order(e):
  9.     for o in sorted(ORDERS):
  10.         if e.scalarmult(o) == Zero:
  11.             return o
  12.  
  13. elem = bytes_to_unknown_group_element(unhexlify(sys.argv[1]))
  14. order = get_order(elem)
  15. if order != L:
  16.     print "Wrong order", ORDERS[order]
  17. else:
  18.     print "Order is OK"
RAW Paste Data