1
1
Este cometimento está contido em:
Henry Case 2021-03-10 15:55:06 +00:00
ascendente 8749bcb1a7
cometimento 070a06bf62
2 ficheiros modificados com 47 adições e 3 eliminações

Ver ficheiro

@ -9,6 +9,8 @@ set(CMAKE_VERBOSE_MAKEFILE ON)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "~/.cmake/Modules")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "3rd/cmake-modules")
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
string(TOLOWER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_LOWER)
@ -301,6 +303,14 @@ define_kem_alg(
lightsaber_clean
PQCLEAN_LIGHTSABER_CLEAN "${SRC_CLEAN_LIGHTSABER}" "${INC_CLEAN_LIGHTSABER}")
#function(define_frodo_src path)
#endif()
# -rw-r--r-- 1 kris kris 13783 Mar 1 12:35 kem.c
# -rw-r--r-- 1 kris kris 3343 Mar 1 12:35 matrix_shake.c
# -rw-r--r-- 1 kris kris 1426 Mar 1 12:35 noise.c
# -rw-r--r-- 1 kris kris 9202 Mar 1 12:35 util.c
# AVX2 targets
if(${ARCH} STREQUAL "ARCH_x86_64")

Ver ficheiro

@ -1,6 +1,8 @@
#include "params.h"
#include "rounding.h"
#include <stdint.h>
#include <stdio.h>
#include <assert.h>
/*************************************************
* Name: PQCLEAN_DILITHIUM2_CLEAN_power2round
@ -37,14 +39,46 @@ int32_t PQCLEAN_DILITHIUM2_CLEAN_power2round(int32_t *a0, int32_t a) {
* Returns a1.
**************************************************/
int32_t PQCLEAN_DILITHIUM2_CLEAN_decompose(int32_t *a0, int32_t a) {
int32_t a1;
int32_t a1 = 0;
uint64_t r;
int32_t r0, r1;
assert(a>0); assert(a<Q);
// mod ALPHA
static const uint32_t u = 360800;
r = ((uint64_t)a)*u;
r >>= 36;
r *= 2 * GAMMA2;
r = a - r;
if (r>(2*GAMMA2)) {
r -= 2*GAMMA2;
}
r1 = ((int32_t)r)*2*GAMMA2;
// centrize
if (r > GAMMA2) {
*a0 = (int32_t)r - 2*GAMMA2;
} else {
*a0 = r;
}
// CASE: r-r0 = q-1 => r1=0, r0 = r0-1
// OLD
a1 = (a + 127) >> 7;
a1 = (a1 * 11275 + (1 << 23)) >> 24;
a1 ^= ((43 - a1) >> 31) & a1;
*a0 = a - a1 * 2 * GAMMA2;
*a0 -= (((Q - 1) / 2 - *a0) >> 31) & Q;
// TODO: ten sam trick co w barrett
int32_t a2 = ((uint64_t)a-*a0)/(2*GAMMA2);
//*a0 = a - a1 * 2 * GAMMA2;
//*a0 -= (((Q - 1) / 2 - *a0) >> 31) & Q;
printf("(%d, %d,\n)", a1, a2);
return a1;
}