{"id":15697223,"url":"https://github.com/noot/htlp-rs","last_synced_at":"2025-05-08T23:43:41.896Z","repository":{"id":122592245,"uuid":"555625388","full_name":"noot/htlp-rs","owner":"noot","description":"linearly homomorphic timelock puzzles implementation","archived":false,"fork":false,"pushed_at":"2022-10-22T00:41:50.000Z","size":8,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-08T23:43:36.382Z","etag":null,"topics":["cryptography","timelock","timelock-puzzle"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/noot.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":"2022-10-22T00:41:39.000Z","updated_at":"2024-09-30T02:01:45.000Z","dependencies_parsed_at":null,"dependency_job_id":"93750f65-1bd1-4017-8886-2dbe5d989147","html_url":"https://github.com/noot/htlp-rs","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/noot%2Fhtlp-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/noot%2Fhtlp-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/noot%2Fhtlp-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/noot%2Fhtlp-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/noot","download_url":"https://codeload.github.com/noot/htlp-rs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253166474,"owners_count":21864467,"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":["cryptography","timelock","timelock-puzzle"],"created_at":"2024-10-03T19:14:18.312Z","updated_at":"2025-05-08T23:43:41.880Z","avatar_url":"https://github.com/noot.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# htlp-rs\n\nThis repository contains an implementation of [Homomorphic Timelock Puzzles](https://eprint.iacr.org/2019/635.pdf) (see section 4.1). A timelock puzzle is a cryptographic primitive that encloses a secret value within a puzzle (ie. encrypts it). The puzzle can be quickly generated, but can only be solved (decrypted) over a period of time by repeated squarings, which cannot be parallelized. It's the opposite of a VDF in a sense, which takes a long time to generate but can be quickly verified.\n\nThe timelock puzzles are linearly homomorphic in that multiple puzzles can be combined and when solved, their output is the summation of their individual secrets.\n\nNote that the time it takes to solve a puzzle is machine-dependent. If one machine can square faster than another, it'll solve the puzzle quicker. If you want to timelock something for definitely *at least* a certain amount of time, try to benchmark solving on the fastest machine you anticipate could try to solve the puzzle. The time parameter passed into `Parameters::new` isn't tied to any real-life measure of time, apart from that a higher value will take longer to solve.\n\n## Usage\n\n```rust\nuse htlp::setup::Parameters;\n\nuse num_bigint_dig::{RandBigInt, ToBigUint};\nuse rand;\n\nfn generate_and_solve() {\n    let security = 32;\n    let time = 100.to_biguint().unwrap();\n    let params = Parameters::new(security, time);\n\n    let one = 1.to_biguint().unwrap();\n    let mut rng = rand::thread_rng();\n    let secret = rng.gen_biguint_range(\u0026one, \u0026(\u0026params.n - \u0026one));\n    let puzzle = \u0026params.generate(\u0026secret);\n\n    let res = puzzle.solve();\n    debug_assert!(secret == res);\n}\n\nfn generate_and_solve_homomorphic() {\n    let security = 32;\n    let time = 100.to_biguint().unwrap();\n    let params = Parameters::new(security, time);\n\n    let one = 1.to_biguint().unwrap();\n    let mut rng = rand::thread_rng();\n    let secret0 = rng.gen_biguint_range(\u0026one, \u0026(\u0026params.n - \u0026one));\n    let puzzle0 = \u0026params.generate(\u0026secret0);\n    let secret1 = rng.gen_biguint_range(\u0026one, \u0026(\u0026params.n - \u0026one));\n    let puzzle1 = \u0026params.generate(\u0026secret1);\n\n    let puzzle = puzzle0.add(puzzle1);\n    let secret = \u0026secret0 + \u0026secret1;\n\n    let res = puzzle.solve();\n    debug_assert!(secret == res);\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnoot%2Fhtlp-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnoot%2Fhtlp-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnoot%2Fhtlp-rs/lists"}