318 Commits
Author SHA1 Message Date
Zach Kelling 95efc99228 feat: add GPU stub packages for mldsa and slhdsa
Add placeholder GPU packages that return false for availability.
These are required by the precompile package.
2025-12-27 05:11:19 -08:00
Zach Kelling cb92212f09 chore: sync dependencies and format code 2025-12-27 04:45:16 -08:00
Zach Kelling af49b0a2b6 chore: sync with node requirements 2025-12-27 04:19:14 -08:00
Zach Kelling f4d92f5ef9 fix: Go version 1.25.5 → 1.22, update bindings 2025-12-27 03:53:12 -08:00
Zach Kelling 5c353ed4a2 fix: correct C bool comparison in blake3 CGO
- Use bool() cast instead of != 0 for C bool type
2025-12-27 03:27:10 -08:00
Zach Kelling bd178f910b chore: update deps to latest 2025-12-27 03:01:07 -08:00
Zach Kelling 4d15ed700c move address/formatting into crypto 2025-12-27 02:35:05 -08:00
Zach Kelling 9bb37d2a91 refactor: update import path to github.com/luxfi/constants 2025-12-27 02:09:03 -08:00
Zach Kelling 91dc988e75 fix(build): change blake3 CGO build tag to GPU
Changed build tag from `//go:build cgo && darwin` to `//go:build gpu && darwin`
so that CGO code requiring luxcpp/crypto is only compiled when explicitly
building with the gpu tag.

This allows the pure Go implementation (using zeebo/blake3) to be used
by default without requiring native library dependencies.
2025-12-27 01:43:01 -08:00
Zach Kelling d034d6f439 chore: update gpu to v0.30.0
Updates github.com/luxfi/gpu to v0.30.0 which includes
ZK operations (Poseidon2, Merkle tree, commitments).
2025-12-27 01:16:58 -08:00
Zach Kelling 7ceaaaa711 refactor(poseidon2): rename gpu files to follow _cgo.go convention 2025-12-27 00:50:56 -08:00
Zach Kelling 18da7f0215 refactor(gpu): rename files to follow _cgo.go convention
CGO implementations: gpu_cgo.go
Pure Go fallbacks: gpu.go
2025-12-27 00:24:54 -08:00
Zach Kelling 5b49b4b551 feat(hashing): add hashing package with SHA256/RIPEMD160
Provides hash primitives needed by luxfi/ids and other packages:
- ComputeHash256/ComputeHash160 for crypto hashes
- PubkeyBytesToAddress for Bitcoin-style address derivation
- Checksum for CB58 encoding
2025-12-26 23:58:52 -08:00
Zach Kelling 45753f9081 feat(verkle): add GPU-accelerated Verkle operations
Add Metal GPU acceleration for Verkle tree witness operations:
- CommitToPoly: GPU polynomial commitment via MSM
- BatchCommitToPoly: Parallel batch commitments
- VerifyProof: GPU IPA proof verification
- BatchVerifyProofs: Parallel proof verification

Links to luxcpp/crypto metal_ipa for Apple Silicon.
Pure Go fallback when CGO disabled.
2025-12-26 23:32:49 -08:00
Zach Kelling 9a952653bd feat(ipa): add GPU-accelerated Verkle/IPA operations
Add Metal GPU acceleration for Verkle tree operations:
- MSM (multi-scalar multiplication) on Banderwagon curve
- Batch MSM for parallel proof verification
- Pedersen commitments with GPU acceleration
- VerkleCommitNode for 256-width tree nodes

Includes pure Go fallback for CGO_ENABLED=0 builds.
Links to luxcpp/crypto metal_ipa implementation.
2025-12-26 23:06:47 -08:00
Zach Kelling 3bd83c6066 refactor: rename pqcrypto to pq for brevity
- Rename crypto/pqcrypto directory to crypto/pq
- Update pure Go fallbacks with correct API signatures
- Use standard cgo/!cgo build tags instead of custom tags
2025-12-26 22:40:45 -08:00
Zach Kelling 9f8cb81a58 fix: update GPU build tags for cgo/pure Go separation
- Change CGO files to use luxgpu tag (opt-in)
- Change pure Go files to use !luxgpu tag (default)
- Fix relative paths to luxcpp/crypto headers

