Skip to content

Commit 1216d63

Browse files
committed
Refactoring into a standalone library
1 parent b200f66 commit 1216d63

File tree

17 files changed

+380
-238
lines changed

17 files changed

+380
-238
lines changed

Cargo.lock

Lines changed: 187 additions & 42 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[package]
2-
name = "client_side_validation"
2+
name = "bp-core"
33
version = "0.5.0-rc.1"
44
license = "Apache-2.0"
55
authors = ["Dr. Maxim Orlovsky <[email protected]>"]
@@ -13,14 +13,14 @@ edition = "2018"
1313
exclude = [".github", "bp-dbc", "bp-seals", "commit_verify", "strict_encoding", "single_use_seals"]
1414

1515
[lib]
16-
name = "client_side_validation"
16+
name = "bp"
1717
path = "src/lib.rs"
1818

1919
[dependencies]
2020
amplify = "3.7.1"
21-
strict_encoding = "1.5.1"
22-
commit_verify = "0.5.0"
23-
single_use_seals = "0.5.1"
21+
strict_encoding = { version = "1.6.0", features = ["bitcoin", "miniscript", "derive"] }
22+
commit_verify = "0.5.4"
23+
single_use_seals = "0.5.3"
2424
bp-dbc = { version = "0.5.0-rc.1", path = "./dbc", optional = true, default-features = false }
2525
bp-seals = { version = "0.5.0-rc.1", path = "./seals", optional = true, default-features = false }
2626

README.md

Lines changed: 25 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -1,147 +1,52 @@
1-
# Client-side-validation library
1+
# Bitcoin protocol core library
22

