Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F96805938
ECCEGKeyGenerator.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, Dec 31, 00:08
Size
1 KB
Mime Type
text/x-java
Expires
Thu, Jan 2, 00:08 (2 d)
Engine
blob
Format
Raw Data
Handle
23227372
Attached To
R3229 Genome Privacy - SHCS App
ECCEGKeyGenerator.java
View Options
package
crypto.elgamal
;
import
java.math.BigInteger
;
import
java.security.SecureRandom
;
import
org.bouncycastle.asn1.nist.NISTNamedCurves
;
import
org.bouncycastle.asn1.x9.X9ECParameters
;
import
org.bouncycastle.math.ec.ECPoint
;
public
class
ECCEGKeyGenerator
{
private
SecureRandom
randGen
;
private
BigInteger
order
;
private
X9ECParameters
ecParams
;
public
ECCEGKeyGenerator
(
String
curveName
)
{
this
.
randGen
=
new
SecureRandom
();
this
.
ecParams
=
NISTNamedCurves
.
getByName
(
curveName
);
this
.
order
=
ecParams
.
getN
();
}
/**
*
* @param order
* order of the group
* @return
*/
public
KeyPair
generateKey
()
{
// generate the secret and random coefficient
BigInteger
secret
=
new
BigInteger
(
order
.
bitLength
()
-
1
,
randGen
);
BigInteger
a1
=
new
BigInteger
(
order
.
bitLength
()
-
1
,
randGen
);
BigInteger
[]
coefficients
=
new
BigInteger
[
2
];
coefficients
[
0
]
=
secret
;
coefficients
[
1
]
=
a1
;
// generate both secret shares
PartialSecret
secretMU
=
new
PartialSecret
(
PartialSecret
.
PART_MU
,
coefficients
,
order
);
PartialSecret
secretSPU
=
new
PartialSecret
(
PartialSecret
.
PART_SPU
,
coefficients
,
order
);
// generate public key
ECPoint
pubKey
=
ecParams
.
getG
().
multiply
(
secret
);
return
new
KeyPair
(
secretMU
,
secretSPU
,
pubKey
);
}
}
Event Timeline
Log In to Comment