use of org.fisco.bcos.web3j.crypto.ECKeyPair 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;
}
use of org.fisco.bcos.web3j.crypto.ECKeyPair in project web3sdk by FISCO-BCOS.
the class GenCredential method create.
public static Credentials create(ECKeyPair keyPair) {
try {
ECKeyPair newKeyPair = createKeyPair(keyPair.getPrivateKey().toString(16));
if (newKeyPair == null)
return null;
Credentials credentials = Credentials.create(newKeyPair);
return credentials;
} catch (Exception e) {
System.out.println("init credential from private key failed ");
logger.error("init credential from private key failed, error msg:" + e.getMessage());
return null;
}
}
use of org.fisco.bcos.web3j.crypto.ECKeyPair in project web3sdk by FISCO-BCOS.
the class TestTxDecode method sentTx.
public static TransactionReceipt sentTx() throws Exception {
// init the Service
ApplicationContext context = new ClassPathXmlApplicationContext("classpath:applicationContext.xml");
Service service = context.getBean(Service.class);
service.run();
ECKeyPair keyPair = Keys.createEcKeyPair();
Credentials credentials = Credentials.create(keyPair);
ChannelEthereumService channelEthereumService = new ChannelEthereumService();
channelEthereumService.setChannelService(service);
service.setGroupId(1);
Web3j web3j = Web3j.build(channelEthereumService, service.getGroupId());
RemoteCall<TableTest> deploy = TableTest.deploy(web3j, credentials, new StaticGasProvider(new BigInteger("30000000"), new BigInteger("30000000")));
TableTest tableTest = deploy.send();
tableTest.create().send();
String name = "fruit";
int item_id = 1;
String item_name = "apple";
RemoteCall<TransactionReceipt> insert = tableTest.insert(name, BigInteger.valueOf(item_id), item_name);
TransactionReceipt txReceipt = insert.send();
return txReceipt;
}
Aggregations