forked from mit-dci/tangled-curl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcurlexamples.py
91 lines (68 loc) · 2.94 KB
/
curlexamples.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
from iota import TryteString
from iota.crypto.pycurl import Curl
from random import randint
def H(msg):
out = []
sponge = Curl()
sponge.absorb(TryteString(msg).as_trits())
sponge.squeeze(out)
return TryteString.from_trits(out)
def simplecol():
msg1 = b'999999999999999999999999999999999999999999999999999999999999999999999999999999999'
msg2 = b'999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999'
hash1 = H(msg1)
hash2 = H(msg2)
print hash1
print hash2
print hash1 == hash2, msg1 == msg2
def prefixcol():
msg1 = b'KXRVLFETGUTUWBCNCC9DWO99JQTEI9YXVOZHWELSYP9SG9KN9WCKXOVTEFHFH9EFZJKFYCZKQPPBXYSGJ'
msg2 = b'999999999999999999999999999999999999999999999999999999999999999999999999999999999KXRVLFETGUTUWBCNCC9DWO99JQTEI9YXVOZHWELSYP9SG9KN9WCKXOVTEFHFH9EFZJKFYCZKQPPBXYSGJ'
hash1 = H(msg1)
hash2 = H(msg2)
print hash1
print hash2
print hash1 == hash2, msg1 == msg2
def paddingshortcol():
msg1 = b'RSWWSFXPQJUBJROQBRQZWZXZJWMUBVIVMHPPTYSNW9YQIQQF9RCSJJCVZG9ZWITXNCSBBDHEEKDRBHV'
msg2 = b'RSWWSFXPQJUBJROQBRQZWZXZJWMUBVIVMHPPTYSNW9YQIQQF9RCSJJCVZG9ZWITXNCSBBDHEEKDRBHV9'
msg3 = b'RSWWSFXPQJUBJROQBRQZWZXZJWMUBVIVMHPPTYSNW9YQIQQF9RCSJJCVZG9ZWITXNCSBBDHEEKDRBHV99'
hash1 = H(msg1)
hash2 = H(msg2)
hash3 = H(msg3)
print hash1
print hash2
print hash3
print hash1 == hash2 == hash3, msg1 == msg2, msg2 == msg3
def paddinglongcol():
msg1 = b'IWASFLYINGINVERTEDNAARIPONBWXUOQUFGNOCUSSLYWKOZMZUKLNITZIFXFWQAYVJCVMDTRSHORGNSTKX9Z9DLWNHZSMNOYTU9AUCGYBVIITEPEKIXBCOFCMQPBGXYJKSHPXNUKFTXIJVYRFILAVXEWTUICZCYYPCKENNYLOGGINS'
msg2 = b'IWASFLYINGINVERTEDNAARIPONBWXUOQUFGNOCUSSLYWKOZMZUKLNITZIFXFWQAYVJCVMDTRSHORGNSTKX9Z9DLWNHZSMNOYTU9AUCGYBVIITEPEKIXBCOFCMQPBGXYJKSHPXNUKFTXIJVYRFILAVXEWTUICZCYYPCKENNYLOGGINSSMJFFCW'
print len(msg1)%81
hash1 = H(msg1)
hash2 = H(msg2)
print hash1
print hash2
print hash1 == hash2, msg1 == msg2
print hash1, hash2
def shortcol():
msg1 = b'RETHT9ES9HRCUITBHVCUHOBPUUUHT9PHLUNWRWGKBKF9YUMDWRXTRVGZHFZEHGATZXZAUPGVEKNMQXFVRXHF9QJQHUTILIPIXUYRVSJEIOJDRIUVWMUABSIKIBAKENE9KVFJUEQUHFRVGELFGJIDXQARWH99XTORHXRETHT9ES9HRCUITBHVCUHOBPUUUHT9PHLUNWRWGKBKF9YUMDWRXTRVGZHFZEHGATZXZAUPGVEKNMQXFVR'
msg2 = b'RETHT9ES9HRCUITBHVCUHOBPUUUHT9PHLUNWRWGKBKF9YUMDWRXTRVGZHFZEHGATZXZAUPGVEKNMQXFVRXHF9QJQHUTILIPIXUYRVSJEIPJDRIUVWMUABSIKIBAKENE9KVFJUEQUHFRVGELFGJIDXQARWH99XTORHXRETHT9ES9HRCUITBHVCUHOBPUUUHT9PHLUNWRWGKBKF9YUMDWRXTRVGZHFZEHGATZXZAUPGVEKNMQXFVR'
hash1 = H(msg1)
hash2 = H(msg2)
print hash1
print hash2
print hash1 == hash2, msg1 == msg2
def shiftedmsgs():
msg1 = b'9999KENNYLOGGINS99999999999999999999999999999999999999999999999999999999999999999'
msg2 = b'9KENNYLOGGINS99999999999999999999999999999999999999999999999999999999999999999999'
hash1 = H(msg1)
hash2 = H(msg2)
print "".join(["9"]*81)
print hash1
print hash2
simplecol()
prefixcol()
paddingshortcol()
paddinglongcol()
shiftedmsgs()
shortcol()