This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
npm run compile- Compile TypeScript to JavaScriptnpm run clean- Clean build artifacts
npm test- Run all unit tests- Test framework: Jest with ts-jest
- Unit tests located in
test/unit/ - Integration tests in
test/root (test-sign-obj.js, test-tag-obj.js)
npm run lint- Run ESLintnpm run format-check- Check code formatting with Prettiernpm run format-fix- Auto-fix formatting issuesnpm run check- Run Google TypeScript Style checks
npm run release:patch- Release patch versionnpm run release:minor- Release minor versionnpm run release:major- Release major versionnpm run release:prerelease- Release prerelease version
The library exports cryptographic utility functions from src/index.ts. Key architectural decisions:
-
Initialization Pattern: The library requires initialization with a 32-byte hex key via
init()before any operations can be performed. This key is used for Blake2b hashing operations. -
Signature Format: Object signatures follow a specific structure:
{ owner: string, // public key of signer sig: string // signature }
-
Type System: Uses
@shardus/lib-typesfor shared type definitions across the Shardus ecosystem. -
Security Considerations:
- The
verify()function is intentionally not exported due to safety concerns - Encrypt/decrypt functions are commented out pending security review (GOLD-264)
- All cryptographic operations use sodium-native (libsodium bindings)
- The
- sodium-native: Core cryptographic operations (Blake2b, Ed25519, Curve25519)
- fast-stable-stringify: Deterministic JSON stringification for consistent hashing
- buffer-xor: XOR operations for cryptographic functions
- Hashing:
hash(),hashObj() - Key Management:
generateKeypair(),convertSkToCurve(),convertPkToCurve() - Signing:
sign(),signObj() - Verification:
verify()(internal only),verifyObj() - Authentication:
tag(),tagObj(),authenticate(),authenticateObj() - Utilities:
randomBytes(),stringify(),setStringifier()
- Node.js version must be exactly 18.19.1
- All releases are published to npm under
@shardus/lib-crypto-utils - CI/CD uses Shardus's reusable workflow with configurable checks via repository variables
- The library is security-critical - all changes should be carefully reviewed