Skip to content

Commit

Permalink
add back commitment to the proof to pass tests
Browse files Browse the repository at this point in the history
  • Loading branch information
thomaslavaur committed Aug 30, 2024
1 parent f6fff11 commit 0ed2cd8
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions cryptarchia/cryptarchia.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ def nullifier(self) -> Id:

@dataclass
class LeaderProof:
# TODO: remove the useless commitment field
commitment: Id
nullifier: Id
evolved_commitment: Id
slot: Slot
Expand Down Expand Up @@ -204,6 +206,7 @@ def new(#Public inputs
evolved_coin = coin.evolve()

return LeaderProof( # TODO: generate the proof with risc0
commitment=coin.commitment(),
nullifier=coin_nullifier,
evolved_commitment=evolved_coin.commitment(),
slot=slot,
Expand Down Expand Up @@ -247,6 +250,8 @@ def update_header_hash(self, h):
h.update(self.parent)

# leader proof
assert len(self.leader_proof.commitment) == 32
h.update(self.leader_proof.commitment)
assert len(self.leader_proof.nullifier) == 32
h.update(self.leader_proof.nullifier)
assert len(self.leader_proof.evolved_commitment) == 32
Expand Down Expand Up @@ -473,11 +478,11 @@ def verify_slot_leader(
threshold_0, threshold_1 = lottery_threshold(self.config.active_slot_coeff, epoch_state.total_active_stake())
return (
proof.verify(slot, current_state.nonce, threshold_0, threshold_1, current_state.commitments_lead, parent) # verify slot leader proof
# Membership verification is included in the proof verification along with the PoS lottery:
#and (
# current_state.verify_eligible_to_lead(proof.commitment)
# or epoch_state.verify_eligible_to_lead_due_to_age(proof.commitment)
#)
# TODO: remove it because membership verification is included in the proof verification along with the PoS lottery:
and (
current_state.verify_eligible_to_lead(proof.commitment)
or epoch_state.verify_eligible_to_lead_due_to_age(proof.commitment)
)
and current_state.verify_unspent(proof.nullifier)
)

Expand Down

0 comments on commit 0ed2cd8

Please sign in to comment.