Skip to content

Commit 7d70a52

Browse files
committed
Added fab file for delpoyment
1 parent 875062a commit 7d70a52

File tree

5 files changed

+53
-9
lines changed

5 files changed

+53
-9
lines changed

derivekey.py

+15-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
import argparse
77

88
parser = argparse.ArgumentParser(description='Derive the public key from a secret password.')
9-
parser.add_argument('--password', type=str, required=True, help='The password that acts as a private key.')
10-
9+
parser.add_argument('--password', type=str, help='The password that acts as a private key.')
10+
parser.add_argument('--store', action='store_true', help='Make up a password and store it.')
1111

1212
args = parser.parse_args()
1313

@@ -16,3 +16,16 @@
1616
public = rscoin.Key(secret, public=False).pub.export()
1717
print("Public: %s" % b64encode(public)) # , b64decode
1818

19+
if args.store:
20+
import os
21+
22+
if not os.path.exists("secret.key"):
23+
key = os.urandom(32)
24+
f = file("secret.key", "w")
25+
f.write(key)
26+
f.close()
27+
else:
28+
key = file("secret.key", "r").read()
29+
30+
public = rscoin.Key(key, public = False).pub.export()
31+
print("Public: %s" % b64encode(public)) # , b64decode

fabfile.py

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
from fabric.api import run, env, cd
2+
3+
env.hosts = ['[email protected]']
4+
5+
def gitpull():
6+
with cd('/home/ubuntu/projects/rscoin/src'):
7+
run('git pull')
8+
9+
def host_type():
10+
run('uname -s')
11+
12+
def start():
13+
with cd('/home/ubuntu/projects/rscoin/src'):
14+
run('twistd -y rscserver.tac.py')
15+
16+
def stop():
17+
with cd('/home/ubuntu/projects/rscoin/src'):
18+
run('kill `cat twistd.pid`')
19+
20+
def keys():
21+
with cd('/home/ubuntu/projects/rscoin/src'):
22+
run('python derivekey.py --store')
23+

rscoin/__init__.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@
99

1010
from os import urandom
1111

12-
_globalECG = EcGroup()
12+
# 415 PASS 4869.3/s X9.62/SECG curve over a 256 bit prime field
13+
# 713 PASS 8499.8/s NIST/SECG curve over a 224 bit prime field
14+
# 716 PASS 1348.2/s NIST/SECG curve over a 521 bit prime field
15+
16+
17+
_globalECG = EcGroup(713)
1318

1419
class Key:
1520
""" Represents a key pair (or just a public key)"""

rscoin/rscservice.py

+8-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33

44
from json import loads
55
from bisect import bisect_left
6-
import bsddb
6+
# import bsddb
7+
8+
from future.moves import dbm
9+
710
from traceback import print_stack, print_exc
811
from hashlib import sha256
912
from os.path import join
@@ -166,15 +169,15 @@ def __init__(self, secret, directory, special_key, conf_dir=None):
166169
keyID = self.key.id()[:10]
167170

168171
# Open the databases
169-
self.dbname = 'keys-%s.db' % hexlify(keyID)
170-
self.logname = 'log-%s.db' % hexlify(keyID)
172+
self.dbname = 'keys-%s' % hexlify(keyID)
173+
self.logname = 'log-%s' % hexlify(keyID)
171174

172175
if conf_dir:
173176
self.dbname = join(conf_dir, self.dbname)
174177
self.logname = join(conf_dir, self.logname)
175178

176-
self.db = bsddb.btopen(self.dbname, 'c')
177-
self.log = bsddb.btopen(self.logname, 'c')
179+
self.db = dbm.open(self.dbname, 'c')
180+
self.log = dbm.open(self.logname, 'c')
178181

179182

180183
def buildProtocol(self, addr):

tests/test_rscservice.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def test_factory():
5050
directory = [(public, "127.0.0.1", 8080)]
5151

5252
factory = RSCFactory(secret, directory, None)
53-
assert os.path.exists(factory.dbname)
53+
assert os.path.exists(factory.dbname + ".db") or os.path.exists(factory.dbname)
5454

5555
def test_authorities():
5656
chars = ["A", "B", "C", "D", "E", "F"]

0 commit comments

Comments
 (0)