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)
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))
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))
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))
def hash_transaction(raw_tx): return obelisk.Hash(raw_tx)[::-1]
def hash_transaction(tx): return obelisk.Hash(tx.serialize())[::-1]
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)