MersennePrimeFieldElement implements FieldElement { @Override public FieldElement negate() { return create(getModulus().subtract(value)); } private  MersennePrimeFieldElement(BigInteger value, MersennePrimeModulus modulus); @Override FieldElement add(FieldElement operand); @Override FieldElement subtract(FieldElement operand); @Override FieldElement negate(); @Override FieldElement multiply(FieldElement operand); @Override FieldElement sqrt(); @Override FieldElement modInverse(); @Override String toString();  }
@Test public void negate() { BigInteger result1 = MersennePrimeFieldElement.extractValue(element1.negate()); BigInteger result2 = MersennePrimeFieldElement.extractValue(element2.negate()); BigInteger result3 = MersennePrimeFieldElement.extractValue(element3.negate()); BigInteger value1 = MersennePrimeFieldElement.extractValue(element1); BigInteger value2 = MersennePrimeFieldElement.extractValue(element2); BigInteger value3 = MersennePrimeFieldElement.extractValue(element3); assertThat(result1, Is.is(modulus.getPrime().subtract(value1))); assertThat(result2, Is.is(modulus.getPrime().subtract(value2))); assertThat(result3, Is.is(modulus.getPrime().subtract(value3))); }