Example #1
0
 def sign_all_inputs(self, tx, secret):
     signatures = []
     key = obelisk.EllipticCurveKey()
     key.set_secret(secret)
     for i, input in enumerate(tx.inputs):
         sighash = generate_signature_hash(tx, i, self.script)
         # Add sighash::all to end of signature.
         signature = key.sign(sighash) + "\x01"
         signatures.append(signature)
     return signatures
Example #2
0
 def respond_pubkey_if_mine(self, nickname, ident_pubkey):
     if ident_pubkey != PUBKEY:
         print "Not my ident."
         return
     pubkey = self._myself.get_pubkey()
     ec_key = obelisk.EllipticCurveKey()
     ec_key.set_secret(SECRET)
     digest = obelisk.Hash(pubkey)
     signature = ec_key.sign(digest)
     self.send(response_pubkey(nickname, pubkey, signature))
Example #3
0
    def sign_all_inputs(self, transaction, secret):
        signatures = []
        key = obelisk.EllipticCurveKey()
        key.set_secret(secret)

        for i, _ in enumerate(transaction.inputs):
            sighash = generate_signature_hash(transaction, i, self.script)
            # Add sighash::all to end of signature.
            signature = key.sign(sighash) + "\x01"
            signatures.append(signature.encode('hex'))
        return signatures
Example #4
0
    def respond_pubkey_if_mine(self, nickname, ident_pubkey):

        if ident_pubkey != PUBKEY:
            print "Public key does not match your identity"
            return

        # Return signed pubkey
        pubkey = self._myself.get_pubkey()
        ec_key = obelisk.EllipticCurveKey()
        ec_key.set_secret(SECRET)
        digest = obelisk.Hash(pubkey)
        signature = ec_key.sign(digest)

        # Send array of nickname, pubkey, signature to transport layer
        self.send(proto_response_pubkey(nickname, pubkey, signature))
Example #5
0
    def respond_pubkey_if_mine(self, nickname, ident_pubkey):

        if ident_pubkey != self.pubkey:
            self.log.info("Public key does not match your identity")
            return

        # Return signed pubkey
        pubkey = self.cryptor.pubkey  # XXX: A Cryptor does not have such a field.
        ec_key = obelisk.EllipticCurveKey()
        ec_key.set_secret(self.secret)
        digest = obelisk.Hash(pubkey)
        signature = ec_key.sign(digest)

        # Send array of nickname, pubkey, signature to transport layer
        self.send(proto_response_pubkey(nickname, pubkey, signature))
Example #6
0
def build_actual_tx(unspent, root_hash):
    print "Building...", root_hash.encode("hex")
    fee = 10000
    optimal_outputs = obelisk.select_outputs(unspent, fee)
    tx = obelisk.Transaction()
    for output in optimal_outputs.points:
        add_input(tx, output.point)
    add_return_output(tx, root_hash)
    change = optimal_outputs.change
    add_output(tx, address, change)
    key = obelisk.EllipticCurveKey()
    key.set_secret(secret)
    for i, output in enumerate(optimal_outputs.points):
        obelisk.sign_transaction_input(tx, i, key)
    broadcast.broadcast(tx)
    tx_hash = hash_transaction(tx)
    return tx_hash
Example #7
0
def main(argv):
    tx = obelisk.Transaction()
    for switch, param in zip(argv[1::2], argv[2::2]):
        if switch == "-i":
            tx_hash, tx_index = param.split(":")
            tx_hash = tx_hash.decode("hex")
            tx_index = int(tx_index)
            add_input(tx, tx_hash, tx_index)
        elif switch == "-o":
            address, value = param.split(":")
            value = D(value)
            add_output(tx, address, value)
    # initialize signing key
    key = obelisk.EllipticCurveKey()
    secret = "59cd7a1d11ef24a1687b7c20bdb9f3bb" \
             "1cb93908401c503f8d69521dbfcd1c6d".decode("hex")
    assert len(secret) == 32
    key.set_secret(secret)
    # sign input 0
    obelisk.sign_transaction_input(tx, 0, key)
    print tx
    print tx.serialize().encode("hex")
Example #8
0
import obelisk

secret = "6aa6f40c1ad36825bf7be87226f42a72" \
         "f5ae28e7daa737611c8c971e4d462a18".decode("hex")
key = obelisk.EllipticCurveKey()
key.set_secret(secret)

digest = obelisk.Hash("message")
signature = key.sign(digest)
assert key.verify(digest, signature)

Example #9
0
 def generate_change_key(self, n):
     key = obelisk.EllipticCurveKey()
     secret = self.wallet.branch_prime(n).secret
     assert len(secret) == 32
     key.set_secret(secret)
     return key
Example #10
0
 def current_change_address(self):
     key = obelisk.EllipticCurveKey()
     return self.wallet.branch_prime(self.key_index).address