Debian Codegraph @

msp/matrix_test.go

raw symbols SCIP
1 package msp
2
3 import (
4 "testing"
5 )
6
7 func TestRecovery(t *testing.T) {
8 // Generate the matrix.
9 height, width := 10, 10
10 M := Matrix(make([]Row, height))
11
12 for i := 0; i < height; i++ {
13 M[i] = NewRow(width)
14
15 for j := 0; j < width; j++ {
16 M[i][j][0] = byte(i + 1)
17 M[i][j] = M[i][j].Exp(j)
18 }
19 }
20
21 // Find the recovery vector.
22 r, ok := M.Recovery()
23 if !ok {
24 t.Fatalf("Failed to find the recovery vector!")
25 }
26
27 // Find the output vector.
28 out := NewRow(width)
29
30 for i := 0; i < height; i++ {
31 out.AddM(M[i].Mul(r[i]))
32 }
33
34 // Check that it is the target vector.
35 if !out[0].IsOne() {
36 t.Fatalf("Output is not the target vector!")
37 }
38
39 for i := 1; i < width; i++ {
40 if !out[i].IsZero() {
41 t.Fatalf("Output is not the target vector!")
42 }
43 }
44 }