{"id":26130583,"url":"https://github.com/emeraldpay/hdpath-rs","last_synced_at":"2025-04-13T19:34:13.223Z","repository":{"id":62440028,"uuid":"249094520","full_name":"emeraldpay/hdpath-rs","owner":"emeraldpay","description":"Rust library for Hierarchical Deterministic Path (BIP32, BIP43, BIP44, BIP49, BIP84)","archived":false,"fork":false,"pushed_at":"2025-03-21T21:49:28.000Z","size":129,"stargazers_count":13,"open_issues_count":1,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-27T10:13:07.377Z","etag":null,"topics":["bip32","bip44","blockchain","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/emeraldpay.png","metadata":{"files":{"readme":"README.adoc","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-03-22T01:51:46.000Z","updated_at":"2025-03-21T21:49:31.000Z","dependencies_parsed_at":"2025-03-10T20:52:03.861Z","dependency_job_id":"e91b8bbf-9490-4059-901a-edc90b8c26fe","html_url":"https://github.com/emeraldpay/hdpath-rs","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emeraldpay%2Fhdpath-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emeraldpay%2Fhdpath-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emeraldpay%2Fhdpath-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emeraldpay%2Fhdpath-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/emeraldpay","download_url":"https://codeload.github.com/emeraldpay/hdpath-rs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248768342,"owners_count":21158618,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bip32","bip44","blockchain","rust"],"created_at":"2025-03-10T20:51:53.582Z","updated_at":"2025-04-13T19:34:13.201Z","avatar_url":"https://github.com/emeraldpay.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"= HD Path for Rust\n:lib-version: 0.5.0\n\nimage:https://github.com/emeraldpay/hdpath-rs/workflows/Test/badge.svg[\"Test\"]\nimage:https://coveralls.io/repos/github/emeraldpay/hdpath-rs/badge.svg[\"Coveralls\"]\nimage:https://codecov.io/gh/emeraldpay/hdpath-rs/branch/master/graph/badge.svg[Codecov,link=https://codecov.io/gh/emeraldpay/hdpath-rs]\nimage:https://img.shields.io/crates/v/hdpath.svg?style=flat-square[\"Crates\",link=\"https://crates.io/crates/hdpath\"]\nimage:https://img.shields.io/badge/License-Apache%202.0-blue.svg[\"License\"]\n\n\nRust crate that implements common structures and utilities to operate HD Path defined by Bitcoin's BIP-32 standard.\n\nThe main specification for the Hierarchical Deterministic Wallets is https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki[BIP-32],\nand HD Path is a part of it which specifies the format for the hierarchy path.\n\nThe crate doesn't try to implement Key Derivation specification, but instead implements all common\nfunctionality for creating, parsing and displaying an HD Path, especially standard paths defined\nby BIP-44 and related.\n\nThe common structure, defined by BIP-43, is `m/purpose'/coin_type'/account'/change/address_index`, for example `m/44'/0'/0'/0/0`\n\nAll supported standards:\n\n- https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki[BIP-32]\n- https://github.com/bitcoin/bips/blob/master/bip-0043.mediawiki[BIP-43]\n- https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki[BIP-44]\n- https://github.com/bitcoin/bips/blob/master/bip-0049.mediawiki[BIP-49]\n- https://github.com/bitcoin/bips/blob/master/bip-0084.mediawiki[BIP-84]\n\n== Use\n\n.Cargo.toml:\n[source,toml,subs=\"attributes\"]\n----\n[dependencies]\nhdpath = \"{lib-version}\"\n----\n\n=== Examples\n\n.Basic usage\n[source, rust]\n----\nuse hdpath::StandardHDPath;\nuse std::str::FromStr;\n\nlet hd_path = StandardHDPath::from_str(\"m/44'/0'/0'/0/0\").unwrap();\n//prints \"m/44'/0'/0'/0/0\"\nprintln!(\"{:?}\", hd_path);\n\n//prints \"0\", which is account id\nprintln!(\"{:?}\", hd_path.account());\n\n//prints: \"purpose: Pubkey, coin: 0, account: 0, change: 0, index: 0\"\nprintln!(\"purpose: {:?}, coin: {}, account: {}, change: {}, index: {}\",\n    hd_path.purpose(),\n    hd_path.coin_type(),\n    hd_path.account(),\n    hd_path.change(),\n    hd_path.index()\n);\n----\n\n.Create from values\n[source, rust]\n----\nuse hdpath::{StandardHDPath, Purpose};\n\nlet hd_path = StandardHDPath::new(Purpose::Witness, 0, 1, 0, 101);\n//prints \"m/84'/0'/1'/0/101\"\nprintln!(\"{:?}\", hd_path);\n----\n\n.Create account and derive addresses\n[source, rust]\n----\nuse hdpath::{AccountHDPath, StandardHDPath, Purpose};\nuse std::convert::TryFrom;\n\nlet hd_account = AccountHDPath::new(Purpose::Witness, 0, 1);\n// prints \"m/44'/0'/1'/x/x\"\nprintln!(\"{:?}\", hd_account);\n\n// get actual address on the account path. Returns StandardHDPath\nlet hd_path = hd_account.address_at(0, 7);\n\n//prints: \"m/44'/0'/1'/0/7\"\nprintln!(\"{:?}\", hd_path);\n----\n\nPlease note that values for HD Path are limited to `2^31-1` because the highest bit is reserved for marking a _hardened_ value.\nTherefore, if you're getting individual values from some user input, you should verify the value before passing to `::new`.\nOtherwise, the constructor may fail with _panic_ if an invalid value is passed.\n\n.Verify before create\n[source, rust]\n----\nuse hdpath::{StandardHDPath, PathValue, Purpose};\n\nfn user_path(index: u32) -\u003e Result\u003cStandardHDPath, ()\u003e {\n  let user_id = 1234 as u32;\n  if PathValue::is_ok(index) {\n    Ok(StandardHDPath::new(Purpose::Witness, 0, user_id, 0, index))\n  } else {\n    Err(())\n  }\n}\n----\n\n=== Use with bitcoin library\n\nEnable `with-bitcoin` feature, that provides extra methods for compatibility with bitcoin lib.\nIt includes conversion into `Vec\u003cChildNumber\u003e` and `DerivationPath`.\n\n[source,toml,subs=\"attributes\"]\n----\nhdpath = { version = \"{lib-version}\", features = [\"with-bitcoin\"] }\n----\n\n.Convert to DerivationPath\n[source,rust]\n----\nuse hdpath::{StandardHDPath};\nuse secp256k1::Secp256k1;\nuse bitcoin::{\n    network::constants::Network,\n    util::bip32::{ExtendedPrivKey, DerivationPath}\n};\n\nfn get_pk(seed: \u0026[u8], hd_path: \u0026StandardHDPath) -\u003e ExtendedPrivKey {\n  let secp = Secp256k1::new();\n  ExtendedPrivKey::new_master(Network::Bitcoin, seed)\n        // we convert HD Path to bitcoin lib format (DerivationPath)\n        .and_then(|k| k.derive_priv(\u0026secp, \u0026DerivationPath::from(hd_path)))\n        .unwrap()\n}\n\n----\n\n== License\n\nCopyright 2020 EmeraldPay, Inc\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\nhttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femeraldpay%2Fhdpath-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Femeraldpay%2Fhdpath-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femeraldpay%2Fhdpath-rs/lists"}