ElGamalPublicBcpgKey
Base class for an ElGamal public key.
using Org.BouncyCastle.Math;
namespace Org.BouncyCastle.Bcpg
{
public class ElGamalPublicBcpgKey : BcpgObject, IBcpgKey
{
private readonly MPInteger m_p;
private readonly MPInteger m_g;
private readonly MPInteger m_y;
public BigInteger P => m_p.Value;
public BigInteger G => m_g.Value;
public BigInteger Y => m_y.Value;
public string Format => "PGP";
public ElGamalPublicBcpgKey(BcpgInputStream bcpgIn)
{
m_p = new MPInteger(bcpgIn);
m_g = new MPInteger(bcpgIn);
m_y = new MPInteger(bcpgIn);
}
public ElGamalPublicBcpgKey(BigInteger p, BigInteger g, BigInteger y)
{
m_p = new MPInteger(p);
m_g = new MPInteger(g);
m_y = new MPInteger(y);
}
public override byte[] GetEncoded()
{
return BcpgOutputStream.GetEncodedOrNull(this);
}
public override void Encode(BcpgOutputStream bcpgOut)
{
bcpgOut.WriteObjects(m_p, m_g, m_y);
}
}
}