Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F99184876
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
Wed, Jan 22, 03:21
Size
1000 B
Mime Type
text/x-java
Expires
Fri, Jan 24, 03:21 (2 d)
Engine
blob
Format
Raw Data
Handle
23721029
Attached To
R3229 Genome Privacy - SHCS App
ECElGamalTest.java
View Options
package
ch.epfl.lca1.crypto
;
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