fix(zkp-hamiltonian): ARM64 build fixes and RPCD CLI flag corrections

- Add #ifndef guard for ZKP_MAX_N in zkp_types.h to allow command-line override
- Copy OpenWrt Makefile to package root for proper feed detection
- Fix RPCD luci.zkp CLI flags: -r for ratio, -o for output prefix
- Add temp directory handling for keygen file generation

Tested on MochaBin router:
- zkp_keygen: generates graph + key pair
- zkp_prover: creates NIZK proof
- zkp_verifier: validates proof → ACCEPT

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
CyberMind-FR 2026-02-24 10:50:25 +01:00
parent a5fc33c8bc
commit 4a972ab0ae
7 changed files with 180 additions and 3 deletions

View File

@ -3239,3 +3239,36 @@ git checkout HEAD -- index.html
- **Files:**
- `luci-app-metablogizer/root/usr/libexec/rpcd/luci.metablogizer`
- **Commit:** `ec8e96a7 fix(metablogizer): Auto-sync mitmproxy routes on HAProxy reload`
42. **LuCI ZKP Dashboard (2026-02-24)**
- Created `luci-app-zkp` package for ZKP Hamiltonian cryptographic proofs.
- **Dashboard Features:**
- Status display: library version, saved keys count, storage paths
- Key generation: node count (4-50), edge density selector
- Prove/Verify workflow with visual ACCEPT/REJECT results
- Keys table with Prove, Verify, Delete actions
- KISS theme with dark mode support
- **RPCD Methods:** status, keygen, prove, verify, list_keys, delete_key, get_graph
- **Menu Location:** Status > ZKP Cryptography
- Note: Requires `zkp-hamiltonian` CLI tools to be built for ARM64
- **Files:**
- `luci-app-zkp/htdocs/luci-static/resources/view/zkp/overview.js`
- `luci-app-zkp/root/usr/libexec/rpcd/luci.zkp`
- **Commit:** `b60d7fd0 feat(luci-app-zkp): Add ZKP Hamiltonian cryptographic dashboard`
43. **ZKP Hamiltonian ARM64 Build & Deployment (2026-02-24)**
- Built `zkp-hamiltonian` package for ARM64 (aarch64_cortex-a72) using full OpenWrt toolchain.
- **Build Notes:**
- SDK lacks target OpenSSL headers; must use full toolchain in `secubox-tools/openwrt/`
- Fixed `ZKP_MAX_N` macro redefinition by adding `#ifndef` guard in `zkp_types.h`
- Fixed RPCD script CLI flags: `-r` for ratio (not `-d`), `-o` for output prefix
- **Deployed CLI Tools:**
- `zkp_keygen` - 75KB binary
- `zkp_prover` - 76KB binary
- `zkp_verifier` - 75KB binary
- **Verification:** Full workflow tested on router (keygen → prove → verify → ACCEPT)
- **Files:**
- `zkp-hamiltonian/Makefile` (moved from openwrt/ subdirectory)
- `zkp-hamiltonian/include/zkp_types.h` (ZKP_MAX_N guard)
- `luci-app-zkp/root/usr/libexec/rpcd/luci.zkp` (CLI flag fixes)

View File

@ -866,6 +866,12 @@ _Last updated: 2026-02-24 (Service Stability Fixes)_
### Just Completed (2026-02-24)
- **LuCI ZKP Dashboard** — DONE (2026-02-24)
- Web UI for ZKP Hamiltonian cryptographic proofs
- Features: keygen, prove, verify, keys management
- KISS theme with dark mode
- Commit: b60d7fd0
- **MetaBlogizer Upload Workflow Fix** — DONE (2026-02-24)
- Sites now work immediately after upload without unpublish + expose cycle
- Root cause: mitmproxy never received reload signal after route creation

View File

@ -417,7 +417,9 @@
"Bash(./zkp_verifier:*)",
"Bash(printf:*)",
"Bash(dd:*)",
"Bash(gh release create:*)"
"Bash(gh release create:*)",
"Bash(# Check if OpenWrt toolchain is available ls -la /home/reepost/CyberMindStudio/secubox-openwrt/secubox-tools/openwrt/)",
"Bash(# Create symlink in SDK feeds cd /home/reepost/CyberMindStudio/secubox-openwrt/secubox-tools/sdk ln -sf ../local-feed/zkp-hamiltonian/openwrt feeds/local/zkp-hamiltonian || true ls -la feeds/local/)"
]
}
}

View File

