Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    How can I verify the signature on my lopy4 device?

    Scheduled Pinned Locked Moved LoPy
    2 Posts 1 Posters 37 Views 1 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • WenboW Offline
      Wenbo
      last edited by

      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?

      A newcomer of Lopy4

      1 Reply Last reply Reply Quote 0
      • WenboW Offline
        Wenbo
        last edited by

        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 "main.py", line 37, in <module>
          File "/flash/lib/blockChain.py", line 158, in addTransaction
          File "/flash/lib/blockChain.py", line 82, in isValid
        ValueError: Invalid private key, mbedtls error code: 0x3D00
        

        So I'm confused ...

        A newcomer of Lopy4

        1 Reply Last reply Reply Quote 0

        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

        With your input, this post could be even better 💗

        Register Login
        • 1 / 1
        • First post
          Last post

        Pycom on Twitter

        Pycom