Search in sources :

Example 1 with DigitalSignatureBlob

use of com.jd.blockchain.transaction.DigitalSignatureBlob 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 DigitalSignatureBlob

use of com.jd.blockchain.transaction.DigitalSignatureBlob in project jdchain-core by blockchain-jd-com.

the class LedgerInitializeWebController method getNodesSignatures.

private DigitalSignature[] getNodesSignatures() {
    ParticipantNode[] parties = this.ledgerInitConfig.getParticipants();
    List<DigitalSignature> signatures = new ArrayList<>();
    for (int i = 0; i < parties.length; i++) {
        if (parties[i].getParticipantNodeState() != ParticipantNodeState.CONSENSUS) {
            continue;
        }
        PubKey pubKey = parties[i].getPubKey();
        SignatureDigest signDigest = this.permissions[i].getTransactionSignature();
        signatures.add(new DigitalSignatureBlob(pubKey, signDigest));
    }
    return signatures.toArray(new DigitalSignature[signatures.size()]);
}
Also used : PubKey(com.jd.blockchain.crypto.PubKey) ParticipantNode(com.jd.blockchain.ledger.ParticipantNode) SignatureDigest(com.jd.blockchain.crypto.SignatureDigest) DigitalSignatureBlob(com.jd.blockchain.transaction.DigitalSignatureBlob) ArrayList(java.util.ArrayList) DigitalSignature(com.jd.blockchain.ledger.DigitalSignature)

Aggregations

SignatureDigest (com.jd.blockchain.crypto.SignatureDigest)2 DigitalSignatureBlob (com.jd.blockchain.transaction.DigitalSignatureBlob)2 AsymmetricKeypair (com.jd.blockchain.crypto.AsymmetricKeypair)1 HashDigest (com.jd.blockchain.crypto.HashDigest)1 PubKey (com.jd.blockchain.crypto.PubKey)1 DigitalSignature (com.jd.blockchain.ledger.DigitalSignature)1 ParticipantNode (com.jd.blockchain.ledger.ParticipantNode)1 TransactionContent (com.jd.blockchain.ledger.TransactionContent)1 TxRequestMessage (com.jd.blockchain.transaction.TxRequestMessage)1 ArrayList (java.util.ArrayList)1