ALL: rearrange out-parameters to consistently match flint logic
This commit is contained in:
parent
8f77c3351a
commit
8ca155efc0
@ -70,16 +70,18 @@ struct keypair {
|
|||||||
* consisting of public and private
|
* consisting of public and private
|
||||||
* components.
|
* components.
|
||||||
*
|
*
|
||||||
|
* @param pair store private and public components here [out]
|
||||||
* @param f a random polynomial
|
* @param f a random polynomial
|
||||||
* @param g a random polynomial
|
* @param g a random polynomial
|
||||||
* @param pair store private and public components here [out]
|
|
||||||
* @param params the NTRU context
|
* @param params the NTRU context
|
||||||
|
* @return true for success, false if f or g are not invertible
|
||||||
|
* (then the caller hast to try different ones)
|
||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
ntru_create_keypair(
|
ntru_create_keypair(
|
||||||
|
keypair *pair,
|
||||||
const fmpz_poly_t f,
|
const fmpz_poly_t f,
|
||||||
const fmpz_poly_t g,
|
const fmpz_poly_t g,
|
||||||
keypair *pair,
|
|
||||||
const ntru_params *params);
|
const ntru_params *params);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -108,28 +110,29 @@ export_priv_key(char const * const filename,
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Import the public key from a file.
|
* Import the public key from a file.
|
||||||
* @param filename the file to get the public key from
|
*
|
||||||
* @param pub where to save the public key [out]
|
* @param pub where to save the public key [out]
|
||||||
|
* @param filename the file to get the public key from
|
||||||
* @param params the NTRU context
|
* @param params the NTRU context
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
import_public_key(char const * const filename,
|
import_public_key(fmpz_poly_t pub,
|
||||||
fmpz_poly_t pub,
|
char const * const filename,
|
||||||
const ntru_params *params);
|
const ntru_params *params);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Import the private key from a file and store him
|
* Import the private key from a file and store him
|
||||||
* along with his inverse.
|
* along with his inverse.
|
||||||
*
|
*
|
||||||
* @param filename the file to get the private key from
|
|
||||||
* @param priv where to save the private key [out]
|
* @param priv where to save the private key [out]
|
||||||
* @param priv_inv where to save the inverse of the private key [out]
|
* @param priv_inv where to save the inverse of the private key [out]
|
||||||
|
* @param filename the file to get the private key from
|
||||||
* @param params the NTRU context
|
* @param params the NTRU context
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
import_priv_key(char const * const filename,
|
import_priv_key(fmpz_poly_t priv,
|
||||||
fmpz_poly_t priv,
|
|
||||||
fmpz_poly_t priv_inv,
|
fmpz_poly_t priv_inv,
|
||||||
|
char const * const filename,
|
||||||
const ntru_params *params);
|
const ntru_params *params);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -44,10 +44,10 @@
|
|||||||
|
|
||||||
void
|
void
|
||||||
ntru_decrypt_poly(
|
ntru_decrypt_poly(
|
||||||
|
fmpz_poly_t out_bin,
|
||||||
const fmpz_poly_t encr_msg,
|
const fmpz_poly_t encr_msg,
|
||||||
const fmpz_poly_t priv_key,
|
const fmpz_poly_t priv_key,
|
||||||
const fmpz_poly_t priv_key_inv,
|
const fmpz_poly_t priv_key_inv,
|
||||||
fmpz_poly_t out_bin,
|
|
||||||
const ntru_params *params)
|
const ntru_params *params)
|
||||||
{
|
{
|
||||||
fmpz_poly_t a,
|
fmpz_poly_t a,
|
||||||
@ -75,9 +75,9 @@ ntru_decrypt_poly(
|
|||||||
fmpz_poly_mod(priv_key_inv_tmp, params->q);
|
fmpz_poly_mod(priv_key_inv_tmp, params->q);
|
||||||
fmpz_poly_mod(encr_msg_tmp, params->q);
|
fmpz_poly_mod(encr_msg_tmp, params->q);
|
||||||
|
|
||||||
poly_starmultiply(priv_key_tmp, encr_msg_tmp, a, params, params->q);
|
poly_starmultiply(a, priv_key_tmp, encr_msg_tmp, params, params->q);
|
||||||
fmpz_poly_mod(a, params->q);
|
fmpz_poly_mod(a, params->q);
|
||||||
poly_starmultiply(a, priv_key_inv_tmp, out_bin, params, params->p);
|
poly_starmultiply(out_bin, a, priv_key_inv_tmp, params, params->p);
|
||||||
fmpz_poly_mod(out_bin, params->p);
|
fmpz_poly_mod(out_bin, params->p);
|
||||||
|
|
||||||
fmpz_poly_clear(a);
|
fmpz_poly_clear(a);
|
||||||
@ -106,9 +106,9 @@ ntru_decrypt_string(
|
|||||||
|
|
||||||
while (*poly_array[i]) {
|
while (*poly_array[i]) {
|
||||||
ntru_decrypt_poly(*poly_array[i],
|
ntru_decrypt_poly(*poly_array[i],
|
||||||
|
*poly_array[i],
|
||||||
priv_key,
|
priv_key,
|
||||||
priv_key_inv,
|
priv_key_inv,
|
||||||
*poly_array[i],
|
|
||||||
params);
|
params);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
@ -40,20 +40,20 @@
|
|||||||
* Decryption of the given Polynom with the private key, its inverse
|
* Decryption of the given Polynom with the private key, its inverse
|
||||||
* and the fitting ntru_params
|
* and the fitting ntru_params
|
||||||
*
|
*
|
||||||
|
* @param out_tern the resulting ternary polynom [out]
|
||||||
* @param encr_msg encrypted polynomial with maximum length of N from
|
* @param encr_msg encrypted polynomial with maximum length of N from
|
||||||
* the given context
|
* the given context
|
||||||
* @param priv_key the polynomial containing the private key to decrypt
|
* @param priv_key the polynomial containing the private key to decrypt
|
||||||
* the message
|
* the message
|
||||||
* @param priv_key_inv the inverse polynome to the private key
|
* @param priv_key_inv the inverse polynome to the private key
|
||||||
* @param out_tern the resulting ternary polynom [out]
|
|
||||||
* @param params the ntru_params
|
* @param params the ntru_params
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
ntru_decrypt_poly(
|
ntru_decrypt_poly(
|
||||||
|
fmpz_poly_t out_tern,
|
||||||
const fmpz_poly_t encr_msg,
|
const fmpz_poly_t encr_msg,
|
||||||
const fmpz_poly_t priv_key,
|
const fmpz_poly_t priv_key,
|
||||||
const fmpz_poly_t priv_key_inv,
|
const fmpz_poly_t priv_key_inv,
|
||||||
fmpz_poly_t out_tern,
|
|
||||||
const ntru_params *params);
|
const ntru_params *params);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -44,10 +44,10 @@
|
|||||||
|
|
||||||
void
|
void
|
||||||
ntru_encrypt_poly(
|
ntru_encrypt_poly(
|
||||||
|
fmpz_poly_t out,
|
||||||
const fmpz_poly_t msg_bin,
|
const fmpz_poly_t msg_bin,
|
||||||
const fmpz_poly_t pub_key,
|
const fmpz_poly_t pub_key,
|
||||||
const fmpz_poly_t rnd,
|
const fmpz_poly_t rnd,
|
||||||
fmpz_poly_t out,
|
|
||||||
const ntru_params *params)
|
const ntru_params *params)
|
||||||
{
|
{
|
||||||
fmpz_poly_t tmp_poly_msg;
|
fmpz_poly_t tmp_poly_msg;
|
||||||
@ -60,7 +60,7 @@ ntru_encrypt_poly(
|
|||||||
fmpz_poly_set(tmp_poly_msg, msg_bin);
|
fmpz_poly_set(tmp_poly_msg, msg_bin);
|
||||||
|
|
||||||
fmpz_poly_zero(out);
|
fmpz_poly_zero(out);
|
||||||
poly_starmultiply(pub_key, rnd, out, params, params->q);
|
poly_starmultiply(out, pub_key, rnd, params, params->q);
|
||||||
|
|
||||||
fmpz_poly_add(out, out, tmp_poly_msg);
|
fmpz_poly_add(out, out, tmp_poly_msg);
|
||||||
fmpz_poly_mod_unsigned(out, params->q);
|
fmpz_poly_mod_unsigned(out, params->q);
|
||||||
@ -88,9 +88,9 @@ ntru_encrypt_string(
|
|||||||
|
|
||||||
while (*poly_array[i]) {
|
while (*poly_array[i]) {
|
||||||
ntru_encrypt_poly(*poly_array[i],
|
ntru_encrypt_poly(*poly_array[i],
|
||||||
|
*poly_array[i],
|
||||||
pub_key,
|
pub_key,
|
||||||
rnd,
|
rnd,
|
||||||
*poly_array[i],
|
|
||||||
params);
|
params);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
@ -51,20 +51,20 @@
|
|||||||
*
|
*
|
||||||
* q = large mod
|
* q = large mod
|
||||||
*
|
*
|
||||||
|
* @param out the output poly which is in the range {0, q-1}
|
||||||
|
* (not ternary!) [out]
|
||||||
* @param msg_tern the message to encrypt, in ternary format
|
* @param msg_tern the message to encrypt, in ternary format
|
||||||
* @param pub_key the public key
|
* @param pub_key the public key
|
||||||
* @param rnd the random poly (should have relatively small
|
* @param rnd the random poly (should have relatively small
|
||||||
* coefficients, but not restricted to {-1, 0, 1})
|
* coefficients, but not restricted to {-1, 0, 1})
|
||||||
* @param out the output poly which is in the range {0, q-1}
|
|
||||||
* (not ternary!) [out]
|
|
||||||
* @param params ntru_params the ntru context
|
* @param params ntru_params the ntru context
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
ntru_encrypt_poly(
|
ntru_encrypt_poly(
|
||||||
|
fmpz_poly_t out,
|
||||||
const fmpz_poly_t msg_tern,
|
const fmpz_poly_t msg_tern,
|
||||||
const fmpz_poly_t pub_key,
|
const fmpz_poly_t pub_key,
|
||||||
const fmpz_poly_t rnd,
|
const fmpz_poly_t rnd,
|
||||||
fmpz_poly_t out,
|
|
||||||
const ntru_params *params);
|
const ntru_params *params);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -45,9 +45,9 @@
|
|||||||
|
|
||||||
bool
|
bool
|
||||||
ntru_create_keypair(
|
ntru_create_keypair(
|
||||||
|
keypair *pair,
|
||||||
const fmpz_poly_t f,
|
const fmpz_poly_t f,
|
||||||
const fmpz_poly_t g,
|
const fmpz_poly_t g,
|
||||||
keypair *pair,
|
|
||||||
const ntru_params *params)
|
const ntru_params *params)
|
||||||
{
|
{
|
||||||
bool retval = false;
|
bool retval = false;
|
||||||
@ -62,13 +62,13 @@ ntru_create_keypair(
|
|||||||
fmpz_poly_init(Fp);
|
fmpz_poly_init(Fp);
|
||||||
fmpz_poly_init(pub);
|
fmpz_poly_init(pub);
|
||||||
|
|
||||||
if (!poly_inverse_poly_q(f, Fq, params))
|
if (!poly_inverse_poly_q(Fq, f, params))
|
||||||
goto _cleanup;
|
goto _cleanup;
|
||||||
|
|
||||||
if (!poly_inverse_poly_p(f, Fp, params))
|
if (!poly_inverse_poly_p(Fp, f, params))
|
||||||
goto _cleanup;
|
goto _cleanup;
|
||||||
|
|
||||||
poly_starmultiply(Fq, g, pub, params, params->q);
|
poly_starmultiply(pub, Fq, g, params, params->q);
|
||||||
fmpz_poly_scalar_mul_ui(pub, pub, params->p);
|
fmpz_poly_scalar_mul_ui(pub, pub, params->p);
|
||||||
fmpz_poly_mod_unsigned(pub, params->q);
|
fmpz_poly_mod_unsigned(pub, params->q);
|
||||||
|
|
||||||
@ -129,8 +129,8 @@ export_priv_key(char const * const filename,
|
|||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
|
|
||||||
void
|
void
|
||||||
import_public_key(char const * const filename,
|
import_public_key(fmpz_poly_t pub,
|
||||||
fmpz_poly_t pub,
|
char const * const filename,
|
||||||
const ntru_params *params)
|
const ntru_params *params)
|
||||||
{
|
{
|
||||||
string *pub_string;
|
string *pub_string;
|
||||||
@ -154,9 +154,9 @@ import_public_key(char const * const filename,
|
|||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
|
|
||||||
void
|
void
|
||||||
import_priv_key(char const * const filename,
|
import_priv_key(fmpz_poly_t priv,
|
||||||
fmpz_poly_t priv,
|
|
||||||
fmpz_poly_t priv_inv,
|
fmpz_poly_t priv_inv,
|
||||||
|
char const * const filename,
|
||||||
const ntru_params *params)
|
const ntru_params *params)
|
||||||
{
|
{
|
||||||
string *pub_string;
|
string *pub_string;
|
||||||
@ -177,7 +177,7 @@ import_priv_key(char const * const filename,
|
|||||||
|
|
||||||
fmpz_poly_set(priv, **imported);
|
fmpz_poly_set(priv, **imported);
|
||||||
|
|
||||||
if (!poly_inverse_poly_p(priv, Fp, params))
|
if (!poly_inverse_poly_p(Fp, priv, params))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
fmpz_poly_mod(Fp, params->p);
|
fmpz_poly_mod(Fp, params->p);
|
||||||
|
@ -67,18 +67,18 @@ struct keypair {
|
|||||||
* consisting of public and private
|
* consisting of public and private
|
||||||
* components.
|
* components.
|
||||||
*
|
*
|
||||||
|
* @param pair store private and public components here [out]
|
||||||
* @param f a random polynomial
|
* @param f a random polynomial
|
||||||
* @param g a random polynomial
|
* @param g a random polynomial
|
||||||
* @param pair store private and public components here [out]
|
|
||||||
* @param params the NTRU context
|
* @param params the NTRU context
|
||||||
* @return true for success, false if f or g are not invertible
|
* @return true for success, false if f or g are not invertible
|
||||||
* (then the caller hast to try different ones)
|
* (then the caller hast to try different ones)
|
||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
ntru_create_keypair(
|
ntru_create_keypair(
|
||||||
|
keypair *pair,
|
||||||
const fmpz_poly_t f,
|
const fmpz_poly_t f,
|
||||||
const fmpz_poly_t g,
|
const fmpz_poly_t g,
|
||||||
keypair *pair,
|
|
||||||
const ntru_params *params);
|
const ntru_params *params);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -107,28 +107,29 @@ export_priv_key(char const * const filename,
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Import the public key from a file.
|
* Import the public key from a file.
|
||||||
* @param filename the file to get the public key from
|
*
|
||||||
* @param pub where to save the public key [out]
|
* @param pub where to save the public key [out]
|
||||||
|
* @param filename the file to get the public key from
|
||||||
* @param params the NTRU context
|
* @param params the NTRU context
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
import_public_key(char const * const filename,
|
import_public_key(fmpz_poly_t pub,
|
||||||
fmpz_poly_t pub,
|
char const * const filename,
|
||||||
const ntru_params *params);
|
const ntru_params *params);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Import the private key from a file and store him
|
* Import the private key from a file and store him
|
||||||
* along with his inverse.
|
* along with his inverse.
|
||||||
*
|
*
|
||||||
* @param filename the file to get the private key from
|
|
||||||
* @param priv where to save the private key [out]
|
* @param priv where to save the private key [out]
|
||||||
* @param priv_inv where to save the inverse of the private key [out]
|
* @param priv_inv where to save the inverse of the private key [out]
|
||||||
|
* @param filename the file to get the private key from
|
||||||
* @param params the NTRU context
|
* @param params the NTRU context
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
import_priv_key(char const * const filename,
|
import_priv_key(fmpz_poly_t priv,
|
||||||
fmpz_poly_t priv,
|
|
||||||
fmpz_poly_t priv_inv,
|
fmpz_poly_t priv_inv,
|
||||||
|
char const * const filename,
|
||||||
const ntru_params *params);
|
const ntru_params *params);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -47,21 +47,21 @@
|
|||||||
* Find the inverse polynomial modulo a power of 2,
|
* Find the inverse polynomial modulo a power of 2,
|
||||||
* which is q.
|
* which is q.
|
||||||
*
|
*
|
||||||
* @param a polynomial to invert
|
|
||||||
* @param Fq polynomial [out]
|
* @param Fq polynomial [out]
|
||||||
|
* @param a polynomial to invert
|
||||||
* @param params NTRU parameters
|
* @param params NTRU parameters
|
||||||
*/
|
*/
|
||||||
static
|
static
|
||||||
void poly_mod2_to_modq(const fmpz_poly_t a,
|
void poly_mod2_to_modq(fmpz_poly_t Fq,
|
||||||
fmpz_poly_t Fq,
|
const fmpz_poly_t a,
|
||||||
const ntru_params *params);
|
const ntru_params *params);
|
||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
poly_mod2_to_modq(const fmpz_poly_t a,
|
poly_mod2_to_modq(fmpz_poly_t Fq,
|
||||||
fmpz_poly_t Fq,
|
const fmpz_poly_t a,
|
||||||
const ntru_params *params)
|
const ntru_params *params)
|
||||||
{
|
{
|
||||||
int v = 2;
|
int v = 2;
|
||||||
@ -75,10 +75,10 @@ poly_mod2_to_modq(const fmpz_poly_t a,
|
|||||||
while (v < (int)(params->q)) {
|
while (v < (int)(params->q)) {
|
||||||
v = v * 2;
|
v = v * 2;
|
||||||
|
|
||||||
poly_starmultiply(a, Fq, poly_tmp, params, v);
|
poly_starmultiply(poly_tmp, a, Fq, params, v);
|
||||||
fmpz_poly_sub(poly_tmp, two, poly_tmp);
|
fmpz_poly_sub(poly_tmp, two, poly_tmp);
|
||||||
fmpz_poly_mod_unsigned(poly_tmp, v);
|
fmpz_poly_mod_unsigned(poly_tmp, v);
|
||||||
poly_starmultiply(Fq, poly_tmp, Fq, params, v);
|
poly_starmultiply(Fq, Fq, poly_tmp, params, v);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -236,9 +236,9 @@ fmpz_add_n(fmpz_t f, const fmpz_t g, const fmpz_t h)
|
|||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
|
|
||||||
void
|
void
|
||||||
poly_starmultiply(const fmpz_poly_t a,
|
poly_starmultiply(fmpz_poly_t c,
|
||||||
|
const fmpz_poly_t a,
|
||||||
const fmpz_poly_t b,
|
const fmpz_poly_t b,
|
||||||
fmpz_poly_t c,
|
|
||||||
const ntru_params *params,
|
const ntru_params *params,
|
||||||
uint32_t modulus)
|
uint32_t modulus)
|
||||||
{
|
{
|
||||||
@ -294,8 +294,8 @@ poly_starmultiply(const fmpz_poly_t a,
|
|||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
|
|
||||||
bool
|
bool
|
||||||
poly_inverse_poly_q(const fmpz_poly_t a,
|
poly_inverse_poly_q(fmpz_poly_t Fq,
|
||||||
fmpz_poly_t Fq,
|
const fmpz_poly_t a,
|
||||||
const ntru_params *params)
|
const ntru_params *params)
|
||||||
{
|
{
|
||||||
bool retval = false;
|
bool retval = false;
|
||||||
@ -383,11 +383,11 @@ poly_inverse_poly_q(const fmpz_poly_t a,
|
|||||||
fmpz_poly_set_coeff_fmpz_n(Fq, j, b_i);
|
fmpz_poly_set_coeff_fmpz_n(Fq, j, b_i);
|
||||||
}
|
}
|
||||||
|
|
||||||
poly_mod2_to_modq(a_tmp, Fq, params);
|
poly_mod2_to_modq(Fq, a_tmp, params);
|
||||||
|
|
||||||
/* check if the f * Fq = 1 (mod p) condition holds true */
|
/* check if the f * Fq = 1 (mod p) condition holds true */
|
||||||
fmpz_poly_set(a_tmp, a);
|
fmpz_poly_set(a_tmp, a);
|
||||||
poly_starmultiply(a_tmp, Fq, a_tmp, params, params->q);
|
poly_starmultiply(a_tmp, a_tmp, Fq, params, params->q);
|
||||||
if (fmpz_poly_is_one(a_tmp))
|
if (fmpz_poly_is_one(a_tmp))
|
||||||
retval = true;
|
retval = true;
|
||||||
else
|
else
|
||||||
@ -406,8 +406,8 @@ _cleanup:
|
|||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
|
|
||||||
bool
|
bool
|
||||||
poly_inverse_poly_p(const fmpz_poly_t a,
|
poly_inverse_poly_p(fmpz_poly_t Fp,
|
||||||
fmpz_poly_t Fp,
|
const fmpz_poly_t a,
|
||||||
const ntru_params *params)
|
const ntru_params *params)
|
||||||
{
|
{
|
||||||
bool retval = false;
|
bool retval = false;
|
||||||
@ -552,7 +552,7 @@ poly_inverse_poly_p(const fmpz_poly_t a,
|
|||||||
|
|
||||||
/* check if the f * Fp = 1 (mod p) condition holds true */
|
/* check if the f * Fp = 1 (mod p) condition holds true */
|
||||||
fmpz_poly_set(a_tmp, a);
|
fmpz_poly_set(a_tmp, a);
|
||||||
poly_starmultiply(a_tmp, Fp, a_tmp, params, params->p);
|
poly_starmultiply(a_tmp, a_tmp, Fp, params, params->p);
|
||||||
if (fmpz_poly_is_one(a_tmp))
|
if (fmpz_poly_is_one(a_tmp))
|
||||||
retval = true;
|
retval = true;
|
||||||
else
|
else
|
||||||
|
@ -169,16 +169,16 @@ fmpz_add_n(fmpz_t f, const fmpz_t g, const fmpz_t h);
|
|||||||
* Starmultiplication, as follows:
|
* Starmultiplication, as follows:
|
||||||
* c = a * b mod (x^N − 1)
|
* c = a * b mod (x^N − 1)
|
||||||
*
|
*
|
||||||
|
* @param c polynom [out]
|
||||||
* @param a polynom to multiply (can be the same as c)
|
* @param a polynom to multiply (can be the same as c)
|
||||||
* @param b polynom to multiply
|
* @param b polynom to multiply
|
||||||
* @param c polynom [out]
|
|
||||||
* @param params NTRU parameters
|
* @param params NTRU parameters
|
||||||
* @param modulus whether we use p or q
|
* @param modulus whether we use p or q
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
poly_starmultiply(const fmpz_poly_t a,
|
poly_starmultiply(fmpz_poly_t c,
|
||||||
|
const fmpz_poly_t a,
|
||||||
const fmpz_poly_t b,
|
const fmpz_poly_t b,
|
||||||
fmpz_poly_t c,
|
|
||||||
const ntru_params *params,
|
const ntru_params *params,
|
||||||
uint32_t modulus);
|
uint32_t modulus);
|
||||||
|
|
||||||
@ -189,14 +189,14 @@ poly_starmultiply(const fmpz_poly_t a,
|
|||||||
* See NTRU Cryptosystems Tech Report #014 "Almost Inverses
|
* See NTRU Cryptosystems Tech Report #014 "Almost Inverses
|
||||||
* and Fast NTRU Key Creation."
|
* and Fast NTRU Key Creation."
|
||||||
*
|
*
|
||||||
* @param a polynomial to invert (is allowed to be the same as param Fq)
|
|
||||||
* @param Fq polynomial [out]
|
* @param Fq polynomial [out]
|
||||||
|
* @param a polynomial to invert (is allowed to be the same as param Fq)
|
||||||
* @param params NTRU parameters
|
* @param params NTRU parameters
|
||||||
* @return true if invertible, false if not
|
* @return true if invertible, false if not
|
||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
poly_inverse_poly_q(const fmpz_poly_t a,
|
poly_inverse_poly_q(fmpz_poly_t Fq,
|
||||||
fmpz_poly_t Fq,
|
const fmpz_poly_t a,
|
||||||
const ntru_params *params);
|
const ntru_params *params);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -204,14 +204,14 @@ poly_inverse_poly_q(const fmpz_poly_t a,
|
|||||||
* See NTRU Cryptosystems Tech Report #014 "Almost Inverses
|
* See NTRU Cryptosystems Tech Report #014 "Almost Inverses
|
||||||
* and Fast NTRU Key Creation."
|
* and Fast NTRU Key Creation."
|
||||||
*
|
*
|
||||||
* @param a polynomial to invert
|
|
||||||
* @param Fp polynomial [out]
|
* @param Fp polynomial [out]
|
||||||
|
* @param a polynomial to invert
|
||||||
* @param params NTRU parameters
|
* @param params NTRU parameters
|
||||||
* @return true if invertible, false if not
|
* @return true if invertible, false if not
|
||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
poly_inverse_poly_p(const fmpz_poly_t a,
|
poly_inverse_poly_p(fmpz_poly_t Fp,
|
||||||
fmpz_poly_t Fp,
|
const fmpz_poly_t a,
|
||||||
const ntru_params *params);
|
const ntru_params *params);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user