Giter VIP home page Giter VIP logo

orochimaru's Introduction

Orochimaru

Orochimaru is a full-node client of Orochi Network which was implemented in pure Rust programming language. Orochi Network isn't a blockchain but a distributed network built to perform Multi Party Computation (MPC) and Zero-Knowledge Proof (ZKP) proving from which we provide trustless and Verifiable Computation. Our mission is to establish High Performance dApp.

Orochi Network

At Orochi Network, we believe that Verifiable Computation is a critical primitive to establish Web3 and Decentralized Autonomous Economy. However, in order to reach this stage, there are still a number of major challenges in this industry to overcome.

  • The limits of computation: EVM can not guarantee semi-native performance, in addition to the extremely high cost and latency to perform computation. dApps nowadays are unfriendly to the mass, unstable, expensive and slow. In other words, they are currently unusable and we can not replace an ordinary application by a dApp yet.
  • Data correctness: There is no way to prove the correctness of data since all data pipelines are stored in a blackbox. We have no idea how data are processed.
  • Data availability: Smart contract executor and application executor are isolated from the internet that prevent data to be accessible from the run-time environment. It always requires a third party service to feed necessary data. This approach is broken since we can not verify the data. Moreover, the latency from the third parties is unacceptable.
┌─────────────────────────────┐
│                             │
│ ┌─────────────────────────┐ │
│ │   Orosign - zkOS's UI   │ │
│ └─────────────────────────┘ │
│                             │
│ ┌─────────────────────────┐ │
│ │  High Performance dApp  │ │
│ └─────────────────────────┘ │
│                             │
│ ┌───────────┐ ┌───────────┐ │
│ │zkDatabase │ │   Orand   │ │
│ └───────────┘ └───────────┘ │
│                             │
│ ┌─────────────────────────┐ │
│ │          zkRISC         │ │
│ └─────────────────────────┘ │
│                             │
└─────────────────────────────┘

┌─────────────────────────────┐
│       Settlement Layer      │
└─────────────────────────────┘

Our solution is to build a universal run-time environment (zkRISC) that provides Verifiable Computation. We can build up the verifiable data pipeline on top of our zkRISC to solve the correctness and availability challenges of the data.

Components

Orand: Decentralized Random Number Generator

Allowed verifiable randomness to be generated and fed to any smart contracts on EVM compatible blockchains. Orand uses Elliptic Curve Verifiable Random Function (ECVRF) to prove and verify randomness. You can learn more about ECVRF in our blog blog.orochi.network.

Request randomness

┌───────────┐         ┌─────┐      ┌──────────────┐
│Application│         │Orand│      │Smart Contract│
└─────┬─────┘         └──┬──┘      └──────┬───────┘
      │                  │                │
      │Request Randomness│                │
      │─────────────────>│                │
      │                  │                │
      │                  │Get latest epoch│
      │                  │───────────────>│
      │                  │                │
      │                  │  Latest epoch  │
      │                  │<───────────────│
      │                  │                │
      │   ECVRF Proof    │                │
      │<─────────────────│                │
      │                  │                │
      │            ECVRF Proof            │
      │──────────────────────────────────>│
┌─────┴─────┐         ┌──┴──┐      ┌──────┴───────┐
│Application│         │Orand│      │Smart Contract│
└───────────┘         └─────┘      └──────────────┘

Orand v1.0 is providing:

  • Verifiable randomness: We're using Elliptic Curve Verifiable Random Function (ECVRF) to generate randomness in the process described here https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-vrf-05#section-5.3. Curve secp256k1 and keccak256 (Ethereum variant) was used to minimizing verification cost for smart contract.

  • Dispersity: A distributed system with many participants/nodes will join to generate randomness by using Multi Party Computation (MPC)

  • Unpredictability: A VRF will perform with the input is previous randomness and it also requires half of participants to participate in MPC

  • High throughput: Game server could request randomness from the Orand system. The result will be provided as soon as half of participants participate in the MPC.

  • Cheap and secure randomness: For the free tier, randomnesses will be given freely for the first 20,000 randomnesses every month.

  • Fault Proof: If the game server tries to delay the feeding process to manipulate the result, a fault proof will be committed so sue the game server.

  • Multi-chain: All EVM compatible blockchains can be supported

