Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F97872294
ECElGamalTest.java
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Tue, Jan 7, 00:46
Size
995 B
Mime Type
text/x-java
Expires
Thu, Jan 9, 00:46 (2 d)
Engine
blob
Format
Raw Data
Handle
23423920
Attached To
R3229 Genome Privacy - SHCS App
ECElGamalTest.java
View Options
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
Log In to Comment