Imported from priyanandrai/SecureCache (
AGENTS.md). Install upstream withnpx skills add priyanandrai/SecureCache. Copyright stays with the author.
AGENTS.md
Project Snapshot
- Java 8-era Maven library for encrypted in-memory caching (
pom.xml,src/main/java). - Core entry point is
com.securecache.main.SecureCache<Key, Value>. - There are no repo-specific AI instruction files; this guide is derived from
README.mdand source code.
Architecture: What Talks to What
SecureCacheorchestrates the full pipeline: serialize -> encrypt/jumble -> store (put) and fetch -> de-jumble/decrypt -> deserialize (get).- Storage is
TimeBasedHashMap<Key, Value>insrc/main/java/com/securecache/dataHandler/TimeBasedHashMap.java; entries are wrapped inValueWithTimestampand expire on read. - Encryption is in
src/main/java/com/securecache/cipher/Cipher.javausing AES plus a generated key fromKeyGenerator(PBKDF2). - Obfuscation stage is pluggable via
JumbleFunctionInterface; default chain isStringmagic,StringLogic,Stringtrickinitialized inSecureCacheconstructors. - Cache-miss loading boundary is
SourcesLoader<Key, Value>#loadValue(src/main/java/com/securecache/Loader/SourcesLoader.java), wired throughSecureCacheBuilder.Loader(...).
Data Flow Details That Matter
SecureCache.putcasts values toSerializablebeforeSerializationUtils.serialize; non-serializable values will fail at runtime.SecureCache.getfirst reads encrypted bytes from map, otherwise callsSourcesLoaderunder synchronization and backfills cache.Cipher.protectDatanow builds a versioned envelope:version | stage-sequence | IV | jumbled-payload.- The payload is paper-aligned:
ciphertext+ hidden key wherehiddenKey = key XOR SHA256(ciphertext). TimeBasedHashMap.getperforms lazy expiration (plusSeconds(expirationTimeInSeconds)), so eviction happens only when keys are accessed.
Build/Test Workflow (Observed)
- Main build command:
mvn clean test. - Current source compiles from clean;
mvn clean testpasses with demo-style tests. mvn testcan still appear green with stale classes intarget/, so use clean builds for reliable validation.- Test classes (
src/test/java/Test.java,src/test/java/RetriveDataFromSources.java) are executable demos withmain, not JUnit assertions.
Local Conventions (Non-Standard)
- Naming is intentionally inconsistent with Java norms in places:
Loaderpackage name is capitalized and builder method isLoader(...). JumbleFunctionInterfacekeeps backward-compatible aliases (JumbleData,Reassbamble) but canonical methods arejumbleDataandreassemble.- Public API behavior uses null/boolean fallbacks instead of rich exceptions (
SecureCache.getreturnsnullon failure,removereturns boolean). - TTL is hard-coded in
SecureCacheconstructor (new TimeBasedHashMap<>(10000000)), not currently exposed via builder config.
Paper Alignment (IJFMR260271936)
- Encryption is now
AES/GCM/NoPaddingwith per-entry random IV (src/main/java/com/securecache/cipher/Cipher.java). - Key material is runtime-generated and camouflaged via XOR-hash binding (
K XOR SHA256(C)) instead of plaintext embedding. - Multi-stage jumbling is applied with a stored function-index sequence; decryption reverses sequence order.
- Envelope versioning is explicit (
Constant.CACHE_VERSION) to support future format migration.
First Files To Read Before Changing Logic
src/main/java/com/securecache/main/SecureCache.javasrc/main/java/com/securecache/cipher/Cipher.javasrc/main/java/com/securecache/dataHandler/TimeBasedHashMap.javasrc/main/java/com/securecache/secureinterface/JumbleFunctionInterface.javasrc/test/java/Test.java