Files
crypto/cache/lru_sized_cache_test.go
T
Hanzo Dev 0be2fe8f6c crypto: implement post-quantum primitives with circl
- Implement ML-DSA-65 (FIPS 204) using cloudflare/circl
  * Single implementation with automatic CGO optimization
  * Sign ~440μs, Verify ~130μs, KeyGen ~165μs on M1 Max
  * All 11 tests passing

- Simplify ML-KEM implementation
  * Remove redundant optimized versions
  * Use circl ML-KEM-768 directly

- Simplify SLH-DSA implementation
  * Remove premature optimizations
  * Clean stub for future circl support (FIPS 205)

- Add comprehensive cache package
  * LRU cache from luxfi/node
  * Metercacher for metrics integration
  * Test utilities

- Add crypto utils
  * Atomic operations
  * Bytes utilities
  * Complete utils package from luxfi/node

- Update secp256k1 and BLS
  * All BLS tests passing (23 tests)
  * secp256k1 fuzz test added

All post-quantum implementations now use cloudflare/circl as single source
of truth, following DRY principle and ensuring FIPS compliance.
2025-11-22 16:37:21 -08:00

55 lines
1.0 KiB
Go

// Copyright (C) 2019-2025, Lux Industries Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package cache_test
import (
"testing"
"github.com/stretchr/testify/require"
"github.com/luxfi/node/cache"
"github.com/luxfi/node/cache/cachetest"
"github.com/luxfi/ids"
)
func TestSizedLRU(t *testing.T) {
c := cache.NewSizedLRU[ids.ID, int64](cachetest.IntSize, cachetest.IntSizeFunc)
cachetest.Basic(t, c)
}
func TestSizedLRUEviction(t *testing.T) {
c := cache.NewSizedLRU[ids.ID, int64](2*cachetest.IntSize, cachetest.IntSizeFunc)
cachetest.Eviction(t, c)
}
func TestSizedLRUWrongKeyEvictionRegression(t *testing.T) {
require := require.New(t)
c := cache.NewSizedLRU[string, struct{}](
3,
func(key string, _ struct{}) int {
return len(key)
},
)
c.Put("a", struct{}{})
c.Put("b", struct{}{})
c.Put("c", struct{}{})
c.Put("dd", struct{}{})
_, ok := c.Get("a")
require.False(ok)
_, ok = c.Get("b")
require.False(ok)
_, ok = c.Get("c")
require.True(ok)
_, ok = c.Get("dd")
require.True(ok)
}