Search in sources :

Example 11 with ECDSASignature

use of com.radixdlt.crypto.ECDSASignature in project radixdlt by radixdlt.

the class SafetyRules method timeoutVote.

public Vote timeoutVote(Vote vote) {
    if (vote.isTimeout()) {
        // vote is already timed out
        return vote;
    }
    final VoteTimeout voteTimeout = VoteTimeout.of(vote);
    final HashCode voteTimeoutHash = hasher.hash(voteTimeout);
    final ECDSASignature timeoutSignature = this.signer.sign(voteTimeoutHash);
    final Vote timeoutVote = vote.withTimeoutSignature(timeoutSignature);
    this.state = this.state.toBuilder().lastVote(timeoutVote).build();
    this.persistentSafetyStateStore.commitState(this.state);
    return timeoutVote;
}
Also used : Vote(com.radixdlt.hotstuff.Vote) HashCode(com.google.common.hash.HashCode) ECDSASignature(com.radixdlt.crypto.ECDSASignature) VoteTimeout(com.radixdlt.hotstuff.liveness.VoteTimeout)

Example 12 with ECDSASignature

use of com.radixdlt.crypto.ECDSASignature in project radixdlt by radixdlt.

the class DifferentTimestampsCauseTimeoutTest method mutateProposal.

private Proposal mutateProposal(Proposal p, int destination) {
    QuorumCertificate committedQC = p.highQC().highestCommittedQC();
    UnverifiedVertex vertex = p.getVertex();
    ECDSASignature signature = p.getSignature();
    return new Proposal(mutateVertex(vertex, destination), committedQC, signature, Optional.empty());
}
Also used : QuorumCertificate(com.radixdlt.hotstuff.QuorumCertificate) ECDSASignature(com.radixdlt.crypto.ECDSASignature) TimestampedECDSASignature(com.radixdlt.hotstuff.TimestampedECDSASignature) UnverifiedVertex(com.radixdlt.hotstuff.UnverifiedVertex) Proposal(com.radixdlt.hotstuff.Proposal)

Example 13 with ECDSASignature

use of com.radixdlt.crypto.ECDSASignature in project radixdlt by radixdlt.

the class DifferentTimestampsCauseTimeoutTest method mutateTimestampedSignature.

private TimestampedECDSASignature mutateTimestampedSignature(TimestampedECDSASignature signature, int destination) {
    long timestamp = signature.timestamp();
    ECDSASignature sig = signature.signature();
    return TimestampedECDSASignature.from(timestamp + destination, sig);
}
Also used : ECDSASignature(com.radixdlt.crypto.ECDSASignature) TimestampedECDSASignature(com.radixdlt.hotstuff.TimestampedECDSASignature)

Example 14 with ECDSASignature

use of com.radixdlt.crypto.ECDSASignature in project radixdlt by radixdlt.

the class PendingVotes method processVoteForTC.

private Optional<TimeoutCertificate> processVoteForTC(Vote vote, BFTValidatorSet validatorSet) {
    if (!vote.isTimeout()) {
        // TC can't be formed if vote is not timed out
        return Optional.empty();
    }
    final ECDSASignature timeoutSignature = vote.getTimeoutSignature().orElseThrow();
    final VoteTimeout voteTimeout = VoteTimeout.of(vote);
    final HashCode voteTimeoutHash = this.hasher.hash(voteTimeout);
    final BFTNode node = vote.getAuthor();
    final ValidationState validationState = this.timeoutVoteState.computeIfAbsent(voteTimeoutHash, k -> validatorSet.newValidationState());
    final boolean signatureAdded = validationState.addSignature(node, vote.getTimestamp(), timeoutSignature);
    if (signatureAdded && validationState.complete()) {
        return Optional.of(new TimeoutCertificate(voteTimeout.getEpoch(), voteTimeout.getView(), validationState.signatures()));
    } else {
        return Optional.empty();
    }
}
Also used : BFTNode(com.radixdlt.hotstuff.bft.BFTNode) ValidationState(com.radixdlt.hotstuff.bft.ValidationState) HashCode(com.google.common.hash.HashCode) ECDSASignature(com.radixdlt.crypto.ECDSASignature) VoteTimeout(com.radixdlt.hotstuff.liveness.VoteTimeout)

Example 15 with ECDSASignature

use of com.radixdlt.crypto.ECDSASignature in project radixdlt by radixdlt.

the class SafetyRules method createVote.

public Vote createVote(VerifiedVertex proposedVertex, BFTHeader proposedHeader, long timestamp, HighQC highQC) {
    final VoteData voteData = constructVoteData(proposedVertex, proposedHeader);
    final var voteHash = Vote.getHashOfData(hasher, voteData, timestamp);
    // TODO make signing more robust by including author in signed hash
    final ECDSASignature signature = this.signer.sign(voteHash);
    return new Vote(this.self, voteData, timestamp, signature, highQC, Optional.empty());
}
Also used : Vote(com.radixdlt.consensus.Vote) ECDSASignature(com.radixdlt.crypto.ECDSASignature) VoteData(com.radixdlt.consensus.VoteData)

Aggregations

ECDSASignature (com.radixdlt.crypto.ECDSASignature)17 HashCode (com.google.common.hash.HashCode)4 Vote (com.radixdlt.consensus.Vote)4 Vote (com.radixdlt.hotstuff.Vote)4 Test (org.junit.Test)4 VoteTimeout (com.radixdlt.consensus.liveness.VoteTimeout)2 Proposal (com.radixdlt.hotstuff.Proposal)2 TimestampedECDSASignature (com.radixdlt.hotstuff.TimestampedECDSASignature)2 VoteTimeout (com.radixdlt.hotstuff.liveness.VoteTimeout)2 Proposal (com.radixdlt.consensus.Proposal)1 VoteData (com.radixdlt.consensus.VoteData)1 BFTNode (com.radixdlt.consensus.bft.BFTNode)1 ValidationState (com.radixdlt.consensus.bft.ValidationState)1 Builder (com.radixdlt.consensus.safety.SafetyState.Builder)1 ECKeyPair (com.radixdlt.crypto.ECKeyPair)1 ECPublicKey (com.radixdlt.crypto.ECPublicKey)1 TxnParseException (com.radixdlt.engine.parser.exceptions.TxnParseException)1 QuorumCertificate (com.radixdlt.hotstuff.QuorumCertificate)1 UnverifiedVertex (com.radixdlt.hotstuff.UnverifiedVertex)1 VoteData (com.radixdlt.hotstuff.VoteData)1