本文整理汇总了Java中org.bouncycastle.math.ec.ECPoint.F2m方法的典型用法代码示例。如果您正苦于以下问题:Java ECPoint.F2m方法的具体用法?Java ECPoint.F2m怎么用?Java ECPoint.F2m使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bouncycastle.math.ec.ECPoint
的用法示例。
在下文中一共展示了ECPoint.F2m方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: decodePoint
import org.bouncycastle.math.ec.ECPoint; //导入方法依赖的package包/类
public static ECPoint decodePoint(ECCurve curve, byte[] bytes)
{
/*byte[] bp_enc=new byte[bytes.length+1];
if (0==(bytes[bytes.length-1]&0x1))
bp_enc[0]=0x02;
else
bp_enc[0]=0x03;
System.arraycopy(bytes, 0, bp_enc, 1, bytes.length);
if (!trace(curve.fromBigInteger(new BigInteger(1, bytes))).equals(curve.getA().toBigInteger()))
bp_enc[bp_enc.length-1]^=0x01;
return curve.decodePoint(bp_enc);*/
BigInteger k = BigInteger.valueOf(bytes[bytes.length - 1] & 0x1);
if (!trace(curve.fromBigInteger(new BigInteger(1, bytes))).equals(curve.getA().toBigInteger()))
{
bytes = Arrays.clone(bytes);
bytes[bytes.length - 1] ^= 0x01;
}
ECCurve.F2m c = (ECCurve.F2m)curve;
ECFieldElement xp = curve.fromBigInteger(new BigInteger(1, bytes));
ECFieldElement yp = null;
if (xp.toBigInteger().equals(ECConstants.ZERO))
{
yp = (ECFieldElement.F2m)curve.getB();
for (int i = 0; i < c.getM() - 1; i++)
{
yp = yp.square();
}
}
else
{
ECFieldElement beta = xp.add(curve.getA()).add(
curve.getB().multiply(xp.square().invert()));
ECFieldElement z = solveQuadradicEquation(beta);
if (z == null)
{
throw new RuntimeException("Invalid point compression");
}
if (!trace(z).equals(k))
{
z = z.add(curve.fromBigInteger(ECConstants.ONE));
}
yp = xp.multiply(z);
}
return new ECPoint.F2m(curve, xp, yp);
}