FieldElementFp extends FieldElement implements Serializable { @Override public FieldElement multInv() { if (this.getData().equals(BigInteger.ZERO)) { throw new ArithmeticException(); } BigInteger tmp = this.getData().modInverse(this.getModulus()); return new FieldElementFp(tmp, this.getModulus()); } FieldElementFp(BigInteger data, BigInteger modulus); private  FieldElementFp(); @Override FieldElement add(FieldElement f); @Override FieldElement mult(FieldElement f); @Override FieldElement addInv(); @Override FieldElement multInv();  }
@Test public void testMultInv() { FieldElementFp tmp = (FieldElementFp) e2.multInv(); FieldElementFp result = new FieldElementFp(new BigInteger("33"), modulus); assertEquals(result, tmp); try { zero.multInv(); fail(); } catch (ArithmeticException e) { } }