mirror of
https://github.com/cloudflare/redoctober.git
synced 2026-01-08 15:21:50 +00:00
- Instead of using GF(2^127-1) as one of many options, move to GF(2^128) exclusively. - Don't clear the first two bits of every secret key.
45 lines
759 B
Go
45 lines
759 B
Go
package msp
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestRecovery(t *testing.T) {
|
|
// Generate the matrix.
|
|
height, width := 10, 10
|
|
M := Matrix(make([]Row, height))
|
|
|
|
for i := 0; i < height; i++ {
|
|
M[i] = NewRow(width)
|
|
|
|
for j := 0; j < width; j++ {
|
|
M[i][j][0] = byte(i + 1)
|
|
M[i][j] = M[i][j].Exp(j)
|
|
}
|
|
}
|
|
|
|
// Find the recovery vector.
|
|
r, ok := M.Recovery()
|
|
if !ok {
|
|
t.Fatalf("Failed to find the recovery vector!")
|
|
}
|
|
|
|
// Find the output vector.
|
|
out := NewRow(width)
|
|
|
|
for i := 0; i < height; i++ {
|
|
out.AddM(M[i].Mul(r[i]))
|
|
}
|
|
|
|
// Check that it is the target vector.
|
|
if !out[0].IsOne() {
|
|
t.Fatalf("Output is not the target vector!")
|
|
}
|
|
|
|
for i := 1; i < width; i++ {
|
|
if !out[i].IsZero() {
|
|
t.Fatalf("Output is not the target vector!")
|
|
}
|
|
}
|
|
}
|