Known-library signature store for twinflame (offline builder + mmap query reader)
Project description
twinflame_libsigs
A known-library signature store for twinflame: an offline builder plus a memory-mapped query reader for a large, version-deduplicated dictionary of library class signatures, computed in twinflame's own 128-bit signature space.
twinflame queries it to label app classes as known-library code — which feeds
provenance.py, demotes third-party churn in the change report, and (the reason
this exists) excludes library classes from the family side of containment
scoring so shared runtimes don't inflate the score.
Status
Beta. The core pipeline is complete end-to-end — catalogue → scrape →
build → detect — and the resulting pack is consumed by twinflame's
--libsigs integration. What's real and tested:
- The build pipeline (
src/twinflame_libsigs/): the Maven/Google-Maven scraper (idempotent per-coordinate cache), version-range dedup (dedup.py), and the packer that emits a single.tflppack plus its coordinate sidecar. Driven by thetwinflame-libsigsCLI (scrape/build/detect/info/query). - The production store — native, exact (
native/, Rust): a Multi-Index Hashing near-neighbour store (Norouzi et al., TPAMI 2014). Exact radius-rHamming search, verified equal to brute force. Measured at R=12: 8.5 µs/query at 200k, 167 µs at 5M, sub-second build; ~6× faster than the Python prototype and exact (vs ≥90% recall). pyo3 moduletfls_mihlets twinflame call it directly. Optional:detect.pyfalls back to a pure-Python brute-force store when the native module isn't built, so the pipeline works without it — the native wheel is a performance accelerator, not a requirement. - The Python prototype (
store.py/build.py, the.tflsformat): the original approximate LSH-banding store + on-disk prefix-directory study. Kept as design reference; superseded by the.tflppack + native store above.
Not yet built:
- Native persistence — the MIH store is rebuilt in memory at load from the
pack's stored signatures (sub-second, so low priority). Serializing it to its
own mmap file is future work. See
native/README.md.
Requirements
- twinflame ≥ 0.3.0b1 — the first release carrying the
--libsigsintegration and theSIGNATURE_STAMPthis store's packs are validated against. A pack is only valid for the twinflame signature stamp it was built against. - The builder additionally needs the
[build]extra (requests) and an Androidd8onPATH(from the Android SDK cmdline-tools) to turn downloaded.aar/.jarartifacts into DEX. The query/reader path needs neither — only the stdlib + twinflame.
Install
pip install twinflame-libsigs # reader + CLI (pure Python)
pip install 'twinflame-libsigs[build]' # + scraper deps (requests); d8 must be on PATH
The signature data pack is not shipped on PyPI — it is a generated asset.
Download a prebuilt .tflp from the GitHub Releases page and place it at
~/.cache/twinflame/libsigs.tflp, where twinflame auto-discovers it. Or build
your own (below).
Usage
Build a pack from a catalogue of Maven coordinates, then let twinflame use it:
# 1. scrape upstream releases into a local cache (idempotent; re-runnable)
twinflame-libsigs scrape -c catalogues/full-2026-07.txt -C libsigs-cache
# 2. build the deduplicated pack from the cache
twinflame-libsigs build -C libsigs-cache -o libsigs.tflp
# 3a. probe an APK directly
twinflame-libsigs detect app.apk libsigs.tflp
# 3b. or install it for twinflame's auto-discovery
cp libsigs.tflp ~/.cache/twinflame/libsigs.tflp
twinflame old.apk new.apk # library classes now labeled / demoted
twinflame --libsigs <pack> and $TWINFLAME_LIBSIGS override the discovery
path. The catalogue is a plain-text list of group:artifact <repo> lines; see
catalogues/full-2026-07.txt.
Design & background
The full design study — why the storage layout is what it is, the finding that
twinflame's R=12 radius breaks exact pigeonhole (Manku) indexing, the
multi-index-hashing escape that fixes it, the measured radius, and the prior-art
survey (near-neighbour search, TPL detection, malware fingerprinting) — lives in
the workspace knowledge library (docs/libsigs/ and docs/knowledge-base/ at the
repo parent), which is the source of truth and is not shipped with this package.
Boundary with twinflame
twinflame core imports only the stdlib-only reader. The builder, its network/Maven/d8 dependencies, and the signature data are an offline asset and never enter the twinflame wheel.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file twinflame_libsigs-0.2.0b1.tar.gz.
File metadata
- Download URL: twinflame_libsigs-0.2.0b1.tar.gz
- Upload date:
- Size: 35.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cad285b8ed1722e261931de7712e7b332742c2198797dbb8f157b3a432e885fb
|
|
| MD5 |
cb8df8af5e4a489fec09e27be979eb7f
|
|
| BLAKE2b-256 |
81e5ad06c912d87d3926ba8b769c68183376b730f5e65330452dfc869355eea5
|
Provenance
The following attestation bundles were made for twinflame_libsigs-0.2.0b1.tar.gz:
Publisher:
release.yml on ankorio/twinflame_libsigs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
twinflame_libsigs-0.2.0b1.tar.gz -
Subject digest:
cad285b8ed1722e261931de7712e7b332742c2198797dbb8f157b3a432e885fb - Sigstore transparency entry: 2169640891
- Sigstore integration time:
-
Permalink:
ankorio/twinflame_libsigs@7676972a8564dd29fe185a81c2c8373e054d9c99 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/ankorio
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@7676972a8564dd29fe185a81c2c8373e054d9c99 -
Trigger Event:
push
-
Statement type:
File details
Details for the file twinflame_libsigs-0.2.0b1-py3-none-any.whl.
File metadata
- Download URL: twinflame_libsigs-0.2.0b1-py3-none-any.whl
- Upload date:
- Size: 32.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c259c186a7e79f3d8ac8f1a34a9bbc53bbeda69be195b0b1ffcf4ef0c2e26081
|
|
| MD5 |
b86363a7b7f97b9a2d9fc5f98b38ab5f
|
|
| BLAKE2b-256 |
23e1db7c80d2506d3612b620398c06155f8b6dd2435ecc670e3da7e90aa1d8fc
|
Provenance
The following attestation bundles were made for twinflame_libsigs-0.2.0b1-py3-none-any.whl:
Publisher:
release.yml on ankorio/twinflame_libsigs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
twinflame_libsigs-0.2.0b1-py3-none-any.whl -
Subject digest:
c259c186a7e79f3d8ac8f1a34a9bbc53bbeda69be195b0b1ffcf4ef0c2e26081 - Sigstore transparency entry: 2169640936
- Sigstore integration time:
-
Permalink:
ankorio/twinflame_libsigs@7676972a8564dd29fe185a81c2c8373e054d9c99 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/ankorio
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@7676972a8564dd29fe185a81c2c8373e054d9c99 -
Trigger Event:
push
-
Statement type: