{"id":24792560,"url":"https://github.com/dojoengine/stark-vrf","last_synced_at":"2025-10-12T17:31:34.776Z","repository":{"id":242757977,"uuid":"810460246","full_name":"dojoengine/stark-vrf","owner":"dojoengine","description":"A VRF implementation using Stark curve and Poseidon hash.","archived":false,"fork":false,"pushed_at":"2024-09-11T18:11:06.000Z","size":43,"stargazers_count":12,"open_issues_count":1,"forks_count":3,"subscribers_count":0,"default_branch":"main","last_synced_at":"2024-09-12T03:58:11.082Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dojoengine.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-06-04T18:34:41.000Z","updated_at":"2024-09-11T17:59:22.000Z","dependencies_parsed_at":null,"dependency_job_id":"990b59bd-bc38-480f-9295-a449feec55a8","html_url":"https://github.com/dojoengine/stark-vrf","commit_stats":null,"previous_names":["reilabs/stark-vrf"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dojoengine%2Fstark-vrf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dojoengine%2Fstark-vrf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dojoengine%2Fstark-vrf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dojoengine%2Fstark-vrf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dojoengine","download_url":"https://codeload.github.com/dojoengine/stark-vrf/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":236254411,"owners_count":19119618,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2025-01-29T20:37:37.065Z","updated_at":"2025-10-12T17:31:29.448Z","avatar_url":"https://github.com/dojoengine.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Stark VRF\n\nThis repository implements the VRF spec (https://datatracker.ietf.org/doc/html/rfc9381)\nusing Stark curve and Poseidon hash for efficient verification on Starknet.\n\nThis repository contains two parts:\n* VRF prover and verifier implemented in Rust. It can be used not only to generate a VRF\n  proof but also supplements all necessary hints for cheap verification in Cairo.\n* An efficient Cairo verifier.\n\n## Usage\n\n### Proof generation\n\nProofs can be generated by using the provided `stark-vrf` crate.\n\n```rust\n  use stark_vrf::{Error, generate_public_key, Proof, ScalarValue, StarkVRF};\n\n  #[test]\n  fn it_generates_proof() -\u003e Result\u003cProof, Error\u003e {\n      let secret_key = ScalarValue!(\"190\");\n      let public_key = generate_public_key(secret_key);\n\n      let seed = \u0026[ScalarValue!(\"42\")];\n      let ecvrf = StarkVRF::new(public_key).unwrap();\n      ecvrf.prove(\u0026secret_key, seed)\n  }\n```\n\n### Hints for fast verification\n\nVRF proof verification requires calculating a square root on field elements which is very\ninefficient when implemented in Cairo. Instead, Rust code can generate a \"sqrt_ratio_hint\"\nthat makes verification much cheaper.\n\n```rust\nlet sqrt_ratio_hint = ecvrf.hash_to_sqrt_ratio_hint(seed);\n```\n\n### Proof verification, random output generation\n\nFor completeness and testing, Rust also provides a way to verify proofs generated by itself.\n\n```rust\necvrf.verify(\u0026proof, seed).expect(\"proof correct\");\nlet random_word = ecvrf.proof_to_hash(\u0026proof).unwrap();\n```\n\n### Proof verification in Cairo\n\nThis repository also provides a \"stark_vrf\" Scarb package for easy VRF proof verification in Cairo.\n\n```rust\npub use stark_vrf::ecvrf::{Point, Proof, ECVRF, ECVRFImpl};\n\n// sample output obtained from Rust code\nfn proof_from_oracle() -\u003e Proof {\n    Proof {\n        gamma: Point {\n            x: 1506339363762384048749124975867331702319430609263271304275332020910807468800,\n            y: 36259598506905210600179635686591002688831785399437338349196739602416217657\n        },\n        c: 2613903846701008054856365693011070443633034612733309583190565217827378733393,\n        s: 1867682679224997956048283066055885717352683300581532690215097247223135564277,\n        sqrt_ratio_hint: 2921944847064913001096235045564630676660517332237551444115611698074403533689,\n    }\n}\n\n#[test]\nfn ecvrf_verify() {\n    // verifiers must ensure the public key hasn't changed\n    let pk = Point {\n        x: 2465182048640915825114623967805639036884813714770257338089158027381626459289,\n        y: 3038635738014387716559859267483610492356329532552881764846792983975787300333\n    }; \n    let proof = proof_from_oracle();\n    let ecvrf = ECVRFImpl::new(pk);\n    let mut seed = ArrayTrait::new();\n    seed.append(42);\n\n    // 👇 proof verification\n    let actual_beta = ecvrf.verify(proof, seed.span()).unwrap();\n\n    let expected_beta = 1749760720107131022781690892024891617311129198096286233628341005792224087740;\n    assert_eq!(expected_beta, actual_beta);\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdojoengine%2Fstark-vrf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdojoengine%2Fstark-vrf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdojoengine%2Fstark-vrf/lists"}