Merge branch 'master' of ssh://gitlab.hasufell.de:22022/Goldi/quantumcrypto
Fixed .gitignore with .project
This commit is contained in:
commit
916c5f6a96
4
.gitignore
vendored
4
.gitignore
vendored
@ -20,4 +20,6 @@ latex/
|
|||||||
src/main.c
|
src/main.c
|
||||||
src/main
|
src/main
|
||||||
|
|
||||||
./.settings/org.eclipse*
|
./.settings/org.eclipse*
|
||||||
|
|
||||||
|
.project
|
11
.project
11
.project
@ -1,11 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<projectDescription>
|
|
||||||
<name>Semesterprojekt2014</name>
|
|
||||||
<comment></comment>
|
|
||||||
<projects>
|
|
||||||
</projects>
|
|
||||||
<buildSpec>
|
|
||||||
</buildSpec>
|
|
||||||
<natures>
|
|
||||||
</natures>
|
|
||||||
</projectDescription>
|
|
@ -19,6 +19,49 @@
|
|||||||
* MA 02110-1301 USA
|
* MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "ntru_decrypt.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Legend
|
||||||
|
*
|
||||||
|
* N : highest degree of the polynom
|
||||||
|
* q : "is given" (... mod q)
|
||||||
|
* p : "is given" (... mod p)
|
||||||
|
* f : private key
|
||||||
|
* Fp: inverse of "modulo p"
|
||||||
|
* e : encrypted message
|
||||||
|
* a : result of first multiplication (StarMultiply(f, e, a, N, q))
|
||||||
|
* d : result of second multiplication (StarMultiply(a, Fp , d, N, p)), decrypted message
|
||||||
|
* */
|
||||||
|
|
||||||
|
// Require: N , q, p, secret key f , inverse polynomial Fp , and encrypted message e.
|
||||||
int ntru_decrypt(char *encr_msg, pb_poly *private_key, ntru_context *context, char ** decr_msg){
|
int ntru_decrypt(char *encr_msg, pb_poly *private_key, ntru_context *context, char ** decr_msg){
|
||||||
return 0;
|
// toDo q = ?, p = ?, fp = ?
|
||||||
|
|
||||||
|
pb_poly *a = first_multiply(private_key, encr_msg, q);// StarMultiply(f, e, a, N, q)
|
||||||
|
|
||||||
|
for(int i = 0, i < N, i++){
|
||||||
|
if(a[i] < 0 ) {
|
||||||
|
a[i] = a[i] + q; // Make all coefficients positive
|
||||||
|
}
|
||||||
|
if(a[i] > q/2) {
|
||||||
|
a[i] = a[i] - q // Shift coefficients of a into range (−q/2, q/2)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
char* d = second_multiply(a, fp, p)// StarMultiply(a, Fp , d, N, p)
|
||||||
|
|
||||||
|
// {Decode returns the decrypted message, d, through the argument list.}
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
|
||||||
|
// toDo fix header file definition and types if needed!
|
||||||
|
pb_poly* first_multiply(pb_poly *private_key, char *encr_msg, int q) {
|
||||||
|
// toDo a= f*e mod q
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// toDo fix header file definition and types if needed!
|
||||||
|
char* second_multiply(pb_poly *a, pb_poly *fp, int p) {
|
||||||
|
//toDo a*Fp mod p
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -26,5 +26,7 @@
|
|||||||
#include "context.h"
|
#include "context.h"
|
||||||
|
|
||||||
int ntru_decrypt(char *encr_msg, pb_poly *private_key, ntru_context *context, char ** decr_msg);
|
int ntru_decrypt(char *encr_msg, pb_poly *private_key, ntru_context *context, char ** decr_msg);
|
||||||
|
pb_poly* first_multiply(pb_poly*, char*, int);
|
||||||
|
char* first_multiply(pb_poly*, pb_poly*, int);
|
||||||
|
|
||||||
#endif /* NTRU_DECRYPT */
|
#endif /* NTRU_DECRYPT */
|
||||||
|
Loading…
Reference in New Issue
Block a user