java.security.interfaces.ECPrivateKey#getParams ( )源码实例Demo

下面列出了java.security.interfaces.ECPrivateKey#getParams ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: snowblossom   文件: KeyUtil.java
/**
 * Get the EC curve parameters used by the secp256k1 keys used for HD seeds
 */
public static ECParameterSpec getECHDSpec()
{
  try
  {
    ECGenParameterSpec spec = new ECGenParameterSpec("secp256k1");
    KeyPairGenerator key_gen = KeyPairGenerator.getInstance("ECDSA", Globals.getCryptoProviderName());
    key_gen.initialize(spec);

    KeyPair pair = key_gen.genKeyPair();
    ECPrivateKey priv = (ECPrivateKey)pair.getPrivate();

    return priv.getParams();
  }
  catch(Exception e)
  {
    throw new RuntimeException(e);
  }

}
 
源代码2 项目: web3sdk   文件: P12Manager.java
public PublicKey getPublicKey()
        throws UnrecoverableKeyException, KeyStoreException, NoSuchAlgorithmException,
                InvalidKeySpecException, NoSuchProviderException {
    ECPrivateKey privateKey = (ECPrivateKey) getPrivateKey();

    ECParameterSpec params = privateKey.getParams();

    org.bouncycastle.jce.spec.ECParameterSpec bcSpec =
            org.bouncycastle.jcajce.provider.asymmetric.util.EC5Util.convertSpec(params, false);
    org.bouncycastle.math.ec.ECPoint q = bcSpec.getG().multiply(privateKey.getS());
    org.bouncycastle.math.ec.ECPoint bcW = bcSpec.getCurve().decodePoint(q.getEncoded(false));
    ECPoint w =
            new ECPoint(
                    bcW.getAffineXCoord().toBigInteger(), bcW.getAffineYCoord().toBigInteger());
    ECPublicKeySpec keySpec = new ECPublicKeySpec(w, tryFindNamedCurveSpec(params));
    return (PublicKey)
            KeyFactory.getInstance("EC", BouncyCastleProvider.PROVIDER_NAME)
                    .generatePublic(keySpec);
}
 
源代码3 项目: web3sdk   文件: PEMManager.java
public PublicKey getPublicKey()
        throws InvalidKeySpecException, NoSuchAlgorithmException, NoSuchProviderException {
    ECPrivateKey privateKey = (ECPrivateKey) getPrivateKey();

    ECParameterSpec params = privateKey.getParams();

    org.bouncycastle.jce.spec.ECParameterSpec bcSpec =
            org.bouncycastle.jcajce.provider.asymmetric.util.EC5Util.convertSpec(params, false);
    org.bouncycastle.math.ec.ECPoint q = bcSpec.getG().multiply(privateKey.getS());
    org.bouncycastle.math.ec.ECPoint bcW = bcSpec.getCurve().decodePoint(q.getEncoded(false));
    ECPoint w =
            new ECPoint(
                    bcW.getAffineXCoord().toBigInteger(), bcW.getAffineYCoord().toBigInteger());
    ECPublicKeySpec keySpec = new ECPublicKeySpec(w, tryFindNamedCurveSpec(params));
    return (PublicKey)
            KeyFactory.getInstance("EC", BouncyCastleProvider.PROVIDER_NAME)
                    .generatePublic(keySpec);
}
 
源代码4 项目: ECTester   文件: ECTesterStandalone.java
/**
 *
 */
private void export() throws NoSuchAlgorithmException, IOException {
    ProviderECLibrary lib = cfg.selected;
    KeyPairGeneratorIdent ident = null;
    String algo = cli.getOptionValue("export.type", "EC");
    for (KeyPairGeneratorIdent kpIdent : lib.getKPGs()) {
        if (kpIdent.contains(algo)) {
            ident = kpIdent;
            break;
        }
    }
    if (ident == null) {
        throw new NoSuchAlgorithmException(algo);
    }
    KeyPairGenerator kpg = ident.getInstance(lib.getProvider());
    if (cli.hasOption("export.bits")) {
        int bits = Integer.parseInt(cli.getOptionValue("export.bits"));
        kpg.initialize(bits);
    }
    KeyPair kp = kpg.genKeyPair();
    ECPrivateKey privateKey = (ECPrivateKey) kp.getPrivate();
    ECParameterSpec params = privateKey.getParams();
    System.out.println(params);
    EC_Curve curve = EC_Curve.fromSpec(params);
    curve.writeCSV(System.out);
}
 
源代码5 项目: ECTester   文件: NativeSignatureSpi.java
@Override
protected void engineInitSign(PrivateKey privateKey) throws InvalidKeyException {
    if (!(privateKey instanceof ECPrivateKey)) {
        throw new InvalidKeyException
                ("Key must be an instance of ECPrivateKey");
    }
    signKey = (ECPrivateKey) privateKey;
    params = signKey.getParams();
    buffer.reset();
}
 
源代码6 项目: ECTester   文件: NativeKeyAgreementSpi.java
@Override
protected void engineInit(Key key, SecureRandom random) throws InvalidKeyException {
    if (!(key instanceof ECPrivateKey)) {
        throw new InvalidKeyException
                ("Key must be instance of ECPrivateKey");
    }
    privateKey = (ECPrivateKey) key;
    this.params = privateKey.getParams();
}
 
源代码7 项目: RipplePower   文件: JCEECPrivateKey.java
public JCEECPrivateKey(
    ECPrivateKey    key)
{
    this.d = key.getS();
    this.algorithm = key.getAlgorithm();
    this.ecSpec = key.getParams();
}
 
源代码8 项目: RipplePower   文件: BCDSTU4145PrivateKey.java
public BCDSTU4145PrivateKey(
    ECPrivateKey key)
{
    this.d = key.getS();
    this.algorithm = key.getAlgorithm();
    this.ecSpec = key.getParams();
}
 
源代码9 项目: RipplePower   文件: BCECPrivateKey.java
public BCECPrivateKey(
    ECPrivateKey key,
    ProviderConfiguration configuration)
{
    this.d = key.getS();
    this.algorithm = key.getAlgorithm();
    this.ecSpec = key.getParams();
    this.configuration = configuration;
}
 
源代码10 项目: RipplePower   文件: BCECGOST3410PrivateKey.java
public BCECGOST3410PrivateKey(
    ECPrivateKey key)
{
    this.d = key.getS();
    this.algorithm = key.getAlgorithm();
    this.ecSpec = key.getParams();
}
 
源代码11 项目: ripple-lib-java   文件: JCEECPrivateKey.java
public JCEECPrivateKey(
    ECPrivateKey    key)
{
    this.d = key.getS();
    this.algorithm = key.getAlgorithm();
    this.ecSpec = key.getParams();
}
 
源代码12 项目: ripple-lib-java   文件: BCDSTU4145PrivateKey.java
public BCDSTU4145PrivateKey(
    ECPrivateKey key)
{
    this.d = key.getS();
    this.algorithm = key.getAlgorithm();
    this.ecSpec = key.getParams();
}
 
源代码13 项目: ripple-lib-java   文件: BCECPrivateKey.java
public BCECPrivateKey(
    ECPrivateKey key,
    ProviderConfiguration configuration)
{
    this.d = key.getS();
    this.algorithm = key.getAlgorithm();
    this.ecSpec = key.getParams();
    this.configuration = configuration;
}
 
源代码14 项目: ripple-lib-java   文件: BCECGOST3410PrivateKey.java
public BCECGOST3410PrivateKey(
    ECPrivateKey key)
{
    this.d = key.getS();
    this.algorithm = key.getAlgorithm();
    this.ecSpec = key.getParams();
}