-
Notifications
You must be signed in to change notification settings - Fork 143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lowram implementation #91
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some small suggestions.
* - size_t *mlen: pointer to output length of message | ||
* - const uint8_t *sm: pointer to signed message | ||
* - size_t smlen: length of signed message | ||
* - const uint8_t *ctx: pointer to context tring |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* - const uint8_t *ctx: pointer to context tring | |
* - const uint8_t *ctx: pointer to context string |
if(ctxlen > 255 || siglen != CRYPTO_BYTES) | ||
return -1; | ||
|
||
/* Compute CRH(h(rho, t1), msg) */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/* Compute CRH(h(rho, t1), msg) */ | |
/* Compute mu = CRH(H(rho, t1), 0, ctxlen, ctx, msg) */ |
#include "poly.h" | ||
#include "polyvec.h" | ||
|
||
#define SMALL_POLY_16_BIT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#define SMALL_POLY_16_BIT |
#ifdef SMALL_POLY_16_BIT | ||
int j; | ||
// buffer is the same, so we neeed to be careful | ||
for (j = N - 1; j >= 0; j--) | ||
{ | ||
r->coeffs[j] = tmp->coeffs[j]; | ||
} | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#ifdef SMALL_POLY_16_BIT | |
int j; | |
// buffer is the same, so we neeed to be careful | |
for (j = N - 1; j >= 0; j--) | |
{ | |
r->coeffs[j] = tmp->coeffs[j]; | |
} | |
#endif | |
int j; | |
// buffer is the same, so we neeed to be careful | |
for (j = N - 1; j >= 0; j--) | |
{ | |
r->coeffs[j] = tmp->coeffs[j]; | |
} |
|
||
/* Code to generate zetas and zetas_inv used in the number-theoretic transform: | ||
|
||
#define KYBER_ROOT_OF_UNITY 17 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#define KYBER_ROOT_OF_UNITY 17 | |
#define KYBER_ROOT_OF_UNITY 17 | |
#define KYBER_Q 3329 | |
#define MONT -1044 |
This PR adds a third implementation variant called
lowram
. It focuses on using very little memory at a performance tradeoff. The implementation is written in C and based on the code in pqm4, which was added in this PR.The original ideas for this implementation are taken from the paper
and parts of the implementation in this PR are written by @mkannwischer.
I tried to retain as many files as possible from the
ref
implementation by moving most memory-optimization related code tolowram.c
. Further,smallntt_3329.c
andsmallpoly.c
contain functions to operate on polynomials with 16-bit coefficients.api.h
,config.h
,Makefile
, andsign.c
are the only files that should be different fromref
-- everything else is just symlinks.If there's anything that could be done to improve the quality of the implementation, feel free to let me know!
Cheers,
Amin