
Research
Two Malicious Rust Crates Impersonate Popular Logger to Steal Wallet Keys
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
github.com/jedisct1/go-fast
A Go implementation of the FAST (Format-preserving encryption And Secure Tokenization) algorithm.
FAST is a format-preserving encryption (FPE) scheme that encrypts data while preserving its format. For example, a 16-byte string will encrypt to another 16-byte string, and numeric data maintains its numeric format.
go get github.com/jedisct1/go-fast
package main
import (
"fmt"
"github.com/jedisct1/go-fast"
)
func main() {
// Create a new FAST cipher with a 16-byte key (AES-128)
key := []byte("0123456789abcdef")
cipher, err := fast.NewCipher(key)
if err != nil {
panic(err)
}
// Encrypt some data
plaintext := []byte("Hello, World!")
ciphertext := cipher.Encrypt(plaintext, nil)
fmt.Printf("Plaintext: %s\n", plaintext)
fmt.Printf("Ciphertext: %x\n", ciphertext)
// Decrypt it back
decrypted := cipher.Decrypt(ciphertext, nil)
fmt.Printf("Decrypted: %s\n", decrypted)
}
// Different tweaks produce different ciphertexts for the same plaintext
data := []byte("sensitive data")
tweak1 := []byte("domain1")
tweak2 := []byte("domain2")
ciphertext1 := cipher.Encrypt(data, tweak1)
ciphertext2 := cipher.Encrypt(data, tweak2)
// ciphertext1 != ciphertext2
// Must use the same tweak to decrypt
decrypted1 := cipher.Decrypt(ciphertext1, tweak1) // ✓ Correct
decrypted2 := cipher.Decrypt(ciphertext1, tweak2) // ✗ Wrong result
FAST supports AES-128, AES-192, and AES-256:
// AES-128 (recommended)
key128 := make([]byte, 16)
cipher128, _ := fast.NewCipher(key128)
// AES-192
key192 := make([]byte, 24)
cipher192, _ := fast.NewCipher(key192)
// AES-256
key256 := make([]byte, 32)
cipher256, _ := fast.NewCipher(key256)
FAST is based on the research paper:
"FAST: Secure and High Performance Format-Preserving Encryption and Tokenization"
https://eprint.iacr.org/2021/1171.pdf
Benchmarks run on Apple M4:
The implementation includes optimizations for the common case of nil tweaks:
Size | Nil Tweak | With Tweak | Improvement |
---|---|---|---|
16B | 418.2 ns/op (38.26 MB/s) | 580.0 ns/op (27.59 MB/s) | 28% faster |
64B | 535.7 ns/op (119.48 MB/s) | 713.7 ns/op (89.68 MB/s) | 25% faster |
256B | 1212 ns/op (211.19 MB/s) | 1474 ns/op (173.69 MB/s) | 18% faster |
1KB | 4267 ns/op (240.01 MB/s) | N/A | N/A |
Memory allocations are also significantly reduced (3-5 allocs vs 10 allocs).
Run the comprehensive test suite:
go test -v
For performance benchmarks:
go test -bench=. -benchtime=10s -run=^$
This implementation is based on the FAST specification and is provided for research and educational purposes.
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
Research
A malicious package uses a QR code as steganography in an innovative technique.
Research
/Security News
Socket identified 80 fake candidates targeting engineering roles, including suspected North Korean operators, exposing the new reality of hiring as a security function.