Search in sources :

Example 1 with ECDSASignature

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

the class BFTEventVerifierTest method when_process_bad_timeout_signature_vote_then_should_not_be_forwarded.

@Test
public void when_process_bad_timeout_signature_vote_then_should_not_be_forwarded() {
    Vote vote = mock(Vote.class);
    when(vote.getView()).thenReturn(View.of(1));
    when(vote.getEpoch()).thenReturn(0L);
    BFTNode author = mock(BFTNode.class);
    when(vote.getAuthor()).thenReturn(author);
    ECDSASignature voteSignature = mock(ECDSASignature.class);
    ECDSASignature timeoutSignature = mock(ECDSASignature.class);
    when(vote.getSignature()).thenReturn(voteSignature);
    when(vote.getTimeoutSignature()).thenReturn(Optional.of(timeoutSignature));
    when(validatorSet.containsNode(eq(author))).thenReturn(true);
    when(verifier.verify(any(), any(), eq(voteSignature))).thenReturn(true);
    when(verifier.verify(any(), any(), eq(timeoutSignature))).thenReturn(false);
    eventVerifier.processVote(vote);
    verify(forwardTo, never()).processVote(any());
}
Also used : Vote(com.radixdlt.consensus.Vote) ECDSASignature(com.radixdlt.crypto.ECDSASignature) Test(org.junit.Test)

Example 2 with ECDSASignature

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

the class BFTEventVerifierTest method when_process_correct_vote_then_should_be_forwarded.

@Test
public void when_process_correct_vote_then_should_be_forwarded() {
    Vote vote = mock(Vote.class);
    when(vote.getView()).thenReturn(View.of(1));
    when(vote.getEpoch()).thenReturn(0L);
    BFTNode author = mock(BFTNode.class);
    when(vote.getAuthor()).thenReturn(author);
    ECDSASignature voteSignature = mock(ECDSASignature.class);
    ECDSASignature timeoutSignature = mock(ECDSASignature.class);
    when(vote.getSignature()).thenReturn(voteSignature);
    when(vote.getTimeoutSignature()).thenReturn(Optional.of(timeoutSignature));
    when(validatorSet.containsNode(eq(author))).thenReturn(true);
    when(verifier.verify(any(), any(), eq(voteSignature))).thenReturn(true);
    when(verifier.verify(any(), any(), eq(timeoutSignature))).thenReturn(true);
    eventVerifier.processVote(vote);
    verify(forwardTo, times(1)).processVote(eq(vote));
}
Also used : Vote(com.radixdlt.consensus.Vote) ECDSASignature(com.radixdlt.crypto.ECDSASignature) Test(org.junit.Test)

Example 3 with ECDSASignature

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

the class SafetyRules method signProposal.

/**
 * Create a signed proposal from a vertex
 *
 * @param proposedVertex vertex to sign
 * @param highestCommittedQC highest known committed QC
 * @param highestTC highest known TC
 * @return signed proposal object for consensus
 */
public Optional<Proposal> signProposal(VerifiedVertex proposedVertex, QuorumCertificate highestCommittedQC, Optional<TimeoutCertificate> highestTC) {
    final Builder safetyStateBuilder = this.state.toBuilder();
    if (!checkLocked(proposedVertex, safetyStateBuilder)) {
        return Optional.empty();
    }
    this.state = safetyStateBuilder.build();
    final ECDSASignature signature = this.signer.sign(proposedVertex.getId());
    return Optional.of(new Proposal(proposedVertex.toSerializable(), highestCommittedQC, signature, highestTC));
}
Also used : Builder(com.radixdlt.consensus.safety.SafetyState.Builder) ECDSASignature(com.radixdlt.crypto.ECDSASignature) Proposal(com.radixdlt.consensus.Proposal)

Example 4 with ECDSASignature

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

the class BFTEventVerifierTest method when_process_correct_vote_then_should_be_forwarded.

@Test
public void when_process_correct_vote_then_should_be_forwarded() {
    Vote vote = mock(Vote.class);
    when(vote.getView()).thenReturn(View.of(1));
    when(vote.getEpoch()).thenReturn(0L);
    BFTNode author = mock(BFTNode.class);
    when(vote.getAuthor()).thenReturn(author);
    ECDSASignature voteSignature = mock(ECDSASignature.class);
    ECDSASignature timeoutSignature = mock(ECDSASignature.class);
    when(vote.getSignature()).thenReturn(voteSignature);
    when(vote.getTimeoutSignature()).thenReturn(Optional.of(timeoutSignature));
    when(validatorSet.containsNode(eq(author))).thenReturn(true);
    when(verifier.verify(any(), any(), eq(voteSignature))).thenReturn(true);
    when(verifier.verify(any(), any(), eq(timeoutSignature))).thenReturn(true);
    when(safetyRules.verifyHighQcAgainstTheValidatorSet(any())).thenReturn(true);
    eventVerifier.processVote(vote);
    verify(forwardTo, times(1)).processVote(eq(vote));
}
Also used : Vote(com.radixdlt.hotstuff.Vote) ECDSASignature(com.radixdlt.crypto.ECDSASignature) Test(org.junit.Test)

Example 5 with ECDSASignature

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

the class BFTEventVerifierTest method when_process_bad_timeout_signature_vote_then_should_not_be_forwarded.

@Test
public void when_process_bad_timeout_signature_vote_then_should_not_be_forwarded() {
    Vote vote = mock(Vote.class);
    when(vote.getView()).thenReturn(View.of(1));
    when(vote.getEpoch()).thenReturn(0L);
    BFTNode author = mock(BFTNode.class);
    when(vote.getAuthor()).thenReturn(author);
    ECDSASignature voteSignature = mock(ECDSASignature.class);
    ECDSASignature timeoutSignature = mock(ECDSASignature.class);
    when(vote.getSignature()).thenReturn(voteSignature);
    when(vote.getTimeoutSignature()).thenReturn(Optional.of(timeoutSignature));
    when(validatorSet.containsNode(eq(author))).thenReturn(true);
    when(verifier.verify(any(), any(), eq(voteSignature))).thenReturn(true);
    when(verifier.verify(any(), any(), eq(timeoutSignature))).thenReturn(false);
    eventVerifier.processVote(vote);
    verify(forwardTo, never()).processVote(any());
}
Also used : Vote(com.radixdlt.hotstuff.Vote) ECDSASignature(com.radixdlt.crypto.ECDSASignature) Test(org.junit.Test)

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