-
Notifications
You must be signed in to change notification settings - Fork 0
/
blind.py
executable file
·48 lines (37 loc) · 1.54 KB
/
blind.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
#!/usr/bin/python
__copyright__ = """
Copyright (C) Timo Engel (timo-e@freenet.de), Berlin 2012.
This program was written as part of a master thesis advised by
Prof. Dr. Ruediger Weis at the Beuth University of Applied
Sciences Berlin.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
import sys
from OpenPGP import *
import blinding
if len(sys.argv) != 3 and len(sys.argv) != 4:
print >>sys.stderr, 'usage: blind.py <RANDOMFILE> <PUBKEYFILE> [<TIME>]'
sys.exit(2)
publicKey = messages.fromRadix64(open(sys.argv[2], 'r').read())
message = sys.stdin.read()
if len(sys.argv) == 4:
sigTime = elements.TimeElement(int(sys.argv[3]))
else:
sigTime = None
r, hashtwo, sigTime, blinded = blinding.blind(publicKey, sigTime, message)
randfile = open(sys.argv[1], 'w')
randfile.write(elements.ScalarElement(r).rep().encode('hex') + '\n')
randfile.write(hashtwo.encode('hex') + '\n')
randfile.write('%d\n' % sigTime.value)
randfile.close()
#print >>sys.stderr, blinded
print blinded.rep()