org.fisco.bcos.web3j.crypto.EncryptType Java Examples
The following examples show how to use
org.fisco.bcos.web3j.crypto.EncryptType.
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: NodeMgrTools.java From WeBASE-Node-Manager with Apache License 2.0 | 6 votes |
/** * get hash value * type: sha256 or sm3 */ public static byte[] getHashValue(byte[] byteArray) { byte[] hashResult; if(EncryptType.encryptType == 1) { hashResult = Hash.sha3(byteArray); return hashResult; } else { MessageDigest sha = null; try { sha = MessageDigest.getInstance("SHA-256"); hashResult = sha.digest(byteArray); return hashResult; } catch (Exception e) { log.error("shaEncode getHashValue fail:", e); return null; } } }
Example #2
Source File: RevertResolverTest.java From web3sdk with Apache License 2.0 | 6 votes |
@Test public void isOutputStartWithRevertMethodSMTest() { EncryptType.setEncryptType(EncryptType.SM2_TYPE); String revertMessage = "isOutputStartWithRevertMethodTest"; Function revertFunction = newFunction("Error", revertMessage); String revertABI = FunctionEncoder.encode(revertFunction); Function testFunction = newFunction("testFunc", revertMessage); String testABI = FunctionEncoder.encode(testFunction); assertTrue(RevertResolver.isOutputStartWithRevertMethod(revertABI)); assertFalse(RevertResolver.isOutputStartWithRevertMethod(testABI)); assertTrue(RevertResolver.isOutputStartWithRevertMethod(revertABI)); assertFalse(RevertResolver.isOutputStartWithRevertMethod(testABI)); EncryptType.setEncryptType(EncryptType.ECDSA_TYPE); }
Example #3
Source File: RevertResolverTest.java From web3sdk with Apache License 2.0 | 6 votes |
@Test public void hasRevertMessageSMTest() throws IOException { EncryptType.setEncryptType(EncryptType.SM2_TYPE); String revertMessage = "RevertMessage"; Function revertFunction = newFunction("Error", revertMessage); String revertABI = FunctionEncoder.encode(revertFunction); Function testFunction = newFunction("testFunc", revertMessage); String testABI = FunctionEncoder.encode(testFunction); assertFalse(RevertResolver.hasRevertMessage(null, null)); assertFalse(RevertResolver.hasRevertMessage("", null)); assertFalse(RevertResolver.hasRevertMessage(null, "")); assertFalse(RevertResolver.hasRevertMessage("", "")); assertFalse(RevertResolver.hasRevertMessage("0x0", "")); assertFalse(RevertResolver.hasRevertMessage("0x0", "")); assertFalse(RevertResolver.hasRevertMessage("0x0", revertABI)); assertTrue(RevertResolver.hasRevertMessage("0x1", revertABI)); assertFalse(RevertResolver.hasRevertMessage(null, revertABI)); assertFalse(RevertResolver.hasRevertMessage("0x0", testABI)); assertFalse(RevertResolver.hasRevertMessage("0x1", testABI)); assertFalse(RevertResolver.hasRevertMessage(null, testABI)); EncryptType.setEncryptType(EncryptType.ECDSA_TYPE); }
Example #4
Source File: TestBase.java From web3sdk with Apache License 2.0 | 6 votes |
@BeforeClass public static void setUpBeforeClass() throws Exception { context = new ClassPathXmlApplicationContext("classpath:applicationContext.xml"); Service service = context.getBean(Service.class); service.run(); ChannelEthereumService channelEthereumService = new ChannelEthereumService(); channelEthereumService.setChannelService(service); System.out.println("EncryptType => " + EncryptType.getEncryptType()); web3j = Web3j.build(channelEthereumService, service.getGroupId()); credentials = GenCredential.create(); Ok ok = Ok.deploy(web3j, credentials, new StaticGasProvider(gasPrice, gasLimit)).send(); blockNumber = ok.getTransactionReceipt().get().getBlockNumber(); blockHash = ok.getTransactionReceipt().get().getBlockHash(); txHash = ok.getTransactionReceipt().get().getTransactionHash(); }
Example #5
Source File: AccountUtils.java From web3sdk with Apache License 2.0 | 6 votes |
public static Account newAccount(boolean flag) throws InvalidAlgorithmParameterException, NoSuchAlgorithmException, NoSuchProviderException { // guomi Account account = new Account(); if (flag) { EncryptType.encryptType = 1; account.setEncryptType("guomi"); } else { EncryptType.encryptType = 0; account.setEncryptType("standard"); } Credentials credentials = GenCredential.create(); String address = credentials.getAddress(); String privateKey = credentials.getEcKeyPair().getPrivateKey().toString(16); String publicKey = credentials.getEcKeyPair().getPublicKey().toString(16); account.setAddress(address); account.setPrivateKey(privateKey); account.setPublicKey(publicKey); return account; }
Example #6
Source File: CommonUtils.java From WeBASE-Transaction with Apache License 2.0 | 6 votes |
/** * signatureDataToString. * 19/12/24 support guomi: add byte[] pub in signatureData * @param signatureData signatureData */ public static String signatureDataToString(SignatureData signatureData) { byte[] byteArr; if(EncryptType.encryptType == 1) { byteArr = new byte[1 + signatureData.getR().length + signatureData.getS().length + publicKeyLength_64]; byteArr[0] = signatureData.getV(); System.arraycopy(signatureData.getR(), 0, byteArr, 1, signatureData.getR().length); System.arraycopy(signatureData.getS(), 0, byteArr, signatureData.getR().length + 1, signatureData.getS().length); System.arraycopy(signatureData.getPub(), 0, byteArr, signatureData.getS().length + signatureData.getR().length + 1, signatureData.getPub().length); } else { byteArr = new byte[1 + signatureData.getR().length + signatureData.getS().length]; byteArr[0] = signatureData.getV(); System.arraycopy(signatureData.getR(), 0, byteArr, 1, signatureData.getR().length); System.arraycopy(signatureData.getS(), 0, byteArr, signatureData.getR().length + 1, signatureData.getS().length); } return Numeric.toHexString(byteArr, 0, byteArr.length, false); }
Example #7
Source File: TransactionEncoderTest.java From WeBASE-Front with Apache License 2.0 | 6 votes |
@Test public void testGMCrendetial() { for (int i = 0; i < 10; i++) { Instant systartTime = Instant.now(); GenCredential.create( "a392604efc2fad9c0b3da43b5f698a2e3f270f170d859912be0d54742275c5f"+i); System.out.println(" siyao useTime: " + Duration.between(systartTime, Instant.now()).toMillis()); // gm createTransaction! EncryptType encryptType = new EncryptType(1); assertSame(encryptType.getEncryptType(),1); Instant gmsystartTime = Instant.now(); GenCredential.create( "a392604efc2fad9c0b3da43b5f698a2e3f270f170d859912be0d54742275c5f"+i); // System.out.println(gmcredentials.getEcKeyPair().getPublicKey().toString(16)); System.out.println(encryptType+ " gmsiyao useTime: " + Duration.between(gmsystartTime, Instant.now()).toMillis()); } }
Example #8
Source File: CommonUtils.java From WeBASE-Front with Apache License 2.0 | 6 votes |
/** * signatureDataToString. 19/12/24 support guomi: add byte[] pub in signatureData * * @param signatureData signatureData */ public static String signatureDataToString(SignatureData signatureData) { byte[] byteArr; if (EncryptType.encryptType == 1) { byteArr = new byte[1 + signatureData.getR().length + signatureData.getS().length + PUBLIC_KEY_LENGTH_64]; byteArr[0] = signatureData.getV(); System.arraycopy(signatureData.getR(), 0, byteArr, 1, signatureData.getR().length); System.arraycopy(signatureData.getS(), 0, byteArr, signatureData.getR().length + 1, signatureData.getS().length); System.arraycopy(signatureData.getPub(), 0, byteArr, signatureData.getS().length + signatureData.getR().length + 1, signatureData.getPub().length); } else { byteArr = new byte[1 + signatureData.getR().length + signatureData.getS().length]; byteArr[0] = signatureData.getV(); System.arraycopy(signatureData.getR(), 0, byteArr, 1, signatureData.getR().length); System.arraycopy(signatureData.getS(), 0, byteArr, signatureData.getR().length + 1, signatureData.getS().length); } return Numeric.toHexString(byteArr, 0, byteArr.length, false); }
Example #9
Source File: FrontCertService.java From WeBASE-Front with Apache License 2.0 | 6 votes |
/** * get cert file's path through concatting nodePath with certType * @param nodePath * @param certType * @return * 2019/12 support guomi */ public Path getCertPath(String nodePath, int certType) { if (certType == CertTypes.CHAIN.getValue()) { if (EncryptType.encryptType == 1){ return Paths.get(nodePath.concat(gmCaCrtPath)); } return Paths.get(nodePath.concat(caCrtPath)); } else if (certType == CertTypes.NODE.getValue()) { if (EncryptType.encryptType == 1){ return Paths.get(nodePath.concat(gmNodeCrtPath)); } return Paths.get(nodePath.concat(nodeCrtPath)); } else if(certType == CertTypes.OTHERS.getValue()){ return getEncrytCertPath(nodePath); } return null; }
Example #10
Source File: Web3Config.java From WeBASE-Front with Apache License 2.0 | 5 votes |
/** * 覆盖EncryptType构造函数 * @return */ @Bean(name = "encryptType") public EncryptType EncryptType() { // 1: guomi, 0: standard log.info("*****init EncrytType:" + encryptType); return new EncryptType(encryptType); }
Example #11
Source File: RevertResolverTest.java From web3sdk with Apache License 2.0 | 5 votes |
@Test public void tryResolveRevertMessageSMTest0() throws IOException { EncryptType.setEncryptType(EncryptType.SM2_TYPE); String revertMessage = ""; Function revertFunction = newFunction("Error", revertMessage); String revertABI = FunctionEncoder.encode(revertFunction); Function testFunction = newFunction("testFunc", revertMessage); String testABI = FunctionEncoder.encode(testFunction); Tuple2<Boolean, String> booleanStringTuple2 = RevertResolver.tryResolveRevertMessage("", ""); assertFalse(booleanStringTuple2.getValue1()); Tuple2<Boolean, String> booleanStringTuple20 = RevertResolver.tryResolveRevertMessage("0x0", revertABI); assertFalse(booleanStringTuple20.getValue1()); Tuple2<Boolean, String> booleanStringTuple21 = RevertResolver.tryResolveRevertMessage("0x0", testABI); assertFalse(booleanStringTuple21.getValue1()); Tuple2<Boolean, String> booleanStringTuple22 = RevertResolver.tryResolveRevertMessage("0x1", testABI); assertFalse(booleanStringTuple22.getValue1()); Tuple2<Boolean, String> booleanStringTuple23 = RevertResolver.tryResolveRevertMessage("0x1", revertABI); assertTrue(booleanStringTuple23.getValue1()); assertEquals(booleanStringTuple23.getValue2(), revertMessage); EncryptType.setEncryptType(EncryptType.ECDSA_TYPE); }
Example #12
Source File: RevertResolverTest.java From web3sdk with Apache License 2.0 | 5 votes |
@Test public void tryResolveRevertMessageSMTest() throws IOException { EncryptType.setEncryptType(EncryptType.SM2_TYPE); String revertMessage = "RevertMessage"; Function revertFunction = newFunction("Error", revertMessage); String revertABI = FunctionEncoder.encode(revertFunction); Function testFunction = newFunction("testFunc", revertMessage); String testABI = FunctionEncoder.encode(testFunction); Tuple2<Boolean, String> booleanStringTuple2 = RevertResolver.tryResolveRevertMessage("", ""); assertFalse(booleanStringTuple2.getValue1()); Tuple2<Boolean, String> booleanStringTuple20 = RevertResolver.tryResolveRevertMessage("0x0", revertABI); assertFalse(booleanStringTuple20.getValue1()); Tuple2<Boolean, String> booleanStringTuple21 = RevertResolver.tryResolveRevertMessage("0x0", testABI); assertFalse(booleanStringTuple21.getValue1()); Tuple2<Boolean, String> booleanStringTuple22 = RevertResolver.tryResolveRevertMessage("0x1", testABI); assertFalse(booleanStringTuple22.getValue1()); Tuple2<Boolean, String> booleanStringTuple23 = RevertResolver.tryResolveRevertMessage("0x1", revertABI); assertTrue(booleanStringTuple23.getValue1()); assertEquals(booleanStringTuple23.getValue2(), revertMessage); EncryptType.setEncryptType(EncryptType.ECDSA_TYPE); }
Example #13
Source File: GMOkTransaction.java From web3sdk with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws Exception { EncryptType encryptType = new EncryptType(1); String groupId = "1"; ApplicationContext context = new ClassPathXmlApplicationContext("classpath:applicationContext.xml"); Service service = context.getBean(Service.class); service.run(); System.out.println("==================================================================="); ChannelEthereumService channelEthereumService = new ChannelEthereumService(); channelEthereumService.setChannelService(service); channelEthereumService.setTimeout(10000); Web3j web3 = Web3j.build(channelEthereumService, Integer.parseInt(groupId)); BigInteger gasPrice = new BigInteger("300000000"); BigInteger gasLimit = new BigInteger("3000000000"); Credentials credentials1 = GenCredential.create( "a392604efc2fad9c0b3da43b5f698a2e3f270f170d859912be0d54742275c5f6"); ContractGasProvider contractGasProvider = new StaticGasProvider(gasPrice, gasLimit); final Ok okDemo = Ok.deploy(web3, credentials1, contractGasProvider).send(); for (int i = 0; i < 1; i++) { System.out.println("####contract address is: " + okDemo.getContractAddress()); TransactionReceipt receipt = okDemo.trans(new BigInteger("4")).send(); System.out.println(" balance = " + okDemo.get().send().intValue()); } System.exit(0); }
Example #14
Source File: GMErc20Transaction.java From web3sdk with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws Exception { EncryptType encryptType = new EncryptType(1); System.out.println(encryptType.getEncryptType()); String groupId = "1"; ApplicationContext context = new ClassPathXmlApplicationContext("classpath:applicationContext.xml"); Service service = context.getBean(Service.class); service.run(); System.out.println("==================================================================="); ChannelEthereumService channelEthereumService = new ChannelEthereumService(); channelEthereumService.setChannelService(service); channelEthereumService.setTimeout(10000); Web3j web3 = Web3j.build(channelEthereumService, Integer.parseInt(groupId)); BigInteger gasPrice = new BigInteger("300000000"); BigInteger gasLimit = new BigInteger("300000000"); Credentials credentials1 = GenCredential.create( "a392604efc2fad9c0b3da43b5f698a2e3f270f170d859912be0d54742275c5f6"); ContractGasProvider contractGasProvider = new StaticGasProvider(gasPrice, gasLimit); NewSolTest erc20 = NewSolTest.deploy(web3, credentials1, contractGasProvider).send(); for (int i = 0; i < 1; i++) { System.out.println("####contract address is: " + erc20.getContractAddress()); erc20.transfer("0x0f49a17d17f82da2a7d92ecf19268274150eaf5e", new BigInteger("100")) .send(); BigInteger oldBalance = erc20.balanceOf("0x0f49a17d17f82da2a7d92ecf19268274150eaf5e").send(); System.out.println( "0x0f49a17d17f82da2a7d92ecf19268274150eaf5e balance" + oldBalance.intValue()); } System.exit(0); }
Example #15
Source File: FrontCertService.java From WeBASE-Front with Apache License 2.0 | 5 votes |
/** * 设置了front对应的节点的目录,如/data/fisco/nodes/127.0.0.1/node0 * 则获取 ${path}/conf 中的ca.crt, node.crt * 无需填agency.crt的读取,因为node.crt会包含node和agency的证书 * @return List<String> 或者 String * 2019/12: support guomi: add encrypt node cert in resultList */ // 0 is node ca, 1 is agency ca public List<String> getNodeCerts() { List<String> resList = new ArrayList<>(); String nodePath = constants.getNodePath(); log.debug("start getNodeCerts in {}" + nodePath); getCertListByPathAndType(nodePath, CertTypes.NODE.getValue(), resList); // gm cert added to resList if (EncryptType.encryptType == GMStatus.GUOMI.getValue()) { getCertListByPathAndType(nodePath, CertTypes.OTHERS.getValue(), resList); } log.debug("end getNodeCerts in {}" + nodePath); return resList; }
Example #16
Source File: CommonUtils.java From WeBASE-Transaction with Apache License 2.0 | 5 votes |
/** * stringToSignatureData. * 19/12/24 support guomi: add byte[] pub in signatureData * @param signatureData signatureData * @return */ public static SignatureData stringToSignatureData(String signatureData) { byte[] byteArr = Numeric.hexStringToByteArray(signatureData); byte[] signR = new byte[32]; System.arraycopy(byteArr, 1, signR, 0, signR.length); byte[] signS = new byte[32]; System.arraycopy(byteArr, 1 + signR.length, signS, 0, signS.length); if (EncryptType.encryptType == 1) { byte[] pub = new byte[64]; System.arraycopy(byteArr, 1 + signR.length + signS.length, pub, 0, pub.length); return new SignatureData(byteArr[0], signR, signS, pub); } else { return new SignatureData(byteArr[0], signR, signS); } }
Example #17
Source File: EncryptTypeController.java From WeBASE-Transaction with Apache License 2.0 | 5 votes |
@GetMapping("") public ResponseEntity getEncryptType() { ResponseEntity response = new ResponseEntity(ConstantCode.RET_SUCCEED); int encrypt = EncryptType.encryptType; log.info("getEncryptType:{}", encrypt); response.setData(encrypt); return response; }
Example #18
Source File: CommonUtils.java From WeBASE-Front with Apache License 2.0 | 5 votes |
/** * stringToSignatureData. 19/12/24 support guomi: add byte[] pub in signatureData * * @param signatureData signatureData * @return */ public static SignatureData stringToSignatureData(String signatureData) { byte[] byteArr = Numeric.hexStringToByteArray(signatureData); byte[] signR = new byte[32]; System.arraycopy(byteArr, 1, signR, 0, signR.length); byte[] signS = new byte[32]; System.arraycopy(byteArr, 1 + signR.length, signS, 0, signS.length); if (EncryptType.encryptType == 1) { byte[] pub = new byte[64]; System.arraycopy(byteArr, 1 + signR.length + signS.length, pub, 0, pub.length); return new SignatureData(byteArr[0], signR, signS, pub); } else { return new SignatureData(byteArr[0], signR, signS); } }
Example #19
Source File: FrontCertService.java From WeBASE-Front with Apache License 2.0 | 5 votes |
public Path getEncrytCertPath(String nodePath) { if (EncryptType.encryptType == 1){ return Paths.get(nodePath.concat(gmEncryptCrtPath)); } else { return null; } }
Example #20
Source File: TransactionEncoderTest.java From WeBASE-Front with Apache License 2.0 | 5 votes |
@Test public void testGMSignMessage() { Credentials credentials = GenCredential.create( "a392604efc2fad9c0b3da43b5f698a2e3f270f170d859912be0d54742275c5f"); Instant startTime = Instant.now(); byte[] signedMessage = TransactionEncoder.signMessage(createContractTransaction(), credentials); System.out.println(" sign useTime: " + Duration.between(startTime, Instant.now()).toMillis()); // String hexMessage = Numeric.toHexString(signedMessage); // gm createTransaction! EncryptType encryptType = new EncryptType(1); assertSame(encryptType.getEncryptType(),1); Credentials gmcredentials = GenCredential.create( "a392604efc2fad9c0b3da43b5f698a2e3f270f170d859912be0d54742275c5f"); Instant startTime1 = Instant.now(); TransactionEncoder.signMessage(createContractTransaction(), gmcredentials); System.out.println(" guomi sign useTime: " + Duration.between(startTime1, Instant.now()).toMillis()); // String hexMessage1 = Numeric.toHexString(signedMessage1); }
Example #21
Source File: Ok.java From web3sdk with Apache License 2.0 | 4 votes |
public static String getBinary() { return (EncryptType.encryptType == EncryptType.ECDSA_TYPE ? BINARY : SM_BINARY); }
Example #22
Source File: ContractService.java From WeBASE-Front with Apache License 2.0 | 4 votes |
public List<RspMultiContractCompile> multiContractCompile(ReqMultiContractCompile inputParam) throws IOException { // clear temp folder CommonUtils.deleteFiles(BASE_FILE_PATH); // unzip CommonUtils.zipBase64ToFile(inputParam.getContractZipBase64(), BASE_FILE_PATH); // get sol files File solFileList = new File(BASE_FILE_PATH); File[] solFiles = solFileList.listFiles(new FilenameFilter() { @Override public boolean accept(File dir, String fileName) { if (!fileName.toLowerCase().endsWith(".sol")) { return false; } return true; } }); if (solFiles == null || solFiles.length == 0) { log.error("There is no sol files in source."); throw new FrontException(ConstantCode.NO_SOL_FILES); } // whether use guomi to compile boolean useSM2 = EncryptType.encryptType == GMStatus.GUOMI.getValue(); List<RspMultiContractCompile> compileInfos = new ArrayList<>(); for (File solFile : solFiles) { String contractName = solFile.getName().substring(0, solFile.getName().lastIndexOf(".")); // compile SolidityCompiler.Result res = SolidityCompiler.compile(solFile, useSM2, true, ABI, SolidityCompiler.Options.BIN); // check result if (res.isFailed()) { log.error("multiContractCompile fail. contract:{} compile error. {}", contractName, res.getErrors()); throw new FrontException(ConstantCode.CONTRACT_COMPILE_FAIL.getCode(), res.getErrors()); } // parse result CompilationResult result = CompilationResult.parse(res.getOutput()); List<CompilationResult.ContractMetadata> contracts = result.getContracts(); if (contracts.size() > 0) { RspMultiContractCompile compileInfo = new RspMultiContractCompile(); compileInfo.setContractName(contractName); compileInfo.setBytecodeBin(result.getContract(contractName).bin); compileInfo.setContractAbi(result.getContract(contractName).abi); compileInfo.setContractSource( CommonUtils.fileToBase64(BASE_FILE_PATH + solFile.getName())); compileInfos.add(compileInfo); } } log.debug("end multiContractCompile."); return compileInfos; }
Example #23
Source File: EncryptTypeConfig.java From WeBASE-Node-Manager with Apache License 2.0 | 4 votes |
/** * 覆盖EncryptType构造函数 * @return */ @Bean(name = "encryptType") public EncryptType EncryptType() { return new EncryptType(encryptType); }
Example #24
Source File: FrontService.java From WeBASE-Node-Manager with Apache License 2.0 | 4 votes |
/** * add new front */ @Transactional public TbFront newFront(FrontInfo frontInfo) { log.debug("start newFront frontInfo:{}", frontInfo); TbFront tbFront = new TbFront(); String frontIp = frontInfo.getFrontIp(); Integer frontPort = frontInfo.getFrontPort(); //check valid ip checkNotSupportIp(frontIp); //check front ip and port NodeMgrTools.checkServerConnect(frontIp, frontPort); //query group list List<String> groupIdList = null; try { groupIdList = frontInterface.getGroupListFromSpecificFront(frontIp, frontPort); } catch (Exception e) { log.error("fail newFront, frontIp:{},frontPort:{}",frontIp,frontPort); throw new NodeMgrException(ConstantCode.REQUEST_FRONT_FAIL); } // check front's encrypt type same as nodemgr(guomi or standard) int encryptType = frontInterface.getEncryptTypeFromSpecificFront(frontIp, frontPort); if (encryptType != EncryptType.encryptType) { log.error("fail newFront, frontIp:{},frontPort:{},front's encryptType:{}," + "local encryptType not match:{}", frontIp, frontPort, encryptType, EncryptType.encryptType); throw new NodeMgrException(ConstantCode.ENCRYPT_TYPE_NOT_MATCH); } //check front not exist SyncStatus syncStatus = frontInterface.getSyncStatusFromSpecificFront(frontIp, frontPort, Integer.valueOf(groupIdList.get(0))); FrontParam param = new FrontParam(); param.setNodeId(syncStatus.getNodeId()); int count = getFrontCount(param); if (count > 0) { throw new NodeMgrException(ConstantCode.FRONT_EXISTS); } String clientVersion = frontInterface.getClientVersion(frontIp, frontPort, Integer.valueOf(groupIdList.get(0))); //copy attribute BeanUtils.copyProperties(frontInfo, tbFront); tbFront.setNodeId(syncStatus.getNodeId()); tbFront.setClientVersion(clientVersion); //save front info frontMapper.add(tbFront); if (tbFront.getFrontId() == null || tbFront.getFrontId() == 0) { log.warn("fail newFront, after save, tbFront:{}", JsonTools.toJSONString(tbFront)); throw new NodeMgrException(ConstantCode.SAVE_FRONT_FAIL); } for (String groupId : groupIdList) { Integer group = Integer.valueOf(groupId); //peer in group List<String> groupPeerList = frontInterface .getGroupPeersFromSpecificFront(frontIp, frontPort, group); //get peers on chain PeerInfo[] peerArr = frontInterface .getPeersFromSpecificFront(frontIp, frontPort, group); List<PeerInfo> peerList = Arrays.asList(peerArr); //add group // check group not existed or node count differs TbGroup checkGroup = groupService.getGroupById(group); if (Objects.isNull(checkGroup) || groupPeerList.size() != checkGroup.getNodeCount()) { groupService.saveGroup(group, groupPeerList.size(), "synchronous", GroupType.SYNC.getValue(), DataStatus.NORMAL.getValue()); } //save front group map frontGroupMapService.newFrontGroup(tbFront, group); //save nodes for (String nodeId : groupPeerList) { PeerInfo newPeer = peerList.stream().map(p -> NodeMgrTools .object2JavaBean(p, PeerInfo.class)) .filter(peer -> nodeId.equals(peer.getNodeId())) .findFirst().orElseGet(() -> new PeerInfo(nodeId)); nodeService.addNodeInfo(group, newPeer); } //add sealer(consensus node) and observer in nodeList refreshSealerAndObserverInNodeList(frontIp, frontPort, group); } // pull cert from new front and its node CertTools.isPullFrontCertsDone = false; //clear cache frontGroupMapCache.clearMapList(); return tbFront; }
Example #25
Source File: EvidenceVerify.java From web3sdk with Apache License 2.0 | 4 votes |
public static String getBinary() { return (EncryptType.encryptType == EncryptType.ECDSA_TYPE ? BINARY : SM_BINARY); }
Example #26
Source File: ParallelOk.java From web3sdk with Apache License 2.0 | 4 votes |
public static final String getBinary() { return (EncryptType.encryptType == EncryptType.ECDSA_TYPE ? BINARY : BINARY_GM); }
Example #27
Source File: DagTransfer.java From web3sdk with Apache License 2.0 | 4 votes |
public static final String getBinary() { return (EncryptType.encryptType == EncryptType.ECDSA_TYPE ? BINARY : BINARY_GM); }
Example #28
Source File: EncryptTypeController.java From WeBASE-Node-Manager with Apache License 2.0 | 4 votes |
@GetMapping("") public Object getEncryptType() { int encrypt = EncryptType.encryptType; log.info("getEncryptType:{}", encrypt); return new BaseResponse(ConstantCode.SUCCESS, encrypt); }
Example #29
Source File: Web3Config.java From WeBASE-Transaction with Apache License 2.0 | 4 votes |
/** * set sdk's encrypt type: 0: standard, 1: guomi sdk switch ecdsa to sm2, sha to sm3. */ @Bean(name = "encryptType") public EncryptType EncryptType() { return new EncryptType(encryptType); }
Example #30
Source File: GenCredential.java From web3sdk with Apache License 2.0 | 4 votes |
public static ECKeyPair createKeyPair(String privKey) { if (EncryptType.encryptType == 1) return createGuomiKeyPair(privKey); return createECDSAKeyPair(privKey); }