Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add readme
Browse files Browse the repository at this point in the history
survived committed Dec 15, 2023
1 parent 4f510f2 commit 4623627
Showing 5 changed files with 73 additions and 4 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/readme.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Check README

on:
pull_request:
branches: [ "*" ]

env:
CARGO_TERM_COLOR: always
CARGO_NET_GIT_FETCH_WITH_CLI: true

jobs:
check_readme:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install cargo-hakari
uses: baptiste0928/cargo-install@v1
with:
crate: cargo-readme
- name: Check that readme matches lib.rs
run: |
cp README.md README-copy.md
make readme
diff README.md README-copy.md
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -9,3 +9,8 @@ docs-open:
docs-private:
RUSTDOCFLAGS="--html-in-header katex-header.html" cargo +nightly doc --no-deps --all-features --document-private-items

readme:
cargo readme -i src/lib.rs --no-indent-headings \
| perl -ne 's/(?<!!)\[([^\[]+?)\]\((?!http)[^\(]+?\)/\1/g; print;' \
| perl -ne 's/(?<!\])\[([^\[,]+?)\](?!\(|:|\[)/\1/g; print;' \
> README.md
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,40 @@
SLIP-10: Deterministic key generation

[SLIP10][slip10-spec] is a specification for implementing HD wallets. It aims at supporting many
curves while being compatible with [BIP32][bip32-spec].

The implementation is based on generic-ec library that provides generic
elliptic curve arithmetic. The crate is `no_std` and `no_alloc` friendly.

### Curves support
Implementation currently does not support ed25519 curve. All other curves are
supported: both secp256k1 and secp256r1. In fact, implementation may work with any
curve, but only those are covered by the SLIP10 specs.

The crate also re-exports supported curves in supported_curves module (requires
enabling a feature), but any other curve implementation will work with the crate.

### Features
* `std`: enables std library support (mainly, it just implements `Error`
trait for the error types)
* `curve-secp256k1` and `curve-secp256r1` add curve implementation into the crate supported_curves
module

### Examples

Derive a master key from the seed, and then derive a child key m/1<sub>H</sub>/10:
```rust
use slip_10::supported_curves::Secp256k1;

let seed = b"16-64 bytes of high entropy".as_slice();
let master_key = slip_10::derive_master_key::<Secp256k1>(seed)?;
let master_key_pair = slip_10::ExtendedKeyPair::from(master_key);

let child_key_pair = slip_10::derive_child_key_pair_with_path(
&master_key_pair,
[1 + slip_10::H, 10],
);
```

[slip10-spec]: https://github.com/satoshilabs/slips/blob/master/slip-0010.md
[bip32-spec]: https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki
1 change: 1 addition & 0 deletions README.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{readme}}
8 changes: 4 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! SLIP-10: Deterministic key generation
//!
//! [SLIP10] is a specification for implementing HD wallets. It aims at supporting many
//! curves while being compatible with [BIP32].
//! [SLIP10][slip10-spec] is a specification for implementing HD wallets. It aims at supporting many
//! curves while being compatible with [BIP32][bip32-spec].
//!
//! The implementation is based on [generic-ec](generic_ec) library that provides generic
//! elliptic curve arithmetic. The crate is `no_std` and `no_alloc` friendly.
@@ -37,8 +37,8 @@
//! # Ok::<(), Box<dyn std::error::Error>>(())
//! ```
//!
//! [SLIP10]: https://github.com/satoshilabs/slips/blob/master/slip-0010.md
//! [BIP32]: https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki
//! [slip10-spec]: https://github.com/satoshilabs/slips/blob/master/slip-0010.md
//! [bip32-spec]: https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki
#![cfg_attr(not(feature = "std"), no_std)]
#![forbid(missing_docs, unsafe_code)]

0 comments on commit 4623627

Please sign in to comment.