| Crates.io | qudag-wasm |
| lib.rs | qudag-wasm |
| version | 0.1.0 |
| created_at | 2025-06-22 16:50:12.4263+00 |
| updated_at | 2025-06-22 16:50:12.4263+00 |
| description | WASM bindings for QuDAG - Quantum Ultra-Fast Distributed Acyclic Graph |
| homepage | |
| repository | https://github.com/ruvnet/QuDAG |
| max_upload_size | |
| id | 1721762 |
| size | 1,056,888 |
WebAssembly bindings for the QuDAG protocol, enabling browser and Node.js applications to interact with the quantum-resistant DAG network.
npm install qudag-wasm
# or
yarn add qudag-wasm
import init, { QuDAGClient, WasmMlDsaKeyPair, WasmDarkResolver } from 'qudag-wasm';
async function main() {
// Initialize the WASM module
await init();
// Create a client
const client = new QuDAGClient();
console.log('QuDAG version:', QuDAGClient.getVersion());
// Generate quantum-resistant keys
const keypair = new WasmMlDsaKeyPair();
const publicKey = keypair.getPublicKey();
// Register a dark domain
const resolver = new WasmDarkResolver();
const domain = await resolver.registerDomain('myservice.dark');
console.log('Registered:', domain);
}
main();
const { QuDAGClient, WasmHasher, WasmVault } = require('qudag-wasm');
// Hash data with BLAKE3
const data = Buffer.from('Hello, QuDAG!');
const hash = WasmHasher.hashBlake3(data);
console.log('Hash:', Buffer.from(hash).toString('hex'));
// Password vault operations
const vault = new WasmVault();
await vault.init('master-password');
// Generate secure password
const password = WasmVault.generatePassword(16, true, true);
await vault.addEntry('github', 'user@example.com', password);
class QuDAGClient {
constructor();
static getVersion(): string;
static hasFeature(feature: string): boolean;
getConfig(): object;
}
// ML-DSA Digital Signatures
class WasmMlDsaKeyPair {
constructor();
getPublicKey(): Uint8Array;
getSecretKey(): Uint8Array;
sign(message: Uint8Array): Uint8Array;
toJson(): object;
}
// ML-KEM-768 Key Encapsulation
class WasmMlKem768 {
constructor();
generateKeyPair(): { publicKey: string, secretKey: string };
encapsulate(publicKey: Uint8Array): { ciphertext: string, sharedSecret: string };
decapsulate(secretKey: Uint8Array, ciphertext: Uint8Array): Uint8Array;
}
// Hashing
class WasmHasher {
static hashBlake3(data: Uint8Array): Uint8Array;
static hashBlake3Hex(data: Uint8Array): string;
}
class WasmDag {
constructor();
addVertex(vertexData: object): string;
getVertex(vertexId: string): object;
getStats(): { vertexCount: number, edgeCount: number, tipCount: number };
getTips(): object[];
validate(): boolean;
}
class WasmConsensus {
constructor();
async queryVertex(vertexId: string): object;
getMetrics(): object;
}
class WasmNetworkManager {
constructor();
listPeers(): object[];
async addPeer(address: string): string;
removePeer(peerId: string): boolean;
banPeer(peerId: string, reason?: string): boolean;
getNetworkStats(): object;
async testConnectivity(): object;
}
class WasmDarkResolver {
constructor();
async registerDomain(domain: string): object;
async resolveDomain(domain: string): object;
generateShadowAddress(ttlSeconds: number): object;
createFingerprint(data: Uint8Array): object;
listDomains(): string[];
isDomainAvailable(domain: string): boolean;
}
class WasmVault {
constructor();
async init(masterPassword: string): void;
addEntry(label: string, username: string, password: string, category?: string): string;
getEntry(label: string): object;
getPassword(label: string): string;
listEntries(category?: string): object[];
removeEntry(label: string): boolean;
static generatePassword(length: number, includeSymbols: boolean, includeNumbers: boolean): string;
getStats(): object;
}
// Logging
function log(message: string): void;
function logError(message: string): void;
function logWarn(message: string): void;
// Performance
class Performance {
static now(): number;
static measure(name: string, start: number): number;
}
// Encoding
class Encoding {
static bytesToHex(bytes: Uint8Array): string;
static hexToBytes(hex: string): Uint8Array;
static stringToBytes(s: string): Uint8Array;
static bytesToString(bytes: Uint8Array): string;
}
// Validation
class Validation {
static isDarkDomain(domain: string): boolean;
static isPeerAddress(address: string): boolean;
static isValidHex(hex: string): boolean;
}
wasm32-unknown-unknown target# Install dependencies
rustup target add wasm32-unknown-unknown
cargo install wasm-pack
# Build the WASM module
wasm-pack build --target web --out-dir pkg
# Build for Node.js
wasm-pack build --target nodejs --out-dir pkg-node
# Build with all optimizations
wasm-pack build --target web --release -- --features wee_alloc
# Run Rust tests
cargo test
# Run WASM tests in browser
wasm-pack test --chrome --firefox
# Run WASM tests in Node.js
wasm-pack test --node
The WASM module is optimized for size and performance:
Node.js 14+ is required for server-side usage.
MIT OR Apache-2.0