1
1
spogulis no https://github.com/henrydcase/pqc.git synced 2024-11-22 07:35:38 +00:00

Add test for Z packing/unpacking

Šī revīzija ir iekļauta:
Henry Case 2023-01-09 11:11:04 +00:00
vecāks c84c6aa8b4
revīzija 5af68581f8

Parādīt failu

@ -6,6 +6,7 @@
#include <random>
extern "C" {
#include "sign/dilithium/dilithium2/clean/reduce.h"
#include "sign/dilithium/dilithium2/clean/poly.h"
#include "sign/dilithium/dilithium2/clean/params.h"
}
@ -93,3 +94,18 @@ TEST(Dilithium, MontREDC) {
ASSERT_EQ(PQCLEAN_DILITHIUM2_CLEAN_montgomery_reduce(3347556), 2070606);
ASSERT_EQ(PQCLEAN_DILITHIUM2_CLEAN_montgomery_reduce(-2581810), 910169);
}
TEST(Dilithium, PolyZ) {
std::random_device rd;
std::uniform_int_distribution<int32_t> dist_z(-((1<<17)-1), 1<<17);
uint8_t out[576];
poly p1, p2;
for (auto &x : p1.coeffs) { x = dist_z(rd); }
PQCLEAN_DILITHIUM2_CLEAN_polyz_pack(out, &p1);
PQCLEAN_DILITHIUM2_CLEAN_polyz_unpack(&p2, out);
for (size_t j=0; j<256; j++) {
ASSERT_EQ(p1.coeffs[j], p2.coeffs[j]);
}
}