Page MenuHomec4science

FragmentEncoded.java
No OneTemporary

File Metadata

Created
Thu, Jan 16, 21:04

FragmentEncoded.java

package crypto.elgamal.encoded;
import org.bouncycastle.math.ec.ECCurve;
import org.bouncycastle.math.ec.ECPoint;
import crypto.elgamal.ECElGamal;
import crypto.elgamal.FragmentEncrypted;
public class FragmentEncoded {
private byte[] encodedR;
private byte[] encodedS;
public FragmentEncoded(ECPoint R, ECPoint S) {
this.encodedR = R.getEncoded();
this.encodedS = S.getEncoded();
}
public FragmentEncoded(byte[] first, byte[] second) {
this.encodedR = first;
this.encodedS = second;
}
public FragmentEncoded(FragmentEncrypted frag) {
this(frag.getR(), frag.getS());
}
public byte[] getEncodedR() {
return encodedR;
}
public byte[] getEncodedS() {
return encodedS;
}
public FragmentEncrypted decodeFragment(ECCurve curve) {
ECPoint pR = curve.decodePoint(encodedR);
ECPoint pS = curve.decodePoint(encodedS);
return new FragmentEncrypted(pR, pS);
}
public FragmentEncrypted decodeFragment(ECElGamal ecceg) {
return decodeFragment(ecceg.getECParams().getCurve());
}
/**
* Size in byte of the data contained
* @return
*/
public int sizeByte() {
return encodedR.length + encodedS.length;
}
// TODO: add
// TODO: scale
}

Event Timeline