Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package org.bouncycastle.pqc.jcajce.provider.mceliece;
  
  
 
     implements CipherParametersPrivateKey
 {


    
 
     private static final long serialVersionUID = 1L;
 
     // the OID of the algorithm
     private String oid;
 
     // the length of the code
     private int n;
 
     // the dimension of the code, k>=n-mt
     private int k;
 
     // the finte field GF(2^m)
     private GF2mField field;
 
     // the irreducible Goppa polynomial
     private PolynomialGF2mSmallM goppaPoly;
 
     // the permutation
     private Permutation p;
 
     // the canonical check matrix
     private GF2Matrix h;
 
     // the matrix used to compute square roots in (GF(2^m))^t
     private PolynomialGF2mSmallM[] qInv;
 
     private McElieceCCA2Parameters mcElieceCCA2Params;

    
Constructor (used by the org.bouncycastle.pqc.crypto.mceliece.McElieceCCA2KeyPairGenerator).

Parameters:
n the length of the code
k the dimension of the code
field the field polynomial
gp the irreducible Goppa polynomial
p the permutation
h the canonical check matrix
qInv the matrix used to compute square roots in (GF(2^m))^t
 
     public BCMcElieceCCA2PrivateKey(String oidint nint kGF2mField field,
                                     PolynomialGF2mSmallM gpPermutation pGF2Matrix h,
                                     PolynomialGF2mSmallM[] qInv)
     {
         this. = oid;
         this. = n;
         this. = k;
         this. = field;
         this. = gp;
         this. = p;
         this. = h;
         this. = qInv;
     }

    
 
     {
         this(keySpec.getOIDString(), keySpec.getN(), keySpec.getK(), keySpec.getField(), keySpec
             .getGoppaPoly(), keySpec.getP(), keySpec.getH(), keySpec
             .getQInv());
    }
    {
        this(params.getOIDString(), params.getN(), params.getK(), params.getField(), params.getGoppaPoly(),
            params.getP(), params.getH(), params.getQInv());
        this. = params.getParameters();
    }

    
Return the name of the algorithm.

Returns:
"McEliece"
    public String getAlgorithm()
    {
        return "McEliece";
    }

    

Returns:
the length of the code
    public int getN()
    {
        return ;
    }

    

Returns:
the dimension of the code
    public int getK()
    {
        return ;
    }

    

Returns:
the degree of the Goppa polynomial (error correcting capability)
    public int getT()
    {
        return .getDegree();
    }

    

Returns:
the finite field
    public GF2mField getField()
    {
        return ;
    }

    

Returns:
the irreducible Goppa polynomial
    {
        return ;
    }

    

Returns:
the permutation vector
    public Permutation getP()
    {
        return ;
    }

    

Returns:
the canonical check matrix
    public GF2Matrix getH()
    {
        return ;
    }

    

Returns:
the matrix used to compute square roots in (GF(2^m))^t
    public PolynomialGF2mSmallM[] getQInv()
    {
        return ;
    }

    

Returns:
a human readable form of the key
    public String toString()
    {
        String result = "";
        result += " extension degree of the field      : " +  + "\n";
        result += " dimension of the code              : " +  + "\n";
        result += " irreducible Goppa polynomial       : " +  + "\n";
        return result;
    }

    
Compare this key with another object.

Parameters:
other the other object
Returns:
the result of the comparison
    public boolean equals(Object other)
    {
        if (other == null || !(other instanceof BCMcElieceCCA2PrivateKey))
        {
            return false;
        }
        BCMcElieceCCA2PrivateKey otherKey = (BCMcElieceCCA2PrivateKey)other;
        return ( == otherKey.n) && ( == otherKey.k)
            && .equals(otherKey.field)
            && .equals(otherKey.goppaPoly) && .equals(otherKey.p)
            && .equals(otherKey.h);
    }

    

Returns:
the hash code of this key
    public int hashCode()
    {
        return  +  + .hashCode() + .hashCode() + .hashCode()
            + .hashCode();
    }

    

Returns:
the OID of the algorithm
    public String getOIDString()
    {
        return ;
    }

    

Returns:
the OID to encode in the SubjectPublicKeyInfo structure
    protected ASN1ObjectIdentifier getOID()
    {
    }

    

Returns:
the algorithm parameters to encode in the SubjectPublicKeyInfo structure
    protected ASN1Primitive getAlgParams()
    {
        return null// FIXME: needed at all?
    }


    
Return the keyData to encode in the SubjectPublicKeyInfo structure.

The ASN.1 definition of the key structure is

   McEliecePrivateKey ::= SEQUENCE {
     m             INTEGER                  -- extension degree of the field
     k             INTEGER                  -- dimension of the code
     field         OCTET STRING             -- field polynomial
     goppaPoly     OCTET STRING             -- irreducible Goppa polynomial
     p             OCTET STRING             -- permutation vector
     matrixH       OCTET STRING             -- canonical check matrix
     sqRootMatrix  SEQUENCE OF OCTET STRING -- square root matrix
   }
 

Returns:
the keyData to encode in the SubjectPublicKeyInfo structure
    public byte[] getEncoded()
    {
        McElieceCCA2PrivateKey privateKey = new McElieceCCA2PrivateKey(new ASN1ObjectIdentifier(), );
        PrivateKeyInfo pki;
        try
        {
            AlgorithmIdentifier algorithmIdentifier = new AlgorithmIdentifier(this.getOID(), .);
            pki = new PrivateKeyInfo(algorithmIdentifierprivateKey);
        }
        catch (IOException e)
        {
            e.printStackTrace();
            return null;
        }
        try
        {
            byte[] encoded = pki.getEncoded();
            return encoded;
        }
        catch (IOException e)
        {
            e.printStackTrace();
            return null;
        }
    }
    public String getFormat()
    {
        // TODO Auto-generated method stub
        return null;
    }
    {
        return ;
    }
New to GrepCode? Check out our FAQ X