本文整理了Java中org.spongycastle.math.ec.ECCurve.getA()
方法的一些代码示例,展示了ECCurve.getA()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ECCurve.getA()
方法的具体详情如下:
包路径:org.spongycastle.math.ec.ECCurve
类名称:ECCurve
方法名:getA
暂无
代码示例来源:origin: com.madgag.spongycastle/core
protected static ECFieldElement[] getInitialZCoords(ECCurve curve)
{
// Cope with null curve, most commonly used by implicitlyCa
int coord = null == curve ? ECCurve.COORD_AFFINE : curve.getCoordinateSystem();
switch (coord)
{
case ECCurve.COORD_AFFINE:
case ECCurve.COORD_LAMBDA_AFFINE:
return EMPTY_ZS;
default:
break;
}
ECFieldElement one = curve.fromBigInteger(ECConstants.ONE);
switch (coord)
{
case ECCurve.COORD_HOMOGENEOUS:
case ECCurve.COORD_JACOBIAN:
case ECCurve.COORD_LAMBDA_PROJECTIVE:
return new ECFieldElement[]{ one };
case ECCurve.COORD_JACOBIAN_CHUDNOVSKY:
return new ECFieldElement[]{ one, one, one };
case ECCurve.COORD_JACOBIAN_MODIFIED:
return new ECFieldElement[]{ one, curve.getA() };
default:
throw new IllegalArgumentException("unknown coordinate system");
}
}
代码示例来源:origin: com.madgag/sc-light-jdk15on
/**
* @param curve base curve
* @param x x point
* @param y y point
* @param withCompression true if encode with point compression.
*/
public F2m(ECCurve curve, ECFieldElement x, ECFieldElement y, boolean withCompression)
{
super(curve, x, y);
if ((x != null && y == null) || (x == null && y != null))
{
throw new IllegalArgumentException("Exactly one of the field elements is null");
}
if (x != null)
{
// Check if x and y are elements of the same field
ECFieldElement.F2m.checkFieldElements(this.x, this.y);
// Check if x and a are elements of the same field
if (curve != null)
{
ECFieldElement.F2m.checkFieldElements(this.x, this.curve.getA());
}
}
this.withCompression = withCompression;
}
代码示例来源:origin: com.madgag.spongycastle/core
public boolean equals(ECCurve other)
{
return this == other
|| (null != other
&& getField().equals(other.getField())
&& getA().toBigInteger().equals(other.getA().toBigInteger())
&& getB().toBigInteger().equals(other.getB().toBigInteger()));
}
代码示例来源:origin: com.madgag.spongycastle/core
public int hashCode()
{
return getField().hashCode()
^ Integers.rotateLeft(getA().toBigInteger().hashCode(), 8)
^ Integers.rotateLeft(getB().toBigInteger().hashCode(), 16);
}
代码示例来源:origin: com.madgag.spongycastle/core
public static void discoverEndomorphisms(X9ECParameters x9)
{
if (x9 == null)
{
throw new NullPointerException("x9");
}
ECCurve c = x9.getCurve();
if (ECAlgorithms.isFpCurve(c))
{
BigInteger characteristic = c.getField().getCharacteristic();
if (c.getA().isZero() && characteristic.mod(ECConstants.THREE).equals(ECConstants.ONE))
{
System.out.println("Curve has a 'GLV Type B' endomorphism with these parameters:");
printGLVTypeBParameters(x9);
}
}
}
代码示例来源:origin: com.madgag.spongycastle/core
private static void discoverEndomorphisms(String curveName)
{
X9ECParameters x9 = ECNamedCurveTable.getByName(curveName);
if (x9 == null)
{
System.err.println("Unknown curve: " + curveName);
return;
}
ECCurve c = x9.getCurve();
if (ECAlgorithms.isFpCurve(c))
{
BigInteger characteristic = c.getField().getCharacteristic();
if (c.getA().isZero() && characteristic.mod(ECConstants.THREE).equals(ECConstants.ONE))
{
System.out.println("Curve '" + curveName + "' has a 'GLV Type B' endomorphism with these parameters:");
printGLVTypeBParameters(x9);
}
}
}
代码示例来源:origin: com.madgag.spongycastle/prov
public static EllipticCurve convertCurve(
ECCurve curve,
byte[] seed)
{
ECField field = convertField(curve.getField());
BigInteger a = curve.getA().toBigInteger(), b = curve.getB().toBigInteger();
// TODO: the Sun EC implementation doesn't currently handle the seed properly
// so at the moment it's set to null. Should probably look at making this configurable
return new EllipticCurve(field, a, b, null);
}
代码示例来源:origin: com.madgag.spongycastle/prov
private static EllipticCurve convertCurve(
ECCurve curve,
byte[] seed)
{
ECField field = convertField(curve.getField());
BigInteger a = curve.getA().toBigInteger(), b = curve.getB().toBigInteger();
return new EllipticCurve(field, a, b, seed);
}
代码示例来源:origin: com.madgag.spongycastle/bcpkix-jdk15on
private static EllipticCurve convertCurve(
ECCurve curve)
{
ECField field = convertField(curve.getField());
BigInteger a = curve.getA().toBigInteger(), b = curve.getB().toBigInteger();
// TODO: the Sun EC implementation doesn't currently handle the seed properly
// so at the moment it's set to null. Should probably look at making this configurable
return new EllipticCurve(field, a, b, null);
}
代码示例来源:origin: com.madgag.spongycastle/pkix
private static EllipticCurve convertCurve(
ECCurve curve)
{
ECField field = convertField(curve.getField());
BigInteger a = curve.getA().toBigInteger(), b = curve.getB().toBigInteger();
// TODO: the Sun EC implementation doesn't currently handle the seed properly
// so at the moment it's set to null. Should probably look at making this configurable
return new EllipticCurve(field, a, b, null);
}
代码示例来源:origin: com.madgag.spongycastle/core
protected Curve25519FieldElement calculateJacobianModifiedW(Curve25519FieldElement Z, int[] ZSquared)
{
Curve25519FieldElement a4 = (Curve25519FieldElement)this.getCurve().getA();
if (Z.isOne())
{
return a4;
}
Curve25519FieldElement W = new Curve25519FieldElement();
if (ZSquared == null)
{
ZSquared = W.x;
Curve25519Field.square(Z.x, ZSquared);
}
Curve25519Field.square(ZSquared, W.x);
Curve25519Field.multiply(W.x, a4.x, W.x);
return W;
}
代码示例来源:origin: es.gob.afirma.jmulticard/jmulticard
private static BigInteger computeAffineY(final BigInteger affineX, final ECParameterSpec params) {
final ECCurve bcCurve = toSpongyCastleECCurve(params);
final ECFieldElement a = bcCurve.getA();
final ECFieldElement b = bcCurve.getB();
final ECFieldElement x = bcCurve.fromBigInteger(affineX);
final ECFieldElement y = x.multiply(x).add(a).multiply(x).add(b).sqrt();
return y.toBigInteger();
}
代码示例来源:origin: com.madgag/scprov-jdk15on
public static EllipticCurve convertCurve(
ECCurve curve,
byte[] seed)
{
// TODO: the Sun EC implementation doesn't currently handle the seed properly
// so at the moment it's set to null. Should probably look at making this configurable
if (curve instanceof ECCurve.Fp)
{
return new EllipticCurve(new ECFieldFp(((ECCurve.Fp)curve).getQ()), curve.getA().toBigInteger(), curve.getB().toBigInteger(), null);
}
else
{
ECCurve.F2m curveF2m = (ECCurve.F2m)curve;
int ks[];
if (curveF2m.isTrinomial())
{
ks = new int[] { curveF2m.getK1() };
return new EllipticCurve(new ECFieldF2m(curveF2m.getM(), ks), curve.getA().toBigInteger(), curve.getB().toBigInteger(), null);
}
else
{
ks = new int[] { curveF2m.getK3(), curveF2m.getK2(), curveF2m.getK1() };
return new EllipticCurve(new ECFieldF2m(curveF2m.getM(), ks), curve.getA().toBigInteger(), curve.getB().toBigInteger(), null);
}
}
}
代码示例来源:origin: com.madgag/scprov-jdk15on
private static EllipticCurve convertCurve(
ECCurve curve,
byte[] seed)
{
if (curve instanceof ECCurve.Fp)
{
return new EllipticCurve(new ECFieldFp(((ECCurve.Fp)curve).getQ()), curve.getA().toBigInteger(), curve.getB().toBigInteger(), seed);
}
else
{
ECCurve.F2m curveF2m = (ECCurve.F2m)curve;
int ks[];
if (curveF2m.isTrinomial())
{
ks = new int[] { curveF2m.getK1() };
return new EllipticCurve(new ECFieldF2m(curveF2m.getM(), ks), curve.getA().toBigInteger(), curve.getB().toBigInteger(), seed);
}
else
{
ks = new int[] { curveF2m.getK3(), curveF2m.getK2(), curveF2m.getK1() };
return new EllipticCurve(new ECFieldF2m(curveF2m.getM(), ks), curve.getA().toBigInteger(), curve.getB().toBigInteger(), seed);
}
}
}
代码示例来源:origin: com.madgag.spongycastle/prov
public static String generateKeyFingerprint(ECPoint publicPoint, org.spongycastle.jce.spec.ECParameterSpec spec)
{
ECCurve curve = spec.getCurve();
ECPoint g = spec.getG();
if (curve != null)
{
return new Fingerprint(Arrays.concatenate(publicPoint.getEncoded(false), curve.getA().getEncoded(), curve.getB().getEncoded(), g.getEncoded(false))).toString();
}
return new Fingerprint(publicPoint.getEncoded(false)).toString();
}
}
代码示例来源:origin: com.madgag/sc-light-jdk15on
public ECPoint twice()
{
if (this.isInfinity())
{
// Twice identity element (point at infinity) is identity
return this;
}
if (this.x.toBigInteger().signum() == 0)
{
// if x1 == 0, then (x1, y1) == (x1, x1 + y1)
// and hence this = -this and thus 2(x1, y1) == infinity
return this.curve.getInfinity();
}
ECFieldElement.F2m lambda
= (ECFieldElement.F2m)this.x.add(this.y.divide(this.x));
ECFieldElement.F2m x3
= (ECFieldElement.F2m)lambda.square().add(lambda).
add(this.curve.getA());
ECFieldElement ONE = this.curve.fromBigInteger(ECConstants.ONE);
ECFieldElement.F2m y3
= (ECFieldElement.F2m)this.x.square().add(
x3.multiply(lambda.add(ONE)));
return new ECPoint.F2m(this.curve, x3, y3, withCompression);
}
代码示例来源:origin: com.madgag.spongycastle/core
v.add(new X9FieldElement(curve.getA()).toASN1Primitive());
v.add(new X9FieldElement(curve.getB()).toASN1Primitive());
v.add(new X9FieldElement(curve.getA()).toASN1Primitive());
v.add(new X9FieldElement(curve.getB()).toASN1Primitive());
代码示例来源:origin: com.madgag.spongycastle/core
protected ECFieldElement calculateJacobianModifiedW(ECFieldElement Z, ECFieldElement ZSquared)
{
ECFieldElement a4 = this.getCurve().getA();
if (a4.isZero() || Z.isOne())
{
return a4;
}
if (ZSquared == null)
{
ZSquared = Z.square();
}
ECFieldElement W = ZSquared.square();
ECFieldElement a4Neg = a4.negate();
if (a4Neg.bitLength() < a4.bitLength())
{
W = W.multiply(a4Neg).negate();
}
else
{
W = W.multiply(a4);
}
return W;
}
代码示例来源:origin: com.madgag.spongycastle/core
private byte[] getZ(Digest digest)
{
addUserID(digest, userID);
addFieldElement(digest, ecParams.getCurve().getA());
addFieldElement(digest, ecParams.getCurve().getB());
addFieldElement(digest, ecParams.getG().getAffineXCoord());
addFieldElement(digest, ecParams.getG().getAffineYCoord());
addFieldElement(digest, pubPoint.getAffineXCoord());
addFieldElement(digest, pubPoint.getAffineYCoord());
byte[] rv = new byte[digest.getDigestSize()];
digest.doFinal(rv, 0);
return rv;
}
代码示例来源:origin: com.madgag.spongycastle/core
private byte[] getZ(Digest digest, byte[] userID, ECPoint pubPoint)
{
addUserID(digest, userID);
addFieldElement(digest, ecParams.getCurve().getA());
addFieldElement(digest, ecParams.getCurve().getB());
addFieldElement(digest, ecParams.getG().getAffineXCoord());
addFieldElement(digest, ecParams.getG().getAffineYCoord());
addFieldElement(digest, pubPoint.getAffineXCoord());
addFieldElement(digest, pubPoint.getAffineYCoord());
byte[] rv = new byte[digest.getDigestSize()];
digest.doFinal(rv, 0);
return rv;
}
内容来源于网络,如有侵权,请联系作者删除!