Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F96807374
FragmentPartial.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:22
Size
1 KB
Mime Type
text/x-java
Expires
Thu, Jan 2, 00:22 (2 d)
Engine
blob
Format
Raw Data
Handle
23227241
Attached To
R3229 Genome Privacy - SHCS App
FragmentPartial.java
View Options
package
crypto.elgamal.fragment
;
import
org.bouncycastle.math.ec.ECPoint
;
import
crypto.elgamal.PartialSecret
;
public
class
FragmentPartial
extends
FragmentEncrypted
{
private
static
final
long
serialVersionUID
=
-
2490398770485746513L
;
private
ECPoint
T
;
private
int
partNumber
;
public
FragmentPartial
(
int
partNumber
,
FragmentEncrypted
encrypted
,
ECPoint
T
)
{
super
(
encrypted
.
getR
(),
encrypted
.
getS
());
if
(!
PartialSecret
.
isValidPartNumber
(
partNumber
))
{
throw
new
IllegalArgumentException
(
"not a valid part number"
);
}
this
.
partNumber
=
partNumber
;
this
.
T
=
T
;
}
public
FragmentPartialEncoded
getFragmentPartialEncoded
()
{
return
new
FragmentPartialEncoded
(
this
);
}
public
ECPoint
getT
()
{
return
T
;
}
public
int
getPartNumber
()
{
return
partNumber
;
}
@Override
public
int
hashCode
()
{
final
int
prime
=
31
;
int
result
=
super
.
hashCode
();
result
=
prime
*
result
+
((
T
==
null
)
?
0
:
T
.
hashCode
());
result
=
prime
*
result
+
partNumber
;
return
result
;
}
@Override
public
boolean
equals
(
Object
obj
)
{
if
(
this
==
obj
)
return
true
;
if
(!
super
.
equals
(
obj
))
return
false
;
if
(
getClass
()
!=
obj
.
getClass
())
return
false
;
FragmentPartial
other
=
(
FragmentPartial
)
obj
;
if
(
T
==
null
)
{
if
(
other
.
T
!=
null
)
return
false
;
}
else
if
(!
T
.
equals
(
other
.
T
))
return
false
;
if
(
partNumber
!=
other
.
partNumber
)
return
false
;
return
true
;
}
/**
* Check if FragmentEncrypted fields are equal.
* Namely, does the partial fragment come from the same
* encrypted data.
*
* @param obj
* @return
*/
public
boolean
equalsFragmentEncrypted
(
Object
obj
)
{
// same object, so same FragmentEncrypted
if
(
this
==
obj
)
return
true
;
// are both FragmentEncrypted equal
if
(!
super
.
equals
(
obj
))
return
false
;
return
true
;
}
}
Event Timeline
Log In to Comment