Git Product home page Git Product logo

gotham-engine's Introduction

Gotham-engine

Gotham engine is the engine for gotham-city server. It abstracts through traits, routes for keygen and sign in a 2P setting for Lindell17 protocol. The level of abstraction allows the implementers to pass specific DB api and authorization policies. The engine provides default trait implementations for keygen and sign logic, such that the implementers are only implementing the peripherals. Any potential change at the cryptographic protocol is done through the gotham-engine and and changes are reflected automatically at the implementers through default implementations. An example of usage is provided in the gotham-city project.

Example Workflow for an Implementer:

  1. Instantiate empty traits for KeyGen and Sign:

    pub struct PublicGotham {
       rocksdb_client: rocksdb::DB,
    }
    impl KeyGen for PublicGotham {}
    impl Sign for PublicGotham {}
  2. Implement the Db trait

   impl Db for PublicGotham {
    async fn insert(
        &self,
        key: &DbIndex,
        table_name: &dyn MPCStruct,
        value: &dyn Value,
    ) -> Result<(), DatabaseError> {
        ///implementation
    }

    async fn get(
        &self,
        key: &DbIndex,
        table_name: &dyn MPCStruct,
    ) -> Result<Option<Box<dyn Value>>, DatabaseError> {
           ///implementation
   }
  1. Implement the TxAuthorization trait
impl Txauthorization for Authorizer {
    /// the granted function implements the logic of tx authorization. If no tx authorization is needed the function returns always true
    fn granted(&self) -> Result<bool, DatabaseError> {
           ///implementation
    }
}
  1. Spin a rocket server and mount gotham-engine existing endpoints for keygen and sign
rocket::Rocket::build()
        .register("/", catchers![internal_error, not_found, bad_request])
        .mount(
            "/",
            routes![
                gotham_engine::routes::wrap_keygen_first,
                gotham_engine::routes::wrap_keygen_second,
                gotham_engine::routes::wrap_keygen_third,
                gotham_engine::routes::wrap_keygen_fourth,
                gotham_engine::routes::wrap_chain_code_first_message,
                gotham_engine::routes::wrap_chain_code_second_message,
                gotham_engine::routes::wrap_sign_first,
                gotham_engine::routes::wrap_sign_second,
            ],
        )
  1. Pass to the gotham-engine the State for Db and TxAuthorization trait as dyn trait objects

    .manage(Mutex::new(Box::new(x) as Box<dyn gotham_engine::traits::Db>))
    .manage(Mutex::new(
             Box::new(tx) as Box<dyn gotham_engine::traits::Txauthorization>
         ))
    

    Details

    Documentation

gotham-engine's People

Contributors

leontiadzen avatar max-zengo avatar

Stargazers

 avatar  avatar  avatar

Watchers

 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.