2 Commits

Author SHA1 Message Date
pezkuwichain 7ba67519fa 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
2026-02-02 04:55:24 +03:00
pezkuwichain 12a26227eb fix: implement scrypt using @noble/hashes/scrypt
- Fixed scrypt function that was throwing 'not yet implemented' error
- Uses @noble/hashes/scrypt for proper scrypt KDF
- Fixes account creation/import in pezkuwi-extension
- Version bump to 7.5.18
2026-02-02 04:47:21 +03:00
10 changed files with 125 additions and 137 deletions
-16
View File
@@ -1,16 +0,0 @@
name: bot
on:
pull_request:
types: [labeled]
jobs:
approve:
if: "! startsWith(github.event.head_commit.message, '[CI Skip]') && (!github.event.pull_request || github.event.pull_request.head.repo.full_name == github.repository)"
runs-on: ubuntu-latest
steps:
- uses: jacogr/action-approve@795afd1dd096a2071d7ec98740661af4e853b7da
with:
authors: jacogr, TarikGul, valentinfernandez1
labels: -auto
token: ${{ secrets.GH_PAT_BOT }}
-16
View File
@@ -1,16 +0,0 @@
name: bot
on:
pull_request:
types: [labeled]
jobs:
merge:
runs-on: ubuntu-latest
steps:
- uses: jacogr/action-merge@d2d64b4545acd93b0a9575177d3d215ae3f92029
with:
checks: pr (build),pr (lint),pr (test)
labels: -auto
strategy: squash
token: ${{ secrets.GH_PAT_BOT }}
+48
View File
@@ -0,0 +1,48 @@
name: CI
on:
push:
branches: [master, dev]
pull_request:
branches: [master]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'yarn'
- name: Install dependencies
run: yarn install --immutable
- name: Build JavaScript
run: yarn build:js
- name: Lint
run: yarn lint
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'yarn'
- name: Setup Rust
uses: dtolnay/rust-action@stable
- name: Install dependencies
run: yarn install --immutable
- name: Run Rust tests
run: yarn test:wasm-crypto:rust
-25
View File
@@ -1,25 +0,0 @@
name: 'Lock Threads'
on:
schedule:
- cron: '20 1/3 * * *'
jobs:
lock:
runs-on: ubuntu-latest
env:
YARN_ENABLE_SCRIPTS: false
steps:
- uses: dessant/lock-threads@c1b35aecc5cdb1a34539d14196df55838bb2f836
with:
github-token: ${{ secrets.GH_PAT_BOT }}
issue-inactive-days: '7'
issue-comment: >
This thread has been automatically locked since there has not been
any recent activity after it was closed. Please open a new issue
if you think you have a related problem or query.
pr-inactive-days: '2'
pr-comment: >
This pull request has been automatically locked since there
has not been any recent activity after it was closed.
Please open a new issue for related bugs.
-30
View File
@@ -1,30 +0,0 @@
name: PR
on: [pull_request]
jobs:
pr:
continue-on-error: true
strategy:
matrix:
step: ['lint', 'test', 'build', 'deno']
runs-on: ubuntu-latest
env:
YARN_ENABLE_SCRIPTS: false
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 'lts/*'
- uses: denoland/setup-deno@v1
with:
deno-version: v1.42.x
- name: ${{ matrix.step }}
if: always()
continue-on-error: true
run: |
yarn install --immutable
if [ "${{ matrix.step }}" != "lint" ]; then
./scripts/install-build-deps.sh
fi
yarn polkadot-dev-deno-map
yarn ${{ matrix.step }}
-36
View File
@@ -1,36 +0,0 @@
name: Master
on:
push:
branches:
- master
jobs:
master:
if: "! startsWith(github.event.head_commit.message, '[CI Skip]')"
strategy:
matrix:
step: ['build:release']
runs-on: ubuntu-latest
env:
YARN_ENABLE_SCRIPTS: false
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
GH_PAT: ${{ secrets.GH_PAT_BOT }}
GH_RELEASE_GITHUB_API_TOKEN: ${{ secrets.GH_PAT_BOT }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GH_PAT_BOT }}
ref: ${{ github.ref }}
- uses: actions/setup-node@v4
with:
node-version: 'lts/*'
- name: Set Execute Permissions
run: chmod +x ./scripts/*
- name: Run Install Build Deps
run: bash ./scripts/install-build-deps.sh
- name: build
run: |
yarn install --immutable
yarn ${{ matrix.step }}
+69 -9
View File
@@ -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
+1 -1
View File
@@ -27,7 +27,7 @@
],
"type": "module",
"types": "./build/index.d.ts",
"version": "7.5.15",
"version": "7.5.18",
"main": "./build/cjs/index.js",
"module": "./build/index.js",
"exports": {
+6 -3
View File
@@ -317,6 +317,7 @@ import { pbkdf2 as noblePbkdf2 } from '@noble/hashes/pbkdf2';
import { blake2b as nobleBlake2b } from '@noble/hashes/blake2b';
import { hmac } from '@noble/hashes/hmac';
import { keccak_256, keccak_512 } from '@noble/hashes/sha3';
import { scrypt as nobleScrypt } from '@noble/hashes/scrypt';
function normalizeString(str: string): string {
return (str || '').normalize('NFKD');
@@ -483,9 +484,11 @@ export function pbkdf2(data: Uint8Array, salt: Uint8Array, rounds: number): Uint
return noblePbkdf2(nobleSha512, data, salt, { c: rounds, dkLen: 64 });
}
export function scrypt(_password: Uint8Array, _salt: Uint8Array, _log2n: number, _r: number, _p: number): Uint8Array {
// scrypt is rarely used - defer to @noble/hashes/scrypt if needed
throw new Error('scrypt not yet implemented - use @pezkuwi/util-crypto scryptSync instead');
export function scrypt(password: Uint8Array, salt: Uint8Array, log2n: number, r: number, p: number): Uint8Array {
// Convert log2n to N (cost parameter)
// log2n is log2(N), so N = 2^log2n
const N = 1 << log2n;
return nobleScrypt(password, salt, { N, r, p, dkLen: 64 });
}
export function sha256(data: Uint8Array): Uint8Array {
+1 -1
View File
@@ -3,4 +3,4 @@
// Do not edit, auto-generated by @pezkuwi/dev
export const packageInfo = { name: '@pezkuwi/wasm-crypto', path: 'auto', type: 'auto', version: '7.5.15' };
export const packageInfo = { name: '@pezkuwi/wasm-crypto', path: 'auto', type: 'auto', version: '7.5.18' };