com.fitbur.bouncycastle.crypto.ec.ECElGamalDecryptor Maven / Gradle / Ivy
package com.fitbur.bouncycastle.crypto.ec;
import com.fitbur.bouncycastle.crypto.CipherParameters;
import com.fitbur.bouncycastle.crypto.params.ECPrivateKeyParameters;
import com.fitbur.bouncycastle.math.ec.ECPoint;
/**
* this does your basic com.fitburcryption ElGamal style using EC
*/
public class ECElGamalDecryptor
implements ECDecryptor
{
private ECPrivateKeyParameters key;
/**
* initialise the com.fitburcryptor.
*
* @param param the necessary EC key parameters.
*/
public void init(
CipherParameters param)
{
if (!(param instanceof ECPrivateKeyParameters))
{
throw new IllegalArgumentException("ECPrivateKeyParameters are required for com.fitburcryption.");
}
this.key = (ECPrivateKeyParameters)param;
}
/**
* Decrypt an EC pair producing the original EC point.
*
* @param pair the EC point pair to process.
* @return the result of the Elgamal process.
*/
public ECPoint com.fitburcrypt(ECPair pair)
{
if (key == null)
{
throw new IllegalStateException("ECElGamalDecryptor not initialised");
}
ECPoint tmp = pair.getX().multiply(key.getD());
return pair.getY().subtract(tmp).normalize();
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy