MersennePrimeFieldDefinition implements FieldDefinition { @Override public BigInteger convertToSigned(BigInteger asUnsigned) { return FieldUtils.convertRepresentation(asUnsigned, getModulus(), modulusHalf); } MersennePrimeFieldDefinition(int bitLength, int constant); @Override FieldElement createElement(long value); @Override FieldElement createElement(String value); @Override FieldElement createElement(BigInteger value); @Override BigInteger getModulus(); @Override int getBitLength(); @Override StrictBitVector convertToBitVector(FieldElement fieldElement); @Override BigInteger convertToUnsigned(FieldElement value); @Override BigInteger convertToSigned(BigInteger asUnsigned); @Override byte[] serialize(FieldElement fieldElement); @Override byte[] serialize(List<FieldElement> fieldElements); @Override FieldElement deserialize(byte[] bytes); @Override List<FieldElement> deserializeList(byte[] bytes);  }
@Test public void convertToSigned() { MersennePrimeFieldDefinition definition_1 = new MersennePrimeFieldDefinition(3,1); testConversions(definition_1,3,3); testConversions(definition_1,4,-3); testConversions(definition_1,6,-1); testConversions(definition_1,7,0); }