#persist #channel #node

no-std bin+lib vls-persist

A library for implementing a Lightning signer, which externalizes and secures cryptographic operations

11 unstable releases (3 breaking)

0.11.0-rc.1 Nov 29, 2023
0.10.0 Aug 17, 2023
0.9.1 Jun 21, 2023
0.9.0-rc.1 May 29, 2023
0.2.0 Mar 14, 2023
Download history 37/week @ 2023-08-16 9/week @ 2023-08-23 3/week @ 2023-08-30 22/week @ 2023-09-06 7/week @ 2023-09-13 32/week @ 2023-09-20 8/week @ 2023-09-27 6/week @ 2023-10-04 5/week @ 2023-10-11 14/week @ 2023-10-18 4/week @ 2023-10-25 5/week @ 2023-11-01 5/week @ 2023-11-08 19/week @ 2023-11-15 251/week @ 2023-11-22 128/week @ 2023-11-29

403 downloads per month
Used in 3 crates (2 directly)


27K SLoC

Validating Lightning Signer

Please see the VLS Project Overview for more information. Our web site.


The following remain to be implemented:

  • vlsd2 --recover-to can only handle a simple force-close by us. It cannot sweep a force-close or a breach by the peer. It also cannot sweep HTLC outputs.
  • there is no facility to recover from loss of signer state.
  • on-chain tracking is not fully implemented, so a malicious node can steal funds by failing to remedy a breach (for example)

Additional Crates

Development Information

Additional HOWTO Documentation

Formatting Code

Enable formatting precommit hooks:


For some reason, the ignore configuration for rustfmt is only available on the nightly channel, even though it's documented as stable.

rustup install nightly

cargo +nightly fmt

Building Validating Lightning Signer

Build VLS and related crates:

cargo build

Running Unit Tests

cargo test

To enable logging for a failing test (adjust log level to preference):

RUST_LOG=trace cargo test

Using llvm-cov for Code Coverage


cargo +stable install cargo-llvm-cov --locked

Run coverage:



Running Benchmarks

cargo bench -p vls-core --bench secp_bench

Note that you might need to add --features=test_utils if you want to run all benches in vls-core.

Without optimizations:

cargo bench -p vls-core --bench secp_bench --profile=dev

Expect something like:

    test fib1_bench        ... bench:           1 ns/iter (+/- 0)
    test fib_bench         ... bench:      17,247 ns/iter (+/- 198)
    test hash_bench        ... bench:         258 ns/iter (+/- 2)
    test secp_create_bench ... bench:      49,981 ns/iter (+/- 642)
    test sign_bench        ... bench:      25,692 ns/iter (+/- 391)
    test verify_bench      ... bench:      31,705 ns/iter (+/- 1,445)

i.e. around 30 microseconds per secp256k1 crypto operation. We also see that creating a secp context is expensive, but not prohibitively so.


~274K SLoC