How can I verify the signature on my lopy4 device?

  • For example, my signature is got by crypto.generate_rsa_signature.
    My code is

    self.signature = crypto.generate_rsa_signature(self.computeHash(), key, pers="my_pers")

    and then how can I do to verify it?

  • My verify code is

        def isValid(self):
            if self.comefrom == "":
                return True
            global public_sender # public key
            message_decrypted = crypto.rsa_decrypt(self.signature, public_sender)
            return self.computeHash() == message_decrypted

    And the function rsa_decrypt can only accept the parameter of a private key. If I use the public key it throws a ValueError:

    Traceback (most recent call last):
      File "", line 37, in <module>
      File "/flash/lib/", line 158, in addTransaction
      File "/flash/lib/", line 82, in isValid
    ValueError: Invalid private key, mbedtls error code: 0x3D00

    So I'm confused ...

Log in to reply

Pycom on Twitter