Files
michaelschiemer/tests/debug/test-generator-polynomial.php
Michael Schiemer 95147ff23e 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.
2025-11-05 12:48:25 +01:00

69 lines
2.3 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
declare(strict_types=1);
require_once __DIR__ . '/../../vendor/autoload.php';
use App\Framework\QrCode\ErrorCorrection\ReedSolomonEncoder;
echo "=== Generator Polynomial Verification ===\n\n";
$rs = new ReedSolomonEncoder();
$reflection = new ReflectionClass($rs);
// Get generator polynomial for 10 EC codewords
$getGeneratorMethod = $reflection->getMethod('getGeneratorPolynomial');
$getGeneratorMethod->setAccessible(true);
$generator = $getGeneratorMethod->invoke($rs, 10);
echo "Current generator polynomial (10 EC codewords):\n";
echo " [" . implode(', ', $generator) . "]\n\n";
// Expected from QR code specification
$expected = [0, 251, 67, 46, 61, 118, 70, 64, 94, 32, 45];
echo "Expected generator polynomial:\n";
echo " [" . implode(', ', $expected) . "]\n\n";
if ($generator === $expected) {
echo "✅ Generator polynomial matches!\n\n";
} else {
echo "❌ Generator polynomial doesn't match!\n";
echo "Differences:\n";
for ($i = 0; $i < min(count($generator), count($expected)); $i++) {
if ($generator[$i] !== $expected[$i]) {
echo " Coefficient {$i}: got {$generator[$i]}, expected {$expected[$i]}\n";
}
}
echo "\n";
}
// Test: Generate polynomial dynamically
echo "=== Testing Dynamic Generation ===\n";
$generateMethod = $reflection->getMethod('generateGeneratorPolynomial');
$generateMethod->setAccessible(true);
$generated = $generateMethod->invoke($rs, 10);
echo "Dynamically generated:\n";
echo " [" . implode(', ', $generated) . "]\n\n";
if ($generated === $expected) {
echo "✅ Dynamic generation matches expected!\n";
} else {
echo "❌ Dynamic generation doesn't match!\n";
echo "This might be the problem - the generator polynomial is wrong.\n";
}
// Check if the issue is with the leading coefficient
// In QR codes, the generator polynomial should be monic (leading coefficient = 1)
// But our polynomials start with 0
echo "\n=== Generator Polynomial Format ===\n";
echo "Note: In our implementation, generator polynomials start with [0, ...]\n";
echo "This might be correct if we're using a different representation.\n";
echo "But let's check if the actual polynomial is correct.\n\n";
// The generator polynomial should be: g(x) = (x - α^0)(x - α^1)...(x - α^9)
// When expanded, this should give us the expected coefficients