DigiHan

How DigiHan works

DigiHan is a free digital stamp you make to sign or validate a file without corporate intermediaries or central authorities.

The parts of a seal

A DigiHan seal: the name DigiHan in the center, a ring of dots around it, inside a solid rim 1 2 3 4 5
  1. Center artworkYours to define: characters, a signature, a crest. Its SHA-256 hash (32 bytes) is registered with your public key and signed into every seal you make.
  2. BridgesEight tabs. The wide one at 12 o'clock shows the scanning camera which way is up.
  3. Locator ringTells the camera the ring's size and tilt.
  4. Data ring1,012 dots in five tracks: 78 bytes of data (described below) plus error correction.
  5. RimThe outer edge of the seal.

What the ring holds

PartSizeWhat it is
Version1 byteThe format version, and which time proof the seal uses.
Public key id8 bytesThe public key's fingerprint: the first 8 bytes of the SHA-256 hash of the signer's public key. The scanner uses it only to find the full public key.
Time5 bytesThe time of the seal’s placement, or for an anchored seal placement, a Bitcoin block number.
Signature64 bytesA Schnorr signature (BIP340), the kind Bitcoin uses.

How it fits together

1On signing

Your private key signs your document. The signature becomes the ring of dots around your artwork.

2After signing

You get back one PDF. Page 1 shows the seal. If your document was a PDF, its original pages follow; a text file or a picture is shown on the pages after the seal. Attached inside the PDF file itself (PDF readers such as Adobe Acrobat list them as attachments): your file unchanged, your public key, your artwork, and the Bitcoin time proof if you chose one.

3The check

The camera reads the ring. You load the stamped PDF or the original file. The scanner compares the two on the phone; your file is not uploaded to the internet.

The ring holds a signature of the document, not the document itself. So a seal is always checked together with the exact file that was stamped.

Signing / Stamping details

Your private key signs four things together: the loaded file's SHA-256 hash (32 bytes), the time, your public key id (the 8-byte fingerprint of your public key) and your artwork's SHA-256 hash (also 32 bytes). Change one byte of the document and the signature no longer matches.

In detail, when you tap Stamp:

  1. The file. The page reads the file you loaded and makes its SHA-256 hash: 32 bytes made from every byte of the file. The file is not sent anywhere.
  2. The time. The page takes the time from your device's clock (seconds since 1 January 1970, UTC) and writes it in 5 bytes. This time is your statement; on its own it proves nothing.
  3. The Bitcoin block, if you chose “no earlier than”. The page asks two Bitcoin sites (mempool.space and blockstream.info) for the block two below the newest one, and uses it only if both give the same answer. The 5 time bytes then hold that block's number instead of the clock time, and the block's 32-byte hash is a fifth thing that is included to be signed. Nobody can know a block's hash before the block exists, so the seal was made after it.
  4. Your public key id. The first 8 bytes of the SHA-256 hash of your public key.
  5. Your artwork. The SHA-256 hash of the exact artwork image registered with your public key (32 bytes).
  6. One hash of everything. The page joins these in a fixed order: file hash (32 bytes), time (5), public key id (8), artwork hash (32), and the block hash (32) if there is one. That is 77 or 109 bytes. It makes one SHA-256 hash of them, marked as DigiHan's (“DigiHan/v1”) so the signature cannot be passed off as a signature on anything else.
  7. The signature. Your private key signs that 32-byte hash. The result is a 64-byte Schnorr signature (BIP340). How a signature works: your private key is a secret number, and your public key is made from it by a calculation that cannot be run backwards, so the public key does not reveal the private key. Signing is a calculation on the private key and the hash from step 6 that gives 64 bytes. Your password unlocks the private key only for this moment, and the page clears it from memory right after.Before going on, the page checks the new signature against your public key: the same check the scanner makes later (see Checking). A signature that fails is not used.With a key kept offline, the page shows the 32-byte hash as a 64-character value; you sign it on your own computer and paste back the 128-character signature.
  8. The ring. The ring stores 78 bytes: version (1), public key id (8), time or block number (5) and the signature (64). The file hash, artwork hash and block hash are not stored in the ring: a checker makes them again from the file, the registered artwork and Bitcoin.
  9. The read-back check. The page draws the seal and reads it back the way the scanner does. If it does not read back exactly, nothing is saved.
  10. “No later than”, if you chose it. The SHA-256 hash of the ring's 78 bytes is sent to OpenTimestamps servers, which record it in a Bitcoin block within a few hours. This is not part of the signature; it proves the finished seal existed by that block. Step 3 on the stamping page collects the finished proof.
  11. The PDF. Page 1 shows the seal. Your file is attached unchanged, with your public key's registration, your artwork and the timestamp proof.

Your private key is made on your device and never leaves it. Or you can keep it elsewhere, and the page asks for a signature once when you set up your seal and once for each document:

Checking

  1. Open the scanner and point the camera at the seal. Or tap the picture-and-folder button and choose a photo or screenshot of the seal, or the stamped PDF or stamped picture itself; neither needs the camera.
  2. Tap Check against a document… and pick the stamped PDF or the original file. It is read on the phone and not uploaded. (The sample seals on this site need no file.)

Checking a signature is a second calculation, on the signer's public key, the hash rebuilt from the file as in step 6, and the 64 bytes in the ring. It answers yes or no. It answers yes only if the matching private key signed exactly that hash: change one bit of the hash, or use another public key, and it answers no.

What the scanner checks

The result is one line per check. Each line names the item and where it came from, and what it is checked against and where that came from, then the result: Match, No match, or Not checked, and why. Marks: ✓ passed, ✗ failed, ! not known, – none, … waiting.

When every check passes and the public key is known, the scanner says Signature valid for this file.

Showing your name

In step 1 of the stamping page, give a name such as [email protected]. The page puts it in your public key's Nostr profile (NIP-05) and shows a small file for your website, at /.well-known/nostr.json, that lists your public key under that name. Scanners then show your name with your seals. Anyone can write your name into the profile of their own public key, but only your website can list a public key under your name.

Time

A plain seal carries the time the signer states; nobody can change it afterwards. Two proofs pin it to Bitcoin:

No earlier than. The seal signs the hash of a recent Bitcoin block. Nobody knows a block's hash before the block is mined, so the seal was made after it.

No later than. The seal's 78 bytes are timestamped with OpenTimestamps, which records them in a Bitcoin block. The seal existed when that block was mined.

Sometime between and including Block A and Block B
A seal with both proofs is bookended. The window is usually one to a few hours.

Open

The format is public domain and anyone may build on it. The code is open source (Apache-2.0): github.com/dav1dpgit/digihan, with the full specification in SPEC.md.

Stamp a documentOpen scanner