本文整理汇总了Java中org.spongycastle.math.ec.ECFieldElement.sqrt方法的典型用法代码示例。如果您正苦于以下问题:Java ECFieldElement.sqrt方法的具体用法?Java ECFieldElement.sqrt怎么用?Java ECFieldElement.sqrt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.spongycastle.math.ec.ECFieldElement
的用法示例。
在下文中一共展示了ECFieldElement.sqrt方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: decompressKey
import org.spongycastle.math.ec.ECFieldElement; //导入方法依赖的package包/类
/** Decompress a compressed public key (x co-ord and low-bit of y-coord). */
private static ECPoint decompressKey(BigInteger xBN, boolean yBit) {
// This code is adapted from Bouncy Castle ECCurve.Fp.decodePoint(), but it wasn't easily re-used.
ECCurve.Fp curve = (ECCurve.Fp) ecParams.getCurve();
ECFieldElement x = new ECFieldElement.Fp(curve.getQ(), xBN);
ECFieldElement alpha = x.multiply(x.square().add(curve.getA())).add(curve.getB());
ECFieldElement beta = alpha.sqrt();
// If we can't find a sqrt we haven't got a point on the curve - invalid inputs.
if (beta == null)
throw new IllegalArgumentException("Invalid point compression");
if (beta.toBigInteger().testBit(0) == yBit) {
return new ECPoint.Fp(curve, x, beta, true);
} else {
ECFieldElement.Fp y = new ECFieldElement.Fp(curve.getQ(), curve.getQ().subtract(beta.toBigInteger()));
return new ECPoint.Fp(curve, x, y, true);
}
}
示例2: decompressKey
import org.spongycastle.math.ec.ECFieldElement; //导入方法依赖的package包/类
/** Decompress a compressed public key (x co-ord and low-bit of y-coord). */
private static ECPoint decompressKey(BigInteger xBN, boolean yBit) {
// This code is adapted from Bouncy Castle ECCurve.Fp.decodePoint(), but it wasn't easily re-used.
ECCurve.Fp curve = (ECCurve.Fp) CURVE.getCurve();
ECFieldElement x = new ECFieldElement.Fp(curve.getQ(), xBN);
ECFieldElement alpha = x.multiply(x.square().add(curve.getA())).add(curve.getB());
ECFieldElement beta = alpha.sqrt();
// If we can't find a sqrt we haven't got a point on the curve - invalid inputs.
if (beta == null)
throw new IllegalArgumentException("Invalid point compression");
if (beta.toBigInteger().testBit(0) == yBit) {
return new ECPoint.Fp(curve, x, beta, true);
} else {
ECFieldElement.Fp y = new ECFieldElement.Fp(curve.getQ(), curve.getQ().subtract(beta.toBigInteger()));
return new ECPoint.Fp(curve, x, y, true);
}
}
示例3: decompressKey
import org.spongycastle.math.ec.ECFieldElement; //导入方法依赖的package包/类
/**
* Decompress a compressed public key (x co-ord and low-bit of y-coord).
*/
private static ECPoint decompressKey(BigInteger xBN, boolean yBit) {
// This code is adapted from Bouncy Castle ECCurve.Fp.decodePoint(), but it wasn't easily re-used.
ECCurve.Fp curve = (ECCurve.Fp) ecParams.getCurve();
ECFieldElement x = new ECFieldElement.Fp(curve.getQ(), xBN);
ECFieldElement alpha = x.multiply(x.square().add(curve.getA())).add(curve.getB());
ECFieldElement beta = alpha.sqrt();
// If we can't find a sqrt we haven't got a point on the curve - invalid inputs.
if (beta == null)
throw new IllegalArgumentException("Invalid point compression");
if (beta.toBigInteger().testBit(0) == yBit) {
return new ECPoint.Fp(curve, x, beta, true);
} else {
ECFieldElement.Fp y = new ECFieldElement.Fp(curve.getQ(), curve.getQ().subtract(beta.toBigInteger()));
return new ECPoint.Fp(curve, x, y, true);
}
}