⚙️ CAIRO RUNE DIFFICULTY: Adept Behavioral

The State

Transitioning between different phases of the FRI protocol.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: State
ARCANUM SCHOOL: Transmutation // Metamorphosis
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// CAIRO PATTERN //
#[derive(Drop)]
enum FriState {
    Commit,
    Query,
    Done,
}

#[derive(Drop)]
struct FriProtocol { state: FriState }

trait IFri { fn next_step(ref self: FriProtocol); }

impl FriImpl of IFri {
    fn next_step(ref self: FriProtocol) {
        self.state = match self.state {
            FriState::Commit => FriState::Query,
            FriState::Query => FriState::Done,
            FriState::Done => FriState::Done,
        };
    }
}

The prover’s behavior morphs completely as it transitions from commitment to query phases.

Runic Tags: #cairo #design-pattern #state