The Builder
Step-by-step assembly of complex STARK proof configurations.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Builder
ARCANUM SCHOOL: Transmutation // Structurization
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// CAIRO PATTERN //
#[derive(Copy, Drop)]
struct ProofConfig { security_level: u32, hash_fn: felt252 }
#[derive(Copy, Drop)]
struct ProofBuilder { security_level: u32, hash_fn: felt252 }
trait IBuilder {
fn new() -> ProofBuilder;
fn set_security(ref self: ProofBuilder, level: u32);
fn set_hash(ref self: ProofBuilder, hash: felt252);
fn build(self: @ProofBuilder) -> ProofConfig;
}
impl BuilderImpl of IBuilder {
fn new() -> ProofBuilder { ProofBuilder { security_level: 0, hash_fn: 0 } }
fn set_security(ref self: ProofBuilder, level: u32) { self.security_level = level; }
fn set_hash(ref self: ProofBuilder, hash: felt252) { self.hash_fn = hash; }
fn build(self: @ProofBuilder) -> ProofConfig { ProofConfig { security_level: *self.security_level, hash_fn: *self.hash_fn } }
}
Construct intricate STARK configurations piece by piece, shielding the final proof generation from incomplete states.
Runic Tags:
#cairo
#design-pattern
#builder