QR Code Seal Stamp
QR codes and official seals are two things that are ubiquitous here in Taiwan. Usually they are of similar size and shape. What if there was a way to combine the two into one?
We'll you can! — But it involves controlling the data within the QR code. Someone else did some research for how to get this sort of stuff to work before me. They didn't do it in the context of Chinese Seals, but nonetheless I was able to take some of their ideas and put them to good use.
How it works
If you start with a url like https://example.com/page# then you can embed junk data at the end of the url that is actually the image data when it gets encoded to the url. This works because everything after the pound symbol will be ignored by the site. So basically the Seal QR Code would look something like:
https://example.com/path#12341234123901203490234...
One insight from [1] is that if the section part is only numbers then we will be able to control the pixels in the final QR code much easier. This is because the QR standard allows mixing the encoding mode. If we switch to it's numeric encoding mode then we'll have control of all of the bits, while still decoding to a valid url.
Designing a Seal
There are some parts of a QR code that must be a certain color. So I've intentionally placed the strokes over the QR code timing pattern in order to make the most of the space available. For this to work with my design, I had to flip my characters upside down. The data in a QR Code is encoded bottom-to-top and right-to-left in a strange zig-zag pattern. Also the error correction bits are placed immediately after the data. Therefore because I want it to still decode to a valid url and because of error correction I'm restricted from placing pixels in the left or right portions of the qr code.
Mapping Pixels
Finally I have the pixel data we just have to figure out how to translate the pixel cordinates and data into the data we can append to the url. There are rules for determining how the pixels map, but I ran into issues wrapping my brain around how to deal with the alignment sections. Instead of spending more hours working on this part I ended up writing code that brute forced generating qr codes chaning one bit of the input each time and finds the (x,y) cordinate of changed module. Running this only takes about 10 seconds and I saved the mapping data in a file that I load when generating qr codes in the future.
Masking
The QR code generator algoithm includes a masking step which can change based off of the data encoded. We have to reverse this part in order for the data we are encoding to correspond to the pixel data. I used a qrcode generator library that allows fixing the mask pattern. So we've gotten to this point:
Now I need to flip the data and export it in a format that I can use for 3D printing. Luckily someone else already did the part for generating it as 3D printing file. I just had to flip the x-axis. I also wonder at this point if this is something that a master seal carver could also carve. Having an ornate seal with some cool designs on the handle would also be nice.Prototyping
I asked my friend who is really into 3D printing to work on a QR Code stamp prototype. I asked him to print a prototype of a normal QR Code first. The only problem is that the stamp isn't actually scannable. If I go back and fill in some of the blochy parts with a pen then it's actually able to scan.
Final Design
(Updated Apr 11) After 2 more iterations here is my final design. I modified the back of the stamp face to have a lip which can wrap around the handle of a real stamp. The best part is that it works really well.
The stamp looks best and properly scans when you stamp it when using a silicon backing. I use my laptop cover. Anyway I'm pretty happy about how this project turned out. I'm planning on making a couple for my friends and maybe possibly selling some if people are interested in having custom ones made.
References
Future Work
What if when signing important documents you didn't use your seal, but a some sort of digital signature? It would be really cool to extend what I have made here into generating digital signatures for documents. For example you could have the stamp be a digitally signed hash of an image of the document.