Skip to content

SDK: Bytecode analysis and preprocessing builder integration #8

@Mikerah

Description

@Mikerah

Overview

Add program-aware bytecode analysis to the Rust SDK for automatic preprocessing configuration.

Tasks

Step 1: Bytecode Analysis in Program

  • Add preprocessing_requirements(threshold: usize) -> (usize, usize) method to Program struct
  • Add count_multiplications() to parse bytecode and count MUL instructions
  • Add count_random_share_consumers() for other preprocessing-consuming ops
  • Detect loops and emit warning
  • Cache analysis results in Program struct

Step 2: Server Builder Integration

  • Modify with_program() to trigger automatic analysis
  • Store calculated preprocessing values in builder
  • Add with_preprocessing_preset(PreprocessingPreset) method
  • Modify with_preprocessing() to override calculated values
  • Add PreprocessingPreset enum (Minimal, Standard, Production)

Step 3: Validation & Error Handling

  • In build(): Error if no program AND no explicit preprocessing
  • Log calculated values at INFO level
  • Warn if user override < calculated requirements

Files to Modify

  • src/program.rs (bytecode analysis methods)
  • src/mpcaas/server.rs (builder integration)
  • src/lib.rs (re-exports)
  • src/prelude.rs (PreprocessingPreset export)
  • examples/honeybadger_mpc_demo.rs (remove explicit preprocessing)
  • examples/README.md (document automatic behavior)

Testing

  • Unit tests for count_multiplications() with various bytecode
  • Unit tests for preprocessing_requirements() calculation
  • Integration test: server builds with only .with_program()

Reference

  • RFC-0001
  • Algorithm: n_triples = mul_count + 2, n_random_shares = 2 + 2 * n_triples

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions