Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F97877184
Test.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, 02:16
Size
2 KB
Mime Type
text/x-c
Expires
Thu, Jan 9, 02:16 (2 d)
Engine
blob
Format
Raw Data
Handle
23424927
Attached To
R3229 Genome Privacy - SHCS App
Test.java
View Options
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package
crypto.dgk
;
import
java.math.BigInteger
;
import
crypto.CryptoException
;
/**
*
* @author raisaro
*/
public
class
Test
{
public
static
void
main
(
String
[]
args
)
throws
CryptoException
{
System
.
out
.
println
(
"Test starts..."
);
int
l
=
16
;
int
t
=
160
;
int
k
=
1024
;
DGK_key_generator
kg
=
new
DGK_key_generator
(
k
,
t
,
l
);
kg
.
generateKeys
();
BigInteger
[]
pk
=
{
kg
.
getN
(),
kg
.
getG
(),
kg
.
getH
(),
kg
.
getU
()};
BigInteger
[]
sk
=
{
kg
.
getP
(),
kg
.
getQ
(),
kg
.
getVpvq
(),
kg
.
getPp_inv
(),
kg
.
getQq_inv
()};
System
.
out
.
println
(
"Key have been succesfully generated!"
);
System
.
out
.
println
(
"u = "
+
kg
.
getU
());
System
.
out
.
println
(
"DGK-scheme generation"
);
DGK_scheme
s
=
new
DGK_scheme
(
pk
,
sk
,
k
,
t
,
l
);
BigInteger
message1
=
BigInteger
.
valueOf
(
2
);
System
.
out
.
println
(
"Encryption of "
+
message1
);
BigInteger
c1
=
s
.
encryption
(
message1
);
System
.
out
.
println
(
"Decryption of "
+
c1
);
boolean
res
=
s
.
decryptionZero
(
c1
);
System
.
out
.
println
(
"The encrypted value is zero? "
+
res
);
BigInteger
m
=
s
.
decryption
(
c1
);
System
.
out
.
println
(
"Result = "
+
m
);
System
.
out
.
println
(
"Homomorphic test"
);
BigInteger
message2
=
BigInteger
.
valueOf
(
3
);
BigInteger
c2
=
s
.
encryption
(
message2
);
BigInteger
c3
=
c1
.
modPow
(
message2
,
kg
.
getN
());
BigInteger
m2
=
s
.
decryption
(
c3
);
BigInteger
message4
=
BigInteger
.
valueOf
(
2
);
BigInteger
c4
=
s
.
encryption
(
message4
);
BigInteger
message5
=
BigInteger
.
valueOf
(
3
);
BigInteger
c5
=
s
.
encryption
(
message5
);
BigInteger
c6
=
c4
.
multiply
(
c5
);
BigInteger
c7
=
c6
.
multiply
(
c3
).
mod
(
kg
.
getN
());
BigInteger
m7
=
s
.
decryption
(
c7
);
System
.
out
.
println
(
"Result = "
+
m7
);
}
}
Event Timeline
Log In to Comment