Files
michaelschiemer/tests/debug/test-generator-polynomial-format.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.4 KiB
PHP

<?php
declare(strict_types=1);
require_once __DIR__ . '/../../vendor/autoload.php';
use App\Framework\QrCode\ErrorCorrection\ReedSolomonEncoder;
echo "=== Generator Polynomial Format Analysis ===\n\n";
$rs = new ReedSolomonEncoder();
$reflection = new ReflectionClass($rs);
// Check stored generator polynomial
$getGeneratorMethod = $reflection->getMethod('getGeneratorPolynomial');
$getGeneratorMethod->setAccessible(true);
$stored = $getGeneratorMethod->invoke($rs, 10);
echo "Stored generator polynomial (10 EC codewords):\n";
echo " [" . implode(', ', $stored) . "]\n";
echo " Length: " . count($stored) . " (expected: 11)\n";
echo " First coefficient: {$stored[0]}\n\n";
// The stored polynomial starts with 0, which is unusual
// In standard RS, generator should be monic (leading coefficient = 1)
// But maybe the stored format is different
// Try generating it dynamically
$generateMethod = $reflection->getMethod('generateGeneratorPolynomial');
$generateMethod->setAccessible(true);
$generated = $generateMethod->invoke($rs, 10);
echo "Dynamically generated:\n";
echo " [" . implode(', ', $generated) . "]\n";
echo " Length: " . count($generated) . " (expected: 11)\n";
echo " First coefficient: {$generated[0]}\n\n";
// The generated one starts with 1 (monic), which is correct
// But the stored one starts with 0
// Maybe we need to prepend 0 to the generated one, or remove the first 0 from stored
echo "=== Hypothesis ===\n";
echo "The stored polynomials might be in a different format.\n";
echo "Maybe we need to:\n";
echo " 1. Use stored polynomials as-is but skip first coefficient?\n";
echo " 2. Or convert stored [0, a, b, ...] to [1, a, b, ...]?\n";
echo " 3. Or use generated polynomials instead of stored ones?\n\n";
// Test: What if we use the generated polynomial instead?
echo "=== Test: Using Generated Polynomial ===\n";
// Modify the encode method to use generated polynomial
// But first, let's check if the stored polynomial is actually correct
// by comparing with known QR code specification values
$expected = [0, 251, 67, 46, 61, 118, 70, 64, 94, 32, 45];
echo "Expected from specification:\n";
echo " [" . implode(', ', $expected) . "]\n\n";
if ($stored === $expected) {
echo "✅ Stored polynomial matches specification!\n";
echo "\nSo the stored format [0, ...] is correct.\n";
echo "The problem must be in how we use it in the division algorithm.\n";
} else {
echo "❌ Stored polynomial doesn't match specification!\n";
}