Git Product home page Git Product logo

aiakos's Introduction

aiakos

Aiakos is a Tendermint PrivValidator (signer) implementation using the YubiHSM2.

It uses the yubihsm-go library to communicate with the YubiHSM connector which needs to be running on the HSM host.

Usage

To implement the PV interface in your Tendermint application you need to initialize it appropriately. To simplify the state management we implemented Tendermint's Service system.

The following example shows you how to implement a simple Aiakos service using env variables (please note that some errors are unhandled for simplicity). We are using the tendermint log package for the service initialization and further log output.

if os.Getenv("AIAKOS_URL") == "" {
  return nil, errors.New("no Aiakos hsm url specified. Please set AIAKOS_URL in the format host:port")
}
aiakosUrl := os.Getenv("AIAKOS_URL")

if os.Getenv("AIAKOS_SIGNING_KEY") == "" {
  return nil, errors.New("no Aiakos signing key ID specified. Please set AIAKOS_SIGNING_KEY")
}
aiakosSigningKey, err := strconv.ParseUint(os.Getenv("AIAKOS_SIGNING_KEY"), 10, 16)
if err != nil {
  return nil, errors.New("invalid Aiakos signing key ID.")
}

if os.Getenv("AIAKOS_AUTH_KEY") == "" {

  return nil, errors.New("no Aiakos auth key ID specified. Please set AIAKOS_AUTH_KEY")
}
aiakosAuthKey, err := strconv.ParseUint(os.Getenv("AIAKOS_AUTH_KEY"), 10, 16)
if err != nil {
  return nil, errors.New("invalid Aiakos auth key ID.")
}

if os.Getenv("AIAKOS_AUTH_KEY_PASSWORD") == "" {
  return nil, errors.New("no Aiakos auth key password specified. Please set AIAKOS_AUTH_KEY_PASSWORD")
}
aiakosAuthPassword := os.Getenv("AIAKOS_AUTH_KEY_PASSWORD")

// Init Aiakos module
hsm, err := aiakos.NewAiakosPV(aiakosUrl, uint16(aiakosSigningKey), uint16(aiakosAuthKey), aiakosAuthPassword, log.NewNopLogger())
if err != nil {
  return nil, err
}

// Start Aiakos
err = hsm.Start()
if err != nil {
  return nil, err
}

if os.Getenv("AIAKOS_IMPORT_KEY") == "TRUE" {
  println("importing private key to Aiakos because AIAKOS_IMPORT_KEY is set.")

  filepv := privval.LoadOrGenFilePV("privval.json")
  key := filepv.PrivKey.(ed25519.PrivKeyEd25519)

  err = hsm.ImportKey(uint16(aiakosSigningKey), key[:32])
  if err != nil {
    println("Could not import key to HSM; skipping this step since it probably already exists")
  }
}

Now you can use hsm as the PV in your Tendermint App initializer.

Notice

This has only been tested with Tendermint v0.24.x

Don't consider this production ready.

aiakos's People

Contributors

hendrikhofstadt avatar mattkanwisher avatar

Watchers

James Cloos avatar Khalifa avatar  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.