Esempio n. 1
0
def verify_signature(m_public_key, signature, message):
    public_key_bytes = base58.b58decode(m_public_key)
    signature_bytes = base58.b58decode(signature)
    message_bytes = signed_data(message)
    
    verified = curve.verifySignature(public_key_bytes, message.encode(), signature_bytes) == 0

    return  verified
Esempio n. 2
0
    def verifySignature(ecPublicSigningKey, message, signature):
        """
        :type ecPublicSigningKey: ECPublicKey
        :type message: bytearray
        :type signature: bytearray
        """

        if ecPublicSigningKey.getType() ==Curve.DJB_TYPE:
            result = _curve.verifySignature(ecPublicSigningKey.getPublicKey(), message, signature)
            return result == 0
        else:
            raise InvalidKeyException("Unknown type: %s" % ecPublicSigningKey.getType())
Esempio n. 3
0
    def verifySignature(ecPublicSigningKey, message, signature):
        """
        :type ecPublicSigningKey: ECPublicKey
        :type message: bytearray
        :type signature: bytearray
        """

        if ecPublicSigningKey.getType() == Curve.DJB_TYPE:
            result = _curve.verifySignature(ecPublicSigningKey.getPublicKey(), message, signature)
            return result == 0
        else:
            raise InvalidKeyException("Unknown type: %s" % ecPublicSigningKey.getType())
Esempio n. 4
0
def verify_signature(public_key, signature, data):
    """
    Verify data signature

    :param public_key: public key value
    :type public_key: bytes
    :param signature: signature value
    :type public_key: bytes
    :param data: signed data
    :type public_key: bytes
    :return: valid or not
    :rtype: bool
    """
    result = axolotl_curve25519.verifySignature(public_key, data, signature)
    return result == 0
Esempio n. 5
0
    def is_valid(self, rs, certificate_data):
        """
        :param rs:
        :type rs: PublicKey
        :param certificate_data:
        :type certificate_data: bytes
        :return:
        :rtype:
        """
        cert = wa20_pb2.NoiseCertificate()
        cert.ParseFromString(certificate_data)
        cert_details = wa20_pb2.NoiseCertificate.Details()
        cert_details.ParseFromString(cert.details)

        logger.debug(
            "NoiseCertificate(signature=[%d bytes], serial=%d, issuer='%s', expires=%d, subject='%s', ""key=[%d bytes])"
            % (
                len(cert.signature), cert_details.serial, cert_details.issuer, cert_details.expires,
                cert_details.subject, len(cert_details.key)
            )
        )

        if cert_details.issuer not in self._pubkeys:
            logger.error("noise certificate issued by unknown source: issuer=%s" % cert_details.issuer)
            return False

        if curve.verifySignature(bytes(self._pubkeys[cert_details.issuer]), cert.details, cert.signature) != 0:
            logger.error("invalid signature on noise ceritificate; issuer=%s" % cert_details.issuer)
            return False

        if cert_details.key != rs.data:
            logger.error("noise certificate key does not match proposed server static key; issuer=%s" % cert_details.issuer)
            return False

        if cert_details.HasField("expires") and cert_details.expires < int(time.time()):
            logger.error("noise certificate expired; issuer=%s" % cert_details.issuer)
            return False

        return True
Esempio n. 6
0
    def test_vsys_sign_tx_proposal(self, client):
        with client:
            client.set_input_flow(self.input_flow(client.debug, num_pages=1))
            public_key = vsys.get_public_key(client, VSYS_PATH)
            resp = vsys.sign_tx(
                client,
                VSYS_PATH,
                dict_to_proto(
                    messages.VsysSignTx,
                    {
                        "protocol": "v.systems",
                        "api": 1,
                        "opc": "transaction",
                        "transactionType": 2,
                        "senderPublicKey": public_key,
                        "amount": 1000000000,
                        "fee": 10000000,
                        "feeScale": 100,
                        "recipient": "AU6GsBinGPqW8zUuvmjgwpBNLfyyTU3p83Q",
                        "timestamp": 1547722056762119200,
                        "attachment": "HXRC"
                    },
                ),
            )

        context_bytes = [
            0x02, 0x15, 0x7a, 0x9d, 0x02, 0xac, 0x57, 0xd4, 0x20, 0x00, 0x00,
            0x00, 0x00, 0x3b, 0x9a, 0xca, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
            0x98, 0x96, 0x80, 0x00, 0x64, 0x05, 0x54, 0x9c, 0x6d, 0xf7, 0xb3,
            0x76, 0x77, 0x1b, 0x19, 0xff, 0x3b, 0xdb, 0x58, 0xd0, 0x4b, 0x49,
            0x99, 0x91, 0x66, 0x3c, 0x47, 0x44, 0x4e, 0x42, 0x5f, 0x00, 0x03,
            0x31, 0x32, 0x33
        ]

        assert (curve.verifySignature(b58decode(public_key),
                                      bytes(context_bytes),
                                      b58decode(resp.signature)) == 0)
 def signatureCheck(self, uid, signature):
     """
     Returns true iff uid (as binary) is the message signed by signature (binary string)
     """
     verified = curve.verifySignature(self.pubKey, uid, signature) == 0
     return verified
Esempio n. 8
0
def validate(pk, m, s):
    return curve_waveslib.verifySignature(pk, m, s) == 0
Esempio n. 9
0
def verify_signature(pub_key, message, signature):
    """ all of the arguments are expected in a string format """
    return curve.verifySignature(base58.b58decode(pub_key), message.encode(),
                                 base58.b58decode(signature)) == 0
 def signatureCheck(self, uid, signature):
     """
     Returns true iff uid (as binary) is the message signed by signature (binary string)
     """
     verified = curve.verifySignature(self.pubKey, uid, signature) == 0
     return verified
Esempio n. 11
0
def validate_signature(public_key: bytes, message: bytes,
                       signature: bytes) -> bool:
    from axolotl_curve25519 import verifySignature

    return True if verifySignature(public_key, message,
                                   signature) == 0 else False
Esempio n. 12
0
def verifySignature(public_key, message, signature):
    return curve.verifySignature(base58.b58decode(public_key), message,
                                 base58.b58decode(signature))