Exemplo n.º 1
0
    def set_signing_crypto(self, signing_cryptosystem, path=None):
        if signing_cryptosystem != 'ECDSA':
            raise Exception('Unsupported cryptosystem' % signing_cryptosystem)

        if path is None:
            pem = utils.make_ecdsa_signing_key()
            crypto = utils.ECDSAClient(pem)
        else:
            raise Exception('Key loading unsupported')

        self.register_crypto(crypto)
        return self.username, short(crypto.key_id)
Exemplo n.º 2
0
def signing_crypto(handler, spec, cryptosystem, path):
    if cryptosystem != 'ECDSA':
        raise Exception('Unsupported cryptosystem')

    if path is None:
        pem = utils.make_ecdsa_signing_key()
        crypto = utils.ECDSAClient(pem)
    else:
        raise Exception('Key loading unsupported')

    handler.register_crypto(crypto)
    return crypto.key_id
Exemplo n.º 3
0
def get_client(cfg):
    secret_pem = cfg.get_value('SECRET_KEY')
    crypto = utils.ECDSAClient(secret_pem)
    endpoint = cfg.get_value('ENDPOINT')
    return client.Client(endpoint, crypto)
Exemplo n.º 4
0
def init_crypto():
    pem = utils.make_ecdsa_signing_key()
    return utils.ECDSAClient(secret=pem)
Exemplo n.º 5
0
from consensus_client.client import Client
from consensus_client import utils

pem = utils.make_ecdsa_signing_key()
crypto = utils.ECDSAClient(pem)
client = Client('http://127.0.0.1:8000/consensus/', crypto)

body = client.negotiation_create()
neg_id = body['id']
assert body['status'] == 'OPEN'
print "Negotiation:"
print body

neg = client.negotiation_retrieve(neg_id)
assert neg == body

body = client.contribution_create(neg_id, 'TEXTTEXT', True)
print "Contribution:"
print body
assert body['signer_key_id'] == crypto.key_id

print "Verify:"
assert client.contribution_verify(body)

body = client.negotiation_retrieve(neg_id)
print "Negotiation:"
print body
assert body['status'] == 'DONE'
consensus_id = body['consensus_id']

body = client.consensus_retrieve(consensus_id)