Browse Source

Almost done

Gustavo Banegas 2 years ago
parent
commit
86ada40f51
9 changed files with 274 additions and 145 deletions
  1. 2 0
      .gitignore
  2. 5 4
      include/keygeneration.h
  3. 1 1
      include/random/rng.h
  4. 1 0
      include/util/util.h
  5. 203 90
      src/keygeneration.c
  6. 14 4
      src/main.c
  7. 2 2
      src/random/random_generator.c
  8. 1 1
      src/random/rng.c
  9. 45 43
      src/util/util.c

+ 2 - 0
.gitignore

@@ -32,3 +32,5 @@
 # Debug files
 *.dSYM/
 
+/Release/
+/Debug/

+ 5 - 4
include/keygeneration.h

@@ -11,11 +11,12 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <sys/resource.h>
+#include <sodium.h>
+
 
 #include "../include/parameters/param.h"
 #include "../include/definitions.h"
 #include "structures/matrix_operations.h"
-#include "random/random_generator.h"
 #include "gf/gf.h"
 #include "util/util.h"
 
@@ -32,9 +33,9 @@ extern int key_pair_generation(unsigned char *pk, unsigned char *sk);
 
 extern void  key_gen(gf *v, gf *y, matrix *G);
 
-extern void build_dyadic_signature(gf *dyadic_signature, gf *omega);
+extern void build_dyadic_signature(gf *dyadic_signature);
 
-extern void build_support(gf omega, gf *signature_h, gf *u, gf *v);
+extern void build_support(gf *signature_h, gf *u, gf *v);
 
 extern void build_cauchy_matrix(gf *u, gf *v, matrix *H_cauchy);
 
@@ -43,6 +44,6 @@ extern void build_trapdoor(const matrix *H_cauchy, const gf *v, const gf *u,
 
 extern void project_H_on_F_q(const matrix *H, matrix *Hbase);
 
-extern void generate_public_key(const matrix *Hbase, matrix *G);
+extern int generate_public_key(const matrix *Hbase, matrix *G);
 
 #endif /* SRC_KEYGENERATION_H_ */

+ 1 - 1
include/random/rng.h

@@ -50,6 +50,6 @@ randombytes_init(unsigned char *entropy_input,
                  int security_strength);
 
 int
-randombytes(unsigned char *x, unsigned long long xlen);
+randombytes_NIST(unsigned char *x, unsigned long long xlen);
 
 #endif /* rng_h */

+ 1 - 0
include/util/util.h

@@ -14,6 +14,7 @@
 #include <stdint.h>
 #include <string.h>
 #include <math.h>
+#include <sodium.h>
 
 #include "../structures/matrix_operations.h"
 

+ 203 - 90
src/keygeneration.c

@@ -47,16 +47,33 @@ void generate_elements_in_F_q_m(gf * set_of_elements_in_F_q_m) {
 	}
 }
 
