Giter Site home page Giter Site logo

samkenxstream / turnkey-triumph-326606_cultivated-card-306821_evm-slot-key-verification Goto Github PK

View Code? Open in Web Editor NEW

This project forked from snapshot-labs/evm-slot-key-verification

0.0 0.0 1.0 2.12 MB

Verify the key of an Ethereum storage slot

TypeScript 74.03% Solidity 11.48% Cairo 14.49%

turnkey-triumph-326606_cultivated-card-306821_evm-slot-key-verification's Introduction

Evm Slot Key Verification

The repo provides the functionality to compute the key of an Ethereum storage slot in Cairo.

The Ethereum storage verifier Fossil allows one to verify any part of the Ethereum state on StarkNet. This enables a wide range of functionality including the on-chain voting protocol Snapshot X. It works by users submitting a proof to StarkNet of the contents of a specific storage slot on Ethereum that they require, and then that proof gets verified in a Cairo contract. However there is no mechanism to check that the slot the user submitted a proof of actually corresponds to the slot claimed.

This repo provides a function to compute the key of a storage slot, which can then be compared against the key submitted as part of the proof. If the keys do not match then the contract will know that the proof is invalid.

Finding the Slot Index

The storage layout hardhat plugin can be used to find the index for the desired slot. Either add the plugin to your repo or clone this repo, add your cotract source code, and run yarn storage-layout. The slot index is found from the storage_slot column of the output table:

alt text

Finding the slot key in Cairo

Once you know the index of the slot, you can then call the get_slot_key cairo function with the slot index and the solidity mapping key as arguments (eg for finding the key of balances[_address], the mapping key would be _address). The interface of `get_slot_key' is as shown:

func get_slot_key{bitwise_ptr : BitwiseBuiltin*, range_check_ptr}(slot_index: felt, mapping_key: felt) -> (slot_key : Uint256):
end 

NOTE: This only works for solidity mappings with value types currently

turnkey-triumph-326606_cultivated-card-306821_evm-slot-key-verification's People

Contributors

dependabot[bot] avatar orland0x avatar samkenxstream avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.