Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
github.com/alecthomas/mph
This library provides Minimal Perfect Hashing (MPH) using the Compress, Hash and Displace (CHD) algorithm.
Primarily, extremely efficient access to potentially very large static datasets, such as geographical data, NLP data sets, etc.
On my 2012 vintage MacBook Air, a benchmark against a wikipedia index with 300K keys against a 2GB TSV dump takes about ~200ns per lookup.
Typically, the table would be used as a fast index into a (much) larger data set, with values in the table being file offsets or similar.
The tables can be serialized. Numeric values are written in little endian form.
Building and serializing an MPH hash table (error checking omitted for clarity):
b := mph.Builder()
for k, v := range data {
b.Add(k, v)
}
h, _ := b.Build()
w, _ := os.Create("data.idx")
_ := h.Write(w)
Deserializing the hash table and performing lookups:
r, _ := os.Open("data.idx")
h, _ := mph.Read(r)
v := h.Get([]byte("some key"))
if v == nil {
// Key not found
}
MMAP is also indirectly supported, by deserializing from a byte slice and slicing the keys and values.
The API documentation has more details.
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
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.