Skip to content

mmsaki/signed-average-safemath-fuzz

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OpenZeppelin's SafeMath fuzzing

In this repo I will be fuzzing OpenZeppelin SafeMath library with woke.

Getting Started

Note: You can set up your you woke environment with my Template here or clone this repo

  1. Setup your environment

    python -m venv venv
    source ./venv/bin/activate
    pip install woke
  2. Install openzepelin contracts you want to fuzz

    pnpm install @openzeppelin/contracts
    # or
    npm install @openzeppelin/contracts

    If you are cloning this project just run npm install or pnpm install

  3. Import contracts and libraries in ./contracts/Imports.sol

  4. Write your contracts in ./contracts/Math.sol

  5. Generate pytypes

    woke init pytypes -w

Fuzzing

  1. Let's fuzz the signed math average function in ./tests/test_signed_math.py

    function average(int256 a, int256 b) internal pure returns (int256) {
        // Formula from the book "Hacker's Delight"
        int256 x = (a & b) + ((a ^ b) >> 1);
        return x + (int256(uint256(x) >> 255) & (a ^ b));
    }
  2. Run woke fuzzer

    woke fuzz tests/test_signed_math.py -n 8

About

Openzeppelin SafeMath Library fuzzing

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published