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.
97 lines
2.3 KiB
PHP
97 lines
2.3 KiB
PHP
<?php
|
||
|
||
declare(strict_types=1);
|
||
|
||
echo "=== Syndrome Calculation Test ===\n\n";
|
||
|
||
// Initialize GF(256)
|
||
$gfLog = array_fill(0, 256, 0);
|
||
$gfExp = array_fill(0, 512, 0);
|
||
|
||
$x = 1;
|
||
for ($i = 0; $i < 255; $i++) {
|
||
$gfExp[$i] = $x;
|
||
$gfLog[$x] = $i;
|
||
$x <<= 1;
|
||
if ($x & 0x100) {
|
||
$x ^= 0x11d;
|
||
}
|
||
}
|
||
|
||
for ($i = 255; $i < 512; $i++) {
|
||
$gfExp[$i] = $gfExp[$i - 255];
|
||
}
|
||
|
||
function gfMult(array $gfExp, array $gfLog, int $a, int $b): int
|
||
{
|
||
if ($a === 0 || $b === 0) return 0;
|
||
return $gfExp[$gfLog[$a] + $gfLog[$b]];
|
||
}
|
||
|
||
// Test: Create a simple RS code manually
|
||
// For RS(7, 4): 4 data codewords, 3 EC codewords
|
||
$data = [1, 2, 3, 4];
|
||
$ecCodewords = 3;
|
||
|
||
// Generator polynomial for degree 3: g(x) = (x-α^0)(x-α^1)(x-α^2)
|
||
// = x^3 + (α^0+α^1+α^2)x^2 + (α^0*α^1 + α^0*α^2 + α^1*α^2)x + (α^0*α^1*α^2)
|
||
// In GF(256): α^0=1, α^1=2, α^2=4
|
||
// g(x) = x^3 + 7x^2 + 14x + 8
|
||
|
||
$generator = [1, 7, 14, 8]; // Monic polynomial
|
||
|
||
// Manual encoding
|
||
$msg = array_merge($data, array_fill(0, $ecCodewords, 0));
|
||
|
||
for ($i = 0; $i < count($data); $i++) {
|
||
$lead = $msg[$i];
|
||
if ($lead !== 0) {
|
||
$msg[$i] = 0;
|
||
for ($j = 1; $j < count($generator); $j++) {
|
||
$msg[$i + $j] ^= gfMult($gfExp, $gfLog, $generator[$j], $lead);
|
||
}
|
||
}
|
||
}
|
||
|
||
$ec = array_slice($msg, count($data));
|
||
echo "Data: " . implode(', ', $data) . "\n";
|
||
echo "EC: " . implode(', ', $ec) . "\n";
|
||
echo "Full: " . implode(', ', array_merge($data, $ec)) . "\n\n";
|
||
|
||
// Calculate syndromes
|
||
echo "Calculating syndromes:\n";
|
||
$full = array_merge($data, $ec);
|
||
$syndromes = [];
|
||
|
||
for ($i = 0; $i < $ecCodewords; $i++) {
|
||
$alphaPower = $gfExp[$i]; // α^i
|
||
$syndrome = 0;
|
||
$power = 1; // (α^i)^0 = 1
|
||
|
||
for ($j = 0; $j < count($full); $j++) {
|
||
$syndrome ^= gfMult($gfExp, $gfLog, $full[$j], $power);
|
||
$power = gfMult($gfExp, $gfLog, $power, $alphaPower);
|
||
}
|
||
|
||
$syndromes[$i] = $syndrome;
|
||
echo " S[{$i}] = {$syndrome}\n";
|
||
}
|
||
|
||
$allZero = true;
|
||
foreach ($syndromes as $s) {
|
||
if ($s !== 0) {
|
||
$allZero = false;
|
||
break;
|
||
}
|
||
}
|
||
|
||
if ($allZero) {
|
||
echo "\n✅ All syndromes are zero - RS encoding is CORRECT!\n";
|
||
echo "\nThis means our algorithm is correct.\n";
|
||
echo "The problem might be with the generator polynomial format.\n";
|
||
} else {
|
||
echo "\n❌ Syndromes are not all zero - RS encoding is WRONG!\n";
|
||
}
|
||
|
||
|