github.com/cloudflare/circl@v1.5.0/sign/dilithium/mode3/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  		0, 0, 1, 8380413, 8380416, 8380416, 3, 0, 1, 8380415,
    16  		8380416, 8380414, 3, 3, 8380416, 2, 1, 1, 3, 3, 3, 2,
    17  		8380414, 2, 3, 8380415, 2, 3, 8380415, 2, 3, 1, 2, 2, 1,
    18  		8380416, 2, 8380414, 0, 3, 2, 8380414, 8380415, 8380415,
    19  		1, 8380413, 8380414, 3, 0, 8380416, 8380416, 4, 2, 4, 1,
    20  		8380414, 8380416, 3, 8380416, 4, 8380413, 8380413, 8380414,
    21  		1, 8380416, 0, 8380415, 8380413, 1, 4, 8380414, 2, 0,
    22  		8380413, 4, 0, 3, 4, 8380415, 8380416, 8380414, 3, 0, 1,
    23  		1, 8380416, 1, 8380414, 8380414, 3, 3, 8380415, 8380413,
    24  		8380413, 3, 3, 2, 8380414, 0, 0, 8380414, 2, 8380414, 0,
    25  		1, 8380415, 0, 0, 8380415, 3, 8380413, 3, 8380414, 8380415,
    26  		8380414, 4, 1, 4, 2, 8380415, 3, 4, 8380413, 1, 0, 0, 1,
    27  		3, 8380414, 8380413, 4, 0, 1, 8380414, 8380414, 8380416,
    28  		8380415, 8380415, 3, 8380413, 8380414, 0, 0, 4, 0, 8380415,
    29  		3, 0, 8380413, 0, 3, 2, 8380416, 3, 2, 4, 0, 0, 8380413,
    30  		8380415, 4, 3, 3, 1, 1, 2, 8380415, 8380414, 0, 0, 8380413,
    31  		0, 2, 8380415, 4, 0, 8380415, 1, 4, 1, 2, 4, 8380415, 3,
    32  		8380414, 4, 1, 8380413, 3, 0, 2, 8380415, 8380416, 4,
    33  		8380413, 0, 3, 0, 8380414, 1, 1, 8380415, 8380416, 8380414,
    34  		8380416, 8380413, 8380416, 8380413, 8380415, 3, 4, 8380415,
    35  		0, 8380413, 8380414, 2, 4, 1, 8380415, 8380413, 3, 3,
    36  		8380415, 1, 3, 2, 8380415, 1, 8380414, 0, 2, 0, 1, 1, 3,
    37  		0, 8380413, 0, 4, 8380413, 8380413, 8380413, 4, 1, 2,
    38  		8380415, 1, 3, 4, 3, 4, 4, 8380416, 0, 2, 1,
    39  	}
    40  	for i := 0; i < 64; i++ {
    41  		seed[i] = byte(i)
    42  	}
    43  	PolyDeriveUniformLeqEta(&p, &seed, 30000)
    44  	p.Normalize()
    45  	if p != p2 {
    46  		t.Fatalf("%v != %v", p, p2)
    47  	}
    48  }
    49  
    50  func TestVectorDeriveUniformLeGamma1(t *testing.T) {
    51  	var p, p2 common.Poly
    52  	var seed [64]byte
    53  	p2 = common.Poly{
    54  		8011853, 7949494, 172552, 263871, 8095275, 155369, 311506,
    55  		8076900, 8307558, 8139232, 8041607, 448815, 380634, 180526,
    56  		8165391, 101857, 8286792, 427645, 8098920, 7860396, 352757,
    57  		8179719, 7954627, 7898860, 28800, 8129086, 111121, 8115657,
    58  		8211418, 7943538, 259410, 7965184, 8232538, 7864584, 7991749,
    59  		23725, 393449, 8344363, 8041712, 196742, 8187277, 230211,
    60  		115522, 205750, 8332267, 8020968, 511882, 66518, 8377952,
    61  		283731, 276156, 488847, 218386, 24973, 7960226, 8019608,
    62  		8163770, 8099393, 8251752, 8055784, 438808, 408276, 245718,
    63  		90648, 8179442, 377149, 66371, 8067974, 8165213, 496174,
    64  		7959821, 8174846, 416247, 8334586, 8277522, 137692, 8260481,
    65  		45327, 8078022, 8223800, 8070188, 8291718, 156021, 516504,
    66  		8144827, 361012, 323861, 8315499, 8004848, 7906709, 7913063,
    67  		230858, 311998, 8280928, 8347571, 8236825, 120069, 412722,
    68  		476656, 372912, 8036734, 465145, 8275725, 8153834, 411759,
    69  		412681, 72836, 8378216, 8305773, 8162477, 8293183, 289061,
    70  		7900478, 8133091, 100678, 267462, 254283, 242941, 8009771,
    71  		364316, 217523, 8026537, 7899325, 7863708, 211663, 339314,
    72  		8133229, 8035753, 135557, 8245724, 7988629, 8042510, 8012465,
    73  		386933, 8351229, 88508, 274815, 8293482, 216047, 8232256,
    74  		8337777, 8305592, 7938394, 378619, 7942432, 7961498, 360341,
    75  		265269, 8346169, 514971, 8255059, 406815, 222421, 8344231,
    76  		464482, 94984, 8147964, 8242727, 8211462, 7945005, 8167987,
    77  		8290153, 8355124, 303031, 180689, 97653, 8032319, 263210,
    78  		684, 437628, 7983244, 359393, 8054335, 223796, 8014878,
    79  		8066876, 335829, 467349, 105150, 326057, 229928, 7934510,
    80  		26854, 8093051, 8162834, 8013975, 8122355, 44783, 7969925,
    81  		465863, 8299023, 8155688, 8256445, 7975782, 7892171, 8075999,
    82  		412728, 7858411, 480155, 7922893, 254722, 381253, 8307390,
    83  		8040031, 280413, 8089206, 7869244, 8050145, 8028110, 8020538,
    84  		8158686, 7875907, 7960483, 7998991, 8317674, 52939, 416219,
    85  		501681, 231283, 8151233, 8241847, 8224119, 454076, 8171231,
    86  		411693, 8324986, 447356, 400055, 490491, 477035, 8055459,
    87  		158775, 383762, 8167063, 8076788, 7956883, 309585, 111368,
    88  		8312360, 7992502, 8259793, 461240, 7937002, 8198300, 7862862,
    89  		302423, 437299, 420919, 8359979, 8191730, 7895992, 75500,
    90  		307359, 435102, 7873624, 457428,
    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  }