mirror of
https://github.com/pezkuwichain/pezkuwi-wasm.git
synced 2026-04-22 03:18:06 +00:00
chore: clean up repo - remove broken workflows, update README
- Remove workflows requiring unavailable secrets - Add simple CI workflow for build and test - Write clean README with usage examples - Prepare for dev branch
This commit is contained in:
@@ -1,17 +1,77 @@
|
||||
# @pezkuwi/wasm
|
||||
# @pezkuwi/wasm-crypto
|
||||
|
||||
Various WASM wrappers around Rust crates
|
||||
WASM cryptographic primitives for PezkuwiChain.
|
||||
|
||||
## overview
|
||||
## Overview
|
||||
|
||||
It is split up into a number of internal packages, namely utilities -
|
||||
This package provides WebAssembly-based cryptographic functions used by PezkuwiChain applications, including:
|
||||
|
||||
- [wasm-crypto](packages/wasm-crypto/) Various hashing functions, sr25519 & ed25519 crypto
|
||||
- **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
|
||||
|
||||
These are split from the `pezkuwi/util` repo where it is heavily used as part of `@pezkuwi/util-crypto`. (There JS fallbacks are available for some interfaces, e.g. hashing, but for sr25519 WASM is the only interface). Since these don't undergo massive changes on a daily basis and has a build overhead (WASM compilation & optimisation), it is better managed as a seperate repo with a specific CI configuration.
|
||||
## Installation
|
||||
|
||||
## development
|
||||
```bash
|
||||
npm install @pezkuwi/wasm-crypto
|
||||
# or
|
||||
yarn add @pezkuwi/wasm-crypto
|
||||
```
|
||||
|
||||
Contributions are welcome!
|
||||
## Usage
|
||||
|
||||
To start off, this repo (along with others in the [@pezkuwichain](https://github.com/pezkuwichain/) family) uses yarn workspaces to organise the code. As such, after cloning, its dependencies _should_ be installed via `yarn`, not via npm; the latter will result in broken dependencies.
|
||||
```javascript
|
||||
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
|
||||
|
||||
```bash
|
||||
# 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
|
||||
|
||||
Reference in New Issue
Block a user