This allows CGO=0 and CGO=1 builds to work without requiring
the full GPU libraries to be installed.
2025-12-26 22:14:43 -08:00
Zach Kelling 4b5676f742 fix: use metal tag for GPU files, pure Go is default 2025-12-26 21:48:40 -08:00
Zach Kelling 46efbf33ed feat: add GPU stub files for CGO-less builds
Add stub implementations for GPU packages that return
false for Available() when GPU libraries are not present.
This allows building with CGO_ENABLED=0 or CGO_ENABLED=1
without requiring Metal/CUDA libraries.

- bls/gpu/gpu_stub.go
- hash/blake3/gpu/gpu_stub.go
- hash/poseidon2/gpu/gpu_stub.go
- pqcrypto/*/gpu/gpu_stub.go (mldsa, mlkem, slhdsa)
2025-12-26 21:22:38 -08:00
Zach Kelling 7b0ce8ca27 Remove dead code and consolidate GPU ZK operations
- Remove crypto/common/math/ (dead code, using luxfi/math instead)
- Consolidate gpu/zk.go to use unified luxfi/gpu package
- Delete platform-specific gpu/zk_metal.go in favor of unified approach
- Update bls/types.go with GPU bindings
- Update dependencies for luxfi/gpu
2025-12-26 20:56:36 -08:00
Zach Kelling c035d2fc95 Update LLM.md 2025-12-26 20:30:33 -08:00
Zach Kelling 676a1899e0 gpu: add Poseidon2 ZK operations with Metal acceleration
Add GPU-accelerated ZK cryptographic primitives:
- Poseidon2 hash (BN254/Fr field) for Merkle trees
- Batch hash, commitment, and nullifier operations
- Threshold-gated routing (GPU for large batches, CPU otherwise)

Architecture:
- zk.go: CPU implementation using gnark-crypto, threshold routing
- zk_metal.go: Metal CGO bindings, registers GPU hooks
- GPU hooks pattern allows future CUDA support

Thresholds (tuned for Apple Silicon):
- Poseidon2: 64 hashes
- Merkle: 128 leaf pairs
- MSM: 256 point-scalar pairs
- Commitment: 128 operations
- FRI: 512 evaluations

All 12 tests pass in both CGO and non-CGO modes.
2025-12-26 20:04:31 -08:00
Zach Kelling 52c5488b7e build: require 'gpu' build tag for CGO GPU code
Changes:
- gpu/crypto_cgo.go: //go:build cgo -> //go:build cgo && gpu
- gpu/pool.go: //go:build cgo -> //go:build cgo && gpu
- gpu/crypto.go: //go:build \!cgo -> //go:build \!cgo || \!gpu
- gpu/crypto_cgo_test.go: //go:build cgo -> //go:build cgo && gpu
- gpu/pool_test.go: //go:build cgo -> //go:build cgo && gpu

This allows CGO_ENABLED=1 builds to work without requiring lux-crypto
to be installed. To enable GPU acceleration, build with -tags gpu.
2025-12-26 19:38:29 -08:00
Zach Kelling 5fca6aec19 Update GPU acceleration 2025-12-26 19:12:27 -08:00
Zach Kelling e66304df30 feat(gpu): remove all stubs, real BLS/ML-DSA/Threshold crypto
- Replace XOR placeholder aggregation with real bls_aggregate_signatures
- Fix BLSAggregatePublicKeys to use bls_aggregate_public_keys
- Fix BLSBatchVerify with proper CGO pointer pinning (Go 1.21+)
- Implement BLSBatchSign using parallel worker pool
- Fix MLDSAKeygen/Sign/Verify signatures to match C API
- Fix ThresholdContext.Keygen buffer sizing (maxShareSize=256)
- Add runtime.Pinner to all functions passing pointer arrays to C
- Fix codeToError to use CRYPTO_* constants
- All GPU crypto tests pass
2025-12-26 18:46:24 -08:00
Zach Kelling 18e359373b fix: add basePath for GitHub Pages 2025-12-26 18:20:22 -08:00
Zach Kelling f1b482c922 docs: add C++ libraries, GPU acceleration, and FHE documentation
- Add cpp-libraries.mdx documenting luxcpp/gpu, luxcpp/lattice, luxcpp/fhe, luxcpp/crypto
- Add gpu-acceleration.mdx with Metal/CUDA backend details and benchmarks
- Add fhe.mdx covering TFHE, CKKS, BGV schemes and threshold FHE
- Update index.mdx with new features and navigation links
2025-12-26 17:54:20 -08:00
Zach Kelling 527004fe2d refactor(hash): remove duplicate hashing package, use hash
- Remove hashing/ directory (duplicate of hash/)
- Update imports in cb58, secp256k1 to use crypto/hash
- Follows Go stdlib naming convention (hash vs hashing)
2025-12-26 17:28:18 -08:00
Zach Kelling f41ac722b2 refactor(hash): add hash package and alias hashing for backwards compat
The hash package is the canonical implementation.
The hashing package now re-exports from hash for backwards compatibility.

New code should import github.com/luxfi/crypto/hash directly.
2025-12-26 17:02:15 -08:00
Fuma Nama 898b7f84c0 feat(bls): implement proper proof of possession with domain separation
Add domain separation tags (DST) to BLS proof of possession signing and
verification to prevent cross-protocol attacks:
- dstSignature for standard BLS signatures
- dstPoP for proof of possession

This ensures signatures cannot be replayed across different contexts.
2025-12-26 16:36:13 -08:00
Zach Kelling 706f762ea6 feat(gpu): add NTT cache, worker pools, and BLS batch verification
- Add NTT cache with LRU eviction for twiddle factors
- Add worker pool for parallel GPU operations
- Add BLS batch signature verification
- Improve element operations for Bandersnatch
- Add comprehensive tests for GPU crypto operations
2025-12-26 16:10:11 -08:00
Zach Kelling 19e22adbcc refactor(gpu): self-contained CGO with runtime backend detection
- CGO_ENABLED=1: Auto-detects Metal (macOS) / CUDA (Linux) / CPU fallback
- CGO_ENABLED=0: Pure Go stubs (no C dependencies)
- Bundled include/gpu_crypto.h header (no external deps for build)
- Runtime GPU detection via gpu_available() and gpu_backend_name()
- Placeholder implementations for BLS, ML-DSA, hashing
- Threshold signatures stub (ErrNotSupported)

Build: go build ./...
Test:  go test ./...
2025-12-26 15:44:09 -08:00
Zach Kelling abaf7655f9 fix(gpu): use luxgpu build tag for CGO bindings
The gpu package requires C++ headers that only exist locally.
Using 'cgo' build tag caused CI failures when CGO was enabled but
headers weren't present.

Now uses 'luxgpu' custom build tag:
- Default: stub implementation (no dependencies)
- With -tags luxgpu: full CGO acceleration

Build locally with GPU: go build -tags luxgpu ./...
2025-12-26 15:18:06 -08:00
Zach Kelling cfb775419b feat(gpu): add GPU-accelerated cryptographic operations via CGO
- BLS12-381 signatures for validator consensus
- ML-DSA post-quantum signatures
- Threshold cryptography operations
- Hash functions (SHA3, BLAKE3)

GPU acceleration uses MLX (Metal on macOS, CUDA on Linux, CPU fallback).
2025-12-26 14:52:04 -08:00
Zach Kelling 168492cbac chore: add grpc-server.log to gitignore 2025-12-26 14:26:02 -08:00
Zach Kelling 18f88f19da Updates for warp, docs 2025-12-26 14:00:00 -08:00
Zach Kelling a67025abb7 style: fix gofmt formatting issues in threshold and aggregated packages 2025-12-20 22:43:34 -08:00
Zach Kelling 642c8bc0d6 ci: update Go version to 1.25.5 2025-12-20 21:42:40 -08:00
Zach Kelling 37bd49c508 feat: add ring signatures for anonymous group signing 2025-12-20 14:02:56 -08:00
Zach Kelling a3d4cd1b71 fix: exclude broken geth v1.16.1 module path mismatch
The Go proxy still serves v1.16.1 which has wrong module path
(github.com/ethereum/go-ethereum instead of github.com/luxfi/geth).
Add exclude directive to prevent this version from being selected.
2025-12-20 13:56:20 -08:00
Zach Kelling fef62f9f4e feat(threshold): add generic threshold signature framework with BLS support
- Add threshold package with generic interfaces for threshold signatures
- Implement BLS threshold signatures with proper Shamir secret sharing
  and Lagrange interpolation (polynomial degree t-1 for t-of-n)
- Add threshold scheme registry for multiple signature schemes
- Add session management for coordinated signing
- Add signer package with unified interface
- Remove obsolete corona/corona.go (moved to threshold repo)
- Remove obsolete unified/signer_simple.go (replaced by signer package)
- Update aggregated package for threshold integration
2025-12-17 14:33:12 -08:00
Zach Kelling 0ee940111e fix(bn256/gnark): fix inverted TestBytes logic in G1/G2 Unmarshal
The TestBytes function returns true when all bytes are zero (point at infinity).
The condition was inverted, causing non-zero points to be treated as infinity.
2025-12-14 21:24:02 -08:00
Zach Kelling 6fe11f3e77 chore: remove local cache/utils, use external luxfi/cache package
- Remove cache/ and utils/ directories (originally copied from luxfi/node)
- Update secp256k1 imports to use github.com/luxfi/cache/lru
- Update sig_fuzz_test.go to use local crypto/hashing instead of node/utils
- Clean up go.mod: remove unused node/geth dependencies
- crypto package is now fully standalone
2025-12-14 21:18:31 -08:00
Zach Kelling deca5e6954 Update dependencies to latest versions 2025-12-13 10:48:20 +00:00
Zach Kelling 29d5bbb311 Fix imports and fuzz tests for proper integration with geth
- Add crypto/common imports instead of geth/common for type independence
- Add HexToAddress wrapper function for address parsing
- Fix secp256k1 fuzz tests to check IsOnCurve before CompressPubkey
2025-12-12 22:06:09 -08:00
Zach Kelling a9769373ca fix: resolve build errors and ensure crypto independence from geth
- Fix bn256/gnark imports to use crypto/bitutil instead of standalone bitutil
- Remove unused secp256k1 import from crypto.go
- Fix mlkem test files to use correct API (GenerateKeyPair returns pub,priv,err)
- Fix mlkem constant names (MLKEM512SharedKeySize not SharedSecretSize)
- Restore crypto/common types as standalone (not aliases to geth/common)
- Update crypto.go and keccak.go to use crypto/common instead of geth/common
- Fix secp256k1 fuzz tests to use correct DecompressPubkey/CompressPubkey API
- Remove stale test files and go.work files

crypto package is now fully independent of geth (geth -> crypto, not reverse)
2025-12-12 21:51:02 -08:00
Zach Kelling 1ae6627f4a Update tests, remove old status files 2025-12-12 19:49:59 -08:00
Zach Kelling 78d37550c9 Sync with geth 2025-12-12 19:49:01 -08:00
Zach Kelling d3c8fb2fe2 Add EthAddress method for Ethereum-compatible address derivation
Adds EthAddress() methods to both PrivateKey and PublicKey types
to compute Ethereum addresses from secp256k1 keys using Keccak256.
2025-12-13 03:05:25 +00:00
Zach Kelling 78e922fa7a fix(bls): reject zero bytes in SecretKeyFromBytes for security
Zero is not a valid BLS12-381 scalar and should be rejected
when deserializing secret keys. This matches the expected
behavior tested in the node package.
2025-12-12 13:02:13 -08:00