Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
cycle_group.fuzzer.hpp File Reference

Differential fuzzer for cycle_group elliptic curve operations. More...

Go to the source code of this file.

Classes

class  CycleGroupBase< Builder >
 The class parametrizing CycleGroup fuzzing instructions, execution, etc. More...
 
class  CycleGroupBase< Builder >::Instruction
 
struct  CycleGroupBase< Builder >::Instruction::Element
 
struct  CycleGroupBase< Builder >::Instruction::TwoArgs
 
struct  CycleGroupBase< Builder >::Instruction::MulArgs
 
struct  CycleGroupBase< Builder >::Instruction::ThreeArgs
 
struct  CycleGroupBase< Builder >::Instruction::FourArgs
 
struct  CycleGroupBase< Builder >::Instruction::BatchMulArgs
 
struct  CycleGroupBase< Builder >::Instruction::ArgumentContents
 
class  CycleGroupBase< Builder >::ArgSizes
 
class  CycleGroupBase< Builder >::InstructionWeights
 Optional subclass that governs limits on the use of certain instructions, since some of them can be too slow. More...
 
class  CycleGroupBase< Builder >::Parser
 Parser class handles the parsing and writing the instructions back to data buffer. More...
 
class  CycleGroupBase< Builder >::ExecutionHandler
 This class implements the execution of cycle group with an oracle to detect discrepancies. More...
 

Macros

#define HAVOC_TESTING
 
#define PUT_RANDOM_BYTE_IF_LUCKY(variable)
 

Enumerations

enum class  SpecialScalarValue : uint8_t {
  One = 0 , MinusOne , SquareRootOfOne , InverseSquareRootOfOne ,
  RootOfUnity13 , Two , HalfModulus , Zero ,
  COUNT , One = 0 , MinusOne , SquareRootOfOne ,
  InverseSquareRootOfOne , RootOfUnity13 , Two , HalfModulus ,
  Zero , COUNT
}
 Special scalar field values used for mutation testing. More...
 

Functions

size_t LLVMFuzzerMutate (uint8_t *Data, size_t Size, size_t MaxSize)
 
template<typename FF >
FF get_special_scalar_value (SpecialScalarValue type)
 Generate a special scalar field value for testing.
 
int LLVMFuzzerInitialize (int *argc, char ***argv)
 
size_t LLVMFuzzerTestOneInput (const uint8_t *Data, size_t Size)
 Fuzzer entry function.
 

Variables

bool circuit_should_fail = false
 
FastRandom VarianceRNG (0)
 
constexpr size_t MINIMUM_MUL_ELEMENTS = 0
 
constexpr size_t MAXIMUM_MUL_ELEMENTS = 8
 
constexpr uint8_t SPECIAL_VALUE_COUNT_NO_ZERO = static_cast<uint8_t>(SpecialScalarValue::Zero)
 
constexpr uint8_t SPECIAL_VALUE_COUNT = static_cast<uint8_t>(SpecialScalarValue::COUNT)
 

Detailed Description

Differential fuzzer for cycle_group elliptic curve operations.

Implements an instruction-based differential fuzzer that validates the cycle_group implementation by executing random sequences of operations both in-circuit (using cycle_group) and natively, then comparing the results. The architecture is as follows:

┌─────────────┐ │ Fuzzer Input│ │ (raw bytes) │ └──────┬──────┘ │ ├──> Parser ──> Instruction Sequence │ v ExecutionHandler (maintains parallel state): ┌─────────────────────────────────────────┐ │ Native: GroupElement + ScalarField │ (ground truth) │ Circuit: cycle_group + cycle_scalar │ └─────────────────────────────────────────┘ │ ├──> Execute each instruction in both representations │ v Verify: cycle_group.get_value() == native_result CircuitChecker::check(circuit)

Definition in file cycle_group.fuzzer.hpp.

Macro Definition Documentation

◆ HAVOC_TESTING

#define HAVOC_TESTING

Definition at line 101 of file cycle_group.fuzzer.hpp.

◆ PUT_RANDOM_BYTE_IF_LUCKY

#define PUT_RANDOM_BYTE_IF_LUCKY (   variable)
Value:
if (rng.next() & 1) { \
variable = rng.next() & 0xff; \
}

Enumeration Type Documentation

◆ SpecialScalarValue

enum class SpecialScalarValue : uint8_t
strong

Special scalar field values used for mutation testing.

Note
: Zero is placed LAST to allow easy exclusion:
  • Use rng.next() % SPECIAL_VALUE_COUNT for all values
  • Use rng.next() % SPECIAL_VALUE_COUNT_NO_ZERO for values excluding Zero (One through HalfModulus)
Enumerator
One 
MinusOne 
SquareRootOfOne 
InverseSquareRootOfOne 
RootOfUnity13 
Two 
HalfModulus 
Zero 
COUNT 
One 
MinusOne 
SquareRootOfOne 
InverseSquareRootOfOne 
RootOfUnity13 
Two 
HalfModulus 
Zero 
COUNT 

Definition at line 128 of file cycle_group.fuzzer.hpp.

Function Documentation

◆ get_special_scalar_value()

template<typename FF >
FF get_special_scalar_value ( SpecialScalarValue  type)
inline

Generate a special scalar field value for testing.

Template Parameters
FFField type (e.g., ScalarField)
Parameters
typeWhich special value to generate
Returns
The special field element

Definition at line 152 of file cycle_group.fuzzer.hpp.

◆ LLVMFuzzerInitialize()

int LLVMFuzzerInitialize ( int *  argc,
char ***  argv 
)

This is used, when we need to determine the probabilities of various mutations. Left here for posterity

Write mutation settings to log

Definition at line 1646 of file cycle_group.fuzzer.hpp.

◆ LLVMFuzzerMutate()

size_t LLVMFuzzerMutate ( uint8_t *  Data,
size_t  Size,
size_t  MaxSize 
)

◆ LLVMFuzzerTestOneInput()

size_t LLVMFuzzerTestOneInput ( const uint8_t *  Data,
size_t  Size 
)

Fuzzer entry function.

Definition at line 1769 of file cycle_group.fuzzer.hpp.

Variable Documentation

◆ circuit_should_fail

bool circuit_should_fail = false

Definition at line 105 of file cycle_group.fuzzer.hpp.

◆ MAXIMUM_MUL_ELEMENTS

constexpr size_t MAXIMUM_MUL_ELEMENTS = 8
constexpr

Definition at line 116 of file cycle_group.fuzzer.hpp.

◆ MINIMUM_MUL_ELEMENTS

constexpr size_t MINIMUM_MUL_ELEMENTS = 0
constexpr

Definition at line 115 of file cycle_group.fuzzer.hpp.

◆ SPECIAL_VALUE_COUNT

constexpr uint8_t SPECIAL_VALUE_COUNT = static_cast<uint8_t>(SpecialScalarValue::COUNT)
constexpr

Definition at line 144 of file cycle_group.fuzzer.hpp.

◆ SPECIAL_VALUE_COUNT_NO_ZERO

constexpr uint8_t SPECIAL_VALUE_COUNT_NO_ZERO = static_cast<uint8_t>(SpecialScalarValue::Zero)
constexpr

Definition at line 141 of file cycle_group.fuzzer.hpp.

◆ VarianceRNG

FastRandom VarianceRNG(0) ( )