API Testing

First starting the service with:

~ $ cargo run

Request service to generate an epoch for a given network:

curl -X POST --data '{"method":"orand_newEpoch","params":["56"]}' http://localhost:3000

Result:

{
    "id": 20,
    "network": 56,
    "keyring_id": 1,
    "epoch": 19,
    "alpha": "2979a78ca2e72317dacf8ac511b48486eeac234dbdcf68c82c787d4adb9a2b17",
    "gamma": "ce809816f05ae6be2c30a8ae9133a53e2095d4d65d15d009e3c5d6be39a83d8eca32382fd95549dd5d3f82d55c71b7d002e5518897d29f20b9ddefc8f137bf36",
    "c": "563103eac20acbec7ed2b2abb0327614f38f7bb2b51c12b049d4a184372bdae2",
    "s": "56af973100d38743a144dab6e70278f09dfa5aba96531ad271b99eb68c89e44e",
    "y": "db2ad98900d91b67a117fc388a20d193ea7152cc05c70479bd9b40beab51d2bd",
    "created_date": "2022-11-11 07:22:36"
}

List recent epoch

curl -X POST --data '{"method":"orand_getPublicEpoch","params":["56","15"]}' http://localhost:3000

Result:

[{
    "id": 16,
    "network": 56,
    "keyring_id": 1,
    "epoch": 15,
    "alpha": "3bc01ff25a742df287f7038063829a8822e91c3f31aeb75b13a6b6eb8950e31b",
    "gamma": "84b4d75c4c7f5d72e155c4b4652286e25f3ade2bbdf391adf9ca0e9e464c60cc2c181327795728913d1f6dd2b407cc61c8d30190455b3a626d8a969219f6e8c3",
    "c": "d7b9aca852b932ce253776402f8c607149366819140fd6d58cfbcfa3b93c9ce5",
    "s": "e34344e4a35f153fbd95b5b44f192160a8fa397a4008af6b4f6ac31ffcc60c80",
    "y": "7b639ee0ee5807b39f012a4f181374e17a36f94b8c35ec4dfc1962069fd8d426",
    "created_date": "2022-11-11 04:56:28"
},
//...
, {
    "id": 20,
    "network": 56,
    "keyring_id": 1,
    "epoch": 19,
    "alpha": "2979a78ca2e72317dacf8ac511b48486eeac234dbdcf68c82c787d4adb9a2b17",
    "gamma": "ce809816f05ae6be2c30a8ae9133a53e2095d4d65d15d009e3c5d6be39a83d8eca32382fd95549dd5d3f82d55c71b7d002e5518897d29f20b9ddefc8f137bf36",
    "c": "563103eac20acbec7ed2b2abb0327614f38f7bb2b51c12b049d4a184372bdae2",
    "s": "56af973100d38743a144dab6e70278f09dfa5aba96531ad271b99eb68c89e44e",
    "y": "db2ad98900d91b67a117fc388a20d193ea7152cc05c70479bd9b40beab51d2bd",
    "created_date": "2022-11-11 07:22:36"
}]

Installation

You must install sea-orm-cli first:

cargo install sea-orm-cli

