{"id":21848912,"url":"https://github.com/r4gus/crypto","last_synced_at":"2026-02-02T03:02:18.791Z","repository":{"id":264917792,"uuid":"871366245","full_name":"r4gus/crypto","owner":"r4gus","description":"Cryptographic algorithms in Zig","archived":false,"fork":false,"pushed_at":"2024-10-13T14:45:29.000Z","size":37,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-21T16:20:13.324Z","etag":null,"topics":["cryptography","vrf","zig","ziglang"],"latest_commit_sha":null,"homepage":"","language":"Zig","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/r4gus.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-11T20:11:51.000Z","updated_at":"2025-12-03T19:16:24.000Z","dependencies_parsed_at":"2024-11-27T00:03:09.444Z","dependency_job_id":null,"html_url":"https://github.com/r4gus/crypto","commit_stats":null,"previous_names":["r4gus/crypto"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/r4gus/crypto","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r4gus%2Fcrypto","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r4gus%2Fcrypto/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r4gus%2Fcrypto/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r4gus%2Fcrypto/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/r4gus","download_url":"https://codeload.github.com/r4gus/crypto/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r4gus%2Fcrypto/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29002632,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-02T01:32:03.847Z","status":"online","status_checked_at":"2026-02-02T02:00:07.448Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cryptography","vrf","zig","ziglang"],"created_at":"2024-11-28T00:09:24.556Z","updated_at":"2026-02-02T03:02:18.776Z","avatar_url":"https://github.com/r4gus.png","language":"Zig","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Crypto\n\nCryptographic algorithms in [Zig](https://ziglang.org/).\n\n## Algorithms\n\n- Verifiable Random Functions (VRFs) [RFC 9381](https://datatracker.ietf.org/doc/rfc9381/)\n  - [x] ECVRF-P256-SHA256-TAI\n  - [ ] ECVRF-P256-SHA256-SSWU\n  - [ ] ECVRF-EDWARDS25519-SHA512-TAI\n  - [ ] ECVRF-EDWARDS25519-SHA512-ELL2\n- Zero-Knowledge Proof\n  - [ ] Schnorr Non-interactive Zero-Knowledge Proof [RFC 8235](https://datatracker.ietf.org/doc/html/rfc8235)\n- Deterministic Random Bit Generator (DRBG)\n  - [x] XDRBG [iacr](https://tosc.iacr.org/index.php/ToSC/article/view/11399)\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cins\u003eVerifiable Random Functions (VRFs)\u003c/ins\u003e\u003c/summary\u003e\n\nA Verifiable Random Function (VRF) [RFC9381](https://datatracker.ietf.org/doc/rfc9381/)\ncan be seen as a public-key version of a cryptographic hash function with the following\nproperties:\n- A private-key is used to calculate a hash value.\n- The hash value can be verified using the corresponding public-key.\n- The hash is unpredictable and can't be skewed.\n\nA key application of the VRF is to provide privacy against offline\ndictionary attacks on data stored in a hash-based data structure.\n\nVRFs can be used as verifiable random numbers with the following properties:\n- *Uniqueness*: There is exactly one result for every computation\n- *Collision Resistance*: It is (almost) impossible to find two inputs that result in the same hash.\n- *Pseudo-randomness*: A hash is indistinguishable from a random value.\n- *Unpredictability*: If the input is unpredictable, the output is uniformly distributed.\n\n---\n\nA VRF comes with a key generation algorithm that generates\na VRF key-pair.\n```zig\nconst crypto = @import(\"crypto\");\nconst vrf = crypto.EcvrfP256Sha256Tai;\nconst kp = try vrf.KeyPair.generate();\n```\n\nThe Prover uses the secret key to construct a proof pi that\nbeta is the correct hash output.\n```zig\nconst alpha = \"test\";\nconst pi = try kp.prove(alpha, null);\n```\n\nThe VRF hash output beta can be directly obtained from the\nproof value pi.\n```zig\nconst beta = try vrf.proofToHash(pi);\n```\n\nThe proof pi allows a Verifier holding the public key to\nverify that beta is the correct VRF hash of input alpha\nunder the given private key.\n\nThis requires that the Prover and the Verifier exchange\npublic keys beforehand.\n\nThen, the Prover submits alpha, beta, and pi to the Verifier.\n\nThe Verifier can verify the correctness by calling `verify`.\nOn success, verify will return beta.\n```zig\n// For demonstration purposes we (the Prover) also call verify.\nconst beta2 = try kp.public_key.verify(alpha, pi, null);\nif (!std.mem.eql(u8, beta[0..], beta2[0..])) {\n    // handle error...\n}\n```\n\n\u003e **Proofs Provide No Secrecy for the VRF Input**\n\u003e \n\u003e The VRF proof pi is not designed to provide secrecy and, in general,\n\u003e may reveal the VRF input alpha.  Anyone who knows the public-key and pi is able\n\u003e to perform an offline dictionary attack to search for alpha, by\n\u003e verifying guesses for alpha using VRF_verify.  This is in contrast to\n\u003e the VRF hash output beta, which, without the proof, is pseudorandom\n\u003e and thus is designed to reveal no information about alpha.\n\nNote: the key exchange, as well as the submission of alpha,\nbeta and pi are out of scope.\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cins\u003eXDRBG\u003c/ins\u003e\u003c/summary\u003e\n\nTODO\n\n\u003c/details\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fr4gus%2Fcrypto","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fr4gus%2Fcrypto","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fr4gus%2Fcrypto/lists"}