Skip to main content

SInDi: Semantic Invariant Differencing for Solidity Smart Contracts

Project description

SINA: Semantic Invariant Analysis for Smart Contracts

SINA is a tool to compare two predicates written in Solidity, the smart contract programming language. PreDi determines if two predicates are equivalent or if one is stronger than the other.

Features

  • Tokenizes and parses each Solidity predicate into an Abstract Syntax Tree (AST)
  • Simplifies AST using symbolic mathematics
  • Compare predicates for equivalence and logical strength either using predefined rules (when applicable) or checking for satisfiability when pre-defined rules are not applicable.

Install Using pip and Use as a Python Library

Running the following command should suffice:

pip install predi

Library Usage

Simple Predicate Comparison

>>> from predi.comparator import Comparator
>>> comparator = Comparator()
>>> comparator.compare("a < b", "a <= b")
'The first predicate is stronger.'
>>> comparator.compare("a > b", "a <= b")
'The predicates are not equivalent and neither is stronger.'

Installing and Using as a CLI Tool

Prerequisites

  • Python 3.8 or higher
  • Install required packages using pip
pip install -r requirements.txt

Running the Tests

To ensure everything is set up correctly, run the unit tests:

python -m unittest discover -s tests

To run an specific test:

python -m unittest tests.test_comparator.TestComparator.test_comparator

CLI Usage

You can compare two predicates using the main.py script. Here's an example:

$ python main.py "msg.sender == msg.origin" "msg.origin == msg.sender"
The predicates are equivalent.

$ python main.py "msg.sender == msg.origin && a >= b" "msg.sender == msg.origin"
The first predicate is stronger.

$ python main.py "msg.sender == msg.origin || a < b" "a < b"
The second predicate is stronger.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sindi-0.1.14.tar.gz (16.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sindi-0.1.14-py3-none-any.whl (13.9 kB view details)

Uploaded Python 3

File details

Details for the file sindi-0.1.14.tar.gz.

File metadata

  • Download URL: sindi-0.1.14.tar.gz
  • Upload date:
  • Size: 16.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.13

File hashes

Hashes for sindi-0.1.14.tar.gz
Algorithm Hash digest
SHA256 6292ae5c4c56cb35608f1dcfc64228386f929cc9fbd87a0116ba1ac4c1f19ca2
MD5 2788a61c385171f4e867a6c98d4e00fc
BLAKE2b-256 31cca16b24d7f6740f230e37d480e354427c1891fdb6ec913e6aff150784a080

See more details on using hashes here.

File details

Details for the file sindi-0.1.14-py3-none-any.whl.

File metadata

  • Download URL: sindi-0.1.14-py3-none-any.whl
  • Upload date:
  • Size: 13.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.13

File hashes

Hashes for sindi-0.1.14-py3-none-any.whl
Algorithm Hash digest
SHA256 0d1676bc1c792df898c4886ed7cf2de79f8556a9351bdc9acf69e1d5a289f9ac
MD5 8635504ac2bc323552f852eef862825f
BLAKE2b-256 97b5a02f72994935910f1e50fe2de60369f718673d32d79e7ce2fc25121adf0a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page