Page MenuHomec4science

ECElGamalTest.java
No OneTemporary

File Metadata

Created
Tue, Jan 7, 00:12

ECElGamalTest.java

package crypto.elgamal;
import static org.junit.Assert.*;
import java.math.BigInteger;
import org.bouncycastle.asn1.nist.NISTNamedCurves;
import org.junit.Test;
public class ECElGamalTest {
@Test
public void testEncrypt() {
ECElGamal eccegScheme = new ECElGamal(NISTNamedCurves.getByName("P-384"));
eccegScheme.initReverseDLTable();
BigInteger msg = new BigInteger("3");
FragmentEncrypted fragEncrypted = eccegScheme.encrypt(msg);
BigInteger msgDecrypted = eccegScheme.decrypt(fragEncrypted);
assertTrue("Dec[Enc[m]] == m", msgDecrypted.equals(new BigInteger("3")));
}
@Test
public void testDecrypt() {
ECElGamal eccegScheme = new ECElGamal(NISTNamedCurves.getByName("P-384"));
eccegScheme.initReverseDLTable();
BigInteger msg = new BigInteger("3");
FragmentEncrypted fragEncrypted = eccegScheme.encrypt(msg);
BigInteger msgDecrypted = eccegScheme.decrypt(fragEncrypted);
assertTrue("Dec[Enc[m]] == m", msgDecrypted.equals(new BigInteger("3")));
}
}

Event Timeline