-void build_dyadic_signature(gf *dyadic_signature, gf *omega) {
-	gf set_of_elements_in_F_q_m[F_q_m_size] = { 0 };
+void remove_integer(int element, int *list, int size) {
+	for (int i = 0; i < size; i++) {
+		if (list[i] == element) {
+			list[i] = -1;
+			return;
+		}
+	}
+}
+
+int vector_contains(gf *signature_h, gf random_e, int length) {
+
+	for (int i = 0; i < length; i++) {
+		if (signature_h[i] == random_e)
+			return 1;
+	}
+	return 0;
+}
+
+void build_dyadic_signature(gf *dyadic_signature) {
 	gf signature_h[F_q_m_size] = { 0 };
 	int block_position[n0] = { 0 };
 	gf temp_list[signature_block_size] = { 0 };
 
-	generate_elements_in_F_q_m(set_of_elements_in_F_q_m);
-
 	gf h0 = 0;
-	h0 = set_of_elements_in_F_q_m[get_random_int(F_q_m_size)];
+	do {
+		h0 = randombytes_uniform(F_q_m_size - 1);
+	} while (h0 == 0);
 #if defined(TEST)
 	h0 = element_test[0];
 	int count = 1;
@@ -64,20 +81,19 @@ void build_dyadic_signature(gf *dyadic_signature, gf *omega) {
 #endif
 	gf h0_inverse = gf_q_m_inv(h0);
 	signature_h[0] = h0;
-	remove_element(h0, set_of_elements_in_F_q_m);
 
 	for (int t = 0; t < extension * subfield; t++) {
 		int i = 1 << t;
 		gf random_e = 0;
 		do {
-			random_e = set_of_elements_in_F_q_m[get_random_int(F_q_m_size)];
-		} while (random_e == 0);
+			random_e = randombytes_uniform(F_q_m_size - 1);
+		} while (random_e == 0
+				|| vector_contains(signature_h, random_e, code_length));
 #if defined(TEST)
 		random_e = element_test[count];
 		count++;
 #endif
 		signature_h[i] = random_e;
-		remove_element(random_e, set_of_elements_in_F_q_m);
 		for (int j = 1; j < i; j++) {
 			if (signature_h[i] != 0 && signature_h[j] != 0) {
 				gf temp = gf_q_m_inv(signature_h[i])
@@ -85,7 +101,6 @@ void build_dyadic_signature(gf *dyadic_signature, gf *omega) {
 				if (temp != 0) {
 					gf temp_inv = gf_q_m_inv(temp);
 					signature_h[i + j] = temp_inv;
-					remove_element(temp_inv, set_of_elements_in_F_q_m);
 				} else {
 					signature_h[i + j] = 0;
 				}
@@ -96,29 +111,30 @@ void build_dyadic_signature(gf *dyadic_signature, gf *omega) {
 
 	}
 	int ll = 0;
-	generate_elements_in_F_q_m(set_of_elements_in_F_q_m);
+	int size_part = (F_q_m_size / signature_block_size) - 1;
+	int part[(F_q_m_size / signature_block_size) - 1] = { 0 };
 
 	for (int i = 0; i < signature_block_size; i++) {
 		temp_list[i] = signature_h[i];
 	}
+
+	for (int i = 0; i < size_part; i++) {
+		part[i] = randombytes_uniform(size_part - 1);
+	}
+	int count_part = 0;
 	if (!contains_zero(temp_list, signature_block_size)) {
 		block_position[0] = 0;
 		ll++;
-		for (int l = 0; l < signature_block_size; l++) {
-			gf h_l_inverse = gf_q_m_inv(signature_h[l]);
-			remove_element(h_l_inverse, set_of_elements_in_F_q_m);
-			gf sum_inverses = h0_inverse ^ h_l_inverse;
-			remove_element(sum_inverses, set_of_elements_in_F_q_m);
-		}
-		int part[(F_q_m_size / signature_block_size) - 1] = { 0 };
-		generate_int_list_of_size(part,
-				(F_q_m_size / signature_block_size) - 1);
 
 		while (ll * signature_block_size < code_length) {
-			int j =
-					part[get_random_int((F_q_m_size / signature_block_size) - 1)];
-			remove_element_int(j, part,
-					(F_q_m_size / signature_block_size) - 1);
+			int j = 0;
+
+			do {
+				j = part[count_part];
+				count_part++;
+			} while (j == 0);
+
+			remove_integer(j, part, size_part);
 #if defined(TEST)
 			j = int_vector_test[counter_vector_int];
 			counter_vector_int++;
@@ -130,21 +146,12 @@ void build_dyadic_signature(gf *dyadic_signature, gf *omega) {
 			if (!contains_zero(aux_list, signature_block_size)) {
 				block_position[ll] = j;
 				ll++;
-				for (int i = j * signature_block_size;
-						i < (j * signature_block_size) + signature_block_size;
-						i++) {
-					gf inverse_sum = gf_q_m_inv(signature_h[i]) ^ h0_inverse;
-					remove_element(inverse_sum, set_of_elements_in_F_q_m);
-				}
 			}
 		}
 	} else {
 		printf("FAIL!");
 		return; //TODO: catch error
 	}
-	do {
-		omega[0] = set_of_elements_in_F_q_m[get_random_int(F_q_m_size)];
-	} while (omega[0] == 0);
 
 	int nr_blocks = floor(F_q_m_size / signature_block_size);
 	struct signature_block blocks[nr_blocks];
@@ -201,11 +208,39 @@ int is_vector_disjoint(gf *list, int n) {
 	return 0;
 }
 
-void build_support(gf omega, gf *signature_h, gf *u, gf *v) {
+void remove_elements(gf *to_remove, gf *elements, int lenght) {
+	for (int i = 0; i < lenght; i++) {
+		for (int j = 0; j < lenght; j++) {
+			if (to_remove[i] == elements[j]) {
+				to_remove[i] = 0;
+			}
 
+		}
+	}
+
+}
+
+void build_support(gf *signature_h, gf *u, gf *v) {
+
+	gf elements_in_F_q_m[F_q_m_size] = { 0 };
+	generate_elements_in_F_q_m(elements_in_F_q_m);
+	gf aux[code_length] = { 0 };
 	gf h0_inv = gf_q_m_inv(signature_h[0]);
 
 	for (int i = 0; i < code_length; i++) {
+		gf sum_inverse = h0_inv ^ gf_q_m_inv(signature_h[i]);
+		aux[i] = sum_inverse;
+	}
+	remove_elements(elements_in_F_q_m, aux, code_length);
+
+	gf omega = 0;
+	int pos = 0;
+	do {
+		omega = elements_in_F_q_m[pos];
+		pos++;
+	} while (omega == 0);
+
+	for (int i = 0; i < code_length; i++) {
 		if (signature_h[i] != 0) {
 			gf sum_inv = gf_q_m_inv(signature_h[i]) ^ h0_inv ^ omega;
 			v[i] = sum_inv;
@@ -262,8 +297,12 @@ void build_trapdoor(const matrix *H_cauchy, const gf *v, const gf *u, gf *y,
 	generate_elements_in_F_q_m(set_of_elements_in_F_q_m);
 
 	for (int i = 0; i < n0; i++) {
-		z[i * signature_block_size] = set_of_elements_in_F_q_m[get_random_int(
-		F_q_m_size)];
+		gf random_el = 0;
+		do {
+			random_el = randombytes_uniform(F_q_m_size - 1);
+		} while (random_el == 0 || vector_contains(z, random_el, code_length));
+
+		z[i * signature_block_size] = random_el;
 		for (int j = 1; j < signature_block_size; j++) {
 			z[(i * signature_block_size) + j] = z[i * signature_block_size];
 		}
@@ -308,43 +347,115 @@ void project_H_on_F_q(const matrix *H, matrix *Hbase) {
 
 }
 
-matrix* generate_systematic_matrix(const matrix* Hbase) {
+int generate_systematic_matrix(const matrix* Hbase) {
+
+	int i, j, l = 0, test = 0;
+	gf temp;
 	int n = Hbase->cols;
-	int r = Hbase->rows;
+	int k = Hbase->rows;
+	printf("\n");
+	for (i = 0; i < k; i++) {
+		test = 0;
+		l = 0;
+		j = i + n - k;
+		if (Hbase->data[(i * n) + i + n - k] == 0) { //We're looking for a non-zero pivot
+			test = 1;
+			//printf("search Pivot\n");
+			for (l = i + 1; l < k; l++) {
+				if (Hbase->data[l * n + j]) {
+					//printf("Find Pivot\n");
+					break;
+				}
+			}
+		}
+		if (l == k && (i != (k - 1))) {
+			printf("Non systematic Matrix %d\n", l);
+			return 1;
+		}
+		if (test == 1) { // We switches the lines l and i
+			test = 0;
+			//printf("Permut line\n");
+			//temp=P[i+n-k];
+			//P[i+n-k]=P[j];
+			//P[j]=temp;
+			for (j = 0; j < n; j++) {
+				temp = Hbase->data[l * n + j];
+				Hbase->data[l * n + j] = Hbase->data[i * n + j];
+				Hbase->data[i * n + j] = temp;
+			}
+		}
+		//   Matrix standardization
+		gf invPiv = 1, aa;
+		if (Hbase->data[(i * n) + i + n - k] != 1) {
+			aa = Hbase->data[(i * n) + i + n - k];
+			invPiv = gf_inv(aa);
+			Hbase->data[(i * n) + i + n - k] = 1;
+
+			for (j = 0; j < n; j++) {
+				if (j == i + n - k) {
+					continue;
+				}
+				Hbase->data[(i * n) + j] = gf_mult(Hbase->data[(i * n) + j],
+						invPiv);
+			}
+		}
 
-	matrix * aux_A = submatrix(Hbase, 0, 0, r, (n - r));
+		//Here we do the elimination on column i + n-k
+		gf piv_align;
+		for (l = 0; l < k; l++) {
+			if (l == i) {
+				continue;
+			}
+			if (Hbase->data[(l * n) + i + n - k]) {
+				piv_align = Hbase->data[(l * n) + i + n - k];
 
-	matrix * aux_B = submatrix(Hbase, 0, (n - r), r, r);
+				for (j = 0; j < n; j++) {
+					Hbase->data[l * n + j] = Hbase->data[l * n + j]
+							^ (gf_mult(piv_align, Hbase->data[i * n + j]));
+				}
+			}
+		}
+	}
+	return 0;
+	/*matrix * aux_A = submatrix(Hbase, 0, 0, r, (n - r));
 
-	matrix * aux_H = augment(aux_B, aux_A);
-	free_matrix(aux_A);
-	free_matrix(aux_B);
+	 matrix * aux_B = submatrix(Hbase, 0, (n - r), r, r);
 
-	echelon_form(aux_H);
+	 matrix * aux_H = augment(aux_B, aux_A);
+	 free_matrix(aux_A);
+	 free_matrix(aux_B);
 
-	matrix *matrix_M = submatrix(aux_H, 0, r, r, (n - r));
+	 print_matrix(aux_H);
 
-	free_matrix(aux_H);
-	matrix *m_temp = make_matrix(r, r);
-	for (int i = 0; i < r; i++)
-		m_temp->data[i * r + i] = 1;
+	 echelon_form(aux_H);
 
-	matrix *H = augment(matrix_M, m_temp);
-	free_matrix(matrix_M);
-	free_matrix(m_temp);
+	 print_matrix(aux_H);
+
+	 matrix *matrix_M = submatrix(aux_H, 0, r, r, (n - r));
+
+	 free_matrix(aux_H);
+	 matrix *m_temp = make_matrix(r, r);
+	 for (int i = 0; i < r; i++)
+	 m_temp->data[i * r + i] = 1;
+
+	 matrix *H = augment(matrix_M, m_temp);
+	 free_matrix(matrix_M);
+	 free_matrix(m_temp);*/
 
-	return H;
 }
 
-void generate_public_key(const matrix *Hbase, matrix *G) {
+int generate_public_key(const matrix *Hbase, matrix *G) {
 
-	matrix *HH = generate_systematic_matrix(Hbase);
+	int ret_val = generate_systematic_matrix(Hbase);
+	if (ret_val) {
+		return 1;
+	}
 	int n = Hbase->cols;
 	int r = Hbase->rows;
 
-	matrix *M = submatrix(HH, 0, 0, r, (n - r));
+	matrix *M = submatrix(Hbase, 0, 0, r, (n - r));
 
-	free_matrix(HH);
+	//free_matrix(HH);
 
 	matrix *m_temp = make_matrix((n - r), (n - r));
 	for (int i = 0; i < (n - r); i++)
@@ -364,6 +475,7 @@ void generate_public_key(const matrix *Hbase, matrix *G) {
 		}
 	}
 	free_matrix(final);
+	return 0;
 
 }
 
@@ -385,38 +497,39 @@ int key_pair_generation(unsigned char *pk, unsigned char *sk) {
 }
 
 void key_gen(gf *v, gf *y, matrix *G) {
-	gf signature_h[code_length] = { 0 };
-	gf u[signature_block_size] = { 0 };
-	gf omega[1] = { 0 };
-	do {
-		build_dyadic_signature(signature_h, omega);
-
-		build_support(omega[0], signature_h, u, v);
-	} while (is_vectors_disjoint(u, v) || is_vector_disjoint(v, code_length)
-			|| is_vector_disjoint(u, signature_block_size));
-
-	matrix H_cauchy;
-	H_cauchy.rows = signature_block_size * extension;
-	H_cauchy.cols = code_length;
-	gf data_cauchy[signature_block_size * extension * code_length] = { 0 };
-	H_cauchy.data = data_cauchy;
-	build_cauchy_matrix(u, v, &H_cauchy);
-
-	matrix H;
-	H.rows = signature_block_size * extension;
-	H.cols = code_length;
-	gf data_H[signature_block_size * extension * code_length] = { 0 };
-	H.data = data_H;
-	build_trapdoor(&H_cauchy, v, u, y, &H);
-
-	matrix Hbase;
-	Hbase.rows = (signature_block_size * extension) * extension;
-	Hbase.cols = code_length;
-	gf data_Hbase[signature_block_size * extension * code_length * extension] =
-			{ 0 };
-	Hbase.data = data_Hbase;
-	project_H_on_F_q(&H, &Hbase);
-
-	generate_public_key(&Hbase, G);
+	int ret_value = 0;
 
+	do {
+		gf signature_h[code_length] = { 0 };
+		gf u[signature_block_size] = { 0 };
+		do {
+			build_dyadic_signature(signature_h);
+			build_support(signature_h, u, v);
+		} while (is_vectors_disjoint(u, v) || is_vector_disjoint(v, code_length)
+				|| is_vector_disjoint(u, signature_block_size));
+
+		matrix H_cauchy;
+		H_cauchy.rows = signature_block_size * extension;
+		H_cauchy.cols = code_length;
+		gf data_cauchy[signature_block_size * extension * code_length] = { 0 };
+		H_cauchy.data = data_cauchy;
+		build_cauchy_matrix(u, v, &H_cauchy);
+
+		matrix H;
+		H.rows = signature_block_size * extension;
+		H.cols = code_length;
+		gf data_H[signature_block_size * extension * code_length] = { 0 };
+		H.data = data_H;
+		build_trapdoor(&H_cauchy, v, u, y, &H);
+
+		matrix Hbase;
+		Hbase.rows = (signature_block_size * extension) * extension;
+		Hbase.cols = code_length;
+		gf data_Hbase[signature_block_size * extension * code_length * extension] =
+				{ 0 };
+		Hbase.data = data_Hbase;
+		project_H_on_F_q(&H, &Hbase);
+
+		ret_value = generate_public_key(&Hbase, G);
+	} while (ret_value);
 }

+ 14 - 4
src/main.c

@@ -11,6 +11,7 @@
 #include <ctype.h>
 #include <inttypes.h>
 #include <sys/resource.h>
+#include <sodium.h>
 
 #include "../include/api.h"
 #include "../include/keygeneration.h"
@@ -43,6 +44,10 @@ long long t_dec[1001];
 
 #if defined(RUN)
 int main(void) {
+	if (sodium_init() < 0) {
+		/* panic! the library couldn't be initialized, it is not safe to use */
+		return 1;
+	}
 	const rlim_t kStackSize = 64L * 1024L * 1024L;   // min stack size = 64 Mb
 	struct rlimit rl;
 	int result;
@@ -93,7 +98,7 @@ int main(void) {
 	randombytes_init(entropy_input, NULL, 256);
 	for (i = 0; i < EXECUTION_TIMES; i++) {
 		fprintf(fp_req, "count = %d\n", i);
-		randombytes(random_values, 48);
+		randombytes_NIST(random_values, 48);
 		fprintBstr(fp_req, "seed = ", random_values, 48);
 		fprintf(fp_req, "pk =\n");
 		fprintf(fp_req, "sk =\n");
@@ -122,6 +127,8 @@ int main(void) {
 	fprintBstr(fp_rsp, "seed = ", seed, 48);
 
 	randombytes_init(seed, NULL, 256);
+	int success = 0;
+	int fails = 0;
 
 	do {
 		gf v[code_length] = { 0 };
@@ -163,13 +170,16 @@ int main(void) {
 		printf("decaps: %lld", final - start);
 		printf("\n");
 		if (ret_val != 0) {
-			printf("Decaps_FAIL\n");
+			printf("FAIL\n");
+			fails++;
 		} else {
-			printf("SUCCESS\n");
+			//printf("SUCCESS\n");
+			success++;
 		}
 		counter++;
 	} while (counter < 100);
-
+	printf("SUCCESS: %d\n", success);
+	printf("fails: %d\n", fails);
 	//free(sk);
 	return 0;
 }

+ 2 - 2
src/random/random_generator.c

@@ -26,7 +26,7 @@ void get_element_F_q_m(gf *set_of_elements) {
 
 int get_random_int(int size) {
 	unsigned char i[1] = { 0 };
-	randombytes(i, 1);
+	randombytes_NIST(i, 1);
 	return (i[0] % size);
 
 }
@@ -36,7 +36,7 @@ void random_elements(gf* set_of_elements_in_F_q_m) {
 	gf tmp;
 	unsigned char *random_bytes = 0;
 	random_bytes = malloc(F_q_m_size * sizeof(gf));
-	randombytes(random_bytes, F_q_m_size * sizeof(gf));
+	randombytes_NIST(random_bytes, F_q_m_size * sizeof(gf));
 	for (i = 1; i <= F_q_m_order; i++) {
 		set_of_elements_in_F_q_m[i - 1] = i;
 	}

+ 1 - 1
src/random/rng.c

@@ -153,7 +153,7 @@ randombytes_init(unsigned char *entropy_input,
 }
 
 int
-randombytes(unsigned char *x, unsigned long long xlen)
+randombytes_NIST(unsigned char *x, unsigned long long xlen)
 {
     unsigned char   block[16];
     int             i = 0;

+ 45 - 43
src/util/util.c

@@ -137,13 +137,14 @@ void generate_int_list_of_size(int *list, int length) {
 }
 
 void random_m(unsigned char *m) {
-	int i;
+	const unsigned char seed[32U] = { 1 };
+	randombytes_buf_deterministic(m, k_prime, seed);
 	//randombytes(m, k_prime);
-	unsigned char data_m[] = { 114, 194, 6, 152, 244, 38, 43, 140, 189, 83, 66,
-			48 };
-	for (i = 0; i < k_prime; i++) {
-		m[i] = data_m[i] & F_q_order;
-	}
+	/*unsigned char data_m[] = { 114, 194, 6, 152, 244, 38, 43, 140, 189, 83, 66,
+	 48 };
+	 for (i = 0; i < k_prime; i++) {
+	 m[i] = data_m[i] & F_q_order;
+	 }*/
 }
 
 int indice_in_vec(unsigned int *v, int j, int size) {
@@ -156,45 +157,46 @@ int indice_in_vec(unsigned int *v, int j, int size) {
 }
 
 void random_e(const unsigned char *sigma, unsigned char *error_array) {
-	unsigned char error[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-			247, 0, 0, 0, 181, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-			0, 0, 0, 160, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0,
-			0, 0, 0, 0, 0 };
+	/*unsigned char error[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+	 247, 0, 0, 0, 181, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+	 0, 0, 0, 160, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0,
+	 0, 0, 0, 0, 0 };
+	 for (int i = 0; i < code_length; i++) {
+	 error_array[i] = error[i];
+	 }*/
+
+	int i, j = 0, k = 0, jeton = 0;
+	unsigned int v[code_length] = { 0 };
+#ifdef DEBUG_P
+	printf("error_position: ");
+#endif
+	for (i = 0; i < code_length; i++) {
+		if (sigma[i] % F_q_size == 0) {
+			continue;
+		}
+		if (j == weight) {
+			break;
+		}
+		do {
+			jeton = (sigma[k + 1] ^ (sigma[k] << 4)) % code_length;
+			k++;
+		} while (indice_in_vec(v, jeton, j + 1) == 1); //Only check j elements
+		v[j] = jeton;
+		error_array[jeton] = sigma[i] % F_q_size;
+#ifdef DEBUG_P
+		printf("%d, ", jeton);
+#endif
+		jeton = 0;
+		j++;
+	}
+#ifdef DEBUG_P
+	printf("\n");
 	for (int i = 0; i < code_length; i++) {
-		error_array[i] = error[i];
+		printf("%d, ", error_array[i]);
 	}
-	/*int i, j = 0, k = 0, jeton = 0;
-	 unsigned int v[code_length] = { 0 };
-	 #ifdef DEBUG_P
-	 printf("error_position: ");
-	 #endif
-	 for (i = 0; i < code_length; i++) {
-	 if (sigma[i] % F_q_size == 0) {
-	 continue;
-	 }
-	 if (j == weight) {
-	 break;
-	 }
-	 do {
-	 jeton = (sigma[k + 1] ^ (sigma[k] << 4)) % code_length;
-	 k++;
-	 } while (indice_in_vec(v, jeton, j + 1) == 1); //Only check j elements
-	 v[j] = jeton;
-	 error_array[jeton] = sigma[i] % F_q_size;
-	 #ifdef DEBUG_P
-	 printf("%d, ", jeton);
-	 #endif
-	 jeton = 0;
-	 j++;
-	 }
-	 #ifdef DEBUG_P
-	 printf("\n");
-	 for (int i = 0; i < code_length; i++) {
-	 printf("%d, ", error_array[i]);
-	 }
-	 printf("\n");
-	 #endif
-	 */}
+	printf("\n");
+#endif
+}
 
 void set_vy_from_sk(gf* v, gf * y, const unsigned char * sk) {
 	int i, a = 0;