# SiliconSignature - Android App A complete native Android application for embedding and verifying SiliconSignature watermarks in images using Reed-Solomon error correction and LSB steganography. ## Features - **Sign Images**: Embed invisible watermarks into images with cryptographic integrity - **Verify Images**: Detect and verify watermarks, showing authenticity status - **History**: Track all signing and verification operations locally - **Pure Kotlin**: No external dependencies beyond Android SDK - **Fully Offline**: Works without internet connectivity - **Material Design 3**: Dark theme with amber (#F5A623) accent ## Technical Architecture ### Reed-Solomon Implementation (`ReedSolomon.kt`) - Pure Kotlin implementation over GF(2^8) - Primitive polynomial: 0x11d - Error correction: 32 symbols (corrects up to 16 errors) - Full Berlekamp-Massey decoder with Forney algorithm ### Watermark Protocol ``` JSON payload -> UTF-8 -> RS encode(nsym=32) -> 4-byte BE length -> 5x repeat -> LSB embed RGB ``` ### LSB Steganography (`WatermarkEngine.kt`) - Embeds in all RGB channels (R0, G0, B0, R1, G1, B1...) - Bit position 0 (LSB) - Operation: `pixel = (pixel & 0xFE) | bit` - 5x repetition for redundancy ## Project Structure ``` android-app/ ├── app/ │ ├── build.gradle.kts # Module build config │ └── src/main/ │ ├── AndroidManifest.xml # Permissions │ ├── java/com/agnuxo1/siliconsignature/ │ │ ├── MainActivity.kt # Bottom nav host │ │ ├── SignFragment.kt # Sign images │ │ ├── VerifyFragment.kt # Verify images │ │ ├── HistoryFragment.kt # View history │ │ ├── HistoryAdapter.kt # RecyclerView adapter │ │ ├── HistoryManager.kt # SharedPreferences storage │ │ ├── ReedSolomon.kt # RS codec │ │ ├── WatermarkEngine.kt # LSB embed/extract │ │ └── SignaturePayload.kt # Data model │ └── res/ │ ├── layout/ # All layout XML files │ ├── values/ │ │ ├── themes.xml # Dark theme + amber │ │ ├── colors.xml # Color definitions │ │ └── strings.xml # App strings │ ├── menu/ │ │ └── bottom_nav_menu.xml │ └── color/ │ └── bottom_nav_color.xml ├── build.gradle.kts # Project build config ├── settings.gradle.kts # Project settings └── gradle.properties # Gradle config ``` ## Build Instructions ### Prerequisites - Android Studio Hedgehog (2023.1.1) or later - JDK 17 - Android SDK with API 34 ### Build Steps 1. Open the `android-app` directory in Android Studio 2. Let Gradle sync complete 3. Connect an Android device (minSdk 24) or start an emulator 4. Click **Run** (Shift+F10) or build an APK: ```bash # Build debug APK ./gradlew :app:assembleDebug # Build release APK ./gradlew :app:assembleRelease # Install on connected device ./gradlew :app:installDebug ``` ### APK Location - Debug: `app/build/outputs/apk/debug/app-debug.apk` - Release: `app/build/outputs/apk/release/app-release-unsigned.apk` ## Signing and Verifying ### To Sign an Image 1. Open the **Sign** tab 2. (Optional) Enter a Creator ID 3. Tap **Select Image from Gallery** 4. Tap **Sign Image** - this computes SHA-256, finds a nonce via CPU PoW, and embeds the watermark 5. Tap **Save to Gallery** to export the signed PNG ### To Verify an Image 1. Open the **Verify** tab 2. Tap **Select Image to Verify** 3. The app automatically extracts and verifies any watermark 4. Result is shown: Green (Authentic), Red (Tampered), or Gray (Not Signed) ## Permissions | Permission | Purpose | |-----------|---------| | `READ_EXTERNAL_STORAGE` | Read images from gallery (API < 33) | | `READ_MEDIA_IMAGES` | Read images from gallery (API 33+) | | `WRITE_EXTERNAL_STORAGE` | Save signed images (API < 30) | | `CAMERA` | Future camera capture support | ## Dependencies | Dependency | Version | |-----------|---------| | Kotlin | 1.9.22 | | Android Gradle Plugin | 8.2.2 | | minSdk | 24 | | targetSdk | 34 | | Material Components | 1.11.0 | | AndroidX Core | 1.12.0 | | AndroidX AppCompat | 1.6.1 | | Lifecycle ViewModel | 2.7.0 | | Activity KTX | 1.8.2 | No external cryptography or image processing libraries - everything is implemented in pure Kotlin using Android SDK APIs. ## Interoperability Images signed by this Android app can be verified by any other SiliconSignature implementation (Web, Go, Rust, Python) and vice versa, as they all use the same binary format: - Same GF(2^8) field with polynomial 0x11d - Same Reed-Solomon generator - Same LSB embedding order (RGB channels) - Same 5x repetition scheme