Skip to content

Latest commit

Β 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

NightAuth Rust SDK β€” Star us on GitHub ⭐

Official NightAuth Rust SDK & Reference Client Suite (Modern Desktop UI in Win32 Pure GDI and Interactive Terminal CLI). Protect your high-performance native Rust software against reverse engineering, piracy, and tampering with zero-trust cloud licensing, HWID locking, realtime encrypted chat, and secure in-memory payload streaming in minutes.

Official Portal: https://nightauth.org
Documentation: https://nightauth.org/docs
Technical Architecture Benchmark: NightAuth vs KeyAuth vs Auth.gg


Languages / Idiomas / Langues / Sprachen:
English β€’ EspaΓ±ol β€’ FranΓ§ais β€’ Deutsch β€’ Italiano β€’ PortuguΓͺs β€’ Русский β€’ TΓΌrkΓ§e β€’ Polski β€’ δΈ­ζ–‡


Note

πŸ“Ί Video Tutorials & System Setup Guides

Official video tutorials and detailed step-by-step guides explaining how to configure applications, plans, subscriptions, cloud variables, webhooks, and licenses in the NightAuth Dashboard will be published soon on our official portal and YouTube channel.


πŸ“Έ Screenshots

Desktop Application (Native Win32 GDI Modern Dark Theme)

Start / Authentication Screen Dashboard & Subscription Management
NightAuth Desktop Login NightAuth Desktop Dashboard

Console Application (Interactive Terminal CLI)

Terminal Login Screen Interactive Console Dashboard
NightAuth Console Login NightAuth Console Dashboard

πŸ›‘οΈ Recommended Security Practices for Rust

  • Binary Virtualization & Packing: Rust compiles directly to native assembly, but symbols, panic paths, and function boundaries can be analyzed in IDA Pro, Ghidra, or Binary Ninja. For production releases, protect compiled binaries using commercial protectors and code virtualizers such as VMProtect, Themida, or CodeVirtualizer.
  • Compiler Hardening & Symbol Stripping: Configure Cargo.toml for hardened production releases:
    [profile.release]
    opt-level = 3
    lto = "fat"
    codegen-units = 1
    panic = "abort"
    strip = true
  • Compile-Time String Encryption: Never leave raw sensitive strings, API keys, or licensing messages in the .rdata section. Use compile-time XOR or ChaCha20 string obfuscation macros to decrypt strings only at the instant they are required.
  • In-Memory Secure File Execution: When streaming protected payloads or DLLs via auth.download_file(file_id), never write decrypted bytes to physical storage or disk. Load and execute payloads directly from memory (e.g., reflective PE loading, manual mapping, or in-memory execution) and immediately wipe the buffer with std::ptr::write_bytes or the zeroize crate.
  • Hardware & Integrity Verification: Keep anti-debugging, memory integrity, and process monitoring active in production releases to mitigate runtime hooking, DLL injection, and debugger attachment.

πŸ“¦ Requirements & Building

Requires Rust 1.75+ with Cargo.

Run the Interactive Terminal CLI

cargo run --manifest-path console/Cargo.toml

Run the Native Win32 Desktop Client (Windows)

cargo run --manifest-path desktop/Cargo.toml

Build in Release Mode

cargo build --release --manifest-path console/Cargo.toml
cargo build --release --manifest-path desktop/Cargo.toml

βš™οΈ Configuration & Initialization

Add the SDK dependency to your project's Cargo.toml:

[dependencies]
nightauth_sdk = { path = "path/to/NightAuth-Rust-SDK/source/sdk" }

Initialize Cryptographic Handshake (init)

You must call init() prior to executing any other SDK functions. This establishes an ephemeral Diffie-Hellman (X25519) key exchange and creates an encrypted session:

use nightauth_sdk::Api;

fn main() {
    // Define your application credentials from the Manage Apps tab of the NightAuth dashboard
    let mut auth = Api::new_simple(
        "Your App Name", // Application Name
        "YOUR_API_KEY",  // Application API Key
        "1.0.0"          // Application Version
    );

    // Perform cryptographic handshake
    auth.init();

    if !auth.response.success {
        eprintln!("[ERROR] Initialization failed: {}", auth.response.message);
        return;
    }

    println!("[SUCCESS] Initialized session: {}", auth.session_key().unwrap_or(""));
}

πŸš€ Core API Operations

1. User Authentication (Login)

Authenticate a user with username, password, and optional TOTP two-factor code:

let success = auth.login("developer_user", "SecurePassword123!", None);

if success {
    println!("[SUCCESS] Logged in as: {}", auth.user_data.username);
    println!("IP Address: {}", auth.user_data.ip);
    println!("HWID Locked: {}", auth.user_data.hwid);
    for sub in &auth.user_data.subscriptions {
        println!("Active Subscription: {} (Expires: {})", sub.subscription, sub.expiry);
    }
} else {
    eprintln!("[ERROR] Login failed: {}", auth.response.message);
}

2. User Registration

Register a new account using a license key and email:

