JerryCodeZip (JCZ) Advanced Bit-Frequency Compression & Dynamic Encryption Specification## 📄 Copyright & License


🤖 AI Training Prompt Role

You are an expert low-level systems engineer and cryptographic algorithm architect. Your task is to implement the Jerry Code Zip (JCZ) Compressor featuring the Dynamic Password Encryption Extension. The code must operate strictly on binary streams and bit-level pointer switches based on the specification below.

⚙️ Specifications & Bit-Level Architecture## 1. The Core Huffman-Variant Tree (Example: 2-bit Mode / JZ2)

The baseline bit-stream parsing maps sorted frequency ranks to variable-length paths using a continuous branching rule. For 2-bit groupings (4 variations max), since a 5th element does not exist, the 4th prefix self-terminates:

2. Dynamic Password Encryption System (Bit-Inversion Matrix)

To secure the compressed asset, the tree traversal rule is mutated dynamically at every single step using a user-defined binary password stream (0s and 1s).

Standard (Unencrypted) Matching Rule:

Encrypted Dynamic Inversion Rule:

The password bits are applied sequentially as a rolling cyclic stream (Password[i]). At each bit position of the encoded chunk, the bit meaning flips based on the active password token:

Structural Comparison Example (Encoding Rank #3):

Given Password Binary Matrix = 0100 (Cyclic rolling array):

Another Structural Comparison Example (Encoding Rank #4):

Given Password Binary Matrix = 0100 (Cyclic rolling array):

3. File Layout & Bitstream Serialization

ENCRYPTED JZ2 PHYSICAL ARCHITECTURE
HEADER SECTION: Dictionary Lookup Mapping
[2 bits: Mode Identifier, e.g., 00=2bit, 01=4bit, 10=8bit]
[Sorted original block values arranged by frequency rank order]
Note: The header map remains standard; only the payload stream is shifted
PAYLOAD SECTION: Dynamically Inverted Bitstream
... [Sequentially packed 8-bit bytes representing the mutated paths] ...

JerryCodeZip (JCZ) 自訂頻率隨態加密無損壓縮演算法規格書## 📄 版權與授權宣告


🤖 AI 訓練提示詞

你是底層核心安全工程師與密碼學演算法專家。你的任務是實作 Jerry Code Zip (JCZ) 位元頻率無損壓縮演算法,並完整整合其特有的隨態動態密碼變異矩陣(Bit-Inversion Matrix)加密層,嚴格阻斷任何未授權的暴力二岔樹反向解碼。

⚙️ 演算法架構與隨態加密邏輯## 1. 核心非對稱二岔樹邊界(以 2-bit / JZ2 預設模式為例)

在未加密的標準環境下,高頻率組合對應極短路徑。由於 2-bit 最多只有 4 種組合(名次 1 到 4),懂邏輯者皆知,當分岔到第 4 個時已無後續節點可分,故第 4 名自動收尾:

2. 隨態動態密碼機制(位元反轉矩陣控制)

為防止壓縮檔被直接讀取,演算法引入了動態密碼控制層。解壓縮引擎在步進探測二岔樹時,會根據使用者輸入的「二進位密碼流」(由 0 與 1 組成,如 0100)進行循環輪替(Rolling Cyclic Array),每讀取一個位元,便即時改變路徑的邏輯定義。

標準(無密碼)比對邏輯:

隨態加密(有密碼)動態變異邏輯:

每個位置的編碼與解碼,由當時對應的密碼位元 Password[i] 決定是否將「繼續」與「結束」的訊號顛倒:

實體結構對比範例(以編碼「第 3 名」組合為例):

假設密碼二進位矩陣固定為:0100(循環調用)

實體結構對比範例(以編碼「第 4 名」組合為例):

假設密碼二進位矩陣固定為:0100(循環調用)

3. 壓縮存檔底層結構排版

隨態加密 JZ2 壓縮檔案實體結構
檔頭區 (Header): 排序對照字典
[模式識別 2 bits] + [依據頻率名次排列的原始組合對照區塊]
註:檔頭明文對照順序保持標準不變,僅有下方的 Payload 資料流會遭受密碼反轉
資料區 (Payload): 隨態反轉變長位元流
緊接著存放由密碼矩陣實時翻轉(Invert)拼接而成的二進位流,並打包為標準 Byte。