Search in sources :

Example 6 with ECKeyPair

use of org.fisco.bcos.web3j.crypto.ECKeyPair in project web3sdk by FISCO-BCOS.

the class PEMManager method getECKeyPair.

public ECKeyPair getECKeyPair() throws UnrecoverableKeyException, KeyStoreException, NoSuchAlgorithmException, InvalidKeySpecException, NoSuchProviderException {
    PrivateKey privateKey = getPrivateKey();
    PublicKey publicKey = getPublicKey();
    KeyPair keyPair = new KeyPair(publicKey, privateKey);
    return ECKeyPair.create(keyPair);
}
Also used : KeyPair(java.security.KeyPair) ECKeyPair(org.fisco.bcos.web3j.crypto.ECKeyPair) ECPrivateKey(java.security.interfaces.ECPrivateKey) PrivateKey(java.security.PrivateKey) PublicKey(java.security.PublicKey)

Example 7 with ECKeyPair

use of org.fisco.bcos.web3j.crypto.ECKeyPair in project web3sdk by FISCO-BCOS.

the class P12Manager method getECKeyPair.

public ECKeyPair getECKeyPair() throws UnrecoverableKeyException, KeyStoreException, NoSuchAlgorithmException, InvalidKeySpecException, NoSuchProviderException {
    PrivateKey privateKey = getPrivateKey();
    PublicKey publicKey = getPublicKey();
    KeyPair keyPair = new KeyPair(publicKey, privateKey);
    return ECKeyPair.create(keyPair);
}
Also used : KeyPair(java.security.KeyPair) ECKeyPair(org.fisco.bcos.web3j.crypto.ECKeyPair) ECPrivateKey(java.security.interfaces.ECPrivateKey) PrivateKey(java.security.PrivateKey) PublicKey(java.security.PublicKey)

Example 8 with ECKeyPair

use of org.fisco.bcos.web3j.crypto.ECKeyPair 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;
}
Also used : KeyPair(java.security.KeyPair) ECKeyPair(org.fisco.bcos.web3j.crypto.ECKeyPair) SM2KeyGenerator(org.fisco.bcos.web3j.crypto.gm.sm2.crypto.asymmetric.SM2KeyGenerator)

Example 9 with ECKeyPair

use of org.fisco.bcos.web3j.crypto.ECKeyPair in project web3sdk by FISCO-BCOS.

the class GenCredential method createECDSAKeyPair.

public static ECKeyPair createECDSAKeyPair(String privKey) {
    try {
        BigInteger bigPrivKey = new BigInteger(privKey, 16);
        ECKeyPair keyPair = ECKeyPair.create(bigPrivKey);
        return keyPair;
    } catch (Exception e) {
        logger.error("create keypair of ECDSA failed, error msg:" + e.getMessage());
        return null;
    }
}
Also used : ECKeyPair(org.fisco.bcos.web3j.crypto.ECKeyPair) BigInteger(java.math.BigInteger)

Example 10 with ECKeyPair

use of org.fisco.bcos.web3j.crypto.ECKeyPair in project web3sdk by FISCO-BCOS.

the class GenCredential method create.

public static Credentials create() {
    try {
        ECKeyPair keyPair = createKeyPair();
        if (keyPair == null)
            return null;
        Credentials credentials = Credentials.create(keyPair);
        logger.debug(" privateKey: {}, publicKey: {}, address: {}", credentials.getEcKeyPair().getPrivateKey(), credentials.getEcKeyPair().getPrivateKey(), credentials.getAddress());
        return credentials;
    } catch (Exception e) {
        System.out.println("init credential failed");
        logger.error("init credential failed, error msg:" + e.getMessage());
        return null;
    }
}
Also used : ECKeyPair(org.fisco.bcos.web3j.crypto.ECKeyPair) Credentials(org.fisco.bcos.web3j.crypto.Credentials)

Aggregations

ECKeyPair (org.fisco.bcos.web3j.crypto.ECKeyPair)13 Credentials (org.fisco.bcos.web3j.crypto.Credentials)6 BigInteger (java.math.BigInteger)5 KeyPair (java.security.KeyPair)4 ApplicationContext (org.springframework.context.ApplicationContext)3 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)3 PrivateKey (java.security.PrivateKey)2 PublicKey (java.security.PublicKey)2 ECPrivateKey (java.security.interfaces.ECPrivateKey)2 Service (org.fisco.bcos.channel.client.Service)2 SM2KeyGenerator (org.fisco.bcos.web3j.crypto.gm.sm2.crypto.asymmetric.SM2KeyGenerator)2 Web3j (org.fisco.bcos.web3j.protocol.Web3j)2 ChannelEthereumService (org.fisco.bcos.web3j.protocol.channel.ChannelEthereumService)2 TransactionReceipt (org.fisco.bcos.web3j.protocol.core.methods.response.TransactionReceipt)2 RateLimiter (com.google.common.util.concurrent.RateLimiter)1 SecureRandom (java.security.SecureRandom)1 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 ECPublicKey (org.bouncycastle.jce.interfaces.ECPublicKey)1 P12Manager (org.fisco.bcos.channel.client.P12Manager)1