Java Code Examples for org.fisco.bcos.web3j.crypto.gm.GenCredential#createKeyPair()
The following examples show how to use
org.fisco.bcos.web3j.crypto.gm.GenCredential#createKeyPair() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: KeyStoreService.java From WeBASE-Front with Apache License 2.0 | 6 votes |
/** * create key store locally and save * with private key */ public KeyStoreInfo createKeyStoreLocally(String userName) { log.info("start createKeyStore. userName:{}", userName); checkUserNameAndTypeNotExist(userName, KeyTypes.LOCALUSER.getValue()); // create keyPair(support guomi) KeyStoreInfo keyStoreInfo; try { ECKeyPair keyPair = GenCredential.createKeyPair(); keyStoreInfo = keyPair2KeyStoreInfo(keyPair, userName); } catch (Exception e) { log.error("fail createKeyStore.", e); throw new FrontException("create keyInfo failed"); } keyStoreInfo.setType(KeyTypes.LOCALUSER.getValue()); String realPrivateKey = keyStoreInfo.getPrivateKey(); keyStoreInfo.setPrivateKey(aesUtils.aesEncrypt(realPrivateKey)); return keystoreRepository.save(keyStoreInfo); }
Example 2
Source File: KeyStoreService.java From WeBASE-Front with Apache License 2.0 | 5 votes |
/** * get random credential to call transaction(not execute) * 2019/11/26 support guomi */ public Credentials getCredentialsForQuery() { log.debug("start getCredentialsForQuery. "); // create keyPair(support guomi) KeyStoreInfo keyStoreInfo; try { ECKeyPair keyPair = GenCredential.createKeyPair(); keyStoreInfo = keyPair2KeyStoreInfo(keyPair, ""); } catch (Exception e) { log.error("fail getCredentialsForQuery.", e); throw new FrontException("create random Credentials for query failed"); } return GenCredential.create(keyStoreInfo.getPrivateKey()); }
Example 3
Source File: KeyStoreService.java From WeBASE-Front with Apache License 2.0 | 5 votes |
public KeyStoreInfo getKeyStoreInfoForQuery() { log.debug("start getKeyStoreInfoForQuery. "); // create keyPair(support guomi) KeyStoreInfo keyStoreInfo; try { ECKeyPair keyPair = GenCredential.createKeyPair(); return keyPair2KeyStoreInfo(keyPair, ""); } catch (Exception e) { log.error("fail getKeyStoreInfoForQuery.", e); throw new FrontException("create random keyInfo for query failed"); } }
Example 4
Source File: KeyStoreService.java From WeBASE-Front with Apache License 2.0 | 5 votes |
/** * save LOCAL_USER key store by private key * @param privateKey * @param userName * @return KeyStoreInfo local user */ public KeyStoreInfo importFromPrivateKey(String privateKey, String userName) { // check name checkUserNameAndTypeNotExist(userName, KeyTypes.LOCALUSER.getValue()); // to store locally ECKeyPair keyPair = GenCredential.createKeyPair(privateKey); if (keyPair == null) { throw new FrontException(ConstantCode.PARAM_ERROR); } KeyStoreInfo keyStoreInfo = keyPair2KeyStoreInfo(keyPair, userName); keyStoreInfo.setType(KeyTypes.LOCALUSER.getValue()); String realPrivateKey = keyStoreInfo.getPrivateKey(); keyStoreInfo.setPrivateKey(aesUtils.aesEncrypt(realPrivateKey)); return keystoreRepository.save(keyStoreInfo); }