#lightning #on-chain #output #formatting #sweep #externalizes #htlc

no-std vls-core

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

26 releases

0.14.0 Nov 7, 2025
0.14.0-rc.1 May 14, 2025
0.13.0 Feb 14, 2025
0.12.0 Aug 9, 2024
0.2.1 Mar 20, 2023

#2 in #externalizes

Download history 384/week @ 2025-09-21 320/week @ 2025-09-28 427/week @ 2025-10-05 357/week @ 2025-10-12 326/week @ 2025-10-19 357/week @ 2025-10-26 278/week @ 2025-11-02 306/week @ 2025-11-09 482/week @ 2025-11-16 735/week @ 2025-11-23 921/week @ 2025-11-30 939/week @ 2025-12-07 467/week @ 2025-12-14 405/week @ 2025-12-21 74/week @ 2025-12-28 263/week @ 2026-01-04

1,220 downloads per month
Used in 14 crates (11 directly)

Apache-2.0

1.5MB
29K SLoC

Validating Lightning Signer

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

Limitations

The following remain to be implemented:

  • vlsd --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

Check out our Docs

We recommend using the nightly version of Rust only in specific cases, such as for cargo fmt and no-std. Otherwise, we explicitly recommend using the stable version.

Formatting Code

Enable formatting precommit hooks:

./scripts/enable-githooks

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

Dependencies:

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

Run coverage:

./scripts/run-llvm-cov

Changing linker to mold instead of ld:

cp .cargo/config.sample.toml .cargo/config.toml

Benchmarks

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.

Dependencies

~25–45MB
~558K SLoC