@ -140,10 +140,22 @@ method_keygen() {
return
fi
# Create temp directory for generation
local tmpdir="/tmp/zkp_gen_$$"
mkdir -p "$tmpdir"
local prefix="$tmpdir/$name"
local output
output=$(zkp_keygen -n "$nodes" -d "$density" -g "$graphfile" -k "$keyfile" 2>&1)
output=$(zkp_keygen -n "$nodes" -r "$density" -o "$prefix" 2>&1)
local rc=$?
# Move generated files to proper locations
if [ $rc -eq 0 ] && [ -f "${prefix}.graph" ] && [ -f "${prefix}.key" ]; then
mv "${prefix}.graph" "$graphfile"
mv "${prefix}.key" "$keyfile"
fi
rm -rf "$tmpdir"
if [ $rc -eq 0 ] && [ -f "$graphfile" ] && [ -f "$keyfile" ]; then
local graph_size=$(stat -c %s "$graphfile")
local key_size=$(stat -c %s "$keyfile")
@ -201,7 +213,7 @@ method_prove() {
fi
local output
output=$(zkp_prover -g "$graphfile" -k "$keyfile" -p "$prooffile" 2>&1)
output=$(zkp_prover -g "$graphfile" -k "$keyfile" -o "$prooffile" 2>&1)
local rc=$?
if [ $rc -eq 0 ] && [ -f "$prooffile" ]; then

View File

@ -0,0 +1,61 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (C) 2026 CyberMind.FR / SecuBox
#
# OpenWrt package for ZKP Hamiltonian library
include $(TOPDIR)/rules.mk
PKG_NAME:=zkp-hamiltonian
PKG_VERSION:=1.0.0
PKG_RELEASE:=1
PKG_LICENSE:=GPL-2.0-or-later
PKG_MAINTAINER:=SecuBox <contact@secubox.fr>
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
PKG_BUILD_PARALLEL:=1
include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/cmake.mk
define Package/zkp-hamiltonian
SECTION:=utils
CATEGORY:=Utilities
SUBMENU:=Encryption
TITLE:=Zero-Knowledge Proof Hamiltonian Library
DEPENDS:=+libopenssl
URL:=https://github.com/gkerma/secubox-openwrt
endef
define Package/zkp-hamiltonian/description
Zero-Knowledge Proof library based on the Hamiltonian Cycle problem.
Implements the Blum 1986 protocol with Fiat-Shamir NIZK transformation.
Uses SHA3-256 for commitments and provides CLI tools for proof generation
and verification.
endef
CMAKE_OPTIONS += \
-DOPENWRT_BUILD=ON \
-DBUILD_TESTS=OFF \
-DBUILD_TOOLS=ON \
-DBUILD_SHARED_LIBS=OFF \
-DUSE_LIBSODIUM=OFF \
-DZKP_MAX_N=50
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
$(CP) $(CURDIR)/src $(PKG_BUILD_DIR)/
$(CP) $(CURDIR)/include $(PKG_BUILD_DIR)/
$(CP) $(CURDIR)/tools $(PKG_BUILD_DIR)/
$(CP) $(CURDIR)/CMakeLists.txt $(PKG_BUILD_DIR)/
endef
define Package/zkp-hamiltonian/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/zkp_keygen $(1)/usr/bin/
$(INSTALL_BIN) $(PKG_BUILD_DIR)/zkp_prover $(1)/usr/bin/
$(INSTALL_BIN) $(PKG_BUILD_DIR)/zkp_verifier $(1)/usr/bin/
$(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_BUILD_DIR)/libzkp_hamiltonian.a $(1)/usr/lib/
endef
$(eval $(call BuildPackage,zkp-hamiltonian))

View File

@ -15,7 +15,9 @@
#include <stddef.h>
/* Protocol constants */
#ifndef ZKP_MAX_N
#define ZKP_MAX_N 128
#endif
#define ZKP_NONCE_SIZE 32
#define ZKP_HASH_SIZE 32
#define ZKP_VERSION 0x01

View File

@ -0,0 +1,61 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (C) 2026 CyberMind.FR / SecuBox
#
# OpenWrt package for ZKP Hamiltonian library
include $(TOPDIR)/rules.mk
PKG_NAME:=zkp-hamiltonian
PKG_VERSION:=1.0.0
PKG_RELEASE:=1
PKG_LICENSE:=GPL-2.0-or-later
PKG_MAINTAINER:=SecuBox <contact@secubox.fr>
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
PKG_BUILD_PARALLEL:=1
include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/cmake.mk
define Package/zkp-hamiltonian
SECTION:=utils
CATEGORY:=Utilities
SUBMENU:=Encryption
TITLE:=Zero-Knowledge Proof Hamiltonian Library
DEPENDS:=+libopenssl
URL:=https://github.com/gkerma/secubox-openwrt
endef
define Package/zkp-hamiltonian/description
Zero-Knowledge Proof library based on the Hamiltonian Cycle problem.
Implements the Blum 1986 protocol with Fiat-Shamir NIZK transformation.
Uses SHA3-256 for commitments and provides CLI tools for proof generation
and verification.
endef
CMAKE_OPTIONS += \
-DOPENWRT_BUILD=ON \
-DBUILD_TESTS=OFF \
-DBUILD_TOOLS=ON \
-DBUILD_SHARED_LIBS=OFF \
-DUSE_LIBSODIUM=OFF \
-DZKP_MAX_N=50
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
$(CP) ../src $(PKG_BUILD_DIR)/
$(CP) ../include $(PKG_BUILD_DIR)/
$(CP) ../tools $(PKG_BUILD_DIR)/
$(CP) ../CMakeLists.txt $(PKG_BUILD_DIR)/
endef
define Package/zkp-hamiltonian/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/zkp_keygen $(1)/usr/bin/
$(INSTALL_BIN) $(PKG_BUILD_DIR)/zkp_prover $(1)/usr/bin/
$(INSTALL_BIN) $(PKG_BUILD_DIR)/zkp_verifier $(1)/usr/bin/
$(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_BUILD_DIR)/libzkp_hamiltonian.a $(1)/usr/lib/
endef
$(eval $(call BuildPackage,zkp-hamiltonian))