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


Java ECParameterSpec.getG方法代码示例

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


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

示例1: generatePublicKeyParameter

import org.bouncycastle.jce.spec.ECParameterSpec; //导入方法依赖的package包/类
static public AsymmetricKeyParameter generatePublicKeyParameter(
    PublicKey    key)
    throws InvalidKeyException
{
    if (key instanceof ECPublicKey)
    {
        ECPublicKey    k = (ECPublicKey)key;
        ECParameterSpec s = k.getParams();

        return new ECPublicKeyParameters(
                        k.getQ(),
                        new ECDomainParameters(s.getCurve(), s.getG(), s.getN()));
    }

    throw new InvalidKeyException("can't identify EC public key.");
}
 
开发者ID:thangbn,项目名称:Direct-File-Downloader,代码行数:17,代码来源:ECUtil.java

示例2: generatePrivateKeyParameter

import org.bouncycastle.jce.spec.ECParameterSpec; //导入方法依赖的package包/类
static public AsymmetricKeyParameter generatePrivateKeyParameter(
    PrivateKey    key)
    throws InvalidKeyException
{
    if (key instanceof ECPrivateKey)
    {
        ECPrivateKey    k = (ECPrivateKey)key;
        ECParameterSpec s = k.getParams();

        return new ECPrivateKeyParameters(
                        k.getD(),
                        new ECDomainParameters(s.getCurve(), s.getG(), s.getN()));
    }
                    
    throw new InvalidKeyException("can't identify EC private key.");
}
 
开发者ID:thangbn,项目名称:Direct-File-Downloader,代码行数:17,代码来源:ECUtil.java

示例3: generatePrivateKeyParameter

import org.bouncycastle.jce.spec.ECParameterSpec; //导入方法依赖的package包/类
public static AsymmetricKeyParameter generatePrivateKeyParameter(
    PrivateKey    key)
    throws InvalidKeyException
{
    if (key instanceof ECPrivateKey)
    {
        ECPrivateKey  k = (ECPrivateKey)key;
        ECParameterSpec s = k.getParameters();

        if (s == null)
        {
            s = BouncyCastleProvider.CONFIGURATION.getEcImplicitlyCa();
        }

        return new ECPrivateKeyParameters(
                        k.getD(),
                        new ECDomainParameters(s.getCurve(), s.getG(), s.getN(), s.getH(), s.getSeed()));
    }
                    
    throw new InvalidKeyException("can't identify EC private key.");
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:22,代码来源:ECUtil.java

示例4: generatePublicKeyParameter

import org.bouncycastle.jce.spec.ECParameterSpec; //导入方法依赖的package包/类
public static AsymmetricKeyParameter generatePublicKeyParameter(
    PublicKey    key)
    throws InvalidKeyException
{
    if (key instanceof ECPublicKey)
    {
        ECPublicKey    k = (ECPublicKey)key;
        ECParameterSpec s = k.getParameters();

        if (s == null)
        {
            s = BouncyCastleProvider.CONFIGURATION.getEcImplicitlyCa();

            return new ECPublicKeyParameters(
                        ((BCECPublicKey)k).engineGetQ(),
                        new ECDomainParameters(s.getCurve(), s.getG(), s.getN(), s.getH(), s.getSeed()));
        }
        else
        {
            return new ECPublicKeyParameters(
                        k.getQ(),
                        new ECDomainParameters(s.getCurve(), s.getG(), s.getN(), s.getH(), s.getSeed()));
        }
    }

    throw new InvalidKeyException("cannot identify EC public key.");
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:28,代码来源:ECUtil.java

示例5: main

import org.bouncycastle.jce.spec.ECParameterSpec; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
	
	SecureRandom sr = new SecureRandom(); // SecureRandom is thread-safe

	Security.addProvider(new BouncyCastleProvider());

	ECParameterSpec ecSpec = ECNamedCurveTable.getParameterSpec("P-256");
	BigInteger n = ecSpec.getN();

	KeyPairGenerator kpg = KeyPairGenerator.getInstance("ECDSA", "BC");

	kpg.initialize(ecSpec, new SecureRandom());
	KeyPair pair = kpg.generateKeyPair();

	ECPoint pki = ((ECPublicKey) pair.getPublic()).getQ();
	BigInteger xi = ((ECPrivateKey) pair.getPrivate()).getD();

	// BigInteger xi = getRandom(n);
	System.out.println("xi = " + xi);
	BigInteger xj = getRandom(sr, n);
	System.out.println("xj = " + xj);

	ECPoint g = ecSpec.getG();
	encoded(g);

	// ECPoint pki = g.multiply(xi);
	System.out.println("pki = " + pki);
	encoded(pki);
	ECPoint pkj = g.multiply(xj);
	System.out.println("pkj = " + pkj);
	encoded(pkj);

	ECPoint m = g.multiply(getRandom(sr, n));
	System.out.println("m = " + m);
	encoded(m);

	ECPoint[] c = encrypt(ecSpec, pki, m, sr);

	ECPoint m2 = decrypt(ecSpec, xi, c);
	System.out.println("m2 = " + m2);
	encoded(m2);

	if (!m2.equals(m)) {
		System.out.println("Error 1!");
	} else {
		System.out.println("m == m2? " + m2.equals(m));
	}

	// RKG & REENC

	BigInteger invxi = xi.modInverse(n);
	BigInteger rk = xj.multiply(invxi).mod(n);

	ECPoint[] c_j = reencrypt(ecSpec, rk, c);

	ECPoint m3 = decrypt(ecSpec, xj, c_j);
	System.out.println("m3 = " + m3);
	if (!m3.equals(m))
		System.out.println("Error 2!");

}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:62,代码来源:BBS98BouncyCastle.java

示例6: createKeyGenParamsBC

import org.bouncycastle.jce.spec.ECParameterSpec; //导入方法依赖的package包/类
protected ECKeyGenerationParameters createKeyGenParamsBC(ECParameterSpec p, SecureRandom r)
{
    return new ECKeyGenerationParameters(new ECDomainParameters(p.getCurve(), p.getG(), p.getN()), r);
}
 
开发者ID:thedrummeraki,项目名称:Aki-SSL,代码行数:5,代码来源:KeyPairGeneratorSpi.java

示例7: encrypt

import org.bouncycastle.jce.spec.ECParameterSpec; //导入方法依赖的package包/类
public static ECPoint[] encrypt(ECParameterSpec ecSpec, ECPoint pk, ECPoint m, SecureRandom sr) {
	ECPoint g = ecSpec.getG();
	BigInteger n = ecSpec.getN();

	BigInteger r = getRandom(sr, n);

	ECPoint g_r = g.multiply(r);

	ECPoint m_g_r = g_r.add(m);
	ECPoint pk_r = pk.multiply(r);

	return new ECPoint[] { pk_r, m_g_r };
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:14,代码来源:BBS98BouncyCastle.java

示例8: PaceECDH

import org.bouncycastle.jce.spec.ECParameterSpec; //导入方法依赖的package包/类
public PaceECDH(ECParameterSpec ecParameterSpec) {

		pointG = ecParameterSpec.getG();
		logger.debug("Point G:\n"+HexString.bufferToHex(pointG.getEncoded(false)));
		
		curve = (org.bouncycastle.math.ec.ECCurve.Fp) ecParameterSpec.getCurve();
		Random rnd = new Random();
		randomGenerator.setSeed(rnd.nextLong());

	}
 
开发者ID:tsenger,项目名称:animamea,代码行数:11,代码来源:PaceECDH.java


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