Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
ArithmeticFuzzHelper< T > Class Template Reference

A templated class containing most of the fuzzing logic for a generic Arithmetic class. More...

#include <fuzzer.hpp>

Static Public Member Functions

static std::vector< typename T::Instruction > crossoverInstructionVector (const std::vector< typename T::Instruction > &vecA, const std::vector< typename T::Instruction > &vecB, FastRandom &rng)
 Splice two instruction vectors into one randomly.
 
static std::vector< typename T::Instruction > parseDataIntoInstructions (const uint8_t *Data, size_t Size)
 Parses a given data buffer into a vector of instructions for testing the arithmetic.
 
static size_t writeInstructionsToBuffer (std::vector< typename T::Instruction > &instructions, uint8_t *Data, size_t MaxSize)
 Write instructions into the buffer until there are no instructions left or there is no more space.
 
template<typename Composer >
requires CheckableComposer<Composer>
static void executeInstructions (std::vector< typename T::Instruction > &instructions)
 Execute instructions in a loop.
 
static size_t MutateInstructionBuffer (uint8_t *Data, size_t Size, size_t MaxSize, FastRandom &rng)
 Interpret the data buffer as a series of arithmetic instructions and mutate it accordingly.
 

Static Private Member Functions

static void swapTwoInstructions (std::vector< typename T::Instruction > &instructions, FastRandom &rng)
 Mutator swapping two instructions together.
 
static void deleteInstructions (std::vector< typename T::Instruction > &instructions, FastRandom &rng, HavocSettings &havoc_settings)
 Mutator, deleting a sequence of instructions.
 
static void duplicateInstruction (std::vector< typename T::Instruction > &instructions, FastRandom &rng, HavocSettings &havoc_settings)
 Mutator duplicating an instruction.
 
static void insertRandomInstruction (std::vector< typename T::Instruction > &instructions, FastRandom &rng, HavocSettings &havoc_settings)
 
static void mutateInstructionStructure (std::vector< typename T::Instruction > &instructions, FastRandom &rng, HavocSettings &havoc_settings)
 Mutator for instruction structure.
 
static void mutateInstructionValue (std::vector< typename T::Instruction > &instructions, FastRandom &rng, HavocSettings &havoc_settings)
 Choose a random instruction from the vector and mutate it.
 
static void mutateInstructionVector (std::vector< typename T::Instruction > &instructions, FastRandom &rng)
 

Detailed Description

template<typename T>
requires ArithmeticFuzzHelperConstraint<T>
class ArithmeticFuzzHelper< T >

A templated class containing most of the fuzzing logic for a generic Arithmetic class.

Template Parameters
T

Definition at line 321 of file fuzzer.hpp.

Member Function Documentation

◆ crossoverInstructionVector()

template<typename T >
static std::vector< typename T::Instruction > ArithmeticFuzzHelper< T >::crossoverInstructionVector ( const std::vector< typename T::Instruction > &  vecA,
const std::vector< typename T::Instruction > &  vecB,
FastRandom rng 
)
inlinestatic

Splice two instruction vectors into one randomly.

Parameters
vecAFirst instruction vector
vecBSecond instruction vector
rngPRNG
Returns
Resulting vector of instructions

Definition at line 486 of file fuzzer.hpp.

◆ deleteInstructions()

template<typename T >
static void ArithmeticFuzzHelper< T >::deleteInstructions ( std::vector< typename T::Instruction > &  instructions,
FastRandom rng,
HavocSettings havoc_settings 
)
inlinestaticprivate

Mutator, deleting a sequence of instructions.

Parameters
instructions
rng
havoc_settings

Definition at line 351 of file fuzzer.hpp.

◆ duplicateInstruction()

template<typename T >
static void ArithmeticFuzzHelper< T >::duplicateInstruction ( std::vector< typename T::Instruction > &  instructions,
FastRandom rng,
HavocSettings havoc_settings 
)
inlinestaticprivate

Mutator duplicating an instruction.

