Hi, I'm wondering is it possible to turn signature, public key, and signed message into a QR code and let others scan the QR code and verifies it?

I spent 10 hours but still can't figure out how to correctly do it.

Currently my QR code contains the signature(raw bytes I suppose) directly , but I don't know how to make a device read the QR code but keep the content in bytes instead of turning them into string.

Maybe I should decode the signature before put it into a QR code? But I can't figure out how to properly do that either

Apr 19, 2023, 5:52 PM
I don't think you really should try to keep QR content in raw bytes 0..255, because many different apps can "try" to read all QRs they see and I suppose you don't want to crash user's device due to bad QR reader app he/she use :)

But explain please, how do you want to _verify_ signature? Something should split QR data to sig/key/msg and perform some cryptographic operations on it. You want to make special app for that?
Apr 19, 2023, 6:13 PM
I wrote a simple python script to perform the necessary cryptographic operations to verify the sig/key/msg. I use my phone to scan the QR code and manually send the content to my python script via input().

However that’s where I’m stuck on. The python script will consider the input as string instead of bytes.
How do I properly decode the signature(raw bytes), put it into QR code, and then encode it from string?
Apr 19, 2023, 6:28 PM
Encode the data into base64 format.
Apr 19, 2023, 7:02 PM
encode sig and make it a QR code, use other device to retrieve the data as string and decode it will work?
When I try to decode the data, my script returns error"'str' object has no attribute 'decode'."
Do i misunderstand something?
maybe there's other process needed before decoding?
Apr 20, 2023, 4:52 AM
base64.b64decode
Apr 20, 2023, 5:41 AM
Thanks for the help. Could you provide a little more detail, my route now is

sig -> nacl.encoding.RawEncoder (the singing function in SDK use this encoder by default) -> base64.b64encode() -> QR code -> base64.b64decode() -> check it w/ verify_sign function in SDK

however it returns an error saying the length of signature is not right
Apr 20, 2023, 5:19 PM

© 2024 Draquery.com All rights reserved.