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