Parameters
instructions
rng
havoc_settings

Definition at line 384 of file fuzzer.hpp.

◆ executeInstructions()

template<typename T >
template<typename Composer >
requires CheckableComposer<Composer>
static void ArithmeticFuzzHelper< T >::executeInstructions ( std::vector< typename T::Instruction > &  instructions)
inlinestatic

Execute instructions in a loop.

Template Parameters
Composercomposer used
Parameters
instructions

Definition at line 628 of file fuzzer.hpp.

◆ insertRandomInstruction()

template<typename T >
static void ArithmeticFuzzHelper< T >::insertRandomInstruction ( std::vector< typename T::Instruction > &  instructions,
FastRandom rng,
HavocSettings havoc_settings 
)
inlinestaticprivate

Definition at line 397 of file fuzzer.hpp.

◆ MutateInstructionBuffer()

template<typename T >
static size_t ArithmeticFuzzHelper< T >::MutateInstructionBuffer ( uint8_t *  Data,
size_t  Size,
size_t  MaxSize,
FastRandom rng 
)
inlinestatic

Interpret the data buffer as a series of arithmetic instructions and mutate it accordingly.

Parameters
DataPointer to the buffer
SizeThe initial filled size
MaxSizeThe size of the buffer
Returns
size_t The new length of data in the buffer

Definition at line 705 of file fuzzer.hpp.

◆ mutateInstructionStructure()

template<typename T >
static void ArithmeticFuzzHelper< T >::mutateInstructionStructure ( std::vector< typename T::Instruction > &  instructions,
FastRandom rng,
HavocSettings havoc_settings 
)
inlinestaticprivate

Mutator for instruction structure.

Parameters
instructions
rng
havoc_settings

Definition at line 412 of file fuzzer.hpp.

◆ mutateInstructionValue()

template<typename T >
static void ArithmeticFuzzHelper< T >::mutateInstructionValue ( std::vector< typename T::Instruction > &  instructions,
FastRandom rng,
HavocSettings havoc_settings 
)
inlinestaticprivate

Choose a random instruction from the vector and mutate it.

Parameters
instructionsVector of instructions
rngPseudorandom number generator
havoc_settingsMutation settings

Definition at line 438 of file fuzzer.hpp.

◆ mutateInstructionVector()

template<typename T >
static void ArithmeticFuzzHelper< T >::mutateInstructionVector ( std::vector< typename T::Instruction > &  instructions,
FastRandom rng 
)
inlinestaticprivate

Definition at line 452 of file fuzzer.hpp.

◆ parseDataIntoInstructions()

template<typename T >
static std::vector< typename T::Instruction > ArithmeticFuzzHelper< T >::parseDataIntoInstructions ( const uint8_t *  Data,
size_t  Size 
)
inlinestatic

Parses a given data buffer into a vector of instructions for testing the arithmetic.

Parameters
DataPointer to the data buffer
SizeData buffer size
Returns
A vector of instructions

Definition at line 548 of file fuzzer.hpp.

◆ swapTwoInstructions()

template<typename T >
static void ArithmeticFuzzHelper< T >::swapTwoInstructions ( std::vector< typename T::Instruction > &  instructions,
FastRandom rng 
)
inlinestaticprivate

Mutator swapping two instructions together.

Parameters
instructions
rng

Definition at line 329 of file fuzzer.hpp.

◆ writeInstructionsToBuffer()

template<typename T >
static size_t ArithmeticFuzzHelper< T >::writeInstructionsToBuffer ( std::vector< typename T::Instruction > &  instructions,
uint8_t *  Data,
size_t  MaxSize 
)
inlinestatic

Write instructions into the buffer until there are no instructions left or there is no more space.

Parameters
instructionsVector of fuzzing instructions
DataPointer to data buffer
MaxSizeSize of buffer
Returns
How much of the buffer was filled with instructions

Definition at line 589 of file fuzzer.hpp.


The documentation for this class was generated from the following file: