Exemplo n.º 1
0
 public WEC3n(GF3nElement a, GF3nElement b, GF3nElement c) {
   if (!(a.getFiniteField().equals(b.getFiniteField())
       || b.getFiniteField().equals(c.getFiniteField())))
     throw new InvalidParameterException("coefficients are not in the same finite field");
   this.a = new GF3nElement(a);
   this.b = new GF3nElement(b);
   this.c = new GF3nElement(c);
 }
Exemplo n.º 2
0
 @Override
 public boolean isSingular() {
   if (a.isZero() && b.isZero()) return false;
   else if (!(a.isZero() || b.isZero())) {
     try {
       GF3nElement x = a.invert().multiply(b);
       if (x.cube().sum(x.multiply(b).negate()).sum(c).isZero()) return false;
       else return true;
     } catch (NoCommonFiniteFieldException | NotInFiniteFieldException e) {
       // This shouldn't happen never
       e.printStackTrace();
       return false;
     }
   } else return true;
 }
Exemplo n.º 3
0
 public HEC3n toHessian() {
   if (this.isSupersingular() && !this.a.equals(this.a.getFiniteField().one()))
     throw new InvalidParameterException(
         "Elliptic curve must be ordinary and the quadratic coefficient must be 1.");
   try {
     GF3nElement x = a.invert().multiply(b);
     GF3nElement newC = x.cube().sum(x.multiply(b).negate()).sum(c);
     int n = this.a.getFiniteField().getExtensionDegree();
     for (int i = 1; i < n; i++) newC = newC.cube();
     newC = newC.invert().negate();
     return new HEC3n(newC);
   } catch (NoCommonFiniteFieldException | NotInFiniteFieldException e) {
     // This shouldn't happen never
     e.printStackTrace();
     return null;
   }
 }