Page MenuHomec4science

FragmentPartial.java
No OneTemporary

File Metadata

Created
Tue, Dec 31, 00:22

FragmentPartial.java

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