let registered = auth.register(
    "new_user",
    "SecurePassword123!",
    "NIGHT-XXXX-XXXX-XXXX", // License Key
    "developer@example.com"
);

if registered {
    println!("[SUCCESS] Account registered and license redeemed!");
} else {
    eprintln!("[ERROR] Registration failed: {}", auth.response.message);
}

3. License Key Only Authentication

For software products that do not require user accounts, authenticate directly with a license key:

let valid = auth.license("NIGHT-XXXX-XXXX-XXXX");

if valid {
    println!("[SUCCESS] Valid license! Welcome, {}", auth.user_data.username);
} else {
    eprintln!("[ERROR] Invalid or expired license: {}", auth.response.message);
}

4. Subscription Upgrade

Extend or upgrade an existing account's tier with a new license key:

let upgraded = auth.upgrade("developer_user", "NIGHT-UPGRADE-KEY");

if upgraded {
    println!("[SUCCESS] Plan successfully upgraded!");
}

5. Session Heartbeat & Periodic Check

Prevent session expiration and verify that the user's license has not been revoked or paused in the dashboard:

// Verify active session integrity
if auth.check() {
    // Send periodic keep-alive heartbeat
    auth.heartbeat();
} else {
    eprintln!("[CRITICAL] Session invalidated or license suspended remotely!");
}

6. Hardware ID (HWID) Reset

Reset the machine binding for a user account:

let reset = auth.reset_hwid("developer_user", "SecurePassword123!", None);

if reset {
    println!("[SUCCESS] HWID reset successful. Machine lock updated.");
}

7. In-Memory Protected File Download

Download proprietary assets, encrypted bytecode, or native DLLs directly into memory without writing to disk:

match auth.download_file("file_id_or_hash") {
    Ok(mut payload_bytes) => {
        println!("[SUCCESS] Downloaded {} bytes securely in-memory.", payload_bytes.len());
        
        // Execute or process payload in RAM (e.g. reflective loader)
        // ...

        // Wipe the buffer from memory immediately after execution
        unsafe {
            std::ptr::write_bytes(payload_bytes.as_mut_ptr(), 0, payload_bytes.len());
        }
    }
    Err(err) => eprintln!("[ERROR] Failed to download payload: {}", err),
}

8. Cloud Variables & Data Storage

Retrieve server-controlled configuration variables and user-specific data:

// Fetch global application variable
if let Some(var_value) = auth.get_var("min_client_version") {
    println!("Global Variable: {}", var_value);
}

// Set user-specific cloud variable
auth.set_var("user_config", "{\"theme\": \"dark\", \"sound\": true}");

9. Realtime Encrypted Chat

Send and receive encrypted messages across application channels:

// Send message
auth.send_chat_message("general", "Hello from Rust!");

// Fetch messages
if let Ok(messages) = auth.fetch_chat_messages("general") {
    for msg in messages {
        println!("[{}] {}: {}", msg.timestamp, msg.author, msg.message);
    }
}

10. Two-Factor Authentication (2FA / TOTP)

Configure and activate hardware/software 2FA (Google Authenticator, Authy):

// Step 1: Initiate 2FA setup
if let Some(setup_data) = auth.two_factor_setup() {
    println!("2FA Secret Key: {}", setup_data.secret);
    println!("Scan QR Code: {}", setup_data.qr_code_url);
    
    // Step 2: Activate with code from authenticator app
    let verified = auth.two_factor_activate("123456");
    if verified {
        println!("[SUCCESS] 2FA is now active on your account!");
    }
}

11. Application Audit Logging

Submit operational and security events to the NightAuth Admin Audit Feed:

auth.log("User opened critical trading terminal module.");

πŸ†š Why NightAuth? (KeyAuth & Auth.gg Comparison)

Feature NightAuth KeyAuth Auth.gg
Cryptography End-to-End Curve25519 (X25519) + ChaCha20-Poly1305 Static AES-CBC (Vulnerable to MITM & Proxy Interception) Legacy HTTPS / Plain JSON
Hardware ID (HWID) Multi-Component Cryptographic Hash (Anti-Spoofing) Raw WMI Strings (Easily Spoofed) Simple Registry / MAC
Edge Network Latency < 35ms Global Anycast Edge Single-Origin VPS (Frequent Outages) Unmaintained / High Latency
Reseller System & Bots Built-in Multi-Tier Balances + Discord & Telegram Bots Manual API / Third-Party Scripts Incomplete / Deprecated
In-Memory Streaming Zero-Disk Decryption & Buffer Wiping Disk Writes Required Not Supported
Internationalization 10 Languages Supported Out of the Box English Only English Only

Read the full architectural benchmark: NightAuth vs KeyAuth vs Auth.gg


πŸ“„ License

This project is licensed under the Elastic License 2.0.

  • You may not provide the software to third parties as a hosted or managed service.
  • You may not move, change, disable, or circumvent the license key functionality.
  • You may not alter, remove, or obscure any licensing or copyright notices.

See the LICENSE file for the full legal text.

Releases

Packages

Contributors

Languages