Skip to content

Write Recursive trait and structures #51

@LindaGuiga

Description

@LindaGuiga

Create a Recursive trait and implement the trait for ProofWires. The Recursive trait is as follows:

pub trait Recursive<F: Field, const D: usize> {
    /// The nonrecursive type associated with the recursive type implementing the trait.
    type Input: Clone;

    /// Creates a new instance of the recursive type. `lens` corresponds to all the vector lengths necessary to build the structure. TODO: They can actually be deduced from StarkGenericConfig and `degree_bits`.
    fn new(
        circuit: &mut CircuitBuilder<F, D>,
        lens: &mut impl Iterator<Item = usize>,
        degree_bits: usize,
    ) -> Self;

    /// Returns a vec of field elements representing the elements of the Input. Used (at least for now) to generate challenges.
    fn get_values(input: Self::Input) -> Vec<F>;

    /// Given an `Input` instance, sets the wires in the current instance to the values in `input`.
    fn set_wires(
        &self,
        circuit: &mut CircuitBuilder<F, D>,
        input: Self::Input,
    ) -> Result<(), CircuitError>;

    /// Returns the number of challenges necessary
    fn num_challenges(&self) -> usize;

    /// Creates new wires for all the necessary challenges.
    fn get_challenges(&self, circuit: &mut CircuitBuilder<F, D>) -> Vec<ExtensionWireId<D>> {
        let num_challenges = self.num_challenges();

        let mut challenges = Vec::with_capacity(num_challenges);
        for _ in 0..num_challenges {
            challenges.push(circuit.new_extension_wires());
        }

        challenges
    }

    // Temporary method used for testing for now. This should be changed into something more generic which relies as little as possible on the actual proof.
    fn lens(input: &Self::Input) -> impl Iterator<Item = usize>;
}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions