use of org.fisco.bcos.web3j.crypto.gm.sm2.crypto.asymmetric.SM2KeyGenerator in project web3sdk by FISCO-BCOS.
the class Sign method smPublicKeyFromPrivate.
/**
* Returns sm public key from the given private key.
*
* @param biPrivateKey the private key to derive the public key from
* @return BigInteger encoded public key
*/
public static BigInteger smPublicKeyFromPrivate(BigInteger biPrivateKey) {
String privateKey = biPrivateKey.toString(16);
SM2KeyGenerator generator = new SM2KeyGenerator();
final KeyPair keyPairData = generator.generateKeyPair(privateKey);
SM2PublicKey pk = (SM2PublicKey) keyPairData.getPublic();
final byte[] publicKey = pk.getEncoded();
BigInteger biPublicKey = new BigInteger(Hex.toHexString(publicKey), 16);
return biPublicKey;
}
use of org.fisco.bcos.web3j.crypto.gm.sm2.crypto.asymmetric.SM2KeyGenerator in project web3sdk by FISCO-BCOS.
the class GenCredential method createGuomiKeyPair.
public static ECKeyPair createGuomiKeyPair() {
final SM2KeyGenerator generator = new SM2KeyGenerator();
final KeyPair keyPairData = generator.generateKeyPair();
if (keyPairData != null)
return genEcPairFromKeyPair(keyPairData);
return null;
}
use of org.fisco.bcos.web3j.crypto.gm.sm2.crypto.asymmetric.SM2KeyGenerator in project web3sdk by FISCO-BCOS.
the class GenCredential method createGuomiKeyPair.
public static ECKeyPair createGuomiKeyPair(String privKey) {
SM2KeyGenerator generator = new SM2KeyGenerator();
final KeyPair keyPairData = generator.generateKeyPair(privKey);
if (keyPairData != null)
return genEcPairFromKeyPair(keyPairData);
return null;
}
Aggregations