Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ DRP is a revolutionary blockchain protocol that combines AI-verified consensus,
├─────────────────────────────────────────────────────────────┤
│ Verification Layer │ PoST │ PoAT │ IoT Sensors │ Privacy │
├─────────────────────────────────────────────────────────────┤
│ Consensus Layer │ BLS Threshold │ MPC │ Post-Quantum │
│ Consensus Layer │ Ed25519 Quorum │ Certificate Checks │
├─────────────────────────────────────────────────────────────┤
│ Networking Layer │ QUIC │ DNSSEC │ TLS │ P2P Discovery │
├─────────────────────────────────────────────────────────────┤
Expand All @@ -41,7 +41,7 @@ DRP is a revolutionary blockchain protocol that combines AI-verified consensus,

### 🔐 Zero-Trust Security
- **Post-Quantum Cryptography**: CRYSTALS-Kyber & Dilithium
- **Multi-Party Computation**: Threshold signatures without key exposure
- **Consensus prototype**: Individually verified Ed25519 votes and quorum certificates; not BLS aggregation or MPC
- **Privacy-Preserving**: Local processing with hashed summaries
- **Incident Response**: Automated threat detection and response

Expand All @@ -66,7 +66,7 @@ DRP/
│ ├── core/ # Core blockchain modules
│ │ ├── ai/ # AI verification & transparency
│ │ ├── blockchain/ # Blockchain implementation
│ │ ├── consensus/ # BLS threshold signatures, MPC
│ │ ├── consensus/ # Ed25519 quorum prototype (not BLS/MPC)
│ │ ├── crypto/ # Cryptographic functions
│ │ ├── networking/ # QUIC, P2P, discovery
│ │ ├── storage/ # ScyllaDB, OrbitDB integration
Expand Down
16 changes: 16 additions & 0 deletions docs/consensus.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# 🔗 DRP Consensus Design Documentation

## Implementation status (repository code)

The design below describes intended DRP consensus goals, not guarantees provided by
the current executable implementation. The current `src/core/protocol/consensus/bls_threshold.py`
module is a development quorum prototype using individual Ed25519 signatures.
Despite its historical name, it does **not** implement BLS aggregation, distributed
key generation, leader election, view changes, or production-grade BFT.

The prototype verifies signed proposals and positive votes, prevents a validator
from voting twice in the same round, and produces a certificate containing
individually verifiable signatures. Its default keys are generated in-process for
local simulation; production deployment requires independently provisioned keys,
persistent validator identity, authenticated peer transport, durable round state,
and adversarial/network-partition testing. Do not use this prototype to secure
real assets or claim production finality.

## 1. Overview
The **Decentralized Rights Protocol (DRP)** introduces a new consensus mechanism that fuses:
- **Proof of Status (PoST):** Validates *who* you are (identity, credentials, rights).
Expand Down
55 changes: 55 additions & 0 deletions infrastructure/testing/tests/test_consensus_quorum.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
from src.core.protocol.consensus.bls_threshold import BLSConsensus


def test_quorum_requires_unique_valid_positive_votes():
consensus = BLSConsensus(total_elders=4, threshold=3)
proposal = consensus.propose_block("elder_0", {"height": 1, "txs": ["a"]})
assert proposal is not None

# Negative votes are authenticated, but cannot contribute to a commit quorum.
assert consensus.vote_on_proposal("elder_0", proposal.block_hash, False) is not None
assert consensus.vote_on_proposal("elder_1", proposal.block_hash, True) is not None
assert consensus.vote_on_proposal("elder_2", proposal.block_hash, True) is not None
assert consensus.collect_threshold_signature(proposal.block_hash) is None

assert consensus.vote_on_proposal("elder_3", proposal.block_hash, True) is not None
certificate = consensus.collect_threshold_signature(proposal.block_hash)
assert certificate is not None
assert certificate.threshold_met is True
assert certificate.participants == ["elder_1", "elder_2", "elder_3"]
assert consensus.verify_threshold_signature(proposal.block_hash, certificate)
assert consensus.get_consensus_status()["bls_aggregation"] is False

certificate.verification_proof = b"{}"
assert not consensus.verify_threshold_signature(proposal.block_hash, certificate)


def test_duplicate_or_conflicting_round_vote_is_rejected():
consensus = BLSConsensus(total_elders=2, threshold=2)
proposal = consensus.propose_block("elder_0", {"height": 1})
assert proposal is not None
assert consensus.vote_on_proposal("elder_1", proposal.block_hash, True) is not None
assert consensus.vote_on_proposal("elder_1", proposal.block_hash, True) is None
assert consensus.vote_on_proposal("elder_1", proposal.block_hash, False) is None


def test_tampered_signature_does_not_count():
consensus = BLSConsensus(total_elders=2, threshold=2)
proposal = consensus.propose_block("elder_0", {"height": 1})
assert proposal is not None
vote = consensus.vote_on_proposal("elder_1", proposal.block_hash, True)
assert vote is not None
vote.signature = b"invalid"
assert consensus.collect_threshold_signature(proposal.block_hash) is None


def test_unknown_proposal_and_invalid_threshold_are_rejected():
consensus = BLSConsensus(total_elders=2, threshold=2)
assert consensus.collect_threshold_signature("unknown") is None
for invalid_threshold in (0, 1, 3):
try:
BLSConsensus(total_elders=2, threshold=invalid_threshold)
except ValueError:
pass
else:
raise AssertionError("non-supermajority or oversized threshold must fail")
Loading
Loading