refactor(deployment): Remove WireGuard VPN dependency and restore public service access
Remove WireGuard integration from production deployment to simplify infrastructure: - Remove docker-compose-direct-access.yml (VPN-bound services) - Remove VPN-only middlewares from Grafana, Prometheus, Portainer - Remove WireGuard middleware definitions from Traefik - Remove WireGuard IPs (10.8.0.0/24) from Traefik forwarded headers All monitoring services now publicly accessible via subdomains: - grafana.michaelschiemer.de (with Grafana native auth) - prometheus.michaelschiemer.de (with Basic Auth) - portainer.michaelschiemer.de (with Portainer native auth) All services use Let's Encrypt SSL certificates via Traefik.
This commit is contained in:
99
tests/debug/test-polynomial-division.php
Normal file
99
tests/debug/test-polynomial-division.php
Normal file
@@ -0,0 +1,99 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
require_once __DIR__ . '/../../vendor/autoload.php';
|
||||
|
||||
use App\Framework\QrCode\ErrorCorrection\ReedSolomonEncoder;
|
||||
|
||||
echo "=== Polynomial Division Step-by-Step ===\n\n";
|
||||
|
||||
// Test with simple data to trace the algorithm
|
||||
$data = [1, 2, 3];
|
||||
$ecCodewords = 3;
|
||||
|
||||
$rs = new ReedSolomonEncoder();
|
||||
$reflection = new ReflectionClass($rs);
|
||||
|
||||
// Get generator polynomial
|
||||
$getGeneratorMethod = $reflection->getMethod('getGeneratorPolynomial');
|
||||
$getGeneratorMethod->setAccessible(true);
|
||||
$generator = $getGeneratorMethod->invoke($rs, $ecCodewords);
|
||||
|
||||
echo "Data: " . implode(', ', $data) . "\n";
|
||||
echo "EC codewords needed: {$ecCodewords}\n";
|
||||
echo "Generator polynomial (degree {$ecCodewords}): " . implode(', ', $generator) . "\n\n";
|
||||
|
||||
// Manually trace the algorithm
|
||||
echo "=== Algorithm Trace ===\n";
|
||||
|
||||
// Step 1: Create message polynomial
|
||||
$messagePoly = array_merge($data, array_fill(0, $ecCodewords, 0));
|
||||
echo "Step 1 - Message polynomial (data + zeros):\n";
|
||||
echo " [" . implode(', ', $messagePoly) . "]\n\n";
|
||||
|
||||
// Step 2: Polynomial division
|
||||
echo "Step 2 - Polynomial division:\n";
|
||||
|
||||
$gfMultiplyMethod = $reflection->getMethod('gfMultiply');
|
||||
$gfMultiplyMethod->setAccessible(true);
|
||||
|
||||
$traceMessagePoly = $messagePoly;
|
||||
|
||||
for ($i = 0; $i < count($data); $i++) {
|
||||
$coefficient = $traceMessagePoly[$i];
|
||||
|
||||
if ($coefficient !== 0) {
|
||||
echo " Iteration {$i}: coefficient = {$coefficient}\n";
|
||||
echo " Before: [" . implode(', ', $traceMessagePoly) . "]\n";
|
||||
|
||||
for ($j = 0; $j < count($generator); $j++) {
|
||||
$multiplied = $gfMultiplyMethod->invoke($rs, $generator[$j], $coefficient);
|
||||
$oldValue = $traceMessagePoly[$i + $j];
|
||||
$traceMessagePoly[$i + $j] ^= $multiplied;
|
||||
$newValue = $traceMessagePoly[$i + $j];
|
||||
|
||||
if ($oldValue !== $newValue) {
|
||||
echo " [{$i}+{$j}] = {$oldValue} XOR {$multiplied} = {$newValue}\n";
|
||||
}
|
||||
}
|
||||
|
||||
echo " After: [" . implode(', ', $traceMessagePoly) . "]\n\n";
|
||||
} else {
|
||||
echo " Iteration {$i}: coefficient = 0 (skip)\n\n";
|
||||
}
|
||||
}
|
||||
|
||||
// Step 3: Extract EC codewords
|
||||
$ec = array_slice($traceMessagePoly, count($data));
|
||||
echo "Step 3 - EC codewords (last {$ecCodewords} coefficients):\n";
|
||||
echo " [" . implode(', ', $ec) . "]\n\n";
|
||||
|
||||
// Verify with actual implementation
|
||||
$actualEC = $rs->encode($data, $ecCodewords);
|
||||
echo "Actual EC codewords from implementation:\n";
|
||||
echo " [" . implode(', ', $actualEC) . "]\n\n";
|
||||
|
||||
if ($ec === $actualEC) {
|
||||
echo "✅ Traced algorithm matches implementation!\n";
|
||||
} else {
|
||||
echo "❌ Traced algorithm doesn't match implementation!\n";
|
||||
echo "Differences:\n";
|
||||
for ($i = 0; $i < min(count($ec), count($actualEC)); $i++) {
|
||||
if ($ec[$i] !== $actualEC[$i]) {
|
||||
echo " Position {$i}: traced={$ec[$i]}, actual={$actualEC[$i]}\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Test with our actual QR code data
|
||||
echo "\n=== Test with QR Code Data ===\n";
|
||||
$qrData = [64, 180, 132, 84, 196, 196, 242, 5, 116, 245, 36, 196, 64, 236, 17, 236];
|
||||
$qrEC = $rs->encode($qrData, 10);
|
||||
|
||||
echo "QR data codewords (16):\n";
|
||||
echo " " . implode(', ', $qrData) . "\n\n";
|
||||
echo "QR EC codewords (10):\n";
|
||||
echo " " . implode(', ', $qrEC) . "\n\n";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user