Exemple #1
0
    def __fetch_cage_key(self, fetch):
        if self.team_ecdh_key is None:
            resp = fetch.get("cages/key")
            decoded_team_cage_key = base64.b64decode(resp["ecdhKey"])

            self.team_ecdh_key = EllipticCurvePublicKey.from_encoded_point(
                ec.SECP256K1(), decoded_team_cage_key)
Exemple #2
0
    def is_valid(self):
        if self.sender == 'System':
            return True
        if self.signature is None or len(self.signature) == 0:
            print('ERROR: No signature found in the transaction')
            return False

        # generate a pub key obj from the sender info
        pub_key_obj = EllipticCurvePublicKey.from_encoded_point(
            ec.SECP256K1(), bytes.fromhex(self.sender))
        data = self.get_data_bytes()
        try:
            pub_key_obj.verify(self.signature, data, ec.ECDSA(hashes.SHA256()))
        except cryptography.exceptions.InvalidSignature as exp:
            print(exp)
            return False
        return True