bolt8

Encrypted and authenticated transport, per BOLT #8 (docs.ppad.tech/bolt8).
git clone git://git.ppad.tech/bolt8.git
Log | Files | Refs | README | LICENSE

README.md (2074B)


      1 # ppad-bolt8
      2 
      3 [![](https://img.shields.io/hackage/v/ppad-bolt8?color=blue)](https://hackage.haskell.org/package/ppad-bolt8)
      4 ![](https://img.shields.io/badge/license-MIT-brightgreen)
      5 [![](https://img.shields.io/badge/haddock-bolt8-lightblue)](https://docs.ppad.tech/bolt8)
      6 
      7 Haskell implementation of BOLT #8 (Lightning Network encrypted
      8 transport), including the `Noise_XK_secp256k1_ChaChaPoly_SHA256` handshake
      9 and encrypted message transport.
     10 
     11 ## Usage
     12 
     13 A sample GHCi session:
     14 
     15 ```
     16   > :set -XOverloadedStrings
     17   >
     18   > import qualified Data.ByteString as BS
     19   > import qualified Lightning.Protocol.BOLT8 as BOLT8
     20   >
     21   > let Just (i_s_sec, i_s_pub) = BOLT8.keypair (BS.replicate 32 0x11)
     22   > let Just (r_s_sec, r_s_pub) = BOLT8.keypair (BS.replicate 32 0x21)
     23   >
     24   > -- initiator knows responder static pubkey
     25   > let Right (msg1, i_hs) = BOLT8.act1 i_s_sec i_s_pub r_s_pub
     26   >                         (BS.replicate 32 0x12)
     27   > let Right (msg2, r_hs) = BOLT8.act2 r_s_sec r_s_pub
     28   >                         (BS.replicate 32 0x22) msg1
     29   > let Right (msg3, i_res) = BOLT8.act3 i_hs msg2
     30   > let Right r_res = BOLT8.finalize r_hs msg3
     31   >
     32   > let i_sess = BOLT8.session i_res
     33   > let r_sess = BOLT8.session r_res
     34   >
     35   > let Right (ct, i_sess') = BOLT8.encrypt i_sess "hello"
     36   > let Right (pt, r_sess') = BOLT8.decrypt r_sess ct
     37   > pt
     38   "hello"
     39 ```
     40 
     41 ## Framing
     42 
     43 On a byte stream, use `decrypt_frame` when you have an exact frame, or
     44 `decrypt_frame_partial` to work incrementally and learn how many bytes
     45 are still required for the next step.
     46 
     47 ## Documentation
     48 
     49 Haddocks are hosted at [docs.ppad.tech/bolt8][hadoc].
     50 
     51 ## Security
     52 
     53 This is a pre-release library that, at present, claims no security
     54 properties whatsoever.
     55 
     56 ## Development
     57 
     58 You'll require [Nix][nixos] with [flake][flake] support enabled. Enter a
     59 development shell with:
     60 
     61 ```
     62 $ nix develop
     63 ```
     64 
     65 Then do e.g.:
     66 
     67 ```
     68 $ cabal build
     69 $ cabal test
     70 $ cabal bench
     71 ```
     72 
     73 [nixos]: https://nixos.org/
     74 [flake]: https://nixos.org/manual/nix/unstable/command-ref/new-cli/nix3-flake.html
     75 [hadoc]: https://docs.ppad.tech/bolt8