mirror of
https://github.com/pezkuwichain/pezkuwi-wasm.git
synced 2026-10-28 14:29:51 +00:00
d0520842dc239f76552ac8cddc171676e288319f
curve25519-dalek 2/3 -> 4.1.3 (timing variability in Scalar52::sub, on every signature), ed25519-dalek 1 -> 2, schnorrkel 0.9 -> 0.11, merlin 2 -> 3, secp256k1 0.21 -> 0.29, tiny-bip39 0.7 -> 1.0 (drops failure), keccak 0.1.6, rand 0.8. wee_alloc is unmaintained and is no longer the global allocator. OSV: 9 crates with advisories before, 0 after. secp256k1 is built with lowmemory: newer libsecp256k1 embeds about 1 MB of precomputed tables, which would have quadrupled the wasm. The signatures are the same; recovery uses a smaller window. getrandom 0.2 is used with a custom backend that calls one fixed import, wbg.ext_fill_random, which the bridge fills from @pezkuwi/x-randomvalues. The getrandom "js" backend would have needed a dozen new hashed wasm-bindgen imports in the bridge; the wasm now has one import instead of 18. The recorded known answers still hold, and signatures made by either build verify in the other.
@pezkuwi/wasm-crypto
WASM cryptographic primitives for PezkuwiChain.
Overview
This package provides WebAssembly-based cryptographic functions used by PezkuwiChain applications, including:
- SR25519 - Schnorr signatures with Ristretto point compression (bizinikiwi signing context)
- ED25519 - Edwards-curve Digital Signature Algorithm
- BIP39 - Mnemonic code for generating deterministic keys
- Hashing - Blake2b, SHA256, SHA512, Keccak, XXHash, Scrypt, PBKDF2
Installation
npm install @pezkuwi/wasm-crypto
# or
yarn add @pezkuwi/wasm-crypto
Usage
import { waitReady, sr25519KeypairFromSeed, sr25519Sign } from '@pezkuwi/wasm-crypto';
// Initialize WASM
await waitReady();
// Generate keypair from seed
const seed = new Uint8Array(32); // your seed here
const keypair = sr25519KeypairFromSeed(seed);
// Sign a message
const publicKey = keypair.slice(64);
const secretKey = keypair.slice(0, 64);
const message = new TextEncoder().encode('Hello PezkuwiChain!');
const signature = sr25519Sign(publicKey, secretKey, message);
Packages
| Package | Description |
|---|---|
@pezkuwi/wasm-crypto |
Main package with all crypto functions |
@pezkuwi/wasm-crypto-wasm |
Compiled WASM binary |
@pezkuwi/wasm-crypto-asmjs |
ASM.js fallback for older browsers |
@pezkuwi/wasm-crypto-init |
Initialization helpers |
@pezkuwi/wasm-bridge |
WASM bridge utilities |
@pezkuwi/wasm-util |
Utility functions |
Building from Source
# Install dependencies
yarn install
# Build WASM and JavaScript
yarn build
# Run tests
yarn test
Prerequisites
- Node.js 18+
- Rust toolchain (for WASM compilation)
- wasm-pack
Signing Context
This package uses bizinikiwi as the SR25519 signing context, which is unique to PezkuwiChain. This ensures signature incompatibility with other networks for security.
License
Apache-2.0
Languages
TypeScript
38.5%
JavaScript
34%
Rust
22.4%
Shell
3.4%
Python
1.7%