rand_poly initial setup
This commit is contained in:
parent
aecf8bb070
commit
b8b1eeeeea
18
Makefile
18
Makefile
@ -0,0 +1,18 @@
|
||||
CC?=gcc
|
||||
AS=$(CC) -c
|
||||
AR?=ar
|
||||
|
||||
CFLAGS?=-g
|
||||
CFLAGS+=-Wall -Wextra
|
||||
|
||||
SRCDIR=src
|
||||
TESTDIR=tests
|
||||
BINDIR=bin
|
||||
|
||||
test_codes = tests/test.c tests/test_util.c
|
||||
|
||||
bin/test:
|
||||
$(CC) $(CFLAGS) -I$(SRCDIR) $(test_codes) -o $@
|
||||
|
||||
clean:
|
||||
rm -f $(BINDIR)/*
|
@ -10,6 +10,9 @@ C polynomial library for ECC based cryptography.
|
||||
|
||||
Libntru use some custom data types declared in `types.h`.
|
||||
|
||||
> `uint8_t` : Unsigned 8-bit integer
|
||||
> `uint16_t` : Unsigned 16-bit integer
|
||||
|
||||
`NtruIntPoly` : Polynomial with 16-bit integer coefficients
|
||||
|
||||
```c
|
||||
@ -38,7 +41,7 @@ Libntru use some custom data types declared in `types.h`.
|
||||
- [ ] Advance Operation (Inversion)
|
||||
- [ ] Bitwise for array
|
||||
- [ ] Pointer management for polynomial indexes
|
||||
- [ ] Random Generators
|
||||
- [ ] ~~Random Generators~~
|
||||
|
||||
|
||||
|
||||
|
11
src/poly.c
11
src/poly.c
@ -1,4 +1,15 @@
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include "types.h"
|
||||
|
||||
uint8_t inf_mult_poly(NtruIntPoly *a,NtruIntPoly *b, NtruIntPoly *c, uint16_t modulus) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
10
src/types.h
10
src/types.h
@ -1,5 +1,11 @@
|
||||
/* Here we Declared our custom data types */
|
||||
|
||||
struct infPoly {
|
||||
#include <stdint.h>
|
||||
|
||||
}
|
||||
#define NTRU_MAX_DEGREE (1499+1)
|
||||
#define NTRU_INT_POLY_SIZE ((NTRU_MAX_DEGREE+16+7)&0XFFF8)
|
||||
|
||||
typedef struct NtruIntPoly {
|
||||
uint16_t N;
|
||||
int16_t coeffs[NTRU_INT_POLY_SIZE];
|
||||
} NtruIntPoly;
|
||||
|
BIN
test_util.o
Normal file
BIN
test_util.o
Normal file
Binary file not shown.
27
tests/test.c
Normal file
27
tests/test.c
Normal file
@ -0,0 +1,27 @@
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include "test_util.h"
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
|
||||
printf("Running Test....\n");
|
||||
|
||||
uint16_t i;
|
||||
uint16_t modulus;
|
||||
uint16_t N;
|
||||
// int16_t coeffs[NTRU_INT_POLY_SIZE];
|
||||
// uint16_t a;
|
||||
|
||||
|
||||
|
||||
modulus = 4;
|
||||
N = 739;
|
||||
NtruIntPoly a, c;
|
||||
// a = 739;
|
||||
|
||||
printf("%d\n", modulus);
|
||||
printf("%d\n", N);
|
||||
// printf("%d\n", &a);
|
||||
|
||||
rand_poly(&a, N, modulus);
|
||||
}
|
19
tests/test_util.c
Normal file
19
tests/test_util.c
Normal file
@ -0,0 +1,19 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include "test_util.h"
|
||||
|
||||
|
||||
void rand_poly(NtruIntPoly *a, uint16_t N, uint16_t modulus){
|
||||
uint16_t i;
|
||||
int16_t coeffs[N];
|
||||
// int16_t coeffs;
|
||||
a->N = N;
|
||||
printf("-> ");
|
||||
for (i=0; i<N; i++){
|
||||
a->coeffs[i] = random() % modulus;
|
||||
printf("%d %d\n ", i+1, coeffs[i] );
|
||||
}
|
||||
}
|
||||
|
11
tests/test_util.h
Normal file
11
tests/test_util.h
Normal file
@ -0,0 +1,11 @@
|
||||
#ifndef TEST_UTIL_H
|
||||
#define TEST_UTIL_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "types.h"
|
||||
|
||||
void rand_poly(NtruIntPoly *a, uint16_t N, uint16_t modulus);
|
||||
|
||||
int main(int argc, char** argv);
|
||||
|
||||
#endif
|
9
tests/testparams.h
Normal file
9
tests/testparams.h
Normal file
@ -0,0 +1,9 @@
|
||||
#include <stdint.h>
|
||||
#include <types.h>
|
||||
|
||||
#define NTRU_P 739
|
||||
#define NTRU_Q 9820
|
||||
#define NTRU_T 204
|
||||
|
||||
|
||||
uint8_t ntruprime_mult_poly(NtruIntPoly *a, NtruIntPoly *b, NtruIntPoly *c, uint16_t modulus);
|
Loading…
Reference in New Issue
Block a user