numerous fixes
This commit is contained in:
parent
c326654f14
commit
4e6bb38260
@ -37,8 +37,8 @@ endif
|
|||||||
LIBS += -L.
|
LIBS += -L.
|
||||||
|
|
||||||
# objects
|
# objects
|
||||||
PQC_OBJS = rand.o poly.o mem.o
|
PQC_OBJS = rand.o poly.o mem.o ntru_decrypt.o
|
||||||
PQC_HEADERS = err.h rand.h poly.h context.h
|
PQC_HEADERS = err.h rand.h poly.h context.h ntru_decrypt.h
|
||||||
# CUNIT_OBJS = cunit.o
|
# CUNIT_OBJS = cunit.o
|
||||||
|
|
||||||
# includes
|
# includes
|
||||||
|
@ -20,8 +20,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "ntru_decrypt.h"
|
#include "ntru_decrypt.h"
|
||||||
#include "poly.h"
|
|
||||||
#include "context.h"
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Legend
|
* Legend
|
||||||
@ -42,11 +40,13 @@ pb_poly* ntru_decrypt(pb_poly *encr_msg, pb_poly *private_key, pb_poly *Fp, ntru
|
|||||||
unsigned int q = context->q;
|
unsigned int q = context->q;
|
||||||
unsigned int p = context->p;
|
unsigned int p = context->p;
|
||||||
unsigned int N = context->N;
|
unsigned int N = context->N;
|
||||||
|
unsigned int i;
|
||||||
|
|
||||||
// StarMultiply(f, e, a, N, q)
|
// StarMultiply(f, e, a, N, q)
|
||||||
pb_poly *a = build_polynom(NULL, N, context);
|
pb_poly *a = build_polynom(NULL, N, context);
|
||||||
pb_starmultiply(private_key, encr_msg, a, context, q);
|
pb_starmultiply(private_key, encr_msg, a, context, q);
|
||||||
|
printf("%s\n", "Nach dem StarMultiply: ");
|
||||||
|
draw_polynom(a);
|
||||||
mp_int mp_q;
|
mp_int mp_q;
|
||||||
mp_int mp_qdiv2;
|
mp_int mp_qdiv2;
|
||||||
mp_int zero;
|
mp_int zero;
|
||||||
@ -56,10 +56,10 @@ pb_poly* ntru_decrypt(pb_poly *encr_msg, pb_poly *private_key, pb_poly *Fp, ntru
|
|||||||
init_integer(&zero);
|
init_integer(&zero);
|
||||||
|
|
||||||
MP_SET_INT(&mp_q, q);
|
MP_SET_INT(&mp_q, q);
|
||||||
mp_div_2(&mp_q, mp_qdiv2);
|
mp_div_2(&mp_q, &mp_qdiv2);
|
||||||
mp_zero(&zero);
|
mp_zero(&zero);
|
||||||
|
|
||||||
for(int i = 0, i < N, i++){
|
for(i = 0; i < N; i++){
|
||||||
if(mp_cmp(&(a->terms[i]),&zero) == MP_LT) { // Make all coefficients positive
|
if(mp_cmp(&(a->terms[i]),&zero) == MP_LT) { // Make all coefficients positive
|
||||||
//a->terms[i] = a->terms[i] + q;
|
//a->terms[i] = a->terms[i] + q;
|
||||||
mp_add((&a->terms[i]),&mp_q,(&a->terms[i]));
|
mp_add((&a->terms[i]),&mp_q,(&a->terms[i]));
|
||||||
@ -73,7 +73,7 @@ pb_poly* ntru_decrypt(pb_poly *encr_msg, pb_poly *private_key, pb_poly *Fp, ntru
|
|||||||
pb_poly *d = build_polynom(NULL, N, context);
|
pb_poly *d = build_polynom(NULL, N, context);
|
||||||
|
|
||||||
// StarMultiply(a, Fp , d, N, p)
|
// StarMultiply(a, Fp , d, N, p)
|
||||||
pb_starmultiply(a, Fp, d, N, p);
|
pb_starmultiply(a, Fp, d, context, p);
|
||||||
|
|
||||||
// {Decode returns the decrypted message, d, through the argument list.}
|
// {Decode returns the decrypted message, d, through the argument list.}
|
||||||
return d;
|
return d;
|
||||||
|
Loading…
Reference in New Issue
Block a user