Menu

#3 Parameter Structure

closed
nobody
None
5
2015-02-21
2015-02-19
Guess Who
No

Could you please add the following C function (or a derivative)? I would like to populate an NtruEncParams structure for a given key pair.

ifndef NTRU_AVOID_HAMMING_WT_PATENT

define ALL_PARAM_SETS {EES401EP1, EES449EP1, EES667EP1, EES1087EP2, EES541EP1, EES613EP1, EES887EP1, EES1171EP1, EES659EP1, EES761EP1, EES1087EP1, EES1499EP1, EES401EP2, EES439EP1, EES593EP1, EES743EP1}

else

define ALL_PARAM_SETS {EES401EP1, EES449EP1, EES667EP1, EES1087EP2, EES541EP1, EES613EP1, EES887EP1, EES1171EP1, EES659EP1, EES761EP1, EES1087EP1, EES1499EP1}

endif / NTRU_AVOID_HAMMING_WT_PATENT /

void ntru_enc_params_from_kp(NtruEncKeyPair keypair, NtruEncParams parameters)
{
if(!keypair || !parameters)
return;

size_t i = 0;
struct NtruEncParams all[] = ALL_PARAM_SETS;

for(i = 0; i < sizeof(all) / sizeof(struct NtruEncParams); i++)
if(keypair->pub.h.N == all[i].N)
{
parameters->N = all[i].N;
parameters->q = all[i].q;
parameters->prod_flag = all[i].prod_flag;
parameters->df1 = all[i].df1;
parameters->df2 = all[i].df2;
parameters->df3 = all[i].df3;
parameters->dm0 = all[i].dm0;
parameters->maxm1 = all[i].maxm1;
parameters->db = all[i].db;
parameters->c = all[i].c;
parameters->min_calls_r = all[i].min_calls_r;
parameters->min_calls_mask = all[i].min_calls_mask;
parameters->hash_seed = all[i].hash_seed;
memcpy(parameters->oid, all[i].oid, 3 * sizeof(uint8_t));
parameters->sparse = all[i].sparse;
parameters->hash = all[i].hash;
parameters->hlen = all[i].hlen;
parameters->pklen = all[i].pklen;
break;
}
}

Discussion

  • Tim Buktu

    Tim Buktu - 2015-02-19

    The problem with that is that there are parameter sets that have the same N value: EES1087EP1 and EES1087EP2. I don't think there is enough information in a public key to uniquely identify the parameter set.

    If you are using libntru in an application, can't you store the name of the parameter set along with the key? You'd also need something like a get_param_set_by_name(char *) function which I wouldn't mind adding to libntru.

     
  • Guess Who

    Guess Who - 2015-02-19

    Ah, yes. I was hoping that you'd identify a better set of attributes. :) For the keys that I am using, N is unique. Your proposed function would be very helpful. Thanks.

     
  • Tim Buktu

    Tim Buktu - 2015-02-20

    Silly me realized you said key pair, not public key. Yes, this can be done. In fact, a private key is enough.
    I added two functions named ntru_params_from_key_pair and ntru_params_from_priv_key. The latest sources are at https://github.com/tbuktu/libntru .

     
  • Tim Buktu

    Tim Buktu - 2015-02-20
    • Status: open --> closed
     
  • Guess Who

    Guess Who - 2015-02-20

    Thanks! If you don't mind, please remove the extra "the" from "for a given the key pair" in the original description.

     
  • Tim Buktu

    Tim Buktu - 2015-02-21
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1,4 +1,4 @@
    -Could you please add the following C function (or a derivative)? I would like to populate an NtruEncParams structure for a given the key pair.
    +Could you please add the following C function (or a derivative)? I would like to populate an NtruEncParams structure for a given key pair.
    
     #ifndef NTRU_AVOID_HAMMING_WT_PATENT
     #define ALL_PARAM_SETS {EES401EP1, EES449EP1, EES667EP1, EES1087EP2, EES541EP1, EES613EP1, EES887EP1, EES1171EP1, EES659EP1, EES761EP1, EES1087EP1, EES1499EP1, EES401EP2, EES439EP1, EES593EP1, EES743EP1}
    
     

Log in to post a comment.

MongoDB Logo MongoDB