The Strategy
Swapping out polynomial commitment schemes on the fly.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Strategy
ARCANUM SCHOOL: Illusion // Adaptability
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// CAIRO PATTERN //
trait ICommitmentStrategy<T> { fn commit(self: @T, data: felt252) -> felt252; }
#[derive(Copy, Drop)]
struct Blake2sStrategy {}
impl BlakeImpl of ICommitmentStrategy<Blake2sStrategy> {
fn commit(self: @Blake2sStrategy, data: felt252) -> felt252 { data + 2 }
}
#[derive(Copy, Drop)]
struct KeccakStrategy {}
impl KeccakImpl of ICommitmentStrategy<KeccakStrategy> {
fn commit(self: @KeccakStrategy, data: felt252) -> felt252 { data + 3 }
}
Empowers the wizard to dynamically select the most potent commitment scheme for the given STARK invocation.
Runic Tags:
#cairo
#design-pattern
#strategy