Search in sources :

Example 1 with TxRequestMessage

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;
}
Also used : AsymmetricKeypair(com.jd.blockchain.crypto.AsymmetricKeypair) HashDigest(com.jd.blockchain.crypto.HashDigest) SignatureDigest(com.jd.blockchain.crypto.SignatureDigest) DigitalSignatureBlob(com.jd.blockchain.transaction.DigitalSignatureBlob) TxRequestMessage(com.jd.blockchain.transaction.TxRequestMessage) TransactionContent(com.jd.blockchain.ledger.TransactionContent)

Example 2 with 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;
}
Also used : TxRequestMessage(com.jd.blockchain.transaction.TxRequestMessage)

Example 3 with TxRequestMessage

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;
}
Also used : HashDigest(com.jd.blockchain.crypto.HashDigest) TxRequestMessage(com.jd.blockchain.transaction.TxRequestMessage) TxBuilder(com.jd.blockchain.transaction.TxBuilder)

Aggregations

TxRequestMessage (com.jd.blockchain.transaction.TxRequestMessage)3 HashDigest (com.jd.blockchain.crypto.HashDigest)2 AsymmetricKeypair (com.jd.blockchain.crypto.AsymmetricKeypair)1 SignatureDigest (com.jd.blockchain.crypto.SignatureDigest)1 TransactionContent (com.jd.blockchain.ledger.TransactionContent)1 DigitalSignatureBlob (com.jd.blockchain.transaction.DigitalSignatureBlob)1 TxBuilder (com.jd.blockchain.transaction.TxBuilder)1