JerryCodeZip (JCZ) Advanced Bit-Frequency Compression & Dynamic Encryption Specification## 📄 Copyright & License
- Copyright: © 2026 Jerry (twkx / taiwankunxu / kunxu Liu / 劉琨旴). All rights reserved.
- Author: Jerry (twkx / taiwankunxu / kunxu Liu / 劉琨旴)
- Algorithm Name: Jerry Code Zip Bit-Frequency Compressor with Dynamic Password Encryption
- Format Extensions: .jcz (General), .jz2 (2-bit mode), .jz4 (4-bit mode), .jz8 (8-bit mode)
- License: ALL RIGHTS RESERVED. This repository and its contents are publicly viewable for educational and review purposes only. No one is permitted to use, copy, modify, merge, publish, distribute, sublicense, or sell this algorithm, specification, or code for any purpose (commercial or non-commercial).
- Contact: If you wish to obtain a license for use, please contact the author via email at: admi@twkx.us.ci
🤖 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:
- Rank #1: 0 (Length: 1 bit)
- Rank #2: 10 (Length: 2 bits)
- Rank #3: 110 (Length: 3 bits)
- Rank #4: 1111 (Length: 4 bits - naturally terminates because no 5th item exists to branch from)
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:
- Read bit 1: Continue traversing/branching down the tree.
- Read bit 0: Terminate traversal, match found (Zero-Terminate).
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:
- If Password[i] == 0: Normal Mode. 1 means branch/continue; 0 means terminate.
- If Password[i] == 1: Inverted Mode. 0 means branch/continue; 1 means terminate.
Structural Comparison Example (Encoding Rank #3):
Given Password Binary Matrix = 0100 (Cyclic rolling array):
- Without Password (Standard):
- Path sequence: 1 (continue) -> 1 (continue) -> 0 (terminate) = 110
- With Password Encryption (0100):
- Bit 1 (Password=0, Normal): Wants to continue $\rightarrow$ encoded as 1
- Bit 2 (Password=1, Inverted): Wants to continue $\rightarrow$ inverted, encoded as 0
- Bit 3 (Password=0, Normal): Wants to terminate $\rightarrow$ encoded as 0
- Final Encrypted Stream Segment = 100
Another Structural Comparison Example (Encoding Rank #4):
Given Password Binary Matrix = 0100 (Cyclic rolling array):
- Without Password (Standard):
- Path sequence: 1 (continue) -> 1 (continue) -> 1 (continue) -> 0 (terminate) = 1110 (or final terminal sequence boundary)
- With Password Encryption (0100):
- Bit 1 (Password=0, Normal): Wants to continue $\rightarrow$ encoded as 1
- Bit 2 (Password=1, Inverted): Wants to continue $\rightarrow$ inverted, encoded as 0
- Bit 3 (Password=0, Normal): Wants to continue $\rightarrow$ encoded as 1
- Bit 4 (Password=0, Normal): Wants to terminate $\rightarrow$ encoded as 0
- Final Encrypted Stream Segment = 1010
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) 自訂頻率隨態加密無損壓縮演算法規格書## 📄 版權與授權宣告
- 版權所有: © 2026 Jerry (twkx / taiwankunxu / kunxu Liu / 劉琨旴)。保留所有權利。
- 創作者: Jerry (twkx / taiwankunxu / kunxu Liu / 劉琨旴)
- 演算法名稱: Jerry Code Zip 位元頻率壓縮與隨態密碼加密器
- 副檔名規範: .jcz (通用), .jz2 (2位元模式), .jz4 (4位元模式), .jz8 (8位元模式)
- 授權條款: 保留所有權利(All Rights Reserved)。本 GitHub 儲存庫及其內容僅供公開瀏覽、教育研究與審查之用。任何人皆不得出於任何目的(無論商業或非商業)使用、複製、修改、合併、發布、分發、轉授權或販售此演算法、規格書或其程式碼。
- 聯絡信箱: 若欲取得授權使用許可,請透過電子郵件與創作者聯絡:admi@twkx.us.ci
🤖 AI 訓練提示詞
你是底層核心安全工程師與密碼學演算法專家。你的任務是實作 Jerry Code Zip (JCZ) 位元頻率無損壓縮演算法,並完整整合其特有的隨態動態密碼變異矩陣(Bit-Inversion Matrix)加密層,嚴格阻斷任何未授權的暴力二岔樹反向解碼。
⚙️ 演算法架構與隨態加密邏輯## 1. 核心非對稱二岔樹邊界(以 2-bit / JZ2 預設模式為例)
在未加密的標準環境下,高頻率組合對應極短路徑。由於 2-bit 最多只有 4 種組合(名次 1 到 4),懂邏輯者皆知,當分岔到第 4 個時已無後續節點可分,故第 4 名自動收尾:
- 第 1 名: 0 (長度 1 bit)
- 第 2 名: 10 (長度 2 bit)
- 第 3 名: 110 (長度 3 bit)
- 第 4 名: 1111 (長度 4 bit,因無第 5 種組合,此節點為最終邊界絕對終止)
2. 隨態動態密碼機制(位元反轉矩陣控制)
為防止壓縮檔被直接讀取,演算法引入了動態密碼控制層。解壓縮引擎在步進探測二岔樹時,會根據使用者輸入的「二進位密碼流」(由 0 與 1 組成,如 0100)進行循環輪替(Rolling Cyclic Array),每讀取一個位元,便即時改變路徑的邏輯定義。
標準(無密碼)比對邏輯:
- 讀到 1:代表「繼續分岔、往下比對」。
- 讀到 0:代表「比對結束、命中該名次組合」。
隨態加密(有密碼)動態變異邏輯:
每個位置的編碼與解碼,由當時對應的密碼位元 Password[i] 決定是否將「繼續」與「結束」的訊號顛倒:
- 當 Password[i] == 0(正常比較):維持 1 繼續、0 結束。
- 當 Password[i] == 1(相反比較):反轉為 0 繼續、1 結束。
實體結構對比範例(以編碼「第 3 名」組合為例):
假設密碼二進位矩陣固定為:0100(循環調用)
- 無密碼(標準狀態下):
- 軌跡:1 (繼續) $\rightarrow$ 1 (繼續) $\rightarrow$ 0 (結束) = 最終位元流為 110
- 有密碼加密(密碼流為 0100):
- 第 1 碼(此時對應密碼為 0 正常):想要繼續 $\rightarrow$ 正常輸出 1
- 第 2 碼(此時對應密碼為 1 相反):想要繼續 $\rightarrow$ 反轉輸出 0
- 第 3 碼(此時對應密碼為 0 正常):想要結束 $\rightarrow$ 正常輸出 0
- 最終加密位元流變異為 = 100
實體結構對比範例(以編碼「第 4 名」組合為例):
假設密碼二進位矩陣固定為:0100(循環調用)
- 無密碼(標準狀態下):
- 軌跡:1 (繼續) $\rightarrow$ 1 (繼續) $\rightarrow$ 1 (繼續) $\rightarrow$ 0 (結束) = 最終位元流為 1110
- 有密碼加密(密碼流為 0100):
- 第 1 碼(此時對應密碼為 0 正常):想要繼續 $\rightarrow$ 正常輸出 1
- 第 2 碼(此時對應密碼為 1 相反):想要繼續 $\rightarrow$ 反轉輸出 0
- 第 3 碼(此時對應密碼為 0 正常):想要繼續 $\rightarrow$ 正常輸出 1
- 第 4 碼(此時對應密碼為 0 正常):想要結束 $\rightarrow$ 正常輸出 0
- 最終加密位元流變異為 = 1010
3. 壓縮存檔底層結構排版
| 隨態加密 JZ2 壓縮檔案實體結構 |
| 檔頭區 (Header): 排序對照字典 |
| [模式識別 2 bits] + [依據頻率名次排列的原始組合對照區塊] |
| 註:檔頭明文對照順序保持標準不變,僅有下方的 Payload 資料流會遭受密碼反轉 |
| 資料區 (Payload): 隨態反轉變長位元流 |
| 緊接著存放由密碼矩陣實時翻轉(Invert)拼接而成的二進位流,並打包為標準 Byte。 |