use of com.jd.blockchain.transaction.TxRequestMessage in project jdchain-core by blockchain-jd-com.
the class LedgerTransactionDataTest method initTxRequestMessage.
private TxRequestMessage initTxRequestMessage(CryptoAlgorithm hashAlgorithm) throws Exception {
TransactionContent txContent = initTransactionContent();
HashDigest txHash = TxBuilder.computeTxContentHash(hashAlgorithm, txContent);
TxRequestMessage txRequestMessage = new TxRequestMessage(txHash, txContent);
AsymmetricKeypair keypair2 = ClassicCryptoService.ED25519.generateKeypair();
SignatureDigest digest1 = ClassicCryptoService.ED25519.sign(keypair.getPrivKey(), "zhangsan".getBytes());
SignatureDigest digest2 = ClassicCryptoService.ED25519.sign(keypair.getPrivKey(), "lisi".getBytes());
DigitalSignatureBlob endPoint1 = new DigitalSignatureBlob(keypair.getPubKey(), digest1);
DigitalSignatureBlob endPoint2 = new DigitalSignatureBlob(keypair2.getPubKey(), digest2);
txRequestMessage.addEndpointSignatures(endPoint1);
txRequestMessage.addEndpointSignatures(endPoint2);
AsymmetricKeypair keypair4 = ClassicCryptoService.ED25519.generateKeypair();
SignatureDigest digest3 = ClassicCryptoService.ED25519.sign(keypair.getPrivKey(), "wangwu".getBytes());
SignatureDigest digest4 = ClassicCryptoService.ED25519.sign(keypair4.getPrivKey(), "zhaoliu".getBytes());
DigitalSignatureBlob node1 = new DigitalSignatureBlob(keypair.getPubKey(), digest3);
DigitalSignatureBlob node2 = new DigitalSignatureBlob(keypair4.getPubKey(), digest4);
txRequestMessage.addNodeSignatures(node1);
txRequestMessage.addNodeSignatures(node2);
return txRequestMessage;
}
use of com.jd.blockchain.transaction.TxRequestMessage in project jdchain-core by blockchain-jd-com.
the class ManagementController method addNodeSigner.
private TransactionRequest addNodeSigner(TransactionRequest txRequest) {
TxRequestMessage txMessage = new TxRequestMessage(txRequest);
HashDigest ledgerHash = txRequest.getTransactionContent().getLedgerHash();
AsymmetricKeypair peerKeypair = ledgerKeypairs.get(ledgerHash);
DigitalSignature nodeSigner = SignatureUtils.sign(ledgerCryptoSettings.get(ledgerHash).getHashAlgorithm(), txRequest.getTransactionContent(), peerKeypair);
txMessage.addNodeSignatures(nodeSigner);
return txMessage;
}
use of com.jd.blockchain.transaction.TxRequestMessage in project jdchain-core by blockchain-jd-com.
the class ParticipantManagerService4Bft method prepareReconfigTx.
// 在指定的账本上准备一笔reconfig操作交易
private TransactionRequest prepareReconfigTx(String type) {
TransactionRequest reconfigTxRequest;
ParticipantContext context = ParticipantContext.context();
HashDigest ledgerHash = context.ledgerHash();
TxBuilder txbuilder = new TxBuilder(ledgerHash, (Short) context.getProperty(ParticipantContext.HASH_ALG_PROP));
// This transaction contains one reconfig op
txbuilder.consensus().reconfig(type);
TransactionRequestBuilder reqBuilder = txbuilder.prepareRequest();
reqBuilder.signAsEndpoint((AsymmetricKeypair) context.getProperty(ParticipantContext.ENDPOINT_SIGNER_PROP));
reconfigTxRequest = reqBuilder.buildRequest();
DigitalSignature nodeSigner = SignatureUtils.sign((Short) context.getProperty(ParticipantContext.HASH_ALG_PROP), reconfigTxRequest.getTransactionContent(), (AsymmetricKeypair) context.getProperty(ParticipantContext.ENDPOINT_SIGNER_PROP));
((TxRequestMessage) reconfigTxRequest).addNodeSignatures(nodeSigner);
return reconfigTxRequest;
}
Aggregations