Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F91679550
FragmentPartialEncoded.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, Nov 13, 09:48
Size
1 KB
Mime Type
text/x-java
Expires
Fri, Nov 15, 09:48 (2 d)
Engine
blob
Format
Raw Data
Handle
22304794
Attached To
R3229 Genome Privacy - SHCS App
FragmentPartialEncoded.java
View Options
package
crypto.elgamal.fragment
;
import
org.apache.commons.codec.binary.Base64
;
import
org.bouncycastle.math.ec.ECCurve
;
import
org.bouncycastle.math.ec.ECPoint
;
import
crypto.elgamal.ECElGamal
;
public
class
FragmentPartialEncoded
extends
FragmentEncoded
{
private
byte
[]
encodedT
;
private
int
partNumber
;
public
FragmentPartialEncoded
(
byte
[]
encodedR
,
byte
[]
encodedS
,
byte
[]
encodedT
,
int
partNumber
)
{
super
(
encodedR
,
encodedS
);
this
.
encodedT
=
encodedT
;
this
.
partNumber
=
partNumber
;
}
public
FragmentPartialEncoded
(
String
base64R
,
String
base64S
,
String
base64T
,
int
partNumber
)
{
super
(
base64R
,
base64S
);
// check sanity
if
(!
Base64
.
isBase64
(
base64T
))
{
throw
new
IllegalArgumentException
(
"Unvalid base64 format!"
);
}
this
.
encodedT
=
Base64
.
decodeBase64
(
base64T
);
this
.
partNumber
=
partNumber
;
}
public
FragmentPartialEncoded
(
FragmentPartial
partial
)
{
super
(
partial
);
encodedT
=
partial
.
getT
().
getEncoded
();
partNumber
=
partial
.
getPartNumber
();
}
public
byte
[]
getEncodedT
()
{
return
encodedT
;
}
public
int
getPartNumber
()
{
return
partNumber
;
}
public
FragmentPartial
decodeFragment
(
ECCurve
curve
)
{
FragmentEncrypted
encrypted
=
super
.
decodeFragment
(
curve
);
ECPoint
T
=
curve
.
decodePoint
(
encodedT
);
return
new
FragmentPartial
(
partNumber
,
encrypted
,
T
);
}
public
FragmentPartial
decodeFragment
(
ECElGamal
ecceg
)
{
return
decodeFragment
(
ecceg
.
getCurve
());
}
public
String
encodeBase64
(
String
separator
)
{
StringBuilder
builder
=
new
StringBuilder
();
builder
.
append
(
Integer
.
toString
(
partNumber
));
builder
.
append
(
separator
);
builder
.
append
(
Base64
.
encodeBase64String
(
super
.
getEncodedR
()));
builder
.
append
(
separator
);
builder
.
append
(
Base64
.
encodeBase64String
(
super
.
getEncodedS
()));
builder
.
append
(
separator
);
builder
.
append
(
Base64
.
encodeBase64String
(
encodedT
));
return
builder
.
toString
();
}
}
Event Timeline
Log In to Comment