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