Generate entity for sqlite (you don't need to perform this step):

sea-orm-cli generate entity -o ./entity

Migrate database or init database for the first time:

sea-orm-cli migrate

Add unique key

ALTER TABLE public.receiver ADD CONSTRAINT address_network_unique UNIQUE (address,network);

Docker

$ cd docker/node
$ docker compose up -d

Postgres will be expose in port 4321, orand service will be exposed to port 31337.

You can add new user by trying to access into by trying:

$ docker exec -ti node-orandservice-1 /bin/bash
$ orand-cli user chiro
Add new user: chiro
 - hmac_secret: 03ddcd77ef81141072db73f928c19db5eb1824924e0539c5
 - public_key: 04b16ddcf3c10129a6f26a92c562bab13a2d2fcf7ff955c381e75023b5a364e69b7641bc381aeb41a4dceedc095c3027d294d533598df7c518d5db1002b897e719
 - secret_key: f27b81c3a0a52ffe2cd06bfe960de90c5631e7ef08db3a782d9b437226b13d39

Copy the hmac_secret and username so we can use it in sdk.

License

Orochi Network's source code licensed under Apache License 2.0

built with ❤️

orochimaru's People

Contributors

chiro-hiro avatar dqtkien avatar happyfalcon22 avatar omahs avatar phamnhatminh1292001 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

orochimaru's Issues

Add HMAC-SHA256 to secure Orand's JSON RPC

We need to use HMAC as a basic authentication to protect Orand's JSON RPC. All requests include following headers:

X-Actor: <username>
X-Signature: <challenge_signed_with_hmac>

Are there a better way to archive this?.

Key Value Storage package allows our full-node to store and lookup data with several engines.

💾 Key Value Storage

Interface and implementation

DatabaseEngine is the common interface which will be shared among its implementations, this approach will allow us to support new storage engine in the future without sacrifice the consistency.

  • LevelDbEngine: A implementation of DatabaseEngine for LevelDB
  • MemoryEngine: A implementation of DatabaseEngine for Memory
  • KeyValueStorage: A implementation of DatabaseEngine, It's also a wrapper of LevelDbEngine and MemoryEngine
type EngineType int

const (
	MemoryEngine EngineType = iota
	LevelDbEngine
)

type SupportedFeature struct {
	Atomic      bool
	Synchronous bool
	Persistent  bool
}

type EngineOption struct {
	Url  string
	Type EngineType
}

type EngineCallOption struct {
	Expired int
}

type DatabaseEngine interface {
	Open(options ...func())
	Get(key []byte) ([]byte, error)
	Put(key []byte, value []byte) bool
	Del(key []byte) error
	BatchPut(keys [][]byte, values [][]byte) []bool
	BatchGet(keys [][]byte) ([][]byte, error)
	BatchDel(keys [][]byte) error
	Option(callOptions EngineCallOption) DatabaseEngine
	Feature() SupportedFeature
	EngineType() EngineType
	Close() error
}

KeyValueStorage will wrap the engine and provide the same interface.

Option modifier

This mechanism allows us to modify the options much more flexible

type LevelDbEngine struct {
}

func (l LevelDbEngine) Open(options ...func()) {
	for _, opt := range options {
		opt()
	}
}

func LevelDbDefaultOption(option *EngineOption, url string) func() {
	return func() {
		option.Type = LEVEL_DB_ENGINE
		option.Url = url
	}
}

func LevelDbChangeDb(option *EngineOption, url string) func() {
	return func() {
		option.Url = url
	}
}

// Usage
levelDb := LevelDbEngine{}
levelDbOption := &EngineOption{}
levelDb.Open(
  LevelDbDefaultOption(levelDbOption, "/data/test.ldb"),
  LevelDbChangeDb(levelDbOption, "/data/another.ldb")
)

Call Option

We allow user to set the option for the next call

Option(callOptions EngineCallOption) DatabaseEngine

// Usage
levelDb.Option(EngineCallOption{Expired: 30000}).set([]byte("testGo"), []byte("AAA"))

Change the database engine and serialization

SQLite is a wrong choice, the performance is poor and cost to serialize the JSON is very expensive. It would be better if we use rocksdb + profobuf. Just pure K-V and protobuf, we also able to implement gRPC base on the same protobuf.

[zkMemory] Use rayon in zkMemory and polynomial evaluation

Rayon and Tokio could be used to improve these kind of code.

        // Evaluate the values p_i(x_i) for i=1,2,...,n and add to the transcript
        for (poly, point) in polynomial_list.iter().zip(&points_list) {
            transcript
                .write_scalar(eval_polynomial(poly, *point))
                .unwrap();
        }

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.