mirror of
https://github.com/henrydcase/pqc.git
synced 2024-11-24 08:21:39 +00:00
WIP
This commit is contained in:
parent
150f905b41
commit
e3134509e7
@ -6,7 +6,7 @@ include(ExternalProject)
|
|||||||
set(CMAKE_CXX_STANDARD 20)
|
set(CMAKE_CXX_STANDARD 20)
|
||||||
set(CMAKE_C_STANDARD 99)
|
set(CMAKE_C_STANDARD 99)
|
||||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||||
|
set(CMAKE_BUILD_TYPE "debug")
|
||||||
enable_language(C)
|
enable_language(C)
|
||||||
enable_language(CXX)
|
enable_language(CXX)
|
||||||
enable_language(ASM)
|
enable_language(ASM)
|
||||||
@ -137,9 +137,9 @@ endif()
|
|||||||
include(.cmake/common.mk)
|
include(.cmake/common.mk)
|
||||||
|
|
||||||
# Control Debug/Release mode
|
# Control Debug/Release mode
|
||||||
if(CMAKE_BUILD_TYPE_LOWER STREQUAL "debug")
|
#if(CMAKE_BUILD_TYPE_LOWER STREQUAL "debug")
|
||||||
string(APPEND PQC_CMAKE_C_CXX_FLAGS " -g3 -O0")
|
string(APPEND PQC_CMAKE_C_CXX_FLAGS " -g0 -ggdb -O0")
|
||||||
endif()
|
#endif()
|
||||||
|
|
||||||
# Set CPU architecture
|
# Set CPU architecture
|
||||||
string(APPEND PQC_CMAKE_C_CXX_FLAGS " -D${ARCH}")
|
string(APPEND PQC_CMAKE_C_CXX_FLAGS " -D${ARCH}")
|
||||||
|
@ -465,7 +465,6 @@ void PQCLEAN_DILITHIUM2_CLEAN_poly_uniform_gamma1(poly *a,
|
|||||||
stream256_init(&state, seed, nonce);
|
stream256_init(&state, seed, nonce);
|
||||||
stream256_squeezeblocks(buf, POLY_UNIFORM_GAMMA1_NBLOCKS, &state);
|
stream256_squeezeblocks(buf, POLY_UNIFORM_GAMMA1_NBLOCKS, &state);
|
||||||
stream256_release(&state);
|
stream256_release(&state);
|
||||||
dump_buffer_hex(0,0,buf,4);
|
|
||||||
PQCLEAN_DILITHIUM2_CLEAN_polyz_unpack(a, buf);
|
PQCLEAN_DILITHIUM2_CLEAN_polyz_unpack(a, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,8 +117,6 @@ int PQCLEAN_DILITHIUM2_CLEAN_crypto_sign_signature(uint8_t *sig,
|
|||||||
|
|
||||||
rej:
|
rej:
|
||||||
/* Sample intermediate vector y */
|
/* Sample intermediate vector y */
|
||||||
dump_buffer_hex(0,0,rhoprime,64);
|
|
||||||
|
|
||||||
PQCLEAN_DILITHIUM2_CLEAN_polyvecl_uniform_gamma1(&y, rhoprime, nonce++);
|
PQCLEAN_DILITHIUM2_CLEAN_polyvecl_uniform_gamma1(&y, rhoprime, nonce++);
|
||||||
|
|
||||||
/* Matrix-vector multiplication */
|
/* Matrix-vector multiplication */
|
||||||
@ -132,7 +130,6 @@ rej:
|
|||||||
PQCLEAN_DILITHIUM2_CLEAN_polyveck_caddq(&w1);
|
PQCLEAN_DILITHIUM2_CLEAN_polyveck_caddq(&w1);
|
||||||
PQCLEAN_DILITHIUM2_CLEAN_polyveck_decompose(&w1, &w0, &w1);
|
PQCLEAN_DILITHIUM2_CLEAN_polyveck_decompose(&w1, &w0, &w1);
|
||||||
PQCLEAN_DILITHIUM2_CLEAN_polyveck_pack_w1(sig, &w1);
|
PQCLEAN_DILITHIUM2_CLEAN_polyveck_pack_w1(sig, &w1);
|
||||||
dump_buffer_hex(0, 4, sig, 10);
|
|
||||||
|
|
||||||
shake256_inc_init(&state);
|
shake256_inc_init(&state);
|
||||||
shake256_inc_absorb(&state, mu, CRHBYTES);
|
shake256_inc_absorb(&state, mu, CRHBYTES);
|
||||||
@ -141,6 +138,7 @@ rej:
|
|||||||
shake256_inc_squeeze(sig, SEEDBYTES, &state);
|
shake256_inc_squeeze(sig, SEEDBYTES, &state);
|
||||||
shake256_inc_ctx_release(&state);
|
shake256_inc_ctx_release(&state);
|
||||||
PQCLEAN_DILITHIUM2_CLEAN_poly_challenge(&cp, sig);
|
PQCLEAN_DILITHIUM2_CLEAN_poly_challenge(&cp, sig);
|
||||||
|
|
||||||
PQCLEAN_DILITHIUM2_CLEAN_poly_ntt(&cp);
|
PQCLEAN_DILITHIUM2_CLEAN_poly_ntt(&cp);
|
||||||
|
|
||||||
/* Compute z, reject if it reveals secret */
|
/* Compute z, reject if it reveals secret */
|
||||||
@ -154,6 +152,7 @@ rej:
|
|||||||
|
|
||||||
/* Check that subtracting cs2 does not change high bits of w and low bits
|
/* Check that subtracting cs2 does not change high bits of w and low bits
|
||||||
* do not reveal secret information */
|
* do not reveal secret information */
|
||||||
|
|
||||||
PQCLEAN_DILITHIUM2_CLEAN_polyveck_pointwise_poly_montgomery(&h, &cp, &s2);
|
PQCLEAN_DILITHIUM2_CLEAN_polyveck_pointwise_poly_montgomery(&h, &cp, &s2);
|
||||||
PQCLEAN_DILITHIUM2_CLEAN_polyveck_invntt_tomont(&h);
|
PQCLEAN_DILITHIUM2_CLEAN_polyveck_invntt_tomont(&h);
|
||||||
PQCLEAN_DILITHIUM2_CLEAN_polyveck_sub(&w0, &w0, &h);
|
PQCLEAN_DILITHIUM2_CLEAN_polyveck_sub(&w0, &w0, &h);
|
||||||
@ -164,12 +163,12 @@ rej:
|
|||||||
|
|
||||||
/* Compute hints for w1 */
|
/* Compute hints for w1 */
|
||||||
PQCLEAN_DILITHIUM2_CLEAN_polyveck_pointwise_poly_montgomery(&h, &cp, &t0);
|
PQCLEAN_DILITHIUM2_CLEAN_polyveck_pointwise_poly_montgomery(&h, &cp, &t0);
|
||||||
|
|
||||||
PQCLEAN_DILITHIUM2_CLEAN_polyveck_invntt_tomont(&h);
|
PQCLEAN_DILITHIUM2_CLEAN_polyveck_invntt_tomont(&h);
|
||||||
PQCLEAN_DILITHIUM2_CLEAN_polyveck_reduce(&h);
|
PQCLEAN_DILITHIUM2_CLEAN_polyveck_reduce(&h);
|
||||||
if (PQCLEAN_DILITHIUM2_CLEAN_polyveck_chknorm(&h, GAMMA2)) {
|
if (PQCLEAN_DILITHIUM2_CLEAN_polyveck_chknorm(&h, GAMMA2)) {
|
||||||
goto rej;
|
goto rej;
|
||||||
}
|
}
|
||||||
|
|
||||||
PQCLEAN_DILITHIUM2_CLEAN_polyveck_add(&w0, &w0, &h);
|
PQCLEAN_DILITHIUM2_CLEAN_polyveck_add(&w0, &w0, &h);
|
||||||
n = PQCLEAN_DILITHIUM2_CLEAN_polyveck_make_hint(&h, &w0, &w1);
|
n = PQCLEAN_DILITHIUM2_CLEAN_polyveck_make_hint(&h, &w0, &w1);
|
||||||
if (n > OMEGA) {
|
if (n > OMEGA) {
|
||||||
|
32
test/ut.cpp
32
test/ut.cpp
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user