{"id":18752625,"url":"https://github.com/vechain/go-ecvrf","last_synced_at":"2025-04-13T00:31:20.885Z","repository":{"id":39797202,"uuid":"244555509","full_name":"vechain/go-ecvrf","owner":"vechain","description":"Elliptic Curve Verifiable Radom Function(ECVRF) library written in Go","archived":false,"fork":false,"pushed_at":"2022-05-25T12:58:49.000Z","size":77,"stargazers_count":10,"open_issues_count":0,"forks_count":12,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-26T18:43:58.067Z","etag":null,"topics":["crypto","curve","ellipitic","hash","random","verifiable","vrf"],"latest_commit_sha":null,"homepage":"","language":"Go","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/vechain.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}},"created_at":"2020-03-03T06:05:44.000Z","updated_at":"2024-12-12T04:47:45.000Z","dependencies_parsed_at":"2022-07-11T03:30:19.968Z","dependency_job_id":null,"html_url":"https://github.com/vechain/go-ecvrf","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vechain%2Fgo-ecvrf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vechain%2Fgo-ecvrf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vechain%2Fgo-ecvrf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vechain%2Fgo-ecvrf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vechain","download_url":"https://codeload.github.com/vechain/go-ecvrf/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248650590,"owners_count":21139670,"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":["crypto","curve","ellipitic","hash","random","verifiable","vrf"],"created_at":"2024-11-07T17:21:33.419Z","updated_at":"2025-04-13T00:31:20.599Z","avatar_url":"https://github.com/vechain.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go-ecvrf\n\n[![GoDoc Reference](https://godoc.org/github.com/vechain/go-ecvrf?status.svg)](https://pkg.go.dev/github.com/vechain/go-ecvrf)\n[![Travis](https://travis-ci.org/vechain/go-ecvrf.svg?branch=master)](https://travis-ci.org/vechain/go-ecvrf)\n[![License](https://img.shields.io/github/license/vechain/go-ecvrf)](https://github.com/vechain/go-ecvrf/blob/master/LICENSE)\n\nGolang implementation of Elliptic Curve Verifiable Random Function (VRF) follows [draft-irtf-cfrg-vrf-06](https://tools.ietf.org/id/draft-irtf-cfrg-vrf-06.html) and [RFC 6979](https://tools.ietf.org/html/rfc6979).\n\n# What's VRF\n\nA Verifiable Random Function (VRF) is the public-key version of a keyed cryptographic hash. Only the holder of the private key can compute the hash, but anyone with public key can verify the correctness of the hash.\n\nA key application of the VRF is to provide privacy against offline enumeration (e.g. dictionary attacks) on data stored in a hash-based data structure. In this application, a Prover holds the VRF private key and uses the VRF hashing to construct a hash-based data structure on the input data. Due to the nature of the VRF, only the Prover can answer queries about whether or not some data is stored in the data structure. Anyone who knows the public VRF key can verify that the Prover has answered the queries correctly. However no offline inferences (i.e. inferences without querying the Prover) can be made about the data stored in the data strucuture.\n\n# Installation\n\n```\ngo get -u github.com/vechain/go-ecvrf\n```\n\n# Examples\n\nUsing SECP256K1_SHA256_TAI cipher suite:\n\n* VRF Proving\n\n    ```golang\n    // the private key\n    var sk *ecdsa.PrivateKey\n    // code to load sk\n    // ... \n\n    // the input to be hashed by the VRF\n    alpha := \"Hello VeChain\"\n\n    // `beta`: the VRF hash output\n    // `pi`: the VRF proof\n    beta, pi, err := ecvrf.Secp256k1Sha256Tai.Prove(sk, []byte(alpha))\n    if err != nil {\n        // something wrong.\n        // most likely sk is not properly loaded.\n        return\n    }\n    ```\n\n* VRF Verifying\n\n    ```golang \n    // the public key\n    var pk *ecdsa.PublicKey\n    // code to load pk\n    // ...\n\n    // the input to be hashed by the VRF\n    alpha := \"Hello VeChain\"\n\n    // `pi` is the VRF proof\n    beta, err := ecvrf.Secp256k1Sha256Tai.Verify(pk, []byte(alpha), pi)\n    if err != nil {\n        // invalid proof\n        return\n    }\n\n    // got correct beta\n    ```\n\n\n# Supported Cipher Suites\n\n* P256_SHA256_TAI \n* SECP256K1_SHA256_TAI\n\nIt's easy to extends this library to use different Weierstrass curves and Hash algorithms, by providing cooked `Config` like:\n\n```golang\n// the following codes build a new P256_SHA256_TAI VRF object.\nvrf := ecvrf.New(\u0026ecvrf.Config{\n    Curve:       elliptic.P256(),\n    SuiteString: 0x01,\n    Cofactor:    0x01,\n    NewHasher:   sha256.New,\n    Decompress: elliptic.UnmarshalCompressed,\n})\n```\n\n# Benchmark\n\n```bash\n$ go test -benchmem -run=^$ -bench ^BenchmarkVRF$ github.com/vechain/go-ecvrf -benchtime=5s\ngoos: linux\ngoarch: amd64\npkg: github.com/vechain/go-ecvrf\ncpu: Intel(R) Core(TM) i7-6700 CPU @ 3.40GHz\nBenchmarkVRF/secp256k1sha256tai-proving-8         \t   22207\t    279600 ns/op\t    4881 B/op\t      95 allocs/op\nBenchmarkVRF/secp256k1sha256tai-verifying-8       \t   15150\t    399938 ns/op\t    5009 B/op\t     114 allocs/op\nBenchmarkVRF/p256sha256tai-proving-8              \t   31328\t    193911 ns/op\t    9083 B/op\t     294 allocs/op\nBenchmarkVRF/p256sha256tai-verifying-8            \t   19875\t    300613 ns/op\t   19472 B/op\t     515 allocs/op\nPASS\nok  \tgithub.com/vechain/go-ecvrf\t36.060s\n```\n\n# References\n\n* [draft-irtf-cfrg-vrf-06](https://tools.ietf.org/id/draft-irtf-cfrg-vrf-06.html)\n* [RFC 6979](https://tools.ietf.org/html/rfc6979)\n* [witnet/vrf-rs](https://github.com/witnet/vrf-rs)\n* [google/keytransparency](https://github.com/google/keytransparency)\n\n# License\n\nCopyright (c) 2020 vechain.org.\nLicensed under the MIT license.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvechain%2Fgo-ecvrf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvechain%2Fgo-ecvrf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvechain%2Fgo-ecvrf/lists"}