Пример #1
0
void gf2m_decomp_rootfind_state::calc_next_Aij()
   {
   /*
   * upon function entry, we have in the state j, Aij.
   * first thing, we declare Aij Aij_minusone and increase j.
   * Case j=0 upon function entry also included, then Aij contains A_{i,j=0}.
   */
   uint32_t i;
   gf2m diff, new_j_gray;
   uint32_t Lik_pos_base;

   this->m_j++;

   new_j_gray =  lex_to_gray(this->m_j);

   if(this->m_j & 1)  /* half of the times */
      {
      Lik_pos_base = 0;
      }
   else if(this->m_j & 2) /* one quarter of the times */
      {
      Lik_pos_base = this->m_outer_summands;
      }
   else if( this->m_j & 4) /* one eighth of the times */
      {
      Lik_pos_base = this->m_outer_summands * 2;
      }
   else if( this->m_j & 8) /* one sixteenth of the times */
      {
      Lik_pos_base = this->m_outer_summands * 3;
      }
   else if( this->m_j & 16) /* ... */
      {
      Lik_pos_base = this->m_outer_summands * 4;
      }
   else
      {
      gf2m delta_offs = 5;
      diff = this->m_j_gray ^ new_j_gray;
      while(((static_cast<gf2m>(1) << delta_offs) & diff) == 0)
         {
         delta_offs++;

         }
      Lik_pos_base = delta_offs * this->m_outer_summands;
      }
   this->m_j_gray = new_j_gray;

   i = 0;
   for(; i < this->m_outer_summands; i++)
      {
      this->m_Aij[i] ^= this->m_Lik[Lik_pos_base + i];
      }

   }
Пример #2
0
std::unique_ptr<binary_matrix> generate_R(std::vector<gf2m> &L, polyn_gf2m* g, std::shared_ptr<GF2m_Field> sp_field, u32bit code_length, u32bit t )
{
    //L- Support
    //t- Number of errors
    //n- Length of the Goppa code
    //m- The extension degree of the GF
    //g- The generator polynomial.
    gf2m x,y;
    u32bit i,j,k,r,n;
    std::vector<int> Laux(code_length);
    n=code_length;
    r=t*sp_field->get_extension_degree();

    binary_matrix H(r, n) ;

    for(i=0; i< n; i++)
    {
        x = g->eval(lex_to_gray(L[i]));//evaluate the polynomial at the point L[i].
        x = sp_field->gf_inv(x);
        y = x;
        for(j=0; j<t; j++)
        {
            for(k=0; k<sp_field->get_extension_degree(); k++)
            {
                if(y & (1<<k))
                {
                    //the co-eff. are set in 2^0,...,2^11 ; 2^0,...,2^11 format along the rows/cols?
                    H.set_coef_to_one(j*sp_field->get_extension_degree()+ k,i);
                }
            }
            y = sp_field->gf_mul(y,lex_to_gray(L[i]));
        }
    }//The H matrix is fed.

    secure_vector<int> perm = H.row_reduced_echelon_form();
    if (perm.size() == 0)
    {
        // result still is NULL
        throw Invalid_State("could not bring matrix in row reduced echelon form");
    }

    std::unique_ptr<binary_matrix> result(new binary_matrix(n-r,r)) ;
    for (i = 0; i < (*result).m_rown; ++i)
    {
        for (j = 0; j < (*result).m_coln; ++j)
        {
            if (H.coef(j,perm[i]))
            {
                result->toggle_coeff(i,j);
            }
        }
    }
    for (i = 0; i < code_length; ++i)
    {
        Laux[i] = L[perm[i]];
    }
    for (i = 0; i < code_length; ++i)
    {
        L[i] = Laux[i];
    }
    return result;
}