use of org.bouncycastle.math.ec.custom.sec.SecP256K1Curve in project web3sdk by FISCO-BCOS.
the class ECCEncrypt method createBCECPublicKey.
/**
* create BCECPublicKey from publicKey and privateKey
*
* @param publicKey
* @return
*/
private BCECPublicKey createBCECPublicKey(BigInteger publicKey) {
// Handle public key.
String publicKeyValue = Numeric.toHexStringNoPrefixZeroPadded(publicKey, Keys.PUBLIC_KEY_LENGTH_IN_HEX);
String prePublicKeyStr = publicKeyValue.substring(0, 64);
String postPublicKeyStr = publicKeyValue.substring(64);
SecP256K1Curve secP256K1Curve = new SecP256K1Curve();
SecP256K1Point secP256K1Point = (SecP256K1Point) secP256K1Curve.createPoint(new BigInteger(prePublicKeyStr, 16), new BigInteger(postPublicKeyStr, 16));
SecP256K1Point secP256K1PointG = (SecP256K1Point) secP256K1Curve.createPoint(ECCParams.POINTG_PRE, ECCParams.POINTG_POST);
ECDomainParameters domainParameters = new ECDomainParameters(secP256K1Curve, secP256K1PointG, ECCParams.FACTOR_N);
ECPublicKeyParameters publicKeyParameters = new ECPublicKeyParameters(secP256K1Point, domainParameters);
BCECPublicKey bcecPublicKey = new BCECPublicKey("ECDSA", publicKeyParameters, ECCParams.ecNamedCurveSpec, BouncyCastleProvider.CONFIGURATION);
return bcecPublicKey;
}
Aggregations