System Algorithms & Detailed Pseudo-Code
This reference provides the complete algorithmic pseudo-code for all five core functional engines in the STEGNOLINES architecture.
1. UI Module Pseudo-Code (Sender & Receiver)
Sender-Side UI Workflow (Figure 4.11)
Input: Secret_Text (String), Cover_Text (String), User_Stego_Key (String), User_Aes_Key (String)
Begin
// Step 1: WebAssembly Environment Verification
WASM_Status ← Initialize_WebAssembly_Module()
If WASM_Status is FAILED Then
Disable_UI_Controls()
Display_Error("Initialization failed: WebAssembly context required.")
Stop_Execution()
EndIf
// Step 2: Capacity Validation
If Length(Secret_Text) > Length(Cover_Text) Then
Display_Error("Capacity Exceeded: Cover text is too short for secret payload.")
Stop_Execution()
EndIf
// Step 3: Automated Key Configuration and Fallback Logic
If User_Aes_Key is Empty Then
Active_Aes_Key ← Active_Stego_Key
Else
Active_Aes_Key ← User_Aes_Key
EndIf
// Step 4: Proceed to Core Pipeline
PassToEmbeddingProcess(Secret_Text, Cover_Text, Active_Stego_Key, Active_Aes_Key)
EndReceiver-Side UI Workflow (Figure 4.12)
Input: Stego_Input (String), User_Stego_Key (String), User_Aes_Key (String)
Begin
If Stego_Input is Empty Then
Display_Error("Extraction Error: Stego-Text input field cannot be empty.")
Stop_Execution()
EndIf
// Isolate invisible Variation Selectors
[Isolated_VS_Bytes, Clean_Cover_Text] ← Isolate_And_Decode_VS(Stego_Input)
If Length(Isolated_VS_Bytes) == 0 Then
Display_Error("Integrity Error: No hidden variation selector payload detected.")
Stop_Execution()
EndIf
If User_Aes_Key is Empty Then
Active_Aes_Key ← Active_Stego_Key
Else
Active_Aes_Key ← User_Aes_Key
EndIf
PassToExtractionProcess(Isolated_VS_Bytes, Clean_Cover_Text, Active_Stego_Key, Active_Aes_Key)
End2. Scanner Engine Algorithm (Figure 4.13)
Input: Raw_Chat_Transcript (String), Stego_Key (String), Optional_AES_Key (String)
Output: Extracted_Secret_Message (String), Secret_Hint (String)
Begin
// Step 1: Automatic Chat Transcript Formatting & Segmentation
Platform_Signature ← Identify_Chat_Platform_Format(Raw_Chat_Transcript)
Structured_Messages[] ← Filter_And_Segment_Transcript(Raw_Chat_Transcript, Platform_Signature)
// Step 2: Steganographic Carrier Isolation
[Clean_Messages[], VS_Payload_Bytes, Carrier_Index] ← Isolate_Steganographic_Payload(Structured_Messages[])
If VS_Payload_Bytes is Null Then
Raise_Error("Security Exception: No embedded steganographic components detected.")
EndIf
XOR_Key_Binary ← Convert_Bytes_To_Binary_String(VS_Payload_Bytes)
// Step 3: Candidate Evaluation Loop
For i = 0 To Length(Clean_Messages) - 1 Do
Target_Positions ← Generate_Deterministic_Positions(Length(Clean_Messages[i]), Length(XOR_Key_Binary), Resolved_Stego_Key)
Recovered_Binary ← Reverse_Bitwise_XOR(Clean_Messages[i], Target_Positions, XOR_Key_Binary)
Payload_Bytes ← Convert_Binary_To_Bytes(Recovered_Binary)
// Decryption & Decompression
Decrypted_Bytes ← Execute_AES_CTR_Decryption(Payload_Bytes, Resolved_AES_Key, Clean_Messages[i])
If Decrypted_Bytes[0] == 0xFE Then
Final_Bytes ← Execute_Brotli_Stream_Decompression(Decrypted_Bytes[1..End])
Else
Final_Bytes ← Decrypted_Bytes
EndIf
[Secret_Message, Secret_Hint, Valid] ← Validate_And_Parse_UTF8(Final_Bytes)
If Valid is TRUE Then
Return Secret_Message, Secret_Hint
EndIf
EndFor
End3. WebAssembly Brotli Compression Engine (Figure 4.14)
Procedure Initialize_Brotli_WASM_Context()
Begin
WASM_Binary_Buffer ← Decode_Base64_To_ArrayBuffer(EMBEDDED_WASM_BASE64_STRING)
WASM_Instance ← WebAssembly_Compile_And_Instantiate(WASM_Binary_Buffer)
WASM_READY_STATUS ← TRUE
End
Function Execute_Brotli_Compression(Raw_Payload_Bytes)
Begin
Compressed_Bytes ← WASM_Stream_Compress(Raw_Payload_Bytes, Quality=11, Chunk_Size=4096)
Return Compressed_Bytes
End
Function Execute_Brotli_Decompression(Compressed_Bytes)
Begin
Restored_Original_Bytes ← WASM_Stream_Decompress(Compressed_Bytes, Chunk_Size=4096)
Return Restored_Original_Bytes
End4. Cryptographic Engine (Key Handler & AES-CTR) (Figure 4.15)
Function Derive_Cryptographic_Parameters(User_Password, Cover_Text)
Begin
// Step 1: Deterministic 16-byte salt from cover hash
Cover_Hash ← SHA-256(Cover_Text)
Cryptographic_Salt ← Cover_Hash[0..15]
// Step 2: PBKDF2 Key Stretching (100,000 rounds)
Derived_48_Bytes ← PBKDF2(User_Password, Cryptographic_Salt, Iterations=100000, Hash=SHA-256, dkLen=48)
AES_256_Key ← Derived_48_Bytes[0..31]
CTR_IV ← Derived_48_Bytes[32..47]
Return AES_256_Key, CTR_IV
End
Function Encrypt_Payload_CTR(Plain_Bytes, User_Password, Cover_Text)
Begin
[AES_Key, CTR_IV] ← Derive_Cryptographic_Parameters(User_Password, Cover_Text)
Cipher_Bytes ← AES_CTR_Encrypt(Key=AES_Key, Counter=CTR_IV, Plaintext=Plain_Bytes)
Return Cipher_Bytes
End5. Steganographic Spatial Engine (Figure 4.16)
Function Generate_Bit_Positions(Cover_Capacity, Payload_Bit_Length, Stego_Key)
Begin
// Step 1: 256-bit PBKDF2 Key Derivation (100,000 rounds)
Key_256 ← PBKDF2(Stego_Key, Salt="StegoLine::CSPRNG::v2::Salt2026!", Iterations=100000, Hash=SHA-256, dkLen=32)
// Step 2: Initialize AES-256-CTR CSPRNG
CSPRNG_Engine ← Initialize_AES256_CTR_CSPRNG(Key_256)
// Step 3: O(K) Lazy Fisher-Yates with Unbiased Rejection Sampling
Target_Positions[] ← Execute_Unbiased_Lazy_Fisher_Yates(Cover_Capacity, Payload_Bit_Length, CSPRNG_Engine)
Return Target_Positions[]
End
Function Embed_Data_Into_Cover(Formatted_Payload_Bytes, Cover_Text, Stego_Key)
Begin
Payload_Binary ← Convert_Bytes_To_Binary(Formatted_Payload_Bytes)
Cover_Binary ← Convert_String_To_Binary(Cover_Text)
Target_Positions ← Generate_Bit_Positions(Length(Cover_Binary), Length(Payload_Binary), Stego_Key)
// Bitwise XOR Key Generation
XOR_Key_Binary ← ""
For i = 0 To Length(Payload_Binary) - 1 Do
If Cover_Binary[Target_Positions[i]] == Payload_Binary[i] Then
XOR_Key_Binary += '0'
Else
XOR_Key_Binary += '1'
EndIf
EndFor
Invisible_VS_String ← Encode_Binary_To_Variation_Selectors(XOR_Key_Binary)
Final_Stego_Object ← Invisible_VS_String + Cover_Text
Return Final_Stego_Object
End