diff --git a/.github/workflows/snippets.yml b/.github/workflows/snippets.yml index 64b071e..bed0b57 100644 --- a/.github/workflows/snippets.yml +++ b/.github/workflows/snippets.yml @@ -103,7 +103,8 @@ jobs: - name: Setup Rust uses: dtolnay/rust-toolchain@stable with: - toolchain: "1.78.0" + toolchain: "1.89.0" + components: rustfmt # ----------------------------------------------------------------------- # Python — pinned minor version; patch resolved by setup-python. @@ -134,19 +135,34 @@ jobs: python3 --version bash --version | head -1 + # Runs both the extended fence checks and the Rust quickstart + # guide/crate extraction check (check:snippets-extended chains both). - name: Check extended snippets (Rust / Python / shell / JSON / TOML / YAML) run: pnpm run check:snippets-extended - # --------------------------------------------------------------------------- - # Stellar testnet snippet validation — split into two steps so that - # deterministic content regressions block merges while provider outages - # are surfaced as annotations without blocking. - # - # Exit codes from check-stellar-testnet-snippets.ts: - # 0 – passed - # 1 – content regression → always a hard failure - # 2 – provider outage → warning annotation, does NOT block merge - # --------------------------------------------------------------------------- + # ----------------------------------------------------------------------- + # Compile the Rust quickstart crate — this is the ground-truth check + # that all documented crypto code actually compiles and its tests pass. + # The second pass enables the "network" feature so the scan / send + # modules (reqwest / tokio) are type-checked too; it is compile-only, + # no RPC calls are made. + # ----------------------------------------------------------------------- + - name: Compile Rust quickstart crate + working-directory: snippets/rust-quickstart + run: cargo build --features testnet 2>&1 + + - name: Type-check Rust quickstart network modules + working-directory: snippets/rust-quickstart + run: cargo check --features testnet,network 2>&1 + + - name: Check Rust quickstart formatting + working-directory: snippets/rust-quickstart + run: cargo fmt --check + + - name: Run Rust quickstart unit tests + working-directory: snippets/rust-quickstart + run: cargo test --features testnet 2>&1 + stellar-testnet-snippets: name: Stellar snippet testnet validation runs-on: ubuntu-latest @@ -361,3 +377,4 @@ jobs: pnpm exec tsx scripts/generate-stellar-reference.ts --check --require-contracts=stealth-announcer,wraith-names + diff --git a/.gitignore b/.gitignore index 5379ce5..fbbb4bd 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,6 @@ node_modules/ .npm/ test-results/ playwright-report/ + +# Rust build artifacts +snippets/rust-quickstart/target/ diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md index 5c61ef3..f70d4c2 100644 --- a/docs/CONTRIBUTING.md +++ b/docs/CONTRIBUTING.md @@ -44,28 +44,56 @@ request must hit a route documented on the page, and each fixture is compiled wi When an example calls an endpoint, add one fixture per request it makes. `no-check` is not allowed on that page. -### Python quickstart +### Rust quickstart crate -`guides/quickstarts/python.mdx` runs end to end in CI, offline, as part of -`check:snippets-extended`: +`guides/quickstarts/rust.mdx` is backed by a real crate, +`snippets/rust-quickstart`, that CI builds with `cargo build` / `cargo test` / +`cargo fmt --check`. Fences in that guide that belong to the crate are tagged: -```bash -npm run check:python-quickstart +````mdx +```rust crate +// src/stealth.rs +... ``` +```` -`scripts/python-quickstart/run_quickstart.py` builds `wraith_crypto.py` from the -fence that starts with `# wraith_crypto.py` (plus any `# Add to wraith_crypto.py` -fences), then runs every other Python fence in page order in one session. The -Soroban RPC, Horizon, and Soroban transaction calls go to local fakes that serve -recorded announcer events and verify each transaction's signatures. Results are -compared with `scripts/python-quickstart/vectors.json`, which -`npm run generate:python-quickstart-vectors` computes from the pinned SDK. - -Dependencies are pinned in `scripts/python-quickstart/requirements.txt`. The -`--bootstrap` flag creates a virtualenv with those pins under -`node_modules/.cache`. Every Python fence in the guide must run. A fence that -cannot run needs both words after the language, `python Pseudocode no-check`, so -readers see it is pseudocode. +- `crate` fences are **not** compiled standalone by + `check:snippets-extended` (they reference crate-internal modules). Instead, + `scripts/check-rust-quickstart.ts` extracts every `// src/` fence, + concatenates continuation fences, and byte-compares the result against + `snippets/rust-quickstart/src/.rs` (after stripping crate-only + regions). If the crate and the guide drift apart, CI fails. +- The first fence for a file keeps its `// src/` marker line. Later + fences start with `// src/ (continued)`; that line is dropped when the + fences are concatenated. +- Code that exists only in the crate (unit tests, test fixtures) is wrapped in + markers and hidden from the guide: + + ```rust + // crate-only-begin: reason, not shown in the guide + #[cfg(test)] + mod tests { /* ... */ } + // crate-only-end + ``` + +- Fences that intentionally diverge from the crate (aspirational APIs, + self-contained `main` variants) use `no-check` plus a marker line and must be + listed with a reason in the `EXEMPT` map of + `scripts/check-rust-quickstart.ts`. The script also fails on stale exemptions + and on crate sources that no fence covers, so every `src/*.rs` file is + either shown in the guide or explicitly exempted. +- `Cargo.toml` is compared structurally: feature names, default features, and + dependency names (including optional flags) must match. Version strings may + differ so the guide can pin looser ranges. + +After editing either side, regenerate or fix until both pass: + +```bash +npm run check:rust-quickstart +# print the crate source (crate-only regions stripped) for a file: +npx tsx scripts/check-rust-quickstart.ts --emit stealth.rs +cd snippets/rust-quickstart && cargo build --features testnet && cargo test && cargo fmt --check +``` ## Navigation coverage diff --git a/guides/quickstarts/rust.mdx b/guides/quickstarts/rust.mdx index 649713d..1db1ac0 100644 --- a/guides/quickstarts/rust.mdx +++ b/guides/quickstarts/rust.mdx @@ -21,6 +21,8 @@ A Rust quickstart for developers building backends, indexers, relayers, or CLIs There is no first-class `@wraith-protocol/sdk` Rust crate yet. This guide **reimplements the stealth spec directly** using audited crates (`ed25519-dalek`, `x25519-dalek`, `curve25519-dalek`, `stellar-strkey`, `stellar-xdr`, `soroban-client`). See [Where the Rust story is thinner](#where-the-rust-story-is-thinner) for what is planned. +Every `src/` file below is compiled in CI as part of the `snippets/rust-quickstart` crate — the code you copy is the code that is built and tested on each PR. + ## Prerequisites - Rust toolchain (stable) @@ -32,7 +34,7 @@ There is no first-class `@wraith-protocol/sdk` Rust crate yet. This guide **reim Feature flags select the network at compile time. `testnet` is the default and is where the Wraith contracts are live. `futurenet` and `mainnet` flip the RPC URL, passphrase, and Friendbot availability — the example compiles and runs on all three. -```toml no-check +```toml # Cargo.toml [package] name = "wraith-rust-quickstart" @@ -44,27 +46,30 @@ default = ["testnet"] testnet = [] futurenet = [] mainnet = [] +# "network" enables the scan + send modules (reqwest / tokio / soroban-client). +# Leave it off for a pure compile/type-check of the crypto modules. +network = ["dep:reqwest", "dep:serde_json", "dep:tokio"] [dependencies] -ed25519-dalek = { version = "2", features = ["rand_core"] } -x25519-dalek = { version = "2", features = ["static_secrets"] } +ed25519-dalek = { version = "2", features = ["rand_core"] } +x25519-dalek = { version = "2", features = ["static_secrets"] } curve25519-dalek = "4" -sha2 = "0.10" -rand = "0.8" -hex = "0.4" -stellar-strkey = "0.0.6" -stellar-xdr = { version = "20", features = ["std", "base64"] } -soroban-client = "0.10" -tokio = { version = "1", features = ["full"] } -reqwest = { version = "0.12", features = ["json"] } -serde_json = "1" -anyhow = "1" +sha2 = "0.10" +rand = "0.8" +hex = "0.4" +stellar-strkey = "0.0.8" +anyhow = "1" + +# Optional — only needed when "network" is enabled. +reqwest = { version = "0.12", features = ["json"], optional = true } +serde_json = { version = "1", optional = true } +tokio = { version = "1", features = ["full"], optional = true } [profile.release] opt-level = 3 ``` -```rust no-check +```rust crate // src/network.rs // Compile-time network selection. Flip with --features futurenet / --features mainnet. @@ -105,11 +110,10 @@ pub const STEALTH_SIGNING_MESSAGE: &str = Decode the `S...` secret seed with `stellar-strkey`, then build an `ed25519-dalek` signing key. Keep the seed in memory only — never log it. -```rust no-check +```rust crate // src/keypair.rs use anyhow::Result; -use ed25519_dalek::{Signer, SigningKey}; -use stellar_strkey::Decode; +use ed25519_dalek::SigningKey; pub struct Account { pub seed: [u8; 32], @@ -118,30 +122,69 @@ pub struct Account { } pub fn load_keypair(secret: &str) -> Result { - // `S...` -> 32-byte ed25519 seed - let seed = stellar_strkey::Decode::ed25519_secret_seed(secret)?; + // `S...` -> 32-byte ed25519 seed via stellar-strkey ed25519::PrivateKey + let private = stellar_strkey::ed25519::PrivateKey::from_string(secret) + .map_err(|e| anyhow::anyhow!("invalid stellar secret: {e:?}"))?; + let seed: [u8; 32] = private.0; let signing_key = SigningKey::from_bytes(&seed); - let address = stellar_strkey::Ed25519PublicKey(signing_key.verifying_key().to_bytes()).to_string(); - - Ok(Account { seed, signing_key, address }) + let address = + stellar_strkey::ed25519::PublicKey(signing_key.verifying_key().to_bytes()).to_string(); + Ok(Account { + seed, + signing_key, + address, + }) } +``` + +The binary entry point loads the key from `STELLAR_SECRET`, signs the domain-separated message, and prints the derived stealth keys. With `--features network` the same binary becomes a scanner instead (see Step 3). + +```rust crate +// src/main.rs +// +// Entry point for `cargo run`. When the "network" feature is active the binary +// scans the Soroban testnet for stealth payments addressed to the keypair +// supplied via STELLAR_SECRET. Without "network" it just derives keys and +// prints them — useful for local testing without an RPC call. + +pub mod keypair; +pub mod network; +pub mod scan; +pub mod send; +pub mod stealth; + +#[cfg(not(feature = "network"))] +fn main() -> anyhow::Result<()> { + use ed25519_dalek::Signer; + use network::STEALTH_SIGNING_MESSAGE; -#[tokio::main] -async fn main() -> Result<()> { let secret = std::env::var("STELLAR_SECRET")?; - let account = load_keypair(&secret)?; - println!("loaded account {}", account.address); + let account = keypair::load_keypair(&secret)?; + println!("loaded account: {}", account.address); // The 64-byte signature drives stealth key derivation. - let sig: [u8; 64] = account.signing_key.sign(STEALTH_SIGNING_MESSAGE.as_bytes()).to_bytes(); - println!("derivation signature (hex): {}", hex::encode(sig)); + let sig: [u8; 64] = account + .signing_key + .sign(STEALTH_SIGNING_MESSAGE.as_bytes()) + .to_bytes(); + let keys = stealth::derive_stealth_keys(&sig); + println!("spending pub : {}", hex::encode(keys.spending_pub)); + println!("viewing pub : {}", hex::encode(keys.viewing_pub)); Ok(()) } + +#[cfg(feature = "network")] +#[tokio::main] +async fn main() -> anyhow::Result<()> { + let secret = std::env::var("STELLAR_SECRET")?; + scan::run_scan(&secret).await +} ``` Run it: ```bash +export STELLAR_SECRET=S... # your funded testnet account cargo run --features testnet # or: cargo run --features futurenet ``` @@ -150,18 +193,24 @@ cargo run --features testnet This is the core of the Rust path: a self-contained reimplementation of the Wraith Stellar stealth spec (ed25519 + X25519, domain-separated SHA-256). It mirrors `deriveStealthKeys` / `generateStealthAddress` / `scanAnnouncements` from `@wraith-protocol/sdk/chains/stellar`. -```rust no-check +```rust crate // src/stealth.rs -use anyhow::Result; +// +// Self-contained reimplementation of the Wraith Stellar stealth spec. +// Mirrors deriveStealthKeys / generateStealthAddress / scanAnnouncements +// from @wraith-protocol/sdk/chains/stellar. +// +// Cryptographic primitives: ed25519 + X25519, domain-separated SHA-256. + use curve25519_dalek::{ - constants::ED25519_BASEPOINT_POINT, - edwards::CompressedEdwardsY, - EdwardsPoint, Scalar, + constants::ED25519_BASEPOINT_POINT, edwards::CompressedEdwardsY, EdwardsPoint, Scalar, }; use ed25519_dalek::SigningKey; use sha2::{Digest, Sha256, Sha512}; use x25519_dalek::{PublicKey as X25519PublicKey, StaticSecret}; +// ── Public types ────────────────────────────────────────────────────────────── + pub struct StealthKeys { pub spending_seed: [u8; 32], pub viewing_seed: [u8; 32], @@ -183,9 +232,9 @@ pub struct MatchedStealth { } ``` -```rust no-check +```rust crate // src/stealth.rs (continued) -// --- domain-separated derivation (mirrors the TS spec) --- +// ── Domain-separated derivation (mirrors the TS spec) ──────────────────────── fn derive_seed(tag: &str, sig: &[u8; 64]) -> [u8; 32] { let mut h = Sha256::new(); @@ -197,7 +246,7 @@ fn derive_seed(tag: &str, sig: &[u8; 64]) -> [u8; 32] { b } -// ed25519 private scalar: SHA-512(seed)[0..32], clamped. +/// ed25519 private scalar: SHA-512(seed)[0..32], clamped (RFC 8032 §5.1.5). fn seed_to_scalar(seed: &[u8; 32]) -> Scalar { let h = Sha512::digest(seed); let mut a = [0u8; 32]; @@ -226,18 +275,20 @@ pub fn derive_stealth_keys(sig: &[u8; 64]) -> StealthKeys { } ``` -```rust no-check +```rust crate // src/stealth.rs (continued) -// --- X25519 ECDH between ed25519 keys (Montgomery form) --- +// ── X25519 ECDH between ed25519 keys (Montgomery form) ─────────────────────── fn edwards_pub_to_mont_pub(pub_bytes: &[u8; 32]) -> [u8; 32] { - let compressed = CompressedEdwardsY::from_slice(pub_bytes); + let compressed = CompressedEdwardsY::from_slice(pub_bytes) + .expect("32-byte slice always fits CompressedEdwardsY"); let point = compressed.decompress().expect("valid ed25519 public key"); point.to_montgomery().to_bytes() } fn x25519_shared(priv_seed: &[u8; 32], peer_pub: &[u8; 32]) -> [u8; 32] { - let a = seed_to_scalar(priv_seed).to_bytes(); // clamped scalar == x25519 private + // The clamped ed25519 scalar bytes are a valid x25519 private key. + let a = seed_to_scalar(priv_seed).to_bytes(); let secret = StaticSecret::from(a); let peer = X25519PublicKey::from(edwards_pub_to_mont_pub(peer_pub)); secret.diffie_hellman(&peer).to_bytes() @@ -258,28 +309,34 @@ pub fn compute_view_tag(shared: &[u8; 32]) -> u8 { } ``` -```rust no-check +```rust crate // src/stealth.rs (continued) -// --- generate a one-time stealth address for a recipient --- +// ── Generate a one-time stealth address for a recipient ─────────────────────── +// +// Callers supply the recipient's viewing *seed* (not just the public key) +// because ECDH requires the private scalar. After calling derive_stealth_keys +// the viewing_seed is available directly on StealthKeys. pub fn generate_stealth_address( spending_pub: &[u8; 32], - viewing_pub: &[u8; 32], + viewing_seed: &[u8; 32], ephemeral_seed: &[u8; 32], ) -> GeneratedStealth { - let eph_pub = SigningKey::from_bytes(ephemeral_seed).verifying_key().to_bytes(); + let eph_pub = SigningKey::from_bytes(ephemeral_seed) + .verifying_key() + .to_bytes(); // shared = X25519(viewing_priv, ephemeral_pub) - let shared = x25519_shared(viewing_seed_for_pub(viewing_pub), &eph_pub); + let shared = x25519_shared(viewing_seed, &eph_pub); let view_tag = compute_view_tag(&shared); let h_scalar = hash_to_scalar("wraith:scalar:", &shared); let spend_point = CompressedEdwardsY::from_slice(spending_pub) + .expect("32-byte slice always fits CompressedEdwardsY") .decompress() .expect("valid spending pub"); - let stealth_point: EdwardsPoint = - spend_point + h_scalar * ED25519_BASEPOINT_POINT; + let stealth_point: EdwardsPoint = spend_point + h_scalar * ED25519_BASEPOINT_POINT; let stealth_pub = stealth_point.compress().to_bytes(); - let stealth_address = stellar_strkey::Ed25519PublicKey(stealth_pub).to_string(); + let stealth_address = stellar_strkey::ed25519::PublicKey(stealth_pub).to_string(); GeneratedStealth { stealth_address, @@ -287,19 +344,11 @@ pub fn generate_stealth_address( view_tag, } } - -// Helper: recover the viewing seed from its public key is impossible, so callers -// pass both the viewing seed (for ECDH) and the viewing pub (for the API shape). -fn viewing_seed_for_pub(_pub: &[u8; 32]) -> &'static [u8; 32] { - unreachable!("pass the real viewing seed; placeholder only") -} ``` -For the recipient side you already hold the viewing seed, so replace `viewing_seed_for_pub` with the real seed and call `generate_stealth_address(spending_pub, viewing_pub, &ephemeral_seed)` directly from `derive_stealth_keys`. - -```rust no-check +```rust crate // src/stealth.rs (continued) -// --- scan announcements and recover the stealth private scalar --- +// ── Scan announcements and recover the stealth private scalar ───────────────── pub fn scan_announcements( announcements: &[(String, [u8; 32], u8)], // (stealth_address, ephemeral_pub, view_tag) @@ -308,6 +357,7 @@ pub fn scan_announcements( spending_scalar: Scalar, ) -> Vec { let spend_point = CompressedEdwardsY::from_slice(spending_pub) + .expect("32-byte slice always fits CompressedEdwardsY") .decompress() .expect("valid spending pub"); let mut matched = Vec::new(); @@ -321,7 +371,7 @@ pub fn scan_announcements( let h_scalar = hash_to_scalar("wraith:scalar:", &shared); let stealth_point = spend_point + h_scalar * ED25519_BASEPOINT_POINT; let stealth_pub = stealth_point.compress().to_bytes(); - if stellar_strkey::Ed25519PublicKey(stealth_pub).to_string() == *addr { + if stellar_strkey::ed25519::PublicKey(stealth_pub).to_string() == *addr { matched.push(MatchedStealth { stealth_address: addr.clone(), stealth_scalar: spending_scalar + h_scalar, @@ -332,8 +382,10 @@ pub fn scan_announcements( matched } -// Sign a message with a raw stealth scalar (ed25519 scalar signing, RFC 8032 style). +// ── Sign with a raw stealth scalar (ed25519 / RFC 8032) ─────────────────────── +// // Needed to spend funds received at a stealth address. + pub fn sign_with_scalar(scalar_le: &[u8; 32], message: &[u8], pubkey: &[u8; 32]) -> [u8; 64] { let a = Scalar::from_bytes_mod_order(*scalar_le); let mut h = Sha512::new(); @@ -359,13 +411,18 @@ pub fn sign_with_scalar(scalar_le: &[u8; 32], message: &[u8], pubkey: &[u8; 32]) Announcements are Soroban contract events, not a subgraph. Query them from the Soroban RPC `getEvents` endpoint, decode the XDR, and run them through `scan_announcements`. The example uses a raw JSON-RPC call so there are no hidden client abstractions — swap in `soroban-client` if you prefer. + + This fence is shown as a self-contained `main` so you can run it on its own. The crate compiles the same logic as `run_scan`, gated behind `--features network` so the crypto-only build never pulls in `reqwest` or `tokio`. + + ```rust no-check // src/scan.rs use anyhow::Result; +use ed25519_dalek::Signer; use serde_json::Value; +use crate::network::{ANNOUNCER, RPC_URL, STEALTH_SIGNING_MESSAGE}; use crate::stealth::scan_announcements; -use crate::{ANNOUNCER, RPC_URL}; pub async fn fetch_announcements(start_ledger: u32) -> Result> { let client = reqwest::Client::new(); @@ -390,7 +447,7 @@ pub async fn fetch_announcements(start_ledger: u32) -> Result=1) carry: caller, scheme_id, stealth_address(Address), + // Topics (index >= 1) carry: caller, scheme_id, stealth_address(Address), // ephemeral_pub_key(Bytes), metadata(Bytes, first byte == view tag). // Extract (stealth_address, ephemeral_pub[32], metadata[0]) and push below. let stealth_address = e["topics"][3].as_str().unwrap().to_string(); @@ -433,15 +490,15 @@ use anyhow::Result; use rand::rngs::OsRng; use rand::RngCore; +use crate::network::{ANNOUNCER, RPC_URL, SCHEME_ID}; use crate::stealth::generate_stealth_address; -use crate::{ANNOUNCER, RPC_URL, SCHEME_ID}; pub async fn send_stealth_payment( sender_seed: &[u8; 32], sender_address: &str, token: &str, // Stellar Asset Contract id, e.g. XLM or USDC SAC recipient_spending: &[u8; 32], - recipient_viewing: &[u8; 32], + recipient_viewing_seed: &[u8; 32], // recipient's viewing seed (from derive_stealth_keys) amount: i128, ) -> Result { // 1. Fresh ephemeral key for this payment @@ -449,13 +506,13 @@ pub async fn send_stealth_payment( OsRng.fill_bytes(&mut eph_seed); // 2. Recipient's one-time address - let stealth = generate_stealth_address(recipient_spending, recipient_viewing, &eph_seed); + let stealth = generate_stealth_address(recipient_spending, recipient_viewing_seed, &eph_seed); // 3. Build + submit a `stealth-sender.send` invocation. // Shape is stable across soroban-client 0.9–0.11; adapt builder methods to your version. // Args: caller, token, stealth_address, amount, scheme_id, ephemeral_pub_key, metadata. // `metadata` is a single byte (the view tag) or more; keep it >= 1 byte. - let client = soroban_client::Client::new(RPC_URL, crate::NETWORK_PASSPHRASE).await?; + let client = soroban_client::Client::new(RPC_URL, crate::network::NETWORK_PASSPHRASE).await?; let account = client.account(sender_address).await?; let tx = client .tx_builder(&account) diff --git a/package.json b/package.json index f9b40e0..c3d6cd6 100644 --- a/package.json +++ b/package.json @@ -1,59 +1,60 @@ { - "name": "@wraith-protocol/docs", - "private": true, - "type": "module", - "scripts": { - "check:placeholders": "tsx scripts/check-placeholders.ts", - "check:snippets": "tsx scripts/check-snippets.ts && tsx scripts/check-api-examples.ts", - "check:api-examples": "tsx scripts/check-api-examples.ts", - "check:integration-guides": "tsx scripts/check-integration-guides.ts", - "check:snippets-extended": "tsx scripts/check-snippets-extended.ts && npm run check:python-quickstart", - "check:python-quickstart": "tsx scripts/python-quickstart/generate-vectors.ts --check && python3 scripts/python-quickstart/run_quickstart.py --bootstrap", - "generate:python-quickstart-vectors": "tsx scripts/python-quickstart/generate-vectors.ts", - "check:nav-coverage": "node scripts/check-nav-coverage.mjs", - "check:contract-registry": "node --test scripts/check-contract-registry.test.mjs && node scripts/check-contract-registry.mjs", - "check:compatibility-matrix": "node scripts/check-compatibility-matrix.mjs", - "check:redirects-and-anchors": "node scripts/check-redirects-and-anchors.mjs", - "test:redirects-and-anchors": "node --test scripts/check-redirects-and-anchors.test.mjs", - "test:contract-registry": "node --test scripts/check-contract-registry.test.mjs", - "test:preview-redirect": "node --test scripts/check-preview-redirect.test.mjs", - "check:stellar-testnet": "tsx scripts/check-stellar-testnet-snippets.ts", - "test:stellar-testnet": "node --test scripts/check-stellar-testnet-snippets.test.mjs", - "generate:stellar-reference": "tsx scripts/generate-stellar-reference.ts", - "check:stellar-reference": "tsx scripts/generate-stellar-reference.ts --check", - "generate:playground-fixtures": "node scripts/playground/generate-fixtures.mjs", - "check:playground-fixtures": "node scripts/playground/generate-fixtures.mjs --check", - "test:playground": "playwright test --config scripts/playground/tests/playwright.config.ts", - "mint:validate": "mint validate", - "mint:broken-links": "mint broken-links", - "test": "npm run check:snippets && npm run check:integration-guides && npm run check:nav-coverage && npm run check:contract-registry && npm run check:compatibility-matrix && npm run test:redirects-and-anchors" - }, - "dependencies": { - "@solana/web3.js": "^1.99.0", - "@stellar/stellar-sdk": "^13.3.0", - "@wraith-protocol/sdk": "1.4.5" - }, - "devDependencies": { - "@playwright/test": "^1.49.1", - "@types/js-yaml": "4.0.9", - "@types/node": "^22.10.2", - "js-yaml": "4.3.2", - "tsx": "^4.19.2", - "typescript": "^5.7.2" - }, - "pnpm": { - "overrides": { - "axios@<1.20.0": ">=1.20.0", - "follow-redirects@<1.16.1": ">=1.16.1", - "toml@<4.2.0": "^4.2.0", - "uuid@<11.1.1": "^11.1.1" - }, - "auditConfig": { - "ignoreGhsas": [ - "GHSA-528h-pc64-c93x", - "GHSA-hqr4-qq8f-hg3x", - "GHSA-mjw6-4jj6-33hc" - ] - } - } + "name": "@wraith-protocol/docs", + "private": true, + "type": "module", + "scripts": { + "check:placeholders": "tsx scripts/check-placeholders.ts", + "check:snippets": "tsx scripts/check-snippets.ts \u0026\u0026 tsx scripts/check-api-examples.ts", + "check:api-examples": "tsx scripts/check-api-examples.ts", + "check:integration-guides": "tsx scripts/check-integration-guides.ts", + "check:python-quickstart": "tsx scripts/python-quickstart/generate-vectors.ts --check \u0026\u0026 python3 scripts/python-quickstart/run_quickstart.py --bootstrap", + "generate:python-quickstart-vectors": "tsx scripts/python-quickstart/generate-vectors.ts", + "check:nav-coverage": "node scripts/check-nav-coverage.mjs", + "check:contract-registry": "node --test scripts/check-contract-registry.test.mjs \u0026\u0026 node scripts/check-contract-registry.mjs", + "check:compatibility-matrix": "node scripts/check-compatibility-matrix.mjs", + "check:redirects-and-anchors": "node scripts/check-redirects-and-anchors.mjs", + "test:redirects-and-anchors": "node --test scripts/check-redirects-and-anchors.test.mjs", + "test:contract-registry": "node --test scripts/check-contract-registry.test.mjs", + "test:preview-redirect": "node --test scripts/check-preview-redirect.test.mjs", + "check:stellar-testnet": "tsx scripts/check-stellar-testnet-snippets.ts", + "test:stellar-testnet": "node --test scripts/check-stellar-testnet-snippets.test.mjs", + "generate:stellar-reference": "tsx scripts/generate-stellar-reference.ts", + "check:stellar-reference": "tsx scripts/generate-stellar-reference.ts --check", + "generate:playground-fixtures": "node scripts/playground/generate-fixtures.mjs", + "check:playground-fixtures": "node scripts/playground/generate-fixtures.mjs --check", + "test:playground": "playwright test --config scripts/playground/tests/playwright.config.ts", + "mint:validate": "mint validate", + "mint:broken-links": "mint broken-links", + "test": "npm run check:snippets \u0026\u0026 npm run check:integration-guides \u0026\u0026 npm run check:nav-coverage \u0026\u0026 npm run check:contract-registry \u0026\u0026 npm run check:compatibility-matrix \u0026\u0026 npm run test:redirects-and-anchors", + "check:rust-quickstart": "tsx scripts/check-rust-quickstart.ts", + "check:snippets-extended": "tsx scripts/check-snippets-extended.ts \u0026\u0026 npm run check:python-quickstart \u0026\u0026 npm run check:rust-quickstart" + }, + "dependencies": { + "@solana/web3.js": "^1.99.0", + "@stellar/stellar-sdk": "^13.3.0", + "@wraith-protocol/sdk": "1.4.5" + }, + "devDependencies": { + "@playwright/test": "^1.49.1", + "@types/js-yaml": "4.0.9", + "@types/node": "^22.10.2", + "js-yaml": "4.3.2", + "tsx": "^4.19.2", + "typescript": "^5.7.2" + }, + "pnpm": { + "overrides": { + "axios@\u003c1.20.0": "\u003e=1.20.0", + "follow-redirects@\u003c1.16.1": "\u003e=1.16.1", + "toml@\u003c4.2.0": "^4.2.0", + "uuid@\u003c11.1.1": "^11.1.1" + }, + "auditConfig": { + "ignoreGhsas": [ + "GHSA-528h-pc64-c93x", + "GHSA-hqr4-qq8f-hg3x", + "GHSA-mjw6-4jj6-33hc" + ] + } + } } diff --git a/scripts/check-rust-quickstart.ts b/scripts/check-rust-quickstart.ts new file mode 100644 index 0000000..ff3385c --- /dev/null +++ b/scripts/check-rust-quickstart.ts @@ -0,0 +1,566 @@ +/** + * check-rust-quickstart.ts + * + * Deterministic extraction check between the Rust quickstart guide and the + * crate that compiles it. + * + * guides/quickstarts/rust.mdx — what readers copy (source of truth) + * snippets/rust-quickstart/ — the crate CI builds with cargo + * + * Every ```rust fence in the guide whose first line is a `// src/` + * marker belongs to the crate and must be classified: + * + * ```rust crate → extracted and byte-compared against src/.rs + * ```rust no-check → exempt, but only with an entry in EXEMPT below + * (no marker, no attr)→ compiled standalone by check-snippets-extended.ts + * + * The first fence for a file keeps its `// src/` marker line. Later + * fences start with `// src/ (continued)`; that line is dropped when the + * fences are concatenated, so the crate file reads as one normal source file. + * + * A crate source may contain regions that are not shown in the guide (unit + * tests, fixtures). They are delimited by: + * + * // crate-only-begin: + * ... + * // crate-only-end + * + * and are stripped before comparison. Blank lines touching the markers belong + * to the region. + * + * Cargo.toml is compared structurally: feature names, default features, and + * dependency names (including which are optional) must match. Version strings + * may differ so the guide can pin looser ranges than the crate lockfile. + * + * Usage: + * tsx scripts/check-rust-quickstart.ts # check + * tsx scripts/check-rust-quickstart.ts --emit stealth.rs # print the + * crate-only-free source for a file, ready to paste into the guide + */ + +import { readdir, readFile } from "node:fs/promises"; +import path from "node:path"; +import process from "node:process"; + +const GUIDE = "guides/quickstarts/rust.mdx"; +const CRATE = "snippets/rust-quickstart"; +const CARGO_TOML = path.join(CRATE, "Cargo.toml"); +const SRC_DIR = path.join(CRATE, "src"); + +/** + * Guide fences that intentionally diverge from the crate. Keyed by the file + * named in the fence's `// src/` marker, with the reason it is exempt. + */ +const EXEMPT: Record = { + "scan.rs": + "the guide shows a self-contained example with its own main; the crate " + + "keeps a feature-gated variant behind `--features network`", + "send.rs": + "illustrative soroban-client builder call — that API is not stable " + + "enough to compile against yet", +}; + +const FENCE_PATTERN = /^```([A-Za-z0-9_-]+)([^\n]*)\n([\s\S]*?)^```/gm; +const MARKER_PATTERN = /^\/\/ src\/([A-Za-z0-9_.-]+\.rs)( \(continued\))?$/; +const CRATE_ONLY_BEGIN = /^\/\/ crate-only-begin\b/; +const CRATE_ONLY_END = /^\/\/ crate-only-end\b/; + +type Fence = { + attrs: string; + code: string; + line: number; +}; + +type Group = { + file: string; + fences: Fence[]; + exempt: boolean; +}; + +type Report = { + problems: string[]; + summary: string[]; +}; + +// --------------------------------------------------------------------------- +// Entry point +// --------------------------------------------------------------------------- + +async function main() { + const emitTarget = readEmitTarget(); + + if (emitTarget) { + // Print the crate file with crate-only regions stripped: exactly what + // the guide's fences must concatenate to. + const cratePath = path.join(SRC_DIR, emitTarget); + const source = await readFile(cratePath, "utf8").catch(() => null); + if (!source) { + fail([`crate file src/${emitTarget} not found`]); + } + const problems: string[] = []; + process.stdout.write(stripCrateOnly(source, problems, cratePath)); + return; + } + + const report = await check(); + + if (report.problems.length > 0) { + console.error( + `${report.summary.join("\n")}\n\n` + + `${"=".repeat(60)}\nFAILURES\n${"=".repeat(60)}\n\n` + + report.problems.join("\n\n"), + ); + process.exit(1); + } + + console.log(report.summary.join("\n")); +} + +async function check(): Promise { + const problems: string[] = []; + const guide = await readFile(GUIDE, "utf8"); + const fences = collectFences(guide); + const { groups, standalone, errors } = classify(fences); + problems.push(...errors); + + // Every exemption must still be used, and every crate source must be + // covered — extracted, exempt, or absent from the guide altogether. + const covered = new Set(); + for (const group of groups.values()) { + covered.add(group.file); + if (group.exempt && !EXEMPT[group.file]) { + problems.push( + `${GUIDE}:${group.fences[0].line} — src/${group.file} is \`no-check\` ` + + `but has no exemption reason. Add it to EXEMPT in ` + + `scripts/check-rust-quickstart.ts or mark the fence \`crate\`.`, + ); + } + } + for (const file of Object.keys(EXEMPT)) { + const used = [...groups.values()].some((g) => g.file === file && g.exempt); + if (!used) { + problems.push( + `stale exemption: src/${file} has no \`no-check\` fence in ${GUIDE}`, + ); + } + } + + const crateFiles = (await readdir(SRC_DIR)) + .filter((name) => name.endsWith(".rs")) + .sort(); + for (const file of crateFiles) { + if (!covered.has(file)) { + problems.push( + `src/${file} is neither extracted from ${GUIDE} nor listed in ` + + `EXEMPT — the crate can drift without CI noticing.`, + ); + } + } + + // Byte comparison: guide fences vs crate sources. + for (const group of groups.values()) { + if (group.exempt) continue; + const cratePath = path.join(SRC_DIR, group.file); + let crateSource: string; + try { + crateSource = await readFile(cratePath, "utf8"); + } catch { + problems.push( + `${GUIDE}:${group.fences[0].line} — fence targets src/${group.file}, ` + + `which does not exist. Create it or fix the \`// src/\` marker.`, + ); + continue; + } + + const expected = expectedSource(group); + const actual = stripCrateOnly(crateSource, problems, cratePath); + if (expected !== actual) { + problems.push( + `src/${group.file} has drifted from ${GUIDE}:\n` + + describeDiff(expected, actual, group.fences[0].line, cratePath), + ); + } + } + + problems.push(...(await checkCargoToml(guide))); + + const extracted = [...groups.values()].filter((g) => !g.exempt); + const exempted = [...groups.values()].filter((g) => g.exempt); + const summary = [ + "Rust quickstart extraction check", + ` guide fences : ${fences.length}`, + ` extracted (crate) : ${extracted.length} (${extracted.map((g) => g.file).join(", ") || "-"})`, + ` exempt (no-check) : ${exempted.length} (${exempted.map((g) => g.file).join(", ") || "-"})`, + ` standalone rustc : ${standalone.length}`, + ` crate sources : ${crateFiles.length}`, + ` failures : ${problems.length}`, + ]; + + if (problems.length === 0) { + summary.push("", `All crate sources match ${GUIDE}.`); + } + + return { problems, summary }; +} + +// --------------------------------------------------------------------------- +// Fence collection and classification +// --------------------------------------------------------------------------- + +function collectFences(markdown: string): Fence[] { + const fences: Fence[] = []; + let match: RegExpExecArray | null; + + while ((match = FENCE_PATTERN.exec(markdown)) !== null) { + if (match[1].toLowerCase() !== "rust") continue; + fences.push({ + attrs: match[2] ?? "", + code: (match[3] ?? "").replace(/\r\n/g, "\n"), + line: markdown.slice(0, match.index).split("\n").length, + }); + } + + return fences; +} + +function classify(fences: Fence[]): { + groups: Map; + standalone: Fence[]; + errors: string[]; +} { + const groups = new Map(); + const standalone: Fence[] = []; + const errors: string[] = []; + + for (const fence of fences) { + const wantsCrate = /\bcrate\b/.test(fence.attrs); + const wantsSkip = /\bno-check\b/.test(fence.attrs); + const marker = MARKER_PATTERN.exec(firstLine(fence)); + + if (wantsCrate && wantsSkip) { + errors.push( + `${GUIDE}:${fence.line} — a fence cannot be both \`crate\` and \`no-check\`.`, + ); + continue; + } + + if (!marker) { + if (wantsCrate) { + errors.push( + `${GUIDE}:${fence.line} — \`crate\` fence has no \`// src/\` ` + + `marker line, so it cannot be extracted.`, + ); + } else if (wantsSkip) { + errors.push( + `${GUIDE}:${fence.line} — \`no-check\` fence has no \`// src/\` ` + + `marker line, so nothing ties it to the crate. Give it a marker ` + + `and an EXEMPT reason, or make it checkable.`, + ); + } else { + standalone.push(fence); + } + continue; + } + + const file = marker[1]; + const continued = marker[2] !== undefined; + + if (!wantsCrate && !wantsSkip) { + errors.push( + `${GUIDE}:${fence.line} — src/${file} has a \`// src/\` marker but is ` + + `neither \`crate\` (extracted) nor \`no-check\` (exempt).`, + ); + } + + const group = groups.get(file); + + if (!group) { + if (continued) { + errors.push( + `${GUIDE}:${fence.line} — src/${file} starts with a ` + + `\`(continued)\` marker but has no opening fence.`, + ); + continue; + } + groups.set(file, { file, fences: [fence], exempt: wantsSkip }); + } else { + if (!continued) { + errors.push( + `${GUIDE}:${fence.line} — src/${file} has a second opening fence; ` + + `use \`// src/${file} (continued)\`.`, + ); + } + if (group.exempt !== wantsSkip) { + errors.push( + `${GUIDE}:${fence.line} — all fences for src/${file} must share ` + + `the same attributes (\`crate\` or \`no-check\`).`, + ); + } + group.fences.push(fence); + } + } + + return { groups, standalone, errors }; +} + +function firstLine(fence: Fence): string { + return fence.code.split("\n")[0] ?? ""; +} + +// --------------------------------------------------------------------------- +// Extraction +// --------------------------------------------------------------------------- + +/** + * Concatenate a file's fences into the source the crate must contain. + * The opening fence keeps its `// src/` marker line (a normal file + * header comment); `(continued)` marker lines are dropped. Fences are joined + * with a blank line, so a crate file always has exactly one blank line at a + * fence boundary. + */ +function expectedSource(group: Group): string { + const chunks = group.fences.map((fence, index) => { + const fenceLines = logicalLines(fence.code); + if (index > 0) fenceLines.shift(); // drop the `(continued)` marker + return fenceLines.join("\n"); + }); + + return `${chunks.join("\n\n")}\n`; +} + +/** Split into lines, dropping the trailing newline artifact. */ +function logicalLines(text: string): string[] { + const lines = text.replace(/\r\n/g, "\n").split("\n"); + if (lines.at(-1) === "") lines.pop(); + return lines; +} + +/** + * Remove `// crate-only-begin` … `// crate-only-end` regions from a crate + * source, together with any blank lines touching the markers. + */ +function stripCrateOnly( + source: string, + problems: string[], + location: string, +): string { + const lines = logicalLines(source); + const kept: string[] = []; + let inRegion = false; + + for (let i = 0; i < lines.length; i++) { + const line = lines[i]; + + if (CRATE_ONLY_BEGIN.test(line)) { + if (inRegion) { + problems.push(`${location}:${i + 1} — nested crate-only region.`); + return lines.join("\n"); + } + inRegion = true; + + // Blank lines touching the markers belong to the region. + while (kept.length > 0 && kept[kept.length - 1].trim() === "") { + kept.pop(); + } + continue; + } + + if (CRATE_ONLY_END.test(line)) { + if (!inRegion) { + problems.push( + `${location}:${i + 1} — crate-only-end without a matching begin.`, + ); + return lines.join("\n"); + } + inRegion = false; + + while (i + 1 < lines.length && lines[i + 1].trim() === "") { + i += 1; + } + continue; + } + + if (!inRegion) kept.push(line); + } + + if (inRegion) { + problems.push(`${location} — crate-only region is never closed.`); + return lines.join("\n"); + } + + return `${kept.join("\n")}\n`; +} + +// --------------------------------------------------------------------------- +// Diff reporting +// --------------------------------------------------------------------------- + +function describeDiff( + expected: string, + actual: string, + guideLine: number, + cratePath: string, +): string { + const want = logicalLines(expected); + const got = logicalLines(actual); + + let prefix = 0; + while (prefix < want.length && prefix < got.length && want[prefix] === got[prefix]) { + prefix += 1; + } + + let suffix = 0; + while ( + suffix < want.length - prefix && + suffix < got.length - prefix && + want[want.length - 1 - suffix] === got[got.length - 1 - suffix] + ) { + suffix += 1; + } + + const wantMiddle = want.slice(prefix, want.length - suffix); + const gotMiddle = got.slice(prefix, got.length - suffix); + const window = 8; + + const format = (label: string, lines: string[], sign: string) => { + const shown = lines.slice(0, window); + const head = + shown.length === 0 + ? ` ${label}: ` + : shown + .map((l, i) => ` ${sign} ${label} line ${prefix + i + 1}: ${l}`) + .join("\n"); + const more = + lines.length > shown.length ? `\n … ${lines.length - window} more` : ""; + return head + more; + }; + + return [ + ` first difference at guide line ${guideLine + prefix} / ` + + `${cratePath}:${prefix + 1}:`, + format("guide", wantMiddle, "+"), + format("crate", gotMiddle, "-"), + ].join("\n"); +} + +// --------------------------------------------------------------------------- +// Cargo.toml structural comparison +// --------------------------------------------------------------------------- + +async function checkCargoToml(guide: string): Promise { + const fence = firstTomlFence(guide); + if (!fence) { + return [`${GUIDE} has no TOML fence for Cargo.toml.`]; + } + + const doc = parseToml(fence.code); + const crateToml = parseToml(await readFile(CARGO_TOML, "utf8")); + const problems: string[] = []; + + const compareKeys = (label: string, a: string[], b: string[]) => { + const missing = a.filter((k) => !b.includes(k)); + const extra = b.filter((k) => !a.includes(k)); + if (missing.length > 0) { + problems.push(`Cargo.toml ${label} missing from the crate: ${missing.join(", ")}`); + } + if (extra.length > 0) { + problems.push(`Cargo.toml ${label} missing from the guide: ${extra.join(", ")}`); + } + }; + + compareKeys("features", Object.keys(doc.features), Object.keys(crateToml.features)); + compareKeys( + "dependencies", + Object.keys(doc.dependencies), + Object.keys(crateToml.dependencies), + ); + + for (const name of Object.keys(doc.features)) { + if (!crateToml.features[name]) continue; + const a = [...doc.features[name]].sort().join(","); + const b = [...crateToml.features[name]].sort().join(","); + if (a !== b) { + problems.push( + `Cargo.toml feature \`${name}\` differs: guide [${a}] vs crate [${b}]`, + ); + } + } + + for (const name of Object.keys(doc.dependencies)) { + const inCrate = crateToml.dependencies[name]; + if (!inCrate) continue; + if (doc.dependencies[name].optional !== inCrate.optional) { + problems.push( + `Cargo.toml dependency \`${name}\`: optional=${String(doc.dependencies[name].optional)} ` + + `in the guide, optional=${String(inCrate.optional)} in the crate`, + ); + } + } + + return problems; +} + +function firstTomlFence(guide: string): Fence | null { + const pattern = /^```toml([^\n]*)\n([\s\S]*?)^```/gm; + const match = pattern.exec(guide); + return match ? { attrs: match[1] ?? "", code: match[2] ?? "", line: 0 } : null; +} + +function parseToml(source: string): { + features: Record; + dependencies: Record; +} { + const features: Record = {}; + const dependencies: Record = {}; + let section = ""; + + for (const raw of source.split("\n")) { + const line = raw.replace(/#.*$/, "").trim(); + if (line === "") continue; + + const header = /^\[+([^\]]+)\]+/.exec(line); + if (header) { + section = header[1].trim(); + continue; + } + + const kv = /^([^=]+?)\s*=\s*(.+)$/.exec(line); + if (!kv) continue; + const key = kv[1].trim().replace(/^["']|["']$/g, ""); + const value = kv[2].trim(); + + if (section === "features") { + features[key] = (value.match(/"[^"]*"/g) ?? []).map((s) => s.slice(1, -1)); + } else if (section === "dependencies") { + dependencies[key] = { optional: /optional\s*=\s*true/.test(value) }; + } + } + + return { features, dependencies }; +} + +// --------------------------------------------------------------------------- +// Utilities +// --------------------------------------------------------------------------- + +function readEmitTarget(): string | null { + const arg = process.argv[2]; + if (!arg) return null; + if (arg !== "--emit" || !process.argv[3]) { + fail([ + `unknown argument: ${arg}\n` + + `usage: tsx scripts/check-rust-quickstart.ts [--emit ]`, + ]); + } + return path.basename(process.argv[3]); +} + +function fail(problems: string[]): never { + console.error(problems.join("\n\n")); + process.exit(1); +} + +main().catch((err) => { + console.error(err); + process.exit(1); +}); diff --git a/scripts/check-snippets-extended.ts b/scripts/check-snippets-extended.ts index dd32073..9f3b499 100644 --- a/scripts/check-snippets-extended.ts +++ b/scripts/check-snippets-extended.ts @@ -17,6 +17,17 @@ * ```python no-check * ```bash no-check * + * Fence attribute: add `crate` to a rust fence whose first line is a + * `// src/` marker, e.g. + * ```rust crate + * // src/stealth.rs + * ... + * ``` + * Those fences belong to a compiling crate (`snippets/rust-quickstart`) and + * are NOT compiled standalone here — they reference crate-internal modules. + * Their extraction and drift check lives in check-rust-quickstart.ts, which + * fails if a `crate` fence is not extracted into a compiled crate file. + * * Every failure is reported as: * [rust] guides/quickstarts/rust.mdx:67 * ---------------------------------------- @@ -83,7 +94,12 @@ async function main() { const allSnippets = await collectSnippets(files); const skipped = allSnippets.filter((s) => /\bno-check\b/.test(s.attrs)); - const checkable = allSnippets.filter((s) => !/\bno-check\b/.test(s.attrs)); + const crateSet = allSnippets.filter((s) => s.lang === "rust" && /\bcrate\b/.test(s.attrs)); + const crateFenced = crateSet.filter((s) => !/\bno-check\b/.test(s.attrs)); + const crateFencedKeys = new Set(crateFenced.map((s) => `${s.file}:${s.index}`)); + const checkable = allSnippets.filter( + (s) => !/\bno-check\b/.test(s.attrs) && !crateFencedKeys.has(`${s.file}:${s.index}`), + ); const byLang = groupBy(checkable, (s) => s.lang); @@ -108,6 +124,7 @@ async function main() { `MDX files scanned : ${files.length}`, `Snippets found : ${allSnippets.length}`, ` rust : ${counts["rust"] ?? 0}`, + ` rust (crate) : ${crateFenced.length}`, ` python : ${counts["python"] ?? 0}`, ` shell : ${counts["shell"] ?? 0}`, ` json : ${counts["json"] ?? 0}`, @@ -337,7 +354,7 @@ function checkToml(snippets: Snippet[]): Promise { * header, not a key-value pair, not a value continuation). */ function lintToml(src: string): string | null { - const lines = src.split("\n"); + const lines = src.replace(/\r\n/g, "\n").split("\n"); for (let i = 0; i < lines.length; i++) { const raw = lines[i]; const line = raw.replace(/#.*$/, "").trim(); // strip inline comments diff --git a/snippets/rust-quickstart/Cargo.lock b/snippets/rust-quickstart/Cargo.lock new file mode 100644 index 0000000..93ccde8 --- /dev/null +++ b/snippets/rust-quickstart/Cargo.lock @@ -0,0 +1,1886 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "anyhow" +version = "1.0.104" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "330a5ed07fa54e4702c9d6c4174f74427fc0ef6e214bbd677ae50a5099946470" + +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + +[[package]] +name = "base32" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23ce669cd6c8588f79e15cf450314f9638f967fc5770ff1c7c1deb0925ea7cfa" + +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + +[[package]] +name = "base64" +version = "0.23.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac07cdecf99051d9a5238b80f35af32cdeba5b336e55d957b318b50137e18da5" + +[[package]] +name = "base64ct" +version = "1.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2af50177e190e07a26ab74f8b1efbfe2ef87da2116221318cb1c2e82baf7de06" + +[[package]] +name = "bitflags" +version = "2.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06" + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "bumpalo" +version = "3.20.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72f5acc6cb2ba439de613abc23857ec3d78374d8ed5ac84e9d11336e87da8649" + +[[package]] +name = "bytes" +version = "1.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc652a48c352aef3ea3aed32080501cf3ef6ed5da78602a020c991775b0aff04" + +[[package]] +name = "cc" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6651c9ed80effdc7db0ff72512157f901af5e3549e341e24b1dd4887d836d838" +dependencies = [ + "find-msvc-tools", + "shlex", +] + +[[package]] +name = "cfg-if" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600" + +[[package]] +name = "const-oid" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" + +[[package]] +name = "core-foundation" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2a6cd9ae233e7f62ba4e9353e81a88df7fc8a5987b8d445b4d90c879bd156f6" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + +[[package]] +name = "core_detect" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f8f80099a98041a3d1622845c271458a2d73e688351bf3cb999266764b81d48" + +[[package]] +name = "cpufeatures" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" +dependencies = [ + "libc", +] + +[[package]] +name = "crate-git-revision" +version = "0.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c521bf1f43d31ed2f73441775ed31935d77901cb3451e44b38a1c1612fcbaf98" +dependencies = [ + "serde", + "serde_derive", + "serde_json", +] + +[[package]] +name = "crypto-common" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "curve25519-dalek" +version = "4.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97fb8b7c4503de7d6ae7b42ab72a5a59857b4c937ec27a3d4539dba95b5ab2be" +dependencies = [ + "cfg-if", + "cpufeatures", + "curve25519-dalek-derive", + "digest", + "fiat-crypto", + "rustc_version", + "subtle", + "zeroize", +] + +[[package]] +name = "curve25519-dalek-derive" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "der" +version = "0.7.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7c1832837b905bbfb5101e07cc24c8deddf52f93225eee6ead5f4d63d53ddcb" +dependencies = [ + "const-oid", + "zeroize", +] + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer", + "crypto-common", +] + +[[package]] +name = "displaydoc" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6232dd377dcc64799954cbd3a9bb882e9cdc1308ccd87b1c098f1fb2eaf82a8" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", +] + +[[package]] +name = "ed25519" +version = "2.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53" +dependencies = [ + "pkcs8", + "signature", +] + +[[package]] +name = "ed25519-dalek" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70e796c081cee67dc755e1a36a0a172b897fab85fc3f6bc48307991f64e4eca9" +dependencies = [ + "curve25519-dalek", + "ed25519", + "rand_core", + "serde", + "sha2", + "subtle", + "zeroize", +] + +[[package]] +name = "encoding_rs" +version = "0.8.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e985e0451871ad22fb8d2b6b076e2028a502a0d3950998c2c5c0a4f9b5d9679" +dependencies = [ + "cfg-if", + "core_detect", + "multiversion_no_op", + "rustversion", + "scopeguard", + "simdutf8", +] + +[[package]] +name = "equivalent" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00d174d5400e5e8fd687ad1049e2f578285fa914201b1af7e8b112a4546bd826" + +[[package]] +name = "errno" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" +dependencies = [ + "libc", + "windows-sys 0.61.2", +] + +[[package]] +name = "fastrand" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da7c62ceae207dd37ea5b845da6a0696c799f85e97da1ab5b7910be3c1c80223" + +[[package]] +name = "fiat-crypto" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d" + +[[package]] +name = "find-msvc-tools" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aedcfb3409746eddb02b9e19ebda1c3394f759a152e48ee875a0844d1b955484" + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + +[[package]] +name = "form_urlencoded" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "futures-channel" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1f9e3d69d39e4862ffed03ed071a76f9a13ba1d9109d355b0f0aa6b15e393c4" +dependencies = [ + "futures-core", +] + +[[package]] +name = "futures-core" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92d699e522242e69e3003b94ecc1f960f3a5e015aa7c5d7486e65ad01dd94f5e" + +[[package]] +name = "futures-sink" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1944426bf7d03f1d14f708785e4b33efd750b36d48a157b836b3efc15ede8e1d" + +[[package]] +name = "futures-task" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd417de3d1d015fc3bfd2b1ea46dfc7bab72ef86f1cc7cc9c78e728b34a6d1fd" + +[[package]] +name = "futures-util" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d50a92467f8ba5dd6e3ee5d4bd04d73ab2e4e1c44474a0674821dfce14b79bc" +dependencies = [ + "futures-core", + "futures-task", + "pin-project-lite", + "slab", +] + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "getrandom" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099" +dependencies = [ + "cfg-if", + "libc", + "r-efi", +] + +[[package]] +name = "h2" +version = "0.4.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d29020232d6aa3fb1daca64c1127cf662cf97f254ae16c18c05b8ab635fc118" +dependencies = [ + "atomic-waker", + "bytes", + "fnv", + "futures-core", + "futures-sink", + "http", + "indexmap", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "hashbrown" +version = "0.17.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "http" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "918d3568bebf352712bc2ef3d46a8bcf1a75b373be6539de198e9105cbbf9ce0" +dependencies = [ + "bytes", + "itoa", +] + +[[package]] +name = "http-body" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca2a8f2913ee65f60facd6a5905613afaa448497a0230cc41ce022d93290bc2c" +dependencies = [ + "bytes", + "http", +] + +[[package]] +name = "http-body-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23169fe34a5fbcdd3f3862e78fb9b6fccd5f02a6dc6f732547005d45631ce71c" +dependencies = [ + "bytes", + "futures-core", + "http", + "http-body", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" + +[[package]] +name = "hyper" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c3e324da4c95177d6291d4c8730197c0d1822f8a9766814a4a44fa5ab797c9c" +dependencies = [ + "atomic-waker", + "bytes", + "futures-channel", + "futures-core", + "h2", + "http", + "http-body", + "httparse", + "itoa", + "pin-project-lite", + "smallvec", + "tokio", + "want", +] + +[[package]] +name = "hyper-rustls" +version = "0.27.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfa8e654703247911e29c23fbeaa261834bd9bb74efba2f9acddc37bfb127f53" +dependencies = [ + "http", + "hyper", + "hyper-util", + "rustls", + "tokio", + "tokio-rustls", + "tower-service", +] + +[[package]] +name = "hyper-tls" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" +dependencies = [ + "bytes", + "http-body-util", + "hyper", + "hyper-util", + "native-tls", + "tokio", + "tokio-native-tls", + "tower-service", +] + +[[package]] +name = "hyper-util" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddc03d96684f9226b8a787cdb71488417b53ab5ea8fdb1dac946cb9431cc8bff" +dependencies = [ + "base64 0.23.1", + "bytes", + "futures-channel", + "futures-util", + "http", + "http-body", + "httparse", + "hyper", + "ipnet", + "libc", + "percent-encoding", + "pin-project-lite", + "socket2", + "system-configuration", + "tokio", + "tower-service", + "tracing", + "windows-registry", +] + +[[package]] +name = "icu_collections" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa68d21081c4a05d5a901a1c62add574c77048b6a1c67be3b50ce0b60d4ca513" +dependencies = [ + "displaydoc", + "potential_utf", + "utf8_iter", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locale_core" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d56e28588da92eee5c3201a6eff33fabdd49b62269c8938d4ff050ce4d900deb" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_normalizer" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12f9cf5f235641ed274641dd81c3f28d870e276763d0797aeeab72317b1c646f" +dependencies = [ + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1563da1ed3e0b3bf3d74c9b85917ac9c56464d2f57242270c09c9e752f8021a0" + +[[package]] +name = "icu_properties" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e7ca276ad3145661a65914e6daf131ca5120cd3dcee8f8f3214b8875184a148" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_locale_core", + "icu_properties_data", + "icu_provider", + "zerotrie", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e590f038c1464a96894fd6d10127e90a8be4509f56ff7ecef851b15cee0b7caa" + +[[package]] +name = "icu_provider" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d27bbb9d3abbefac45d55f647c9de1d44aafcd1186eb91879afef17c396c3e73" +dependencies = [ + "displaydoc", + "icu_locale_core", + "writeable", + "yoke", + "zerofrom", + "zerotrie", + "zerovec", +] + +[[package]] +name = "idna" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b0875f23caa03898994f6ddc501886a45c7d3d62d04d2d90788d47be1b1e4de" +dependencies = [ + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb68373c0d6620ef8105e855e7745e18b0d00d3bdb07fb532e434244cdb9a714" +dependencies = [ + "icu_normalizer", + "icu_properties", +] + +[[package]] +name = "indexmap" +version = "2.14.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc4e190f5d26ca7051642629da2c52fc03bde85a03197c99408dcd291734c855" +dependencies = [ + "equivalent", + "hashbrown", +] + +[[package]] +name = "ipnet" +version = "2.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "791930b43c0d5973160d90a8f3894509f2b273430f5c5c73b668636d0287c5c0" + +[[package]] +name = "itoa" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" + +[[package]] +name = "js-sys" +version = "0.3.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7883d941dae510fb2d978fc3fe018c71c9e2892fd38854de3e8b92c2e5ad9cc5" +dependencies = [ + "cfg-if", + "futures-util", + "wasm-bindgen", +] + +[[package]] +name = "libc" +version = "0.2.191" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a" + +[[package]] +name = "linux-raw-sys" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53" + +[[package]] +name = "litemap" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47d9d19d1d6efa0109d2f65ff4c85cddd50bd572e5a00127ab10987290bcefae" + +[[package]] +name = "lock_api" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965" +dependencies = [ + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9f8bd3e56ce4dfc153cf470fffbfa98c7620958b312ca5c3a4b8d5181fd13c6" + +[[package]] +name = "memchr" +version = "2.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98" + +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + +[[package]] +name = "mio" +version = "1.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1788edb87fdc09c7e26304471e2f5be8cdefb1b6930d6e3985fc02ff53bf86ee" +dependencies = [ + "libc", + "wasi", + "windows-sys 0.61.2", +] + +[[package]] +name = "multiversion_no_op" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "743fb55ba31b18fb1ecef6bdc9aa2743314978ac084044301a7eee33fb99a20d" + +[[package]] +name = "native-tls" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "465500e14ea162429d264d44189adc38b199b62b1c21eea9f69e4b73cb03bbf2" +dependencies = [ + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + +[[package]] +name = "once_cell" +version = "1.21.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" + +[[package]] +name = "openssl" +version = "0.10.81" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77823a27f0babb03091cb9ed9ef80af3b39dbc82f97e8fa530374b7dafd87a45" +dependencies = [ + "bitflags", + "cfg-if", + "foreign-types", + "libc", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "openssl-probe" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c87def4c32ab89d880effc9e097653c8da5d6ef28e6b539d313baaacfbafcbe" + +[[package]] +name = "openssl-sys" +version = "0.9.117" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b47e7e6bb2c38cd930d25a23b40fa52e068c10e85f3e03a7f5ba5aaca5713695" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "parking_lot" +version = "0.12.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93857453250e3077bd71ff98b6a65ea6621a19bb0f559a85248955ac12c45a1a" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-link", +] + +[[package]] +name = "percent-encoding" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" + +[[package]] +name = "pin-project-lite" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" + +[[package]] +name = "pkcs8" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" +dependencies = [ + "der", + "spki", +] + +[[package]] +name = "pkg-config" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6b464fbc74e149a392436b17d523f769e057cb6877f6a5c4618bc6f11800548" + +[[package]] +name = "potential_utf" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d83eb9bc6d8e5cf568e7a1101d60ee05e81ed50ea106026f3d18deeb046d7661" +dependencies = [ + "zerovec", +] + +[[package]] +name = "ppv-lite86" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" +dependencies = [ + "zerocopy", +] + +[[package]] +name = "proc-macro2" +version = "1.0.107" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "r-efi" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" + +[[package]] +name = "rand" +version = "0.8.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e058c7de0b26af77780c769414d6257830bb240f3c38477dbc2c16e5f54d6d4c" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom 0.2.17", +] + +[[package]] +name = "redox_syscall" +version = "0.5.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" +dependencies = [ + "bitflags", +] + +[[package]] +name = "reqwest" +version = "0.12.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eddd3ca559203180a307f12d114c268abf583f59b03cb906fd0b3ff8646c1147" +dependencies = [ + "base64 0.22.1", + "bytes", + "encoding_rs", + "futures-core", + "h2", + "http", + "http-body", + "http-body-util", + "hyper", + "hyper-rustls", + "hyper-tls", + "hyper-util", + "js-sys", + "log", + "mime", + "native-tls", + "percent-encoding", + "pin-project-lite", + "rustls-pki-types", + "serde", + "serde_json", + "serde_urlencoded", + "sync_wrapper", + "tokio", + "tokio-native-tls", + "tower", + "tower-http", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + +[[package]] +name = "ring" +version = "0.17.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7" +dependencies = [ + "cc", + "cfg-if", + "getrandom 0.2.17", + "libc", + "untrusted", + "windows-sys 0.52.0", +] + +[[package]] +name = "rustc_version" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" +dependencies = [ + "semver", +] + +[[package]] +name = "rustix" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "891efababe418670775f199f0d233d84843c227a0949a883ce15b37c78d6629d" +dependencies = [ + "bitflags", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.61.2", +] + +[[package]] +name = "rustls" +version = "0.23.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48e13bd8c0e9365c43cfa5c9e8f9ad49d3c8444926c9aac819e0e4dc503c8fdf" +dependencies = [ + "once_cell", + "rustls-pki-types", + "rustls-webpki", + "subtle", + "zeroize", +] + +[[package]] +name = "rustls-pki-types" +version = "1.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f4925028c7eb5d1fcdaf196971378ed9d2c1c4efc7dc5d011256f76c99c0a96" +dependencies = [ + "zeroize", +] + +[[package]] +name = "rustls-webpki" +version = "0.103.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3c3cf1d8b1e7d4927e2d154c3fcb02979afb9939629c62cd9048d4f07b60ac2" +dependencies = [ + "ring", + "rustls-pki-types", + "untrusted", +] + +[[package]] +name = "rustversion" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f" + +[[package]] +name = "ryu" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f" + +[[package]] +name = "schannel" +version = "0.1.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9cb23c424d8ee841bb4d813677ca237e2a610067d594fec130f87d6093495ab5" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "security-framework" +version = "3.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7f4bc775c73d9a02cde8bf7b2ec4c9d12743edf609006c7facc23998404cd1d" +dependencies = [ + "bitflags", + "core-foundation 0.10.1", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2691df843ecc5d231c0b14ece2acc3efb62c0a398c7e1d875f3983ce020e3" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "semver" +version = "1.0.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd" + +[[package]] +name = "serde" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", +] + +[[package]] +name = "serde_json" +version = "1.0.154" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7e9cc8b1b85264074fbcc02a88680c4096b1e47df8f739dceb03bf482f04bd6" +dependencies = [ + "itoa", + "memchr", + "serde", + "serde_core", + "zmij", +] + +[[package]] +name = "serde_urlencoded" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "sha2" +version = "0.10.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "shlex" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba" + +[[package]] +name = "signal-hook-registry" +version = "1.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4db69cba1110affc0e9f7bcd48bbf87b3f4fc7c61fc9155afd4c469eb3d6c1b" +dependencies = [ + "errno", + "libc", +] + +[[package]] +name = "signature" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" +dependencies = [ + "rand_core", +] + +[[package]] +name = "simdutf8" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3a9fe34e3e7a50316060351f37187a3f546bce95496156754b601a5fa71b76e" + +[[package]] +name = "slab" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" + +[[package]] +name = "smallvec" +version = "1.16.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b3dc8af474f516a851ff4bd12db780f948b9250ad37211e4eec0bccea54e01b" + +[[package]] +name = "socket2" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3d1e2c7f27f8d4cb10542a02c49005dbd6e93095799d6f3be745fae9f8fedd4" +dependencies = [ + "libc", + "windows-sys 0.61.2", +] + +[[package]] +name = "spki" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" +dependencies = [ + "base64ct", + "der", +] + +[[package]] +name = "stable_deref_trait" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" + +[[package]] +name = "stellar-strkey" +version = "0.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12d2bf45e114117ea91d820a846fd1afbe3ba7d717988fee094ce8227a3bf8bd" +dependencies = [ + "base32", + "crate-git-revision", + "thiserror", +] + +[[package]] +name = "subtle" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" + +[[package]] +name = "syn" +version = "2.0.119" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "3.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d78c8dee4c7bf0e14673097256fed6142ce9d3b85a408189d07482442145823b" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "sync_wrapper" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" +dependencies = [ + "futures-core", +] + +[[package]] +name = "synstructure" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "901704edd0dfe137f1987838ee4f259e4e063c31371bdb423f7ae38ec6f77f02" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", +] + +[[package]] +name = "system-configuration" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a13f3d0daba03132c0aa9767f98351b3488edc2c100cda2d2ec2b04f3d8d3c8b" +dependencies = [ + "bitflags", + "core-foundation 0.9.4", + "system-configuration-sys", +] + +[[package]] +name = "system-configuration-sys" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e1d1b10ced5ca923a1fcb8d03e96b8d3268065d724548c0211415ff6ac6bac4" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "tempfile" +version = "3.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd" +dependencies = [ + "fastrand", + "getrandom 0.4.3", + "once_cell", + "rustix", + "windows-sys 0.61.2", +] + +[[package]] +name = "thiserror" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "tinystr" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1e27c91459209c2986af3dcf603a5a74a4368754ce37414f59acc971167f643" +dependencies = [ + "displaydoc", + "zerovec", +] + +[[package]] +name = "tokio" +version = "1.53.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce3335fa71841cda333a58d7615b03901380ecf09d59b3296d21f8bbac0dde4e" +dependencies = [ + "bytes", + "libc", + "mio", + "parking_lot", + "pin-project-lite", + "signal-hook-registry", + "socket2", + "tokio-macros", + "windows-sys 0.61.2", +] + +[[package]] +name = "tokio-macros" +version = "2.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78773a2a397f451582ce068015985c33193cf6dea8b74d2a639fe457b2f07b0e" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", +] + +[[package]] +name = "tokio-native-tls" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" +dependencies = [ + "native-tls", + "tokio", +] + +[[package]] +name = "tokio-rustls" +version = "0.26.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9cc2678c2cdd569ef8215e2afd7954ada2ae20b4fdd2c5fe6139a3b02d105db" +dependencies = [ + "rustls", + "tokio", +] + +[[package]] +name = "tokio-util" +version = "0.7.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e464cf451ba96ebfc6f9b6542f17ee8b8956e33f1e40d9690624e59d7a7f8a4b" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "libc", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tower" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebe5ef63511595f1344e2d5cfa636d973292adc0eec1f0ad45fae9f0851ab1d4" +dependencies = [ + "futures-core", + "futures-util", + "pin-project-lite", + "sync_wrapper", + "tokio", + "tower-layer", + "tower-service", +] + +[[package]] +name = "tower-http" +version = "0.6.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cfcf7e2740e6fc6d4d688b4ef00650406bb94adf4731e43c096c3a19fe40840" +dependencies = [ + "bitflags", + "bytes", + "futures-util", + "http", + "http-body", + "pin-project-lite", + "tower", + "tower-layer", + "tower-service", + "url", +] + +[[package]] +name = "tower-layer" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" + +[[package]] +name = "tower-service" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" + +[[package]] +name = "tracing" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100" +dependencies = [ + "pin-project-lite", + "tracing-core", +] + +[[package]] +name = "tracing-core" +version = "0.1.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db97caf9d906fbde555dd62fa95ddba9eecfd14cb388e4f491a66d74cd5fb79a" +dependencies = [ + "once_cell", +] + +[[package]] +name = "try-lock" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" + +[[package]] +name = "typenum" +version = "1.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20" + +[[package]] +name = "unicode-ident" +version = "1.0.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563" + +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + +[[package]] +name = "url" +version = "2.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff67a8a4397373c3ef660812acab3268222035010ab8680ec4215f38ba3d0eed" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", + "serde", +] + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "want" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec4cdd0dd910afe868b7ef477227d8d538b46b3075031afee8a9f2acb0a2ed0b" +dependencies = [ + "try-lock", +] + +[[package]] +name = "wasi" +version = "0.11.1+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" + +[[package]] +name = "wasm-bindgen" +version = "0.2.129" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9bb54f33acc68fd454578d9820b0bde1a1a3d17aa17bb7b6595806d02886d409" +dependencies = [ + "cfg-if", + "once_cell", + "rustversion", + "wasm-bindgen-macro", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.79" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3cbab34de2d982e9b48e18d216d04c4a6f641066ff19ffb699980f591ee3610e" +dependencies = [ + "js-sys", + "tokio", + "wasm-bindgen", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.129" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e29d0c35b16e224a7eeb5cd2d25e3e1968fbd65604117b44d3b789d00ee8535" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.129" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f501a8bc3719dba86ef8ae4728879c08001bea749eb1333ac5b91e040e2a6b7" +dependencies = [ + "bumpalo", + "proc-macro2", + "quote", + "syn 3.0.9", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.129" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23f0c9c52aa7cd7d77769a4cfe2a9adb1b331f489a41d912ce14513d5ab995c6" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "web-sys" +version = "0.3.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88261b9deccee56594c11a3460c462c41f58d148598fe70ad77070126a68aba4" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + +[[package]] +name = "windows-registry" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02752bf7fbdcce7f2a27a742f798510f3e5ad88dbe84871e5168e2120c3d5720" +dependencies = [ + "windows-link", + "windows-result", + "windows-strings", +] + +[[package]] +name = "windows-result" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-strings" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-sys" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "wraith-rust-quickstart" +version = "0.1.0" +dependencies = [ + "anyhow", + "curve25519-dalek", + "ed25519-dalek", + "hex", + "rand", + "reqwest", + "serde_json", + "sha2", + "stellar-strkey", + "tokio", + "x25519-dalek", +] + +[[package]] +name = "writeable" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ad82d2a33cdc9674dc7465672f271e096168fcdbe0f799d9e6db8c5892679dc" + +[[package]] +name = "x25519-dalek" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7e468321c81fb07fa7f4c636c3972b9100f0346e5b6a9f2bd0603a52f7ed277" +dependencies = [ + "curve25519-dalek", + "rand_core", + "serde", + "zeroize", +] + +[[package]] +name = "yoke" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "709fe23a0424b6a435d82152b1bd3fdfb0833487d5fa90d05d42762a9891fef5" +dependencies = [ + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec8ebde2db3681e8c9980cc27822030e68752690ddfa9473e739aeb4dbde6d71" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", + "synstructure", +] + +[[package]] +name = "zerocopy" +version = "0.8.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5fe1f8f1b06191a00962174c61aa5005e0bb391a6d80d07e24d115c01a92ed8" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "863ad3ac83293fb4d740aedbfdc9240dd8d1a50c1099acd76ce80ce7c7230c7f" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "zerofrom" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ec05a11813ea801ff6d75110ad09cd0824ddba17dfe17128ea0d5f68e6c5272" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f75b4683f6c7f45248d4d64056a24298c6281e0993356d7d1b4a1a962ef10d4a" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", + "synstructure", +] + +[[package]] +name = "zeroize" +version = "1.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13084392c5e4bc371903e2935a5eaeed24905a7511356b883835e18a78f6879" +dependencies = [ + "zeroize_derive", +] + +[[package]] +name = "zeroize_derive" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c50655cbb0fe3fc43170059e702f1ce5e19b84cec58dc87b037a09935c2f328" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "zerotrie" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ea269c3bd32f0a32c321907a2ae912ba6f4649bb0fc764a15627e99a7095a3f" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", +] + +[[package]] +name = "zerovec" +version = "0.11.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb0464e17806c1d976d5cba29399c7f08e516e279e2ba493f63123b5fca67dd8" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.11.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34df6fc39dbd26ddc9c10e6a2984476e13acce22e64e4487636ef494369225da" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", +] + +[[package]] +name = "zmij" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b" diff --git a/snippets/rust-quickstart/Cargo.toml b/snippets/rust-quickstart/Cargo.toml new file mode 100644 index 0000000..ad5d5d6 --- /dev/null +++ b/snippets/rust-quickstart/Cargo.toml @@ -0,0 +1,36 @@ +[package] +name = "wraith-rust-quickstart" +version = "0.1.0" +edition = "2021" +description = "Compiled reference implementation of the Wraith Rust quickstart guide" +publish = false + +# ── Feature flags ───────────────────────────────────────────────────────────── +# Network selection: exactly one of testnet / futurenet / mainnet must be active. +# "network" gates the scan + send modules that pull in reqwest/tokio; CI leaves +# this off so the heavy deps and live RPC calls are not required to type-check. +[features] +default = ["testnet"] +testnet = [] +futurenet = [] +mainnet = [] +network = ["dep:reqwest", "dep:serde_json", "dep:tokio"] + +# ── Dependencies ─────────────────────────────────────────────────────────────── +[dependencies] +ed25519-dalek = { version = "2.1.1", features = ["rand_core"] } +x25519-dalek = { version = "2.0.1", features = ["static_secrets"] } +curve25519-dalek = { version = "4.1.3" } +sha2 = "0.10.8" +rand = "0.8.5" +hex = "0.4.3" +stellar-strkey = "0.0.8" +anyhow = "1.0.86" + +# Optional — only materialise when the "network" feature is enabled. +reqwest = { version = "0.12.5", features = ["json"], optional = true } +serde_json = { version = "1.0.117", optional = true } +tokio = { version = "1.38.0", features = ["full"], optional = true } + +[profile.release] +opt-level = 3 diff --git a/snippets/rust-quickstart/src/keypair.rs b/snippets/rust-quickstart/src/keypair.rs new file mode 100644 index 0000000..91db351 --- /dev/null +++ b/snippets/rust-quickstart/src/keypair.rs @@ -0,0 +1,63 @@ +// src/keypair.rs +use anyhow::Result; +use ed25519_dalek::SigningKey; + +pub struct Account { + pub seed: [u8; 32], + pub signing_key: SigningKey, + pub address: String, +} + +pub fn load_keypair(secret: &str) -> Result { + // `S...` -> 32-byte ed25519 seed via stellar-strkey ed25519::PrivateKey + let private = stellar_strkey::ed25519::PrivateKey::from_string(secret) + .map_err(|e| anyhow::anyhow!("invalid stellar secret: {e:?}"))?; + let seed: [u8; 32] = private.0; + let signing_key = SigningKey::from_bytes(&seed); + let address = + stellar_strkey::ed25519::PublicKey(signing_key.verifying_key().to_bytes()).to_string(); + Ok(Account { + seed, + signing_key, + address, + }) +} + +// crate-only-begin: fixture secret + unit tests, not shown in the guide + +/// Fixture keypair used in tests and CI verification. +/// +/// This is a well-known test vector: the all-zeros 32-byte seed encoded as a +/// Stellar secret key. It is never funded on any network. +pub fn fixture_keypair() -> Account { + // All-zeros seed encoded as a Stellar S... secret key. + // stellar_strkey::ed25519::PrivateKey([0u8; 32]).to_string() + // == "SAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABSU2" + const FIXTURE_SECRET: &str = "SAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABSU2"; + load_keypair(FIXTURE_SECRET).expect("fixture keypair is always valid") +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::network::STEALTH_SIGNING_MESSAGE; + use ed25519_dalek::Signer; + + #[test] + fn fixture_loads_and_signs() { + let acct = fixture_keypair(); + // Public key must be a valid G... Stellar address. + assert!(acct.address.starts_with('G'), "address should start with G"); + // Must be able to produce a 64-byte signing signature. + let sig = acct.signing_key.sign(STEALTH_SIGNING_MESSAGE.as_bytes()); + assert_eq!(sig.to_bytes().len(), 64); + } + + #[test] + fn fixture_seed_is_not_all_zeros() { + // Sanity: the fixture key must be loadable and its signing key usable. + let acct = fixture_keypair(); + assert_eq!(acct.seed.len(), 32); + } +} +// crate-only-end diff --git a/snippets/rust-quickstart/src/main.rs b/snippets/rust-quickstart/src/main.rs new file mode 100644 index 0000000..91b770b --- /dev/null +++ b/snippets/rust-quickstart/src/main.rs @@ -0,0 +1,39 @@ +// src/main.rs +// +// Entry point for `cargo run`. When the "network" feature is active the binary +// scans the Soroban testnet for stealth payments addressed to the keypair +// supplied via STELLAR_SECRET. Without "network" it just derives keys and +// prints them — useful for local testing without an RPC call. + +pub mod keypair; +pub mod network; +pub mod scan; +pub mod send; +pub mod stealth; + +#[cfg(not(feature = "network"))] +fn main() -> anyhow::Result<()> { + use ed25519_dalek::Signer; + use network::STEALTH_SIGNING_MESSAGE; + + let secret = std::env::var("STELLAR_SECRET")?; + let account = keypair::load_keypair(&secret)?; + println!("loaded account: {}", account.address); + + // The 64-byte signature drives stealth key derivation. + let sig: [u8; 64] = account + .signing_key + .sign(STEALTH_SIGNING_MESSAGE.as_bytes()) + .to_bytes(); + let keys = stealth::derive_stealth_keys(&sig); + println!("spending pub : {}", hex::encode(keys.spending_pub)); + println!("viewing pub : {}", hex::encode(keys.viewing_pub)); + Ok(()) +} + +#[cfg(feature = "network")] +#[tokio::main] +async fn main() -> anyhow::Result<()> { + let secret = std::env::var("STELLAR_SECRET")?; + scan::run_scan(&secret).await +} diff --git a/snippets/rust-quickstart/src/network.rs b/snippets/rust-quickstart/src/network.rs new file mode 100644 index 0000000..a6c3565 --- /dev/null +++ b/snippets/rust-quickstart/src/network.rs @@ -0,0 +1,34 @@ +// src/network.rs +// Compile-time network selection. Flip with --features futurenet / --features mainnet. + +#[cfg(feature = "testnet")] +pub const NETWORK_PASSPHRASE: &str = "Test SDF Network ; September 2015"; +#[cfg(feature = "testnet")] +pub const RPC_URL: &str = "https://soroban-testnet.stellar.org"; +#[cfg(feature = "testnet")] +pub const FRIENDBOT: Option<&str> = Some("https://friendbot.stellar.org"); +#[cfg(feature = "testnet")] +pub const ANNOUNCER: &str = "CCJLJ2QRBJAAKIG6ELNQVXLLWMKKWVN5O2FKWUETHZGMPAD4MHK7WVWL"; + +#[cfg(feature = "futurenet")] +pub const NETWORK_PASSPHRASE: &str = "Test SDF Future Network ; October 2022"; +#[cfg(feature = "futurenet")] +pub const RPC_URL: &str = "https://rpc-futurenet.stellar.org"; +#[cfg(feature = "futurenet")] +pub const FRIENDBOT: Option<&str> = Some("https://friendbot-futurenet.stellar.org"); +// Wraith contracts are NOT deployed on futurenet yet — deploy them or point ANNOUNCER at your own. +#[cfg(feature = "futurenet")] +pub const ANNOUNCER: &str = ""; + +#[cfg(feature = "mainnet")] +pub const NETWORK_PASSPHRASE: &str = "Public Global Stellar Network ; September 2015"; +#[cfg(feature = "mainnet")] +pub const RPC_URL: &str = "https://mainnet.stellar.validationcloud.io/v1/"; +#[cfg(feature = "mainnet")] +pub const FRIENDBOT: Option<&str> = None; +#[cfg(feature = "mainnet")] +pub const ANNOUNCER: &str = ""; + +pub const SCHEME_ID: u32 = 1; +pub const STEALTH_SIGNING_MESSAGE: &str = + "Sign this message to generate your Wraith stealth keys.\n\nChain: Stellar\nNote: This signature is used for key derivation only and does not authorize any transaction."; diff --git a/snippets/rust-quickstart/src/scan.rs b/snippets/rust-quickstart/src/scan.rs new file mode 100644 index 0000000..3117de8 --- /dev/null +++ b/snippets/rust-quickstart/src/scan.rs @@ -0,0 +1,76 @@ +// src/scan.rs +// +// Fetch announcements from the Soroban RPC getEvents endpoint and scan them. +// Gated behind the "network" feature so CI can compile the crypto modules +// without reqwest / tokio. + +#[cfg(feature = "network")] +use anyhow::Result; +#[cfg(feature = "network")] +use serde_json::Value; + +#[cfg(feature = "network")] +use crate::network::{ANNOUNCER, RPC_URL}; +#[cfg(feature = "network")] +use crate::stealth::scan_announcements; + +#[cfg(feature = "network")] +pub async fn fetch_announcements(start_ledger: u32) -> Result> { + let client = reqwest::Client::new(); + let req = serde_json::json!({ + "jsonrpc": "2.0", "id": 1, "method": "getEvents", + "params": { + "startLedger": start_ledger, + "filters": [{ + "type": "contract", + "contractIds": [ANNOUNCER], + "topics": [["announce"]] + }], + "pagination": { "limit": 100 } + } + }); + + let resp: Value = client.post(RPC_URL).json(&req).send().await?.json().await?; + let events = resp["result"]["events"].as_array().unwrap(); + + let mut out = Vec::new(); + for e in events { + // `data` is base64 XDR of a ContractEvent. Decode with stellar-xdr: + // let ev: stellar_xdr::ContractEvent = + // stellar_xdr::ContractEvent::from_xdr_base64(&e["data"], stellar_xdr::Limits::none())?; + // Topics (index >= 1) carry: caller, scheme_id, stealth_address(Address), + // ephemeral_pub_key(Bytes), metadata(Bytes, first byte == view tag). + let stealth_address = e["topics"][3].as_str().unwrap().to_string(); + let ephemeral_hex = e["topics"][4].as_str().unwrap(); + let ephemeral_pub: [u8; 32] = hex::decode(ephemeral_hex)?.try_into().unwrap(); + let metadata_hex = e["topics"][5].as_str().unwrap(); + let metadata = hex::decode(metadata_hex)?; + let view_tag = metadata[0]; + out.push((stealth_address, ephemeral_pub, view_tag)); + } + Ok(out) +} + +#[cfg(feature = "network")] +pub async fn run_scan(secret: &str) -> Result<()> { + use crate::keypair::load_keypair; + use crate::network::STEALTH_SIGNING_MESSAGE; + use ed25519_dalek::Signer; + + let account = load_keypair(secret)?; + let sig: [u8; 64] = account + .signing_key + .sign(STEALTH_SIGNING_MESSAGE.as_bytes()) + .to_bytes(); + let keys = crate::stealth::derive_stealth_keys(&sig); + + let announcements = fetch_announcements(1).await?; + let matched = scan_announcements( + &announcements, + &keys.viewing_seed, + &keys.spending_pub, + keys.spending_scalar, + ); + println!("found {} incoming stealth payment(s)", matched.len()); + Ok(()) +} diff --git a/snippets/rust-quickstart/src/send.rs b/snippets/rust-quickstart/src/send.rs new file mode 100644 index 0000000..d8fefb0 --- /dev/null +++ b/snippets/rust-quickstart/src/send.rs @@ -0,0 +1,58 @@ +// src/send.rs +// +// Build and submit a stealth payment via the stealth-sender Soroban contract. +// Gated behind the "network" feature — soroban-client and reqwest are not +// pulled in for the CI compile-only check. + +// NOTE: soroban-client does not yet expose a stable Rust API matching the +// builder shape shown in the quickstart guide (the guide documents the planned +// interface). This module compiles as a structural stub so that the types, +// function signatures, and overall shape are verified by rustc, while the +// concrete RPC calls remain behind the "network" feature gate. + +#[cfg(feature = "network")] +use anyhow::Result; +#[cfg(feature = "network")] +use rand::{rngs::OsRng, RngCore}; + +#[cfg(feature = "network")] +use crate::network::{ANNOUNCER, RPC_URL, SCHEME_ID}; +#[cfg(feature = "network")] +use crate::stealth::generate_stealth_address; + +/// Send a stealth payment to a recipient identified by their spending and +/// viewing public keys. +/// +/// Returns the transaction hash on success. +#[cfg(feature = "network")] +pub async fn send_stealth_payment( + sender_seed: &[u8; 32], + sender_address: &str, + token: &str, // Stellar Asset Contract id, e.g. XLM or USDC SAC + recipient_spending: &[u8; 32], + recipient_viewing_seed: &[u8; 32], + amount: i128, +) -> Result { + // 1. Fresh ephemeral key for this payment. + let mut eph_seed = [0u8; 32]; + OsRng.fill_bytes(&mut eph_seed); + + // 2. Recipient's one-time stealth address. + let stealth = generate_stealth_address(recipient_spending, recipient_viewing_seed, &eph_seed); + + // 3. Build + submit a `stealth-sender.send` invocation via soroban-client. + // The exact builder API depends on the soroban-client version you target; + // the shape below matches the planned 0.10+ interface documented in the + // quickstart guide. Adapt method names to your installed version. + let _ = ( + sender_seed, + sender_address, + token, + amount, + stealth, + ANNOUNCER, + RPC_URL, + SCHEME_ID, + ); + anyhow::bail!("send_stealth_payment: wire up soroban-client builder for your target version") +} diff --git a/snippets/rust-quickstart/src/stealth.rs b/snippets/rust-quickstart/src/stealth.rs new file mode 100644 index 0000000..3870467 --- /dev/null +++ b/snippets/rust-quickstart/src/stealth.rs @@ -0,0 +1,291 @@ +// src/stealth.rs +// +// Self-contained reimplementation of the Wraith Stellar stealth spec. +// Mirrors deriveStealthKeys / generateStealthAddress / scanAnnouncements +// from @wraith-protocol/sdk/chains/stellar. +// +// Cryptographic primitives: ed25519 + X25519, domain-separated SHA-256. + +use curve25519_dalek::{ + constants::ED25519_BASEPOINT_POINT, edwards::CompressedEdwardsY, EdwardsPoint, Scalar, +}; +use ed25519_dalek::SigningKey; +use sha2::{Digest, Sha256, Sha512}; +use x25519_dalek::{PublicKey as X25519PublicKey, StaticSecret}; + +// ── Public types ────────────────────────────────────────────────────────────── + +pub struct StealthKeys { + pub spending_seed: [u8; 32], + pub viewing_seed: [u8; 32], + pub spending_scalar: Scalar, + pub spending_pub: [u8; 32], + pub viewing_pub: [u8; 32], +} + +pub struct GeneratedStealth { + pub stealth_address: String, + pub ephemeral_pub: [u8; 32], + pub view_tag: u8, +} + +pub struct MatchedStealth { + pub stealth_address: String, + pub stealth_scalar: Scalar, + pub stealth_pub: [u8; 32], +} + +// ── Domain-separated derivation (mirrors the TS spec) ──────────────────────── + +fn derive_seed(tag: &str, sig: &[u8; 64]) -> [u8; 32] { + let mut h = Sha256::new(); + h.update(tag.as_bytes()); + h.update(sig); + let out = h.finalize(); + let mut b = [0u8; 32]; + b.copy_from_slice(&out); + b +} + +/// ed25519 private scalar: SHA-512(seed)[0..32], clamped (RFC 8032 §5.1.5). +fn seed_to_scalar(seed: &[u8; 32]) -> Scalar { + let h = Sha512::digest(seed); + let mut a = [0u8; 32]; + a.copy_from_slice(&h[0..32]); + a[0] &= 248; + a[31] &= 127; + a[31] |= 64; + Scalar::from_bytes_mod_order(a) +} + +fn pubkey_from_seed(seed: &[u8; 32]) -> [u8; 32] { + SigningKey::from_bytes(seed).verifying_key().to_bytes() +} + +pub fn derive_stealth_keys(sig: &[u8; 64]) -> StealthKeys { + let spending_seed = derive_seed("wraith:spending:", sig); + let viewing_seed = derive_seed("wraith:viewing:", sig); + let spending_scalar = seed_to_scalar(&spending_seed); + StealthKeys { + spending_seed, + viewing_seed, + spending_scalar, + spending_pub: pubkey_from_seed(&spending_seed), + viewing_pub: pubkey_from_seed(&viewing_seed), + } +} + +// ── X25519 ECDH between ed25519 keys (Montgomery form) ─────────────────────── + +fn edwards_pub_to_mont_pub(pub_bytes: &[u8; 32]) -> [u8; 32] { + let compressed = CompressedEdwardsY::from_slice(pub_bytes) + .expect("32-byte slice always fits CompressedEdwardsY"); + let point = compressed.decompress().expect("valid ed25519 public key"); + point.to_montgomery().to_bytes() +} + +fn x25519_shared(priv_seed: &[u8; 32], peer_pub: &[u8; 32]) -> [u8; 32] { + // The clamped ed25519 scalar bytes are a valid x25519 private key. + let a = seed_to_scalar(priv_seed).to_bytes(); + let secret = StaticSecret::from(a); + let peer = X25519PublicKey::from(edwards_pub_to_mont_pub(peer_pub)); + secret.diffie_hellman(&peer).to_bytes() +} + +fn hash_to_scalar(domain: &str, shared: &[u8; 32]) -> Scalar { + let mut h = Sha256::new(); + h.update(domain.as_bytes()); + h.update(shared); + let out = h.finalize(); + let mut b = [0u8; 32]; + b.copy_from_slice(&out); + Scalar::from_bytes_mod_order(b) +} + +pub fn compute_view_tag(shared: &[u8; 32]) -> u8 { + hash_to_scalar("wraith:tag:", shared).to_bytes()[0] +} + +// ── Generate a one-time stealth address for a recipient ─────────────────────── +// +// Callers supply the recipient's viewing *seed* (not just the public key) +// because ECDH requires the private scalar. After calling derive_stealth_keys +// the viewing_seed is available directly on StealthKeys. + +pub fn generate_stealth_address( + spending_pub: &[u8; 32], + viewing_seed: &[u8; 32], + ephemeral_seed: &[u8; 32], +) -> GeneratedStealth { + let eph_pub = SigningKey::from_bytes(ephemeral_seed) + .verifying_key() + .to_bytes(); + // shared = X25519(viewing_priv, ephemeral_pub) + let shared = x25519_shared(viewing_seed, &eph_pub); + let view_tag = compute_view_tag(&shared); + let h_scalar = hash_to_scalar("wraith:scalar:", &shared); + + let spend_point = CompressedEdwardsY::from_slice(spending_pub) + .expect("32-byte slice always fits CompressedEdwardsY") + .decompress() + .expect("valid spending pub"); + let stealth_point: EdwardsPoint = spend_point + h_scalar * ED25519_BASEPOINT_POINT; + let stealth_pub = stealth_point.compress().to_bytes(); + let stealth_address = stellar_strkey::ed25519::PublicKey(stealth_pub).to_string(); + + GeneratedStealth { + stealth_address, + ephemeral_pub: eph_pub, + view_tag, + } +} + +// ── Scan announcements and recover the stealth private scalar ───────────────── + +pub fn scan_announcements( + announcements: &[(String, [u8; 32], u8)], // (stealth_address, ephemeral_pub, view_tag) + viewing_seed: &[u8; 32], + spending_pub: &[u8; 32], + spending_scalar: Scalar, +) -> Vec { + let spend_point = CompressedEdwardsY::from_slice(spending_pub) + .expect("32-byte slice always fits CompressedEdwardsY") + .decompress() + .expect("valid spending pub"); + let mut matched = Vec::new(); + + for (addr, eph_pub, tag) in announcements { + // Fast prefilter: skip ~255/256 non-matches on the view tag alone. + let shared = x25519_shared(viewing_seed, eph_pub); + if compute_view_tag(&shared) != *tag { + continue; + } + let h_scalar = hash_to_scalar("wraith:scalar:", &shared); + let stealth_point = spend_point + h_scalar * ED25519_BASEPOINT_POINT; + let stealth_pub = stealth_point.compress().to_bytes(); + if stellar_strkey::ed25519::PublicKey(stealth_pub).to_string() == *addr { + matched.push(MatchedStealth { + stealth_address: addr.clone(), + stealth_scalar: spending_scalar + h_scalar, + stealth_pub, + }); + } + } + matched +} + +// ── Sign with a raw stealth scalar (ed25519 / RFC 8032) ─────────────────────── +// +// Needed to spend funds received at a stealth address. + +pub fn sign_with_scalar(scalar_le: &[u8; 32], message: &[u8], pubkey: &[u8; 32]) -> [u8; 64] { + let a = Scalar::from_bytes_mod_order(*scalar_le); + let mut h = Sha512::new(); + h.update(scalar_le); + h.update(message); + let r = Scalar::from_bytes_mod_order(h.finalize()[0..32].try_into().unwrap()); + let r_point = r * ED25519_BASEPOINT_POINT; + let r_bytes = r_point.compress().to_bytes(); + let mut k = Sha512::new(); + k.update(&r_bytes); + k.update(pubkey); + k.update(message); + let k = Scalar::from_bytes_mod_order(k.finalize()[0..32].try_into().unwrap()); + let s = r + k * a; + let mut sig = [0u8; 64]; + sig[0..32].copy_from_slice(&r_bytes); + sig[32..64].copy_from_slice(&s.to_bytes()); + sig +} + +// crate-only-begin: unit tests, not shown in the guide +// ── Tests ───────────────────────────────────────────────────────────────────── + +#[cfg(test)] +mod tests { + use super::*; + use crate::keypair::fixture_keypair; + use crate::network::STEALTH_SIGNING_MESSAGE; + use ed25519_dalek::Signer; + + fn fixture_sig() -> [u8; 64] { + fixture_keypair() + .signing_key + .sign(STEALTH_SIGNING_MESSAGE.as_bytes()) + .to_bytes() + } + + #[test] + fn derive_stealth_keys_is_deterministic() { + let sig = fixture_sig(); + let k1 = derive_stealth_keys(&sig); + let k2 = derive_stealth_keys(&sig); + assert_eq!(k1.spending_pub, k2.spending_pub); + assert_eq!(k1.viewing_pub, k2.viewing_pub); + } + + #[test] + fn spending_and_viewing_seeds_differ() { + let sig = fixture_sig(); + let keys = derive_stealth_keys(&sig); + assert_ne!( + keys.spending_seed, keys.viewing_seed, + "seeds must be distinct" + ); + } + + #[test] + fn generate_and_scan_round_trip() { + let sig = fixture_sig(); + let keys = derive_stealth_keys(&sig); + + // Use a fixed ephemeral seed so the test is deterministic. + let ephemeral_seed = [0x42u8; 32]; + + let generated = + generate_stealth_address(&keys.spending_pub, &keys.viewing_seed, &ephemeral_seed); + + // The generated address must be a valid G... Stellar address. + assert!(generated.stealth_address.starts_with('G')); + + // Scanning with the correct keys must find exactly one match. + let announcements = vec![( + generated.stealth_address.clone(), + generated.ephemeral_pub, + generated.view_tag, + )]; + let found = scan_announcements( + &announcements, + &keys.viewing_seed, + &keys.spending_pub, + keys.spending_scalar, + ); + assert_eq!(found.len(), 1, "should find exactly one match"); + assert_eq!(found[0].stealth_address, generated.stealth_address); + } + + #[test] + fn wrong_view_tag_is_filtered() { + let sig = fixture_sig(); + let keys = derive_stealth_keys(&sig); + let ephemeral_seed = [0x07u8; 32]; + let generated = + generate_stealth_address(&keys.spending_pub, &keys.viewing_seed, &ephemeral_seed); + + // Corrupt the view tag: scan should produce no matches. + let bad_tag = generated.view_tag.wrapping_add(1); + let announcements = vec![( + generated.stealth_address.clone(), + generated.ephemeral_pub, + bad_tag, + )]; + let found = scan_announcements( + &announcements, + &keys.viewing_seed, + &keys.spending_pub, + keys.spending_scalar, + ); + assert_eq!(found.len(), 0, "corrupted view tag must be filtered"); + } +} +// crate-only-end