当前位置: 首页>>代码示例>>Java>>正文


Java EllipticCurve.getA方法代码示例

本文整理汇总了Java中java.security.spec.EllipticCurve.getA方法的典型用法代码示例。如果您正苦于以下问题:Java EllipticCurve.getA方法的具体用法?Java EllipticCurve.getA怎么用?Java EllipticCurve.getA使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.security.spec.EllipticCurve的用法示例。


在下文中一共展示了EllipticCurve.getA方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: convertCurve

import java.security.spec.EllipticCurve; //导入方法依赖的package包/类
private static ECCurve convertCurve(
    EllipticCurve ec)
{
    ECField field = ec.getField();
    BigInteger a = ec.getA();
    BigInteger b = ec.getB();

    if (field instanceof ECFieldFp)
    {
        return new ECCurve.Fp(((ECFieldFp)field).getP(), a, b);
    }
    else
    {
        throw new IllegalStateException("not implemented yet!!!");
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:17,代码来源:JcaPublicKeyConverter.java

示例2: convertCurve

import java.security.spec.EllipticCurve; //导入方法依赖的package包/类
public static ECCurve convertCurve(
    EllipticCurve ec)
{
    ECField field = ec.getField();
    BigInteger a = ec.getA();
    BigInteger b = ec.getB();

    if (field instanceof ECFieldFp)
    {
        return new ECCurve.Fp(((ECFieldFp)field).getP(), a, b);
    }
    else
    {
        ECFieldF2m fieldF2m = (ECFieldF2m)field;
        int m = fieldF2m.getM();
        int ks[] = ECUtil.convertMidTerms(fieldF2m.getMidTermsOfReductionPolynomial());
        return new ECCurve.F2m(m, ks[0], ks[1], ks[2], a, b); 
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:20,代码来源:EC5Util.java

示例3: mapNonceGMWithECDH

import java.security.spec.EllipticCurve; //导入方法依赖的package包/类
private static ECParameterSpec mapNonceGMWithECDH(final BigInteger nonceS,
		                                          final ECPoint sharedSecretPointH,
		                                          final ECParameterSpec params) {
	// D~ = (p, a, b, G~, n, h) where G~ = [s]G + H
	final ECPoint generator = params.getGenerator();
	final EllipticCurve curve = params.getCurve();
	final BigInteger a = curve.getA();
	final BigInteger b = curve.getB();
	final ECFieldFp field = (ECFieldFp)curve.getField();
	final BigInteger p = field.getP();
	final BigInteger order = params.getOrder();
	final int cofactor = params.getCofactor();
	final ECPoint ephemeralGenerator = add(multiply(nonceS, generator, params), sharedSecretPointH, params);
	if (!toBouncyCastleECPoint(ephemeralGenerator, params).isValid()) {
		LOGGER.warning("Se ha generado un punto invalido"); //$NON-NLS-1$
	}
	return new ECParameterSpec(new EllipticCurve(new ECFieldFp(p), a, b), ephemeralGenerator, order, cofactor);
}
 
开发者ID:MiFirma,项目名称:mi-firma-android,代码行数:19,代码来源:JseCryptoHelper.java

示例4: mapNonceGMWithECDH

import java.security.spec.EllipticCurve; //导入方法依赖的package包/类
private static ECParameterSpec mapNonceGMWithECDH(final BigInteger nonceS,
		                                          final ECPoint sharedSecretPointH,
		                                          final ECParameterSpec params) {
	// D~ = (p, a, b, G~, n, h) where G~ = [s]G + H
	final ECPoint generator = params.getGenerator();
	final EllipticCurve curve = params.getCurve();
	final BigInteger a = curve.getA();
	final BigInteger b = curve.getB();
	final ECFieldFp field = (ECFieldFp)curve.getField();
	final BigInteger p = field.getP();
	final BigInteger order = params.getOrder();
	final int cofactor = params.getCofactor();
	final ECPoint ephemeralGenerator = add(multiply(nonceS, generator, params), sharedSecretPointH, params);
	if (!toSpongyCastleECPoint(ephemeralGenerator, params).isValid()) {
		LOGGER.warning("Se ha generado un punto invalido"); //$NON-NLS-1$
	}
	return new ECParameterSpec(new EllipticCurve(new ECFieldFp(p), a, b), ephemeralGenerator, order, cofactor);
}
 
开发者ID:MiFirma,项目名称:mi-firma-android,代码行数:19,代码来源:JseCryptoHelper.java

示例5: convertCurve

import java.security.spec.EllipticCurve; //导入方法依赖的package包/类
private static ECCurve convertCurve(
    EllipticCurve ec, BigInteger order, int coFactor)
{
    ECField field = ec.getField();
    BigInteger a = ec.getA();
    BigInteger b = ec.getB();

    if (field instanceof ECFieldFp)
    {
        return new ECCurve.Fp(((ECFieldFp)field).getP(), a, b, order, BigInteger.valueOf(coFactor));
    }
    else
    {
        throw new IllegalStateException("not implemented yet!!!");
    }
}
 
开发者ID:thedrummeraki,项目名称:Aki-SSL,代码行数:17,代码来源:JcaPublicKeyConverter.java

示例6: convertCurve

import java.security.spec.EllipticCurve; //导入方法依赖的package包/类
public static ECCurve convertCurve(
    EllipticCurve ec)
{
    ECField field = ec.getField();
    BigInteger a = ec.getA();
    BigInteger b = ec.getB();

    if (field instanceof ECFieldFp)
    {
        ECCurve.Fp curve = new ECCurve.Fp(((ECFieldFp)field).getP(), a, b);

        if (customCurves.containsKey(curve))
        {
            return (ECCurve)customCurves.get(curve);
        }

        return curve;
    }
    else
    {
        ECFieldF2m fieldF2m = (ECFieldF2m)field;
        int m = fieldF2m.getM();
        int ks[] = ECUtil.convertMidTerms(fieldF2m.getMidTermsOfReductionPolynomial());
        return new ECCurve.F2m(m, ks[0], ks[1], ks[2], a, b); 
    }
}
 
开发者ID:thedrummeraki,项目名称:Aki-SSL,代码行数:27,代码来源:EC5Util.java

示例7: decodePoint

import java.security.spec.EllipticCurve; //导入方法依赖的package包/类
/**
 * Decode a point on this curve which has been encoded using point
 * compression (X9.62 s 4.2.1 and 4.2.2) or regular encoding.
 * 
 * @param curve
 *            The elliptic curve.
 * @param encoded
 *            The encoded point.
 * @return the decoded point.
 */
public static ECPoint decodePoint(
   EllipticCurve curve, 
   byte[] encoded)
{
    ECCurve c = null;
    
    if (curve.getField() instanceof ECFieldFp)
    {
        c = new ECCurve.Fp(
                ((ECFieldFp)curve.getField()).getP(), curve.getA(), curve.getB());
    }
    else
    {
        int k[] = ((ECFieldF2m)curve.getField()).getMidTermsOfReductionPolynomial();
        
        if (k.length == 3)
        {
            c = new ECCurve.F2m(
                    ((ECFieldF2m)curve.getField()).getM(), k[2], k[1], k[0], curve.getA(), curve.getB());
        }
        else
        {
            c = new ECCurve.F2m(
                    ((ECFieldF2m)curve.getField()).getM(), k[0], curve.getA(), curve.getB());
        }
    }
    
    org.bouncycastle.math.ec.ECPoint p = c.decodePoint(encoded);
    
    return new ECPoint(p.getX().toBigInteger(), p.getY().toBigInteger());
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:42,代码来源:ECPointUtil.java

示例8: toBouncyCastleECCurve

import java.security.spec.EllipticCurve; //导入方法依赖的package包/类
private static ECCurve toBouncyCastleECCurve(final ECParameterSpec params) {
	final EllipticCurve curve = params.getCurve();
	final ECField field = curve.getField();
	if (!(field instanceof ECFieldFp)) {
		throw new IllegalArgumentException(
			"Solo se soporta 'ECFieldFp' y se proporciono  " + field.getClass().getCanonicalName() //$NON-NLS-1$
		);
	}
	final int coFactor = params.getCofactor();
	final BigInteger order = params.getOrder();
	final BigInteger a = curve.getA();
	final BigInteger b = curve.getB();
	final BigInteger p = getPrime(params);
	return new ECCurve.Fp(p, a, b, order, BigInteger.valueOf(coFactor));
}
 
开发者ID:MiFirma,项目名称:mi-firma-android,代码行数:16,代码来源:JseCryptoHelper.java

示例9: toSpongyCastleECCurve

import java.security.spec.EllipticCurve; //导入方法依赖的package包/类
private static ECCurve toSpongyCastleECCurve(final ECParameterSpec params) {
	final EllipticCurve curve = params.getCurve();
	final ECField field = curve.getField();
	if (!(field instanceof ECFieldFp)) {
		throw new IllegalArgumentException(
			"Solo se soporta 'ECFieldFp' y se proporciono  " + field.getClass().getCanonicalName() //$NON-NLS-1$
		);
	}
	final int coFactor = params.getCofactor();
	final BigInteger order = params.getOrder();
	final BigInteger a = curve.getA();
	final BigInteger b = curve.getB();
	final BigInteger p = getPrime(params);
	return new ECCurve.Fp(p, a, b, order, BigInteger.valueOf(coFactor));
}
 
开发者ID:MiFirma,项目名称:mi-firma-android,代码行数:16,代码来源:JseCryptoHelper.java

示例10: decodePoint

import java.security.spec.EllipticCurve; //导入方法依赖的package包/类
/**
 * Decode a point on this curve which has been encoded using point
 * compression (X9.62 s 4.2.1 and 4.2.2) or regular encoding.
 * 
 * @param curve
 *            The elliptic curve.
 * @param encoded
 *            The encoded point.
 * @return the decoded point.
 */
public static ECPoint decodePoint(
   EllipticCurve curve, 
   byte[] encoded)
{
    ECCurve c = null;
    
    if (curve.getField() instanceof ECFieldFp)
    {
        c = new ECCurve.Fp(
                ((ECFieldFp)curve.getField()).getP(), curve.getA(), curve.getB());
    }
    else
    {
        int k[] = ((ECFieldF2m)curve.getField()).getMidTermsOfReductionPolynomial();
        
        if (k.length == 3)
        {
            c = new ECCurve.F2m(
                    ((ECFieldF2m)curve.getField()).getM(), k[2], k[1], k[0], curve.getA(), curve.getB());
        }
        else
        {
            c = new ECCurve.F2m(
                    ((ECFieldF2m)curve.getField()).getM(), k[0], curve.getA(), curve.getB());
        }
    }
    
    org.bouncycastle.math.ec.ECPoint p = c.decodePoint(encoded);

    return new ECPoint(p.getAffineXCoord().toBigInteger(), p.getAffineYCoord().toBigInteger());
}
 
开发者ID:thedrummeraki,项目名称:Aki-SSL,代码行数:42,代码来源:ECPointUtil.java

示例11: decodePoint

import java.security.spec.EllipticCurve; //导入方法依赖的package包/类
/**
 * Decode a point on this curve which has been encoded using point
 * compression (X9.62 s 4.2.1 and 4.2.2) or regular encoding.
 * 
 * @param curve
 *            The elliptic curve.
 * @param encoded
 *            The encoded point.
 * @return the decoded point.
 */
public static ECPoint decodePoint(
   EllipticCurve curve, 
   byte[] encoded)
{
    ECCurve c = null;
    
    if (curve.getField() instanceof ECFieldFp)
    {
        c = new ECCurve.Fp(
                ((ECFieldFp)curve.getField()).getP(), curve.getA(), curve.getB());
    }
    else
    {
        int k[] = ((ECFieldF2m)curve.getField()).getMidTermsOfReductionPolynomial();
        
        if (k.length == 3)
        {
            c = new ECCurve.F2m(
                    ((ECFieldF2m)curve.getField()).getM(), k[2], k[1], k[0], curve.getA(), curve.getB());
        }
        else
        {
            c = new ECCurve.F2m(
                    ((ECFieldF2m)curve.getField()).getM(), k[0], curve.getA(), curve.getB());
        }
    }
    
    org.ripple.bouncycastle.math.ec.ECPoint p = c.decodePoint(encoded);

    return new ECPoint(p.getAffineXCoord().toBigInteger(), p.getAffineYCoord().toBigInteger());
}
 
开发者ID:cping,项目名称:RipplePower,代码行数:42,代码来源:ECPointUtil.java

示例12: getY

import java.security.spec.EllipticCurve; //导入方法依赖的package包/类
/**
 * Computes the y coordinate of a point on an elliptic curve. This method can be used to
 * decompress elliptic curve points.
 *
 * @param x the x-coordinate of the point
 * @param lsb the least significant bit of the y-coordinate of the point.
 * @param curve this must be an elliptic curve over a prime field using Weierstrass
 *     representation.
 * @return the y coordinate.
 * @throws GeneralSecurityException if there is no point with coordinate x on the curve, or if
 *     curve is not supported.
 */
public static BigInteger getY(BigInteger x, boolean lsb, EllipticCurve curve)
    throws GeneralSecurityException {
  BigInteger p = getModulus(curve);
  BigInteger a = curve.getA();
  BigInteger b = curve.getB();
  BigInteger rhs = x.multiply(x).add(a).multiply(x).add(b).mod(p);
  BigInteger y = modSqrt(rhs, p);
  if (lsb != y.testBit(0)) {
    y = p.subtract(y).mod(p);
  }
  return y;
}
 
开发者ID:google,项目名称:tink,代码行数:25,代码来源:EllipticCurves.java


注:本文中的java.security.spec.EllipticCurve.getA方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。