3-
![Build](https://github.com/LNP-BP/client_side_validation/workflows/Build/badge.svg)
4-
![Tests](https://github.com/LNP-BP/client_side_validation/workflows/Tests/badge.svg)
5-
![Lints](https://github.com/LNP-BP/client_side_validation/workflows/Lints/badge.svg)
6-
[![codecov](https://codecov.io/gh/LNP-BP/client_side_validation/branch/master/graph/badge.svg)](https://codecov.io/gh/LNP-BP/client_side_validation)
3+
![Build](https://github.com/LNP-BP/bp-core/workflows/Build/badge.svg)
4+
![Tests](https://github.com/LNP-BP/bp-core/workflows/Tests/badge.svg)
5+
![Lints](https://github.com/LNP-BP/bp-core/workflows/Lints/badge.svg)
6+
[![codecov](https://codecov.io/gh/LNP-BP/bp-core/branch/master/graph/badge.svg)](https://codecov.io/gh/LNP-BP/bp-core)
77

8-
[![crates.io](https://meritbadge.herokuapp.com/client_side_validation)](https://crates.io/crates/client_side_validation)
9-
[![Docs](https://docs.rs/lnpbp/badge.svg)](https://docs.rs/client_side_validation)
8+
[![crates.io](https://img.shields.io/crates/v/bp-core)](https://crates.io/crates/bp-core)
9+
[![Docs](https://docs.rs/bp-core/badge.svg)](https://docs.rs/bp-core)
1010
[![unsafe forbidden](https://img.shields.io/badge/unsafe-forbidden-success.svg)](https://github.com/rust-secure-code/safety-dance/)
11-
[![Apache-2 licensed](https://img.shields.io/crates/l/client_side_validation)](./LICENSE)
11+
[![Apache-2 licensed](https://img.shields.io/crates/l/bp-core)](./LICENSE)
1212

13-
This is an implementation defining standard of client-side-validation, i.e. its
14-
Core library.
13+
The library implements bitcoin protocol elements which are missed from other
14+
existing bitcoin libraries, like [rust-bitcoin] and [descriptor wallet].
15+
Currently, it includes components necessary for [client-side-validation] over
16+
bitcoin, specifically
17+
- deterministic bitcoin commitments API (LNPBP-1, 2 & 3 standards)
18+
- bitcoin-based single-use-seal API (LNPBP-10 and LNPBP-39 standards)
1519

1620
Client-side-validation is a paradigm for distributed computing, based on top of
1721
proof-of-publication/commitment medium layer, which may be a bitcoin blockchain
1822
or other type of distributed consensus system.
1923

2024
The development of the library is supported by [LNP/BP Standards Association](https://lnp-bp.org).
21-
The original idea of client-side-validation was proposed by Peter Todd with its
22-
possible applications designed by Giacomo Zucco. It was shaped into a protocol-
23-
level design by Dr Maxim Orlovsky with a big input from the community and
24-
implemented by him as this set of libraries.
25-
26-
27-
## Documentation
28-
29-
Detailed developer & API documentation for all libraries can be accessed
30-
at <https://docs.rs/client_side_validation/>
31-
32-
To learn about the technologies enabled by the library please check
33-
[slides from our tech presentations](https://github.com/LNP-BP/FAQ/blob/master/Presentation%20slides/)
34-
and [LNP/BP tech talks videos](https://www.youtube.com/channel/UCK_Q3xcQ-H3ERwArGaMKsxg)
35-
36-
37-
## Components
38-
39-
This library consists of the following main three components, which define
40-
independent parts constituting together client-side-validation API and its core
41-
functionality. These are:
42-
- Strict encoding (LNPBP-7 standard): binary standard of encoding
43-
client-side-validated data
44-
- Commit-verify scheme and its client-side-validation specific implementations
45-
* consensus commitments
46-
* multi-commitments (LNPBP-4 standard)
47-
- Single-use-seals (LNPBP-8 standard)
48-
49-
Basing on these APIs, this library includes specific applications for commitment/
50-
proof-of-publication mediums. Currently, this is *Bitcoin transaction graph*
51-
(both blockchain and state channel-based), consisting of two main components:
52-
- deterministic bitcoin commitments API (LNPBP-1, 2 & 3 standards)
53-
- bitcoin-based single-use-seal API (LNPBP-10 and LNPBP-39 standards)
5425

5526

5627
## Usage
5728

58-
The repository contains rust libraries for client-side validation and
59-
command-line tools for debugging/low-level hacking mode.
60-
61-
### Use library in other projects
62-
63-
To use libraries, you just need lates version of libraries, published to
29+
To use libraries, you just need latest version of libraries, published to
6430
[crates.io](https://crates.io) into `[dependencies]` section of your project
6531
`Cargo.toml`. Here is the full list of available libraries from this repository:
6632

6733
```toml
68-
client_side_validation = "1" # "Umbrella" library including all other libraries
69-
strict_encoding = "1" # Strict encoding API and derivation macros
70-
commit_verify = "1" # Consensus and multi-message commitments
71-
single_use_seals = "1" # Generic (non-bitcoin-specific) API
72-
bp-dbc = "1" # Deterministic bitcoin commitments library
73-
bp-seals = "1" # Bitcoin single-use-seals library
34+
bp-dbc = "0.5" # Deterministic bitcoin commitments crate
35+
bp-seals = "0.5" # Bitcoin single-use-seals crate
36+
bp-core = "0.5" # Library including both of the previous crates
7437
```
7538

76-
"Umbrella" `client_side_validation` library is configured with default set of
77-
features enabling all of its functionality (and including all of other libraries
78-
from this repository, listed above). If you need to restrict this set, either
79-
use specific libraries - or configure main library with a set of features in
80-
the following way:
81-
```toml
82-
[dependencies.client_side_validation]
83-
version = "1"
84-
default-features = false
85-
features = [] # Your set of features goes here
86-
# Avaliable features
87-
# * `derivation` - includes strict encoding derivation macros
88-
# * `strict_encoding` - strict encoding library (by default does not include
89-
# derivation macros, to use it you need`derivation`
90-
# feature to be explicetly enabled
91-
# * `multi-commitments` - LNPBP-4 multi-commitments
92-
# * `dbc` - deterministic bitcoin commitments
93-
# * `seals-all` - All single-use-seals component, including bitcoin seals
94-
# library
95-
# * `seals-api` - single-use-seals core API (without bitcoin-specific extensions)
96-
# * `seals-utxo - Bitcoin-based UTXO single-use-seals
97-
```
98-
99-
For specific features which may be enabled for the libraries, please check
100-
library-specific guidelines, located in `README.md` files in each of library
101-
subdirectories.
102-
103-
104-
### Use command-line tool
105-
106-
First, you have to install rust toolchain using instructions from
107-
[the official website](https://www.rust-lang.org/tools/install).
108-
109-
Next, if you need the latest published version, you can simply run
110-
```shell script
111-
cargo install client_side_validation
112-
```
113-
which will give you the latest version of the command-line tool. For now, you
114-
can use it by typing in terminal
115-
```shell script
116-
clisv help
117-
```
118-
119-
If you need a latest `master` version (which may be unstable), you need to clone
120-
git repository and compile the project locally:
121-
```shell script
122-
git clone https://github.com/LNP-BP/client_side_validation
123-
cd client_side_validation
124-
cargo install --path .
125-
```
39+
`bp-core` crate is an "umbrella" library containing both deterministic bitcoin
40+
commitments and bitcoin seals crates inside.
12641

12742

12843
## Known applications
12944

13045
The current list of the projects based on the library include:
13146
* [RGB](https://github.com/LNP-BP/rgb-node): Confidential & scalable smart
13247
contracts for Bitcoin & Lightning
133-
* [LNP](https://www.youtube.com/watch?v=YmmNsWS5wiM): generalized lightning
134-
network and it's reference implementations named
135-
[LNP Core](https://github.com/LNP-BP/lnp-core) and
136-
[LNP Node](https://github.com/LNP-BP/lnp-node)
13748
* [Bitcoin-based decentralized identity](https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2021-February/018381.html)
13849
proposal uses single-use-seals
139-
* [Internet2 project](https://github.com/internet2-org) uses strict-encoding
140-
for building its Internet2 APIs and microservice architecture
141-
142-
To learn more about the technologies enabled by the library please check
143-
[slides from our tech presentations](https://github.com/LNP-BP/FAQ/blob/master/Presentation%20slides/)
144-
and [LNP/BP tech talks videos](https://www.youtube.com/channel/UCK_Q3xcQ-H3ERwArGaMKsxg)
14550

14651

14752
## Contributing
@@ -160,3 +65,8 @@ be declined.
16065
### Licensing
16166

16267
See [LICENCE](LICENSE) file.
68+
69+
70+
[rust-bitcoin]: https://github.com/rust-bitcoin/rust-bitcoin
71+
[descriptor-wallet]: https://github.com/LNP-BP/descriptor-wallet
72+
[client-side-validation]: https://docs.rs/client_side_validation/

dbc/Cargo.toml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,12 @@ name = "dbc"
1616
path = "src/lib.rs"
1717

1818
[dependencies]
19-
amplify = "3.4"
20-
bitcoin = "0.26"
21-
descriptor-wallet = "0.4.1"
22-
strict_encoding = "1.2.3"
23-
commit_verify = "0.5.0"
19+
amplify = "3.7.1"
20+
bitcoin = "0.27.0"
21+
descriptor-wallet = "0.5.0-alpha.1"
22+
strict_encoding = "1.6.0"
23+
commit_verify = "0.5.4"
24+
miniscript = "6.0.1"
25+
26+
[dev-dependencies]
27+
secp256k1 = { version = "0.20.3", features = ["global-context"] }

dbc/src/keyset.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use std::collections::BTreeSet;
1717

1818
use bitcoin::hashes::{sha256, Hmac};
1919
use bitcoin::secp256k1;
20-
use client_side_validation::commit_verify::EmbedCommitVerify;
20+
use commit_verify::EmbedCommitVerify;
2121
use miniscript::Segwitv0;
2222

2323
use super::{Container, Error, Proof, ScriptEncodeData};
@@ -132,16 +132,14 @@ where
132132
#[cfg(test)]
133133
mod test {
134134
use super::*;
135-
use crate::dbc::pubkey::*;
136-
use crate::test::gen_secp_pubkeys;
137-
use amplify::Wrapper;
138-
use bitcoin::hashes::{hex::ToHex, sha256, Hash};
135+
use crate::pubkey::*;
136+
use crate::lnpbp1::test_helpers::*;
137+
use bitcoin::hashes::{sha256, Hash};
139138
use bitcoin::secp256k1;
140-
use client_side_validation::commit_verify::test_helpers::{
141-
embed_commit_verify_suite, gen_messages,
142-
};
143139
use std::iter::FromIterator;
144140
use std::str::FromStr;
141+
use amplify::Wrapper;
142+
use amplify::hex::ToHex;
145143

146144
#[test]
147145
fn test_lnpbp1_vs_lnpbp2() {

dbc/src/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,13 @@
1111
// along with this software.
1212
// If not, see <https://opensource.org/licenses/MIT>.
1313

14+
#[macro_use]
15+
extern crate amplify;
16+
#[macro_use]
17+
extern crate strict_encoding;
18+
1419
mod error;
20+
pub mod lnpbp1;
1521
pub mod keyset;
1622
pub mod lockscript;
1723
pub mod pubkey;

0 commit comments

Comments
 (0)