{"id":50940100,"url":"https://github.com/ppad-tech/bolt4","last_synced_at":"2026-06-17T13:04:09.147Z","repository":{"id":352577893,"uuid":"1214035968","full_name":"ppad-tech/bolt4","owner":"ppad-tech","description":"Onion routing protocol, per BOLT #4.","archived":false,"fork":false,"pushed_at":"2026-04-20T08:28:28.000Z","size":135,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-04-20T09:27:30.732Z","etag":null,"topics":["haskell","lightning","onion"],"latest_commit_sha":null,"homepage":"","language":"Haskell","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/ppad-tech.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null}},"created_at":"2026-04-18T03:31:17.000Z","updated_at":"2026-04-20T08:28:32.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/ppad-tech/bolt4","commit_stats":null,"previous_names":["ppad-tech/bolt4"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/ppad-tech/bolt4","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ppad-tech%2Fbolt4","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ppad-tech%2Fbolt4/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ppad-tech%2Fbolt4/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ppad-tech%2Fbolt4/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ppad-tech","download_url":"https://codeload.github.com/ppad-tech/bolt4/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ppad-tech%2Fbolt4/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34449283,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-17T02:00:05.408Z","response_time":127,"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":["haskell","lightning","onion"],"created_at":"2026-06-17T13:04:07.985Z","updated_at":"2026-06-17T13:04:09.139Z","avatar_url":"https://github.com/ppad-tech.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ppad-bolt4\n\n[![](https://img.shields.io/hackage/v/ppad-bolt4?color=blue)](https://hackage.haskell.org/package/ppad-bolt4)\n![](https://img.shields.io/badge/license-MIT-brightgreen)\n[![](https://img.shields.io/badge/haddock-bolt4-lightblue)](https://docs.ppad.tech/bolt4)\n\nA pure Haskell implementation of [BOLT #4][bolt4] (onion routing) from\nthe Lightning Network protocol specification, including packet\nconstruction and processing, error handling, and route blinding.\n\n## Usage\n\nA sample GHCi session:\n\n```\n  \u003e :set -XOverloadedStrings\n  \u003e\n  \u003e -- construct an onion packet for a 3-hop route\n  \u003e import qualified Crypto.Curve.Secp256k1 as Secp256k1\n  \u003e import qualified Data.ByteString as BS\n  \u003e import qualified Lightning.Protocol.BOLT4.Construct as Construct\n  \u003e import qualified Lightning.Protocol.BOLT4.Process as Process\n  \u003e import Lightning.Protocol.BOLT4.Types\n  \u003e\n  \u003e -- session key (32 bytes random, use CSPRNG in production)\n  \u003e let sessionKey = BS.replicate 32 0x41\n  \u003e\n  \u003e -- node keys (in production, these come from the network)\n  \u003e let Just hop1Sec = Secp256k1.parse_integer (BS.replicate 32 0x01)\n  \u003e let Just hop1Pub = Secp256k1.mul Secp256k1._CURVE_G hop1Sec\n  \u003e\n  \u003e -- build a minimal payload\n  \u003e let payload = emptyHopPayload { hpAmtToForward = Just 1000\n  \u003e                               , hpOutgoingCltv = Just 144 }\n  \u003e let hop = Construct.Hop hop1Pub payload\n  \u003e\n  \u003e -- construct packet (returns packet + shared secrets for error handling)\n  \u003e let assocData = BS.replicate 32 0x00  -- typically payment_hash\n  \u003e let Right (packet, secrets) = Construct.construct sessionKey [hop] assocData\n  \u003e\n  \u003e -- process at receiving node\n  \u003e let result = Process.process (BS.replicate 32 0x01) packet assocData\n  \u003e case result of\n  \u003e   Right (Process.Receive info) -\u003e print (riPayload info)\n  \u003e   _ -\u003e putStrLn \"not final hop\"\n```\n\n## Modules\n\nThe library is organized into the following modules:\n\n* `Lightning.Protocol.BOLT4.Construct` - onion packet construction\n* `Lightning.Protocol.BOLT4.Process` - onion packet processing\n* `Lightning.Protocol.BOLT4.Error` - failure message handling\n* `Lightning.Protocol.BOLT4.Blinding` - route blinding support\n* `Lightning.Protocol.BOLT4.Types` - core data types\n* `Lightning.Protocol.BOLT4.Codec` - serialization (BigSize, TLV)\n* `Lightning.Protocol.BOLT4.Prim` - cryptographic primitives\n\n## Documentation\n\nHaddocks are hosted at [docs.ppad.tech/bolt4][hadoc].\n\n## Security\n\nThis is a pre-release library that claims no security properties whatsoever.\n\n## Development\n\nYou'll require [Nix][nixos] with [flake][flake] support enabled. Enter a\ndevelopment shell with:\n\n```\n$ nix develop\n```\n\nThen do e.g.:\n\n```\n$ cabal build\n$ cabal test\n$ cabal bench\n```\n\n[bolt4]: https://github.com/lightning/bolts/blob/master/04-onion-routing.md\n[hadoc]: https://docs.ppad.tech/bolt4\n[nixos]: https://nixos.org/\n[flake]: https://nixos.org/manual/nix/unstable/command-ref/new-cli/nix3-flake.html\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fppad-tech%2Fbolt4","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fppad-tech%2Fbolt4","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fppad-tech%2Fbolt4/lists"}