github.com/cloudflare/circl@v1.5.0/sign/dilithium/mode2/internal/params_test.go (about)

     1  package internal
     2  
     3  import (
     4  	"testing"
     5  
     6  	common "github.com/cloudflare/circl/sign/internal/dilithium"
     7  )
     8  
     9  // Tests specific to the current mode
    10  
    11  func TestVectorDeriveUniformLeqEta(t *testing.T) {
    12  	var p common.Poly
    13  	var seed [64]byte
    14  	p2 := common.Poly{
    15  		8380415, 1, 8380415, 8380416, 1, 8380415, 8380416, 8380415,
    16  		8380415, 8380416, 8380416, 2, 2, 1, 8380415, 8380415,
    17  		8380416, 1, 8380416, 8380415, 2, 0, 0, 1, 1, 2, 2, 8380415,
    18  		0, 8380416, 8380416, 8380416, 8380415, 1, 2, 0, 1, 8380415,
    19  		0, 1, 8380415, 1, 0, 8380415, 2, 1, 2, 0, 1, 0, 8380416,
    20  		1, 8380416, 1, 0, 1, 1, 0, 1, 8380416, 0, 0, 8380416,
    21  		8380415, 8380416, 2, 0, 0, 8380415, 1, 1, 0, 0, 1, 8380415,
    22  		1, 8380416, 1, 8380415, 8380416, 8380416, 8380415, 0, 1,
    23  		8380415, 8380415, 1, 8380415, 0, 2, 2, 8380415, 1, 2,
    24  		8380415, 8380415, 0, 2, 2, 1, 8380415, 8380416, 0, 8380415,
    25  		2, 1, 8380415, 2, 2, 8380416, 8380416, 0, 8380416, 0, 2,
    26  		8380416, 1, 8380415, 8380416, 8380415, 1, 8380416, 8380416,
    27  		2, 2, 0, 0, 0, 8380415, 8380415, 2, 8380416, 2, 2, 8380415,
    28  		8380415, 2, 2, 2, 8380415, 1, 2, 1, 2, 8380415, 0, 2, 1,
    29  		8380415, 2, 8380415, 8380415, 8380416, 0, 8380416, 8380415,
    30  		8380415, 8380416, 8380416, 2, 8380416, 2, 0, 0, 1, 1, 1,
    31  		8380416, 0, 8380416, 8380416, 1, 1, 1, 0, 8380416, 2, 0,
    32  		8380415, 8380415, 0, 0, 2, 8380416, 1, 0, 0, 8380415,
    33  		8380415, 1, 0, 8380416, 1, 2, 8380415, 0, 8380416, 8380415,
    34  		1, 1, 0, 1, 8380416, 8380415, 1, 0, 0, 8380416, 1, 0, 2,
    35  		8380416, 2, 2, 0, 0, 1, 1, 2, 8380415, 2, 8380416, 8380416,
    36  		2, 1, 2, 8380416, 8380415, 8380415, 8380415, 0, 8380416,
    37  		1, 0, 2, 8380416, 2, 8380415, 8380415, 2, 2, 8380415,
    38  		8380416, 0, 8380415, 8380415, 0, 2, 8380415, 1, 8380415,
    39  		8380415, 1, 1, 8380416, 8380416,
    40  	}
    41  	for i := 0; i < 64; i++ {
    42  		seed[i] = byte(i)
    43  	}
    44  	PolyDeriveUniformLeqEta(&p, &seed, 30000)
    45  	p.Normalize()
    46  	if p != p2 {
    47  		t.Fatalf("%v != %v", p, p2)
    48  	}
    49  }
    50  
    51  func TestVectorDeriveUniformLeGamma1(t *testing.T) {
    52  	var p, p2 common.Poly
    53  	var seed [64]byte
    54  	p2 = common.Poly{
    55  		24652, 8360658, 8306, 8359852, 10689, 106730, 8321632,
    56  		8295173, 8263144, 8362203, 8270304, 86550, 8352484, 112252,
    57  		8326622, 8263346, 1209, 8357433, 8276262, 106912, 111719,
    58  		8266410, 8001, 8249719, 8298833, 108641, 127143, 74178,
    59  		8266405, 27781, 128456, 8359778, 8337159, 8336455, 8380097,
    60  		8339564, 8275392, 8298630, 8257822, 5932, 233, 8367273,
    61  		8335081, 8257869, 8350642, 8317253, 8256389, 8341263,
    62  		8360509, 8368380, 33767, 81445, 8265057, 8353702, 8270465,
    63  		61206, 8309816, 8281560, 8295763, 6244, 8353442, 8378970,
    64  		72579, 8351700, 8341053, 104835, 8344333, 8313546, 8373167,
    65  		61430, 8339993, 113603, 8254406, 8302777, 99473, 8342736,
    66  		54456, 65097, 8255826, 8329025, 23031, 8328165, 57608,
    67  		30426, 98210, 8264076, 8267955, 8351117, 22980, 8302860,
    68  		42373, 8349139, 6523, 8375937, 13127, 8270690, 40178, 105482,
    69  		74831, 8261990, 8306279, 5925, 8260573, 55220, 110952,
    70  		8273377, 8267217, 8275798, 124100, 119164, 8360113, 67060,
    71  		8351620, 8364798, 59495, 8362276, 8285770, 8313138, 37321,
    72  		8379867, 56428, 45742, 46037, 18715, 8330440, 99372, 8270907,
    73  		8341031, 49485, 63571, 111869, 8339624, 8311220, 8277176,
    74  		8357815, 60583, 8356010, 98423, 8360878, 84829, 8264301,
    75  		63134, 8321092, 8279722, 8352609, 8261763, 62169, 8317324,
    76  		122488, 8373120, 8337853, 8300028, 50829, 64411, 8330934,
    77  		8363377, 91994, 7023, 5142, 94655, 8335648, 28257, 129346,
    78  		68918, 14273, 27103, 8323037, 104538, 8307539, 55606, 94886,
    79  		8272263, 77952, 8314535, 9544, 8253819, 46445, 8267118,
    80  		85028, 8357851, 105779, 32474, 8256782, 89388, 8265113,
    81  		8291502, 48133, 57355, 60120, 8281124, 8346594, 8255737,
    82  		41780, 67374, 80423, 86222, 8334625, 97415, 8288685, 81515,
    83  		98856, 8300724, 36434, 89698, 4154, 21804, 70249, 102464,
    84  		101103, 8277794, 72647, 67640, 8323688, 61139, 91234, 74869,
    85  		8368270, 8367469, 8373445, 8249916, 86939, 8254257, 12306,
    86  		8270129, 48350, 8345018, 8364752, 8327455, 14568, 8252624,
    87  		62944, 32561, 8258436, 96011, 8331595, 33812, 8303001, 2233,
    88  		28847, 13235, 23003, 40644, 8279857, 8261616, 46409, 8369530,
    89  		112030, 97207, 8269039, 102924, 75641, 85486, 8358768,
    90  		65209, 92920, 34770,
    91  	}
    92  	for i := 0; i < 64; i++ {
    93  		seed[i] = byte(i)
    94  	}
    95  	PolyDeriveUniformLeGamma1(&p, &seed, 30000)
    96  	p.Normalize()
    97  	if p != p2 {
    98  		t.Fatalf("%v != %v", p, p2)
    99  	}
   100  }