A Rust implementation of cryptographic primitives for the Jazz project, compiled to WebAssembly.
The codebase is organized into the following modules:
src
├── crypto
│ ├── ed25519.rs // Ed25519 functions for signing and verification
│ ├── encrypt.rs // High-level encryption functions
│ ├── seal.rs // High-level sealing and unsealing functions
│ ├── sign.rs // High-level signing and verification functions
│ ├── x25519.rs // X25519 key exchange
│ └── xsalsa20.rs // XSalsa20 and XSalsa20-Poly1305 encryption
├── error.rs // Error types for cryptographic operations
├── hash
│ └── blake3.rs // BLAKE3 hashing functionality
└── lib.rs // Main entry point for the library
- Ed25519 signing and verification
- X25519 key exchange
- XSalsa20 and XSalsa20-Poly1305 encryption
- BLAKE3 hashing with incremental state updates
- Secure nonce generation
- WebAssembly bindings for all operations
The library exposes WebAssembly-compatible functions for all cryptographic operations. See the individual module files for detailed documentation of available functions.
Get a working Rust environment (rustup).
rustup install stable
rustup default stable
Then add wasm target to your toolchain:
rustup target add wasm32-unknown-unknown
wasm-pack build --target web
Install the rust-analyzer
extension to get Rust support in VSCode. rust-analyzer
expects a Cargo.toml
file in the root of the project, so configure the workspace setting with the root directory of the project:
// .vscode/settings.json
{
"rust-analyzer.linkedProjects": [
"wasm/Cargo.toml"
]
}
Test both Rust source code and Node.js' build.
pnpm test