瀏覽代碼

Extract derivation-path crate (#2056)

* extract derivation-path crate

* remove now unused dep

* update derivation_path dependents

* remove now-unused derivation-path dep
Kevin Heavey 1 年之前
父節點
當前提交
1ab8e07d7a

+ 18 - 3
Cargo.lock

@@ -5917,6 +5917,7 @@ dependencies = [
  "chrono",
  "clap 2.33.3",
  "rpassword",
+ "solana-derivation-path",
  "solana-remote-wallet",
  "solana-sdk",
  "tempfile",
@@ -5934,6 +5935,7 @@ dependencies = [
  "chrono",
  "clap 3.2.23",
  "rpassword",
+ "solana-derivation-path",
  "solana-remote-wallet",
  "solana-sdk",
  "solana-zk-token-sdk",
@@ -6316,6 +6318,17 @@ dependencies = [
 name = "solana-define-syscall"
 version = "2.1.0"
 
+[[package]]
+name = "solana-derivation-path"
+version = "2.1.0"
+dependencies = [
+ "assert_matches",
+ "derivation-path",
+ "qstring",
+ "thiserror",
+ "uriparse",
+]
+
 [[package]]
 name = "solana-dos"
 version = "2.1.0"
@@ -6610,6 +6623,7 @@ dependencies = [
  "num_cpus",
  "solana-clap-v3-utils",
  "solana-cli-config",
+ "solana-derivation-path",
  "solana-remote-wallet",
  "solana-sdk",
  "solana-version",
@@ -7197,6 +7211,7 @@ dependencies = [
  "parking_lot 0.12.3",
  "qstring",
  "semver 1.0.23",
+ "solana-derivation-path",
  "solana-sdk",
  "thiserror",
  "uriparse",
@@ -7492,7 +7507,6 @@ dependencies = [
  "byteorder",
  "chrono",
  "curve25519-dalek 4.1.3",
- "derivation-path",
  "digest 0.10.7",
  "ed25519-dalek",
  "ed25519-dalek-bip32",
@@ -7510,7 +7524,6 @@ dependencies = [
  "num-traits",
  "num_enum",
  "pbkdf2 0.11.0",
- "qstring",
  "qualifier_attr",
  "rand 0.7.3",
  "rand 0.8.5",
@@ -7525,6 +7538,7 @@ dependencies = [
  "siphasher",
  "solana-bn254",
  "solana-decode-error",
+ "solana-derivation-path",
  "solana-frozen-abi",
  "solana-frozen-abi-macro",
  "solana-logger",
@@ -7539,7 +7553,6 @@ dependencies = [
  "static_assertions",
  "thiserror",
  "tiny-bip39",
- "uriparse",
  "wasm-bindgen",
 ]
 
@@ -8287,6 +8300,7 @@ dependencies = [
  "serde_derive",
  "serde_json",
  "sha3",
+ "solana-derivation-path",
  "solana-program",
  "solana-sdk",
  "subtle",
@@ -8344,6 +8358,7 @@ dependencies = [
  "serde_json",
  "sha3",
  "solana-curve25519",
+ "solana-derivation-path",
  "solana-program",
  "solana-sdk",
  "subtle",

+ 2 - 0
Cargo.toml

@@ -105,6 +105,7 @@ members = [
     "sdk/cargo-test-sbf",
     "sdk/clock",
     "sdk/decode-error",
+    "sdk/derivation-path",
     "sdk/gen-headers",
     "sdk/hash",
     "sdk/macro",
@@ -380,6 +381,7 @@ solana-cost-model = { path = "cost-model", version = "=2.1.0" }
 solana-curve25519 = { path = "curves/curve25519", version = "=2.1.0" }
 solana-decode-error = { path = "sdk/decode-error", version = "=2.1.0" }
 solana-define-syscall = { path = "define-syscall", version = "=2.1.0" }
+solana-derivation-path = { path = "sdk/derivation-path", version = "=2.1.0" }
 solana-download-utils = { path = "download-utils", version = "=2.1.0" }
 solana-entry = { path = "entry", version = "=2.1.0" }
 solana-faucet = { path = "faucet", version = "=2.1.0" }

+ 1 - 0
clap-utils/Cargo.toml

@@ -13,6 +13,7 @@ edition = { workspace = true }
 chrono = { workspace = true, features = ["default"] }
 clap = "2.33.0"
 rpassword = { workspace = true }
+solana-derivation-path = { workspace = true }
 solana-remote-wallet = { workspace = true }
 solana-sdk = { workspace = true }
 thiserror = { workspace = true }

+ 1 - 1
clap-utils/src/keypair.rs

@@ -18,13 +18,13 @@ use {
     bip39::{Language, Mnemonic, Seed},
     clap::ArgMatches,
     rpassword::prompt_password,
+    solana_derivation_path::{DerivationPath, DerivationPathError},
     solana_remote_wallet::{
         locator::{Locator as RemoteWalletLocator, LocatorError as RemoteWalletLocatorError},
         remote_keypair::generate_remote_keypair,
         remote_wallet::{maybe_wallet_manager, RemoteWalletError, RemoteWalletManager},
     },
     solana_sdk::{
-        derivation_path::{DerivationPath, DerivationPathError},
         hash::Hash,
         message::Message,
         pubkey::Pubkey,

+ 1 - 0
clap-v3-utils/Cargo.toml

@@ -13,6 +13,7 @@ edition = { workspace = true }
 chrono = { workspace = true, features = ["default"] }
 clap = { version = "3.2.23", features = ["cargo"] }
 rpassword = { workspace = true }
+solana-derivation-path = { workspace = true }
 solana-remote-wallet = { workspace = true }
 solana-sdk = { workspace = true }
 solana-zk-token-sdk = { workspace = true }

+ 1 - 1
clap-v3-utils/src/input_parsers/signer.rs

@@ -5,12 +5,12 @@ use {
         ASK_KEYWORD, SKIP_SEED_PHRASE_VALIDATION_ARG,
     },
     clap::{builder::ValueParser, ArgMatches},
+    solana_derivation_path::{DerivationPath, DerivationPathError},
     solana_remote_wallet::{
         locator::{Locator as RemoteWalletLocator, LocatorError as RemoteWalletLocatorError},
         remote_wallet::RemoteWalletManager,
     },
     solana_sdk::{
-        derivation_path::{DerivationPath, DerivationPathError},
         pubkey::Pubkey,
         signature::{read_keypair_file, Keypair, Signature, Signer},
     },

+ 1 - 1
clap-v3-utils/src/keygen/derivation_path.rs

@@ -1,6 +1,6 @@
 use {
     clap::{Arg, ArgMatches},
-    solana_sdk::derivation_path::DerivationPath,
+    solana_derivation_path::DerivationPath,
     std::error,
 };
 

+ 1 - 1
clap-v3-utils/src/keypair.rs

@@ -18,12 +18,12 @@ use {
     bip39::{Language, Mnemonic, Seed},
     clap::ArgMatches,
     rpassword::prompt_password,
+    solana_derivation_path::DerivationPath,
     solana_remote_wallet::{
         remote_keypair::generate_remote_keypair,
         remote_wallet::{maybe_wallet_manager, RemoteWalletError, RemoteWalletManager},
     },
     solana_sdk::{
-        derivation_path::DerivationPath,
         hash::Hash,
         message::Message,
         pubkey::Pubkey,

+ 1 - 0
keygen/Cargo.toml

@@ -16,6 +16,7 @@ dirs-next = { workspace = true }
 num_cpus = { workspace = true }
 solana-clap-v3-utils = { workspace = true }
 solana-cli-config = { workspace = true }
+solana-derivation-path = { workspace = true }
 solana-remote-wallet = { workspace = true, features = ["default"] }
 solana-sdk = { workspace = true }
 solana-version = { workspace = true }

+ 15 - 3
programs/sbf/Cargo.lock

@@ -4762,6 +4762,7 @@ dependencies = [
  "chrono",
  "clap",
  "rpassword",
+ "solana-derivation-path",
  "solana-remote-wallet",
  "solana-sdk",
  "thiserror",
@@ -5017,6 +5018,16 @@ dependencies = [
 name = "solana-define-syscall"
 version = "2.1.0"
 
+[[package]]
+name = "solana-derivation-path"
+version = "2.1.0"
+dependencies = [
+ "derivation-path",
+ "qstring",
+ "thiserror",
+ "uriparse",
+]
+
 [[package]]
 name = "solana-download-utils"
 version = "2.1.0"
@@ -5588,6 +5599,7 @@ dependencies = [
  "parking_lot 0.12.2",
  "qstring",
  "semver",
+ "solana-derivation-path",
  "solana-sdk",
  "thiserror",
  "uriparse",
@@ -6291,7 +6303,6 @@ dependencies = [
  "bytemuck_derive",
  "byteorder 1.5.0",
  "chrono",
- "derivation-path",
  "digest 0.10.7",
  "ed25519-dalek",
  "ed25519-dalek-bip32",
@@ -6308,7 +6319,6 @@ dependencies = [
  "num-traits",
  "num_enum",
  "pbkdf2 0.11.0",
- "qstring",
  "qualifier_attr",
  "rand 0.7.3",
  "rand 0.8.5",
@@ -6322,6 +6332,7 @@ dependencies = [
  "siphasher",
  "solana-bn254",
  "solana-decode-error",
+ "solana-derivation-path",
  "solana-program",
  "solana-program-memory",
  "solana-sanitize",
@@ -6330,7 +6341,6 @@ dependencies = [
  "solana-serde-varint",
  "solana-short-vec",
  "thiserror",
- "uriparse",
  "wasm-bindgen",
 ]
 
@@ -6843,6 +6853,7 @@ dependencies = [
  "serde_derive",
  "serde_json",
  "sha3",
+ "solana-derivation-path",
  "solana-program",
  "solana-sdk",
  "subtle",
@@ -6885,6 +6896,7 @@ dependencies = [
  "serde_json",
  "sha3",
  "solana-curve25519",
+ "solana-derivation-path",
  "solana-program",
  "solana-sdk",
  "subtle",

+ 1 - 0
remote-wallet/Cargo.toml

@@ -19,6 +19,7 @@ num-traits = { workspace = true }
 parking_lot = { workspace = true }
 qstring = { workspace = true }
 semver = { workspace = true }
+solana-derivation-path = { workspace = true }
 solana-sdk = { workspace = true }
 thiserror = { workspace = true }
 uriparse = { workspace = true }

+ 1 - 1
remote-wallet/src/ledger.rs

@@ -5,7 +5,7 @@ use {
     console::Emoji,
     dialoguer::{theme::ColorfulTheme, Select},
     semver::Version as FirmwareVersion,
-    solana_sdk::derivation_path::DerivationPath,
+    solana_derivation_path::DerivationPath,
     std::{fmt, rc::Rc},
 };
 #[cfg(feature = "hidapi")]

+ 1 - 1
remote-wallet/src/remote_keypair.rs

@@ -7,8 +7,8 @@ use {
             RemoteWalletType,
         },
     },
+    solana_derivation_path::DerivationPath,
     solana_sdk::{
-        derivation_path::DerivationPath,
         pubkey::Pubkey,
         signature::{Signature, Signer, SignerError},
     },

+ 1 - 1
remote-wallet/src/remote_wallet.rs

@@ -8,8 +8,8 @@ use {
     },
     log::*,
     parking_lot::RwLock,
+    solana_derivation_path::{DerivationPath, DerivationPathError},
     solana_sdk::{
-        derivation_path::{DerivationPath, DerivationPathError},
         pubkey::Pubkey,
         signature::{Signature, SignerError},
     },

+ 1 - 3
sdk/Cargo.toml

@@ -54,7 +54,6 @@ bytemuck_derive = { workspace = true }
 byteorder = { workspace = true, optional = true }
 chrono = { workspace = true, features = ["alloc"], optional = true }
 curve25519-dalek = { workspace = true, optional = true }
-derivation-path = { workspace = true }
 digest = { workspace = true, optional = true }
 ed25519-dalek = { workspace = true, optional = true }
 ed25519-dalek-bip32 = { workspace = true, optional = true }
@@ -72,7 +71,6 @@ num-derive = { workspace = true }
 num-traits = { workspace = true }
 num_enum = { workspace = true }
 pbkdf2 = { workspace = true }
-qstring = { workspace = true }
 qualifier_attr = { workspace = true, optional = true }
 rand = { workspace = true, optional = true }
 rand0-7 = { package = "rand", version = "0.7", optional = true }
@@ -86,6 +84,7 @@ sha3 = { workspace = true, optional = true }
 siphasher = { workspace = true }
 solana-bn254 = { workspace = true }
 solana-decode-error = { workspace = true }
+solana-derivation-path = { workspace = true }
 solana-frozen-abi = { workspace = true, optional = true }
 solana-frozen-abi-macro = { workspace = true, optional = true }
 solana-program = { workspace = true }
@@ -96,7 +95,6 @@ solana-secp256k1-recover = { workspace = true }
 solana-serde-varint = { workspace = true }
 solana-short-vec = { workspace = true }
 thiserror = { workspace = true }
-uriparse = { workspace = true }
 
 [target.'cfg(target_arch = "wasm32")'.dependencies]
 getrandom = { version = "0.1", features = ["wasm-bindgen"] }

+ 22 - 0
sdk/derivation-path/Cargo.toml

@@ -0,0 +1,22 @@
+[package]
+name = "solana-derivation-path"
+description = "Solana BIP44 derivation paths."
+documentation = "https://docs.rs/solana-derivation-path"
+version = { workspace = true }
+authors = { workspace = true }
+repository = { workspace = true }
+homepage = { workspace = true }
+license = { workspace = true }
+edition = { workspace = true }
+
+[dependencies]
+derivation-path = { workspace = true }
+qstring = { workspace = true }
+thiserror = { workspace = true }
+uriparse = { workspace = true }
+
+[dev-dependencies]
+assert_matches = { workspace = true }
+
+[package.metadata.docs.rs]
+targets = ["x86_64-unknown-linux-gnu"]

+ 0 - 0
sdk/src/derivation_path.rs → sdk/derivation-path/src/lib.rs


+ 2 - 1
sdk/src/lib.rs

@@ -63,7 +63,6 @@ pub mod account_utils;
 pub mod client;
 pub mod commitment_config;
 pub mod compute_budget;
-pub mod derivation_path;
 pub mod deserialize_utils;
 pub mod ed25519_instruction;
 pub mod entrypoint;
@@ -113,6 +112,8 @@ pub mod wasm;
 pub use solana_bn254 as alt_bn128;
 #[deprecated(since = "2.1.0", note = "Use `solana-decode-error` crate instead")]
 pub use solana_decode_error as decode_error;
+#[deprecated(since = "2.1.0", note = "Use `solana-derivation-path` crate instead")]
+pub use solana_derivation_path as derivation_path;
 #[deprecated(since = "2.1.0", note = "Use `solana-program-memory` crate instead")]
 pub use solana_program_memory as program_memory;
 #[deprecated(since = "2.1.0", note = "Use `solana-sanitize` crate instead")]

+ 1 - 1
sdk/src/signer/keypair.rs

@@ -4,7 +4,6 @@
 use wasm_bindgen::prelude::*;
 use {
     crate::{
-        derivation_path::DerivationPath,
         pubkey::Pubkey,
         signature::Signature,
         signer::{EncodableKey, EncodableKeypair, SeedDerivable, Signer, SignerError},
@@ -13,6 +12,7 @@ use {
     ed25519_dalek_bip32::Error as Bip32Error,
     hmac::Hmac,
     rand0_7::{rngs::OsRng, CryptoRng, RngCore},
+    solana_derivation_path::DerivationPath,
     std::{
         error,
         io::{Read, Write},

+ 1 - 1
sdk/src/signer/mod.rs

@@ -4,12 +4,12 @@
 
 use {
     crate::{
-        derivation_path::DerivationPath,
         pubkey::Pubkey,
         signature::{PresignerError, Signature},
         transaction::TransactionError,
     },
     itertools::Itertools,
+    solana_derivation_path::DerivationPath,
     std::{
         error,
         fs::{self, File, OpenOptions},

+ 1 - 0
zk-sdk/Cargo.toml

@@ -33,6 +33,7 @@ serde = { workspace = true }
 serde_derive = { workspace = true }
 serde_json = { workspace = true }
 sha3 = { workspace = true }
+solana-derivation-path = { workspace = true }
 solana-sdk = { workspace = true }
 subtle = { workspace = true }
 zeroize = { workspace = true, features = ["zeroize_derive"] }

+ 1 - 1
zk-sdk/src/encryption/auth_encryption.rs

@@ -14,8 +14,8 @@ use {
     base64::{prelude::BASE64_STANDARD, Engine},
     rand::{rngs::OsRng, Rng},
     sha3::{Digest, Sha3_512},
+    solana_derivation_path::DerivationPath,
     solana_sdk::{
-        derivation_path::DerivationPath,
         signature::Signature,
         signer::{
             keypair::generate_seed_from_seed_phrase_and_passphrase, EncodableKey, SeedDerivable,

+ 1 - 1
zk-sdk/src/encryption/elgamal.rs

@@ -34,8 +34,8 @@ use {
     rand::rngs::OsRng,
     serde::{Deserialize, Serialize},
     sha3::{Digest, Sha3_512},
+    solana_derivation_path::DerivationPath,
     solana_sdk::{
-        derivation_path::DerivationPath,
         signature::Signature,
         signer::{
             keypair::generate_seed_from_seed_phrase_and_passphrase, EncodableKey, EncodableKeypair,

+ 1 - 0
zk-token-sdk/Cargo.toml

@@ -35,6 +35,7 @@ serde = { workspace = true }
 serde_derive = { workspace = true }
 serde_json = { workspace = true }
 sha3 = { workspace = true }
+solana-derivation-path = { workspace = true }
 solana-sdk = { workspace = true }
 subtle = { workspace = true }
 zeroize = { workspace = true, features = ["zeroize_derive"] }

+ 1 - 1
zk-token-sdk/src/encryption/auth_encryption.rs

@@ -6,8 +6,8 @@ use {
     crate::errors::AuthenticatedEncryptionError,
     base64::{prelude::BASE64_STANDARD, Engine},
     sha3::{Digest, Sha3_512},
+    solana_derivation_path::DerivationPath,
     solana_sdk::{
-        derivation_path::DerivationPath,
         signature::Signature,
         signer::{
             keypair::generate_seed_from_seed_phrase_and_passphrase, EncodableKey, SeedDerivable,

+ 1 - 1
zk-token-sdk/src/encryption/elgamal.rs

@@ -33,8 +33,8 @@ use {
         traits::Identity,
     },
     serde::{Deserialize, Serialize},
+    solana_derivation_path::DerivationPath,
     solana_sdk::{
-        derivation_path::DerivationPath,
         signature::Signature,
         signer::{
             keypair::generate_seed_from_seed_phrase_and_passphrase, EncodableKey, EncodableKeypair,