created_at2024-03-17 11:57:38.075546
updated_at2024-04-02 12:22:08.091645
descriptionPrivacy friendly presence tokens
Robert Cutajar



# Presence Lib and tool to generate short discrete presence tokens. The token can be verified for validity in a certain time range, but otherwise appears random and is plausibly deniable. This should be good for privacy! # Anatomy The token shall be conveyed in a upper-hex string or in binary 8 bytes array. The first 4 bytes is a sha256 hash of the salt upper-hex + the unix timestamp decimal string. The other 4 bytes is the random salt. # CLI The companion CLI tool will verify or generate presence tokens. It give a non-zero exit code if no presence is matched or generated (like grep) It can also produce presence signed with ed25519 if you specify SECRET (string to be hashed into a seed), SECRET_SEED (32 bytes as hex), or SECRET_SEED_FILE (file containing 32+ bytes in binary, only first 32 are read). ## Install: ```sh $ cargo install presence ``` ## Usage: generate a new token or a few ```sh $ presence new 67CE238185EA6D0B $ presence new new new new 54C2BACC2E2DAF45 FBB0E058058CFF1E 71FE18E54F52DC76 22E8DAEBBDD7A220 ``` check a token ```sh $ presence 1234567890123456 1234567890123456 None $ presence nonsense nonsense Failed: string must be 16 bytes long $ presence nonsenseXXXXXXXX nonsenseXXXXXXXX Failed: string must be a hex ``` also works with stdin when no args are given ```sh $ presence 1234567890123456 | presence 1234567890123456 None ``` and you can use stdin to also generate tokens with empty line ```sh $ echo | presence FFA86CA7292F9225 ``` ouroboros, printing the matching timestamp ```sh $ echo | presence | presence B615BEDA94640BA7 OK 1710799816 ``` we can create the same presence token in shell easily ```sh presence_sh () { local time="${time:-$(date +%s)}" local salt="${salt:-$(head -c32 /dev/random | sha256sum | head -c8 | tr 'a-f' 'A-F')}" printf "$salt$time" | sha256sum | head -c8 | tr 'a-f' 'A-F' printf "$salt\n" } time=1710799816 salt=94640BA7 presence_sh ``` generate 3 x ed25519 signed presence revealing the public key ```sh $ printf "12345678901234567890123456789012\n\n\n" | SECRET_SEED_FILE="/dev/stdin" REVEAL_PUBLIC_KEY=yp presence pubkey: 02F8C6129D816CF51C374BC7F8C3E63ED156CF78AEFB4A6550D97B87997977EE 76DF4CA121D3253EbazupoVjFItfM6gPG0bZce7adrWwFjrTiePI7KUwifVQwBc9Q8hWNOLcNpNQr6LlcMi0t5HMWxBajCFWhQ-LCQ A1FB3851EFB04D71OUvhSXJ1WaVEKGTVJLO-0FiI9CJk1CjxC0JI2vYj_8Pyx0UHqN-gqN0z9g6J1vWSmT09pqvq7JZy7Jb3T_JqDg 772A7DBBFC75C305oZnUM5XX_TAIQ-0UAyFClaWGudOKuq5CUnvirTiHbVKBAtK7g8nfefel9Ep5dxd7gmoxDWv8r3cY-j5ejweuCA ``` stay present ```sh $ while echo; do sleep 1; done | presence C0C6792F43904B94 3418E6B820D54FE3 DBA0FD7F65FDD4D7 492F9AED9F2A904F AC646257A1B78CCE A09249459EA29CAA 4D0AAFB96D3970F0 ... ```
Commit count: 12

cargo fmt