org.bouncycastle.math.ec.ECCurve.getA()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(9.1k)|赞(0)|评价(0)|浏览(76)

本文整理了Java中org.bouncycastle.math.ec.ECCurve.getA()方法的一些代码示例,展示了ECCurve.getA()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ECCurve.getA()方法的具体详情如下:
包路径:org.bouncycastle.math.ec.ECCurve
类名称:ECCurve
方法名:getA

ECCurve.getA介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

ECCurve curve = //...
ECFieldElement x = //...
ECFieldElement y = //...

ECFieldElement a = curve.getA();
ECFieldElement b = curve.getB();
ECFieldElement lhs = y.multiply(y);
ECFieldElement rhs = x.multiply(x).multiply(x).add(a.multiply(x)).add(b);

boolean pointIsOnCurve = lhs.equals(rhs);

代码示例来源:origin: org.bouncycastle/bcprov-debug-jdk15on

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: redfish64/TinyTravelTracker

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: org.bouncycastle/bcprov-debug-jdk15on

public int hashCode() 
{
  return getField().hashCode()
    ^ Integers.rotateLeft(getA().toBigInteger().hashCode(), 8)
    ^ Integers.rotateLeft(getB().toBigInteger().hashCode(), 16);
}

代码示例来源:origin: redfish64/TinyTravelTracker

public int hashCode() 
{
  return getField().hashCode()
    ^ Integers.rotateLeft(getA().toBigInteger().hashCode(), 8)
    ^ Integers.rotateLeft(getB().toBigInteger().hashCode(), 16);
}

代码示例来源:origin: org.bouncycastle/bcprov-debug-jdk15on

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: org.bouncycastle/bcprov-debug-jdk15on

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: redfish64/TinyTravelTracker

private static void discoverEndomorphism(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: org.bouncycastle/bcprov-debug-jdk15on

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: org.bouncycastle/bcprov-debug-jdk15on

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: horrorho/InflatableDonkey

@Deprecated
public static ECPoint decompressFPPoint(ECCurve curve, BigInteger X) {
  // See Andrey Jivsov https://www.ietf.org/archive/id/draft-jivsov-ecc-compact-05.txt.
  ECFieldElement x = curve.fromBigInteger(X);
  ECFieldElement rhs = x.square().add(curve.getA()).multiply(x).add(curve.getB());
  // y' = sqrt( C(x) ), where y'>0
  ECFieldElement yTilde = rhs.sqrt();
  if (yTilde == null) {
    throw new IllegalArgumentException("invalid point compression");
  }
  // y = min(y',p-y')
  BigInteger yT = yTilde.toBigInteger();
  BigInteger yTn = yTilde.negate().toBigInteger();
  BigInteger y = yT.compareTo(yTn) == -1 ? yT : yTn;
  // Q=(x,y) is the canonical representation of the point
  ECPoint Q = curve.createPoint(X, y);
  return Q;
}

代码示例来源:origin: horrorho/InflatableDonkey

public static BigInteger y(ECCurve curve, BigInteger x) {
  // Andrey Jivsov https://www.ietf.org/archive/id/draft-jivsov-ecc-compact-05.txt.
  ECFieldElement X = curve.fromBigInteger(x);
  ECFieldElement rhs = X.square().add(curve.getA()).multiply(X).add(curve.getB());
  // y' = sqrt( C(x) ), where y'>0
  ECFieldElement yTilde = rhs.sqrt();
  if (yTilde == null) {
    throw new IllegalArgumentException("invalid point compression");
  }
  // y = min(y',p-y')
  BigInteger yT = yTilde.toBigInteger();
  BigInteger yTn = yTilde.negate().toBigInteger();
  BigInteger y = yT.compareTo(yTn) == -1 ? yT : yTn;
  return y;
}

代码示例来源:origin: org.bouncycastle/bcprov-debug-jdk15on

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: redfish64/TinyTravelTracker

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: org.bouncycastle/bcprov-debug-jdk15on

public static String generateKeyFingerprint(ECPoint publicPoint, org.bouncycastle.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: org.bouncycastle/bcprov-debug-jdk15on

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: redfish64/TinyTravelTracker

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: org.bouncycastle/bcprov-debug-jdk15on

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());
  return digestDoFinal();
}

代码示例来源:origin: org.bouncycastle/bcprov-debug-jdk15on

private byte[] getZ(byte[] userID)
{
  digest.reset();
  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[] result = new byte[digest.getDigestSize()];
  digest.doFinal(result, 0);
  return result;
}

代码示例来源:origin: org.xipki/security

public static byte[] getSM2Z(byte[] userID, ASN1ObjectIdentifier curveOid,
  BigInteger pubPointX, BigInteger pubPointY) {
 SM3Digest digest = new SM3Digest();
 addUserId(digest, userID);
 X9ECParameters ecParams = GMNamedCurves.getByOID(curveOid);
 addFieldElement(digest, ecParams.getCurve().getA());
 addFieldElement(digest, ecParams.getCurve().getB());
 addFieldElement(digest, ecParams.getG().getAffineXCoord());
 addFieldElement(digest, ecParams.getG().getAffineYCoord());
 int fieldSize = (ecParams.getCurve().getFieldSize() + 7) / 8;
 byte[] bytes = BigIntegers.asUnsignedByteArray(fieldSize, pubPointX);
 digest.update(bytes, 0, fieldSize);
 bytes = BigIntegers.asUnsignedByteArray(fieldSize, pubPointY);
 digest.update(bytes, 0, fieldSize);
 byte[] result = new byte[digest.getDigestSize()];
 digest.doFinal(result, 0);
 return result;
}

相关文章