Esempio n. 1
0
def generate_signature_hash(parent_tx, input_index, script_code):
    tx = obelisk.copy_tx(parent_tx)
    if input_index >= len(tx.inputs):
        return None
    for input in tx.inputs:
        input.script = ""
    tx.inputs[input_index].script = script_code
    raw_tx = tx.serialize() + "\x01\x00\x00\x00"
    return obelisk.Hash(raw_tx)
Esempio n. 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))
Esempio n. 3
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))
Esempio n. 4
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))
Esempio n. 5
0
def hash_transaction(raw_tx):
    return obelisk.Hash(raw_tx)[::-1]
Esempio n. 6
0
def hash_transaction(tx):
    return obelisk.Hash(tx.serialize())[::-1]
Esempio n. 7
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)