npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

codius-engine

v1.2.1

Published

Codius smart oracle runtime engine for Node.js

Downloads

3

Readme

Contracts Engine

The engine to run contracts

Playing with the engine

  • npm install
  • npm test runs the existing tests
  • Use the codius-cli to run test contracts

Structure of the engine

The engine is the part of Codius responsible for running sandboxed code and providing APIs for that code to communicate with.

For the sandbox we are currently using codius/node-sandbox, which utilizes Native Client.

The Engine is the main component used to run contract code and the ContractRunner is responsible for handling messages coming from the sandbox and passing valid ones to the corresponding APIs.

Contract code uses the postMessage command to communicate with the outside. The format is defined below. Most contracts will not use the postMessage command directly but will instead use modules or runtime_library components, which are loaded into the sandbox by default.

Questions?

Any questions? Join the live chat! Gitter chat

APIs and Message Formats

IPC Messaging Format

Contract -> Sandbox

API call with callback

{
  "type": "api",
  "api": "http",
  "method": "get",
  "data": "http://some.url",
  "callback": 4
}

Sandbox -> Contract

API callback

{
  "type": "callback",
  "callback": 4,
  "error": null,
  "result": "some stringified result"
}

Contract-specific Secrets and Keypairs

Secret Derivation

The engine must be started with a MASTER_SECRET.

This secret is used to derive multiple other secrets, which are used to provide contracts with unique private values and public/private key pairs. Derived secrets are the HMAC of the "parent" secret and the name of the "child" secret

  • CONTRACT_SECRET_GENERATOR - used to generate 512-bit private values
  • CONTRACT_KEYPAIR_GENERATOR_ec_secp256k1 - used to generate secp256k1 key pairs (e.g. CONTRACT_KEYPAIR_13550350a8681c84c861aac2e5b440161c2b33a3e4f302ac680ca5b686de48de)
  • other CONTRACT_KEYPAIR_GENERATOR_{other signature schemes} (e.g. ec_ed25519)
  • MASTER_KEYPAIR_ec_secp256k1 - used to sign contracts' public keys
  • other MASTER_KEYPAIR_{other signature schemes} (e.g. ec_ed25519)

API

var secrets = require('secrets');

// Get a secret that is deterministically generated and unique for the contract
secrets.getSecret(function(error, secret){
  // error: null
  // secret: "c88097bb32531bd14fc0c4e8afbdb8aa22d4d6eefcbe980d8c52bd6381c6c60ca746b330ce93decf5061a011ed71afde8b4ed4fbbf1531d010788e8bb79c8b6d"
});

// Get a secp256k1 key pair and the engine's signature on the public key
// Note that the signature is in DER format
secrets.getKeypair('ec_secp256k1', function(error, keypair){
  // error: null
  // keypair: {
  //   public: '0417b9f5b3ba8d550f19fdfb5233818cd27d19aaea029b667f547f5918c307ed3b1ee32e285f9152d61c2a85b275f1b27d955c2b59a313900c4006377afa538370',
  //   private: '9e623166ac44d4e75fa842f3443485b9c8380551132a8ffaa898b5c93bb18b7d',
  //   signature: '304402206f1c9e05bc2ad120e0bb58ff368035359d40597ef034509a7dc66a79d4648bea022015b417401d194cf2917e853a7565cfbce32ee90c5c8f34f54075ee2f87519d88'
  // }
});