Giter VIP home page Giter VIP logo

quorum-key-manager's Introduction

Website Website

CircleCI Go Report Card Quality Gate Status Coverage

Quorum Key Manager

Quorum Key Manager (QKM) is a key management service developed under the BSL 1.1 license and written in Go.

Quorum Key Manager is no longer actively maintained by Consensys and is provided as-is. It is an open-source project and contributions are welcome. See the license for more details.

The documentation can now be found here within this repo.

Quorum Key Manager exposes an HTTP API service to manage your secrets, keys and Ethereum accounts. QKM supports the integration with AWS Key Management Service, Azure Key Vault and HashiCorp Vault.

In addition, using the JSON-RPC interface of the QKM, you can connect to your Ethereum nodes to sign your transaction using the Ethereum account stored in your secure key vault.

Useful links

Run QKM

First, define your Quorum Key Manager environment setup using manifest files. Examples can be found at ./deps/config/manifests. More information about how to set up service can be found in documentation.

Now launch Quorum Key Manager service using docker-compose with the following command:

docker-compose up

Build from source

Prerequisites

To build binary locally requires Go (version 1.15 or later) and C compiler.

Build

After downloading dependencies (ie go mod download) you can run following command to compile the binary

go build -o ./build/bin/key-manager

Binary will be located in ./build/bin/key-manager

License

Orchestrate is licensed under Apache-2.0.

Please refer to the LICENSE file for a detailed description of the license.

quorum-key-manager's People

Contributors

6l20 avatar darioanongba avatar dependabot[bot] avatar dolanor avatar ggarri avatar joshuafernandes avatar julien-marchand avatar kriys94 avatar nmvalera avatar non-fungible-nelson avatar snyk-bot 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

Watchers

 avatar  avatar  avatar

quorum-key-manager's Issues

Integrate OpenAPI

Acceptance criteria

  • Evalulate alternatives for OpenAPI generation
  • Write annotation for KM endpoints
  • Generate OpenAPI files
  • Including pipeline docs publish and build

Implement ready and liveness endpoints

Implement ready and live endpoints in the key manager. Following the same implementation than in Orchestrate, on a dedicated port.

Acceptance criteria

  • Implement a simple health check over the readiness of the API service
  • Check the liveness on the e2e tests

Implement /keys endpoints

Implement http.Handler exposing the base keys.Store functionalities.

Method and route naming are to be discussed and confirmed as part of this task

  • POST /keys/{id}
  • PATCH /keys/{id}/import
  • GET /keys/{id}
  • GET /keys
  • PATCH /keys/{id}
  • DELETE /keys/{id}
  • GET /keys/deleted
  • GET /keys/deleted/{id}
  • DELETE /keys/{id}/destroy
  • POST /keys/{id}/sign
  • POST /keys/{id}/verify

Create http.Server accepting connection

Implement http.Server logic,

  • should define the type Config struct for the main application to run
  • should expose a non-TLS listener.
  • use gorilla as webserver ???

json-rpc http e2e tests

Write acceptance test for the following:

  • eea_sendTransaction
  • eth_accounts
  • eth_sendTransaction (with and without private_args)
  • eth_sign
  • eth_sign_transaction

Include Besu and go-quorum

Add Hahsicorp key store

IMPORTANT: Current Orchestrate client impl align with the one required here

To be implemented in core/store/keys/hashicorp

  • Define type Config struct
  • Implement New(cfg *Config) *Store creating store from configuration
  • Implement Create(...)
  • Implement Get(...)
  • Implement Update(...)
  • Implement List(...)
  • Implement Sign(...)
  • Implement Sign....(...)
  • All other methods should return NotImplementedError

IMPORTANT: Compare impl with https://github.com/ConsenSys/quorum-signer-plugin-for-hashicorp-vault

Implement builder functions for initial type of stores

  • Implement function taking manifest specs, extracting it to create the corresponding store

  • Implement a Manifest Loader that loads manifest files from a filesystem folder this is expected to be static (load only once)
    As part of this task, we should define the type of file format json, yaml, toml...? Initialize Hashicorp Vault secret store

Evaluate logger alternatives and implement best solution

The goal of this ticket is to evaluate different logger alternatives, such as go-kit or zap

Requirements are:

  • Decouple from our application and easy to unplug
  • Support Context logging
  • Use interfaces instead of structs for logging

websocket e2e test

Write acceptance test for the following:

  • eea_sendTransaction
  • eth_accounts
  • eth_sendTransaction (with and without private_args)
  • eth_sign
  • eth_sign_transaction

Include Besu and go-quorum

Discuss and refactor Node implementation

  1. [HIGH] Node component appears to be one of our application core component which it belongs to our business layer, so that, two things about it:
    Node should not be aware of the outside layer of our application what it is at the moment because its interface it exposes httpClient, jsonrpc.Client, jsonrpc.Handler, all of them are part of what we could called INFRA layer. Alternatively I think Node should implement jsonrpc call methods required by the service layer (a proxy receiving a method and a payload req) and help methods such as getGasPrice, getNonce to be used on the business layer
    This component should be place at /src/core/node

  2. [HIGH] IMO sessions should not be manage by the node components. Session will not necessarily depend on the node but on the users making the requests to the same node. For that the most standardized way to do is SESSION_ID which lives in the Request object and exchanged between the client and the server. To achieve that gorilla provides a library which I believe we could easily integrate https://github.com/gorilla/sessions

  3. [MEDIUM] Everything related to jsonrpc server code, proxy logic and the preparer /pkg/http/request/preparer_proxy.go should be moved together under /src/infra. As far as I see all that logic appear to be out outside facing layer including the proxy preparer which IMO it is not a preparer but part of business logic of our proxy server.

4. [MEDIUM] If I am not mistaken we could skip the wrapper implementations of json-rpc request and response and it would be enough with a RequestMSG and ResponseMSG. As far as I understand a request will flow over different request preparers till it reaches the intended Besu/Quorum node and same for the response over the modifiers till it comes back to the user. Accounting on that I think it would be cleaner if we attach things directly over the http.request and http.response and make all the work of transforming to the right formats using static parsing methods fetching the context attached on those objects (alternatively on the context in case those object can not hold key-value fields)

5. [MEDIUM-LOW] Config structs should be a things initialize once and we never modify over the course of execution. The initialization of those config struct should only happen when the application inits, or when a new request it is coming into our application via our service layer. So that all config struct should remain under infra package (edited)

  1. [LOW] We should avoid prefixing every modified and preparer by that name by adding them into a subfolder call with the same name

Add AKV Key Store

To be implemented in core/store/keys/azure-key-vault

  • Define type Config struct
  • Implement New(cfg *Config) *Store creating store from configuration
  • Implement Create(...)
  • Implement Get(...)
  • Implement Update(...)
  • Implement List(...)
  • Implement Sign(...)
  • All other methods should return NotImplementedError

Implement Azure Secret Manager

type Store interface {
	// Info returns store information
	Info(context.Context) (*entities.StoreInfo, error)

	// Set secret
	Set(ctx context.Context, id, value string, attr *entities.Attributes) (*entities.Secret, error)

	// Get a secret
	Get(ctx context.Context, id string, version int) (*entities.Secret, error)

	// List secrets
	List(ctx context.Context) ([]string, error)

	// Update secret
	Refresh(ctx context.Context, id string, expirationDate time.Time) error

	// Delete secret not permanently, by using Undelete the secret can be restored
	Delete(ctx context.Context, id string, versions ...int) (*entities.Secret, error)

	// GetDeleted secrets
	GetDeleted(ctx context.Context, id string) (*entities.Secret, error)

	// ListDeleted secrets
	ListDeleted(ctx context.Context) ([]string, error)

	// Undelete a previously deleted secret
	Undelete(ctx context.Context, id string) error

	// Destroy secret permanently
	Destroy(ctx context.Context, id string, versions ...int) error
}

Add AWS KMS Key Store

To be implemented in core/store/keys/aws-kms

  • Define type Config struct
  • Implement New(cfg *Config) *Store creating store from configuration
  • Implement Create(...)
  • Implement Get(...)
  • Implement Update(...)
  • Implement List(...)
  • Implement Sign(...)
  • All other methods should return NotImplementedError

Quorum key manager storage

Currently, the ETH account data comes from the underlying key store. This data is not enough to index the accounts because the address is not present in the keys. We need to store the address to be able to query accounts by address:

  • DB server implementation (ex: PG)
  • DB local implementation (SQLite, Redis)
  • In-memory solution

Acceptance criteria

  • Decide on a storage implementation for accounts, stores, audit logs and other persistent data.

Please read comments of the ticket

[Spike] JSON-RPC use-case implementation design

JSON-RPC use-case (e.g. eth_sendTransaction) needs some functional logic in order to synchronize various operation involving secure Stores, downstream node, etc.

What is the best approach for implementation?

Update Hashicorp plugin to use ECDSA standard signatures

Currently, the Hashicorp plugin keys domain uses Ethereum [R||S||V] signature scheme instead of the standard ECDSA [R||S] signatures. This should be modified to make the keys compatible with other stores (AKV, AWS).

Acceptance criteria:

  • Stop using go-ethereum libraries for signature, use ecdsa standard package.
  • Return base64 format
  • integration tests
  • Eth1.Store should work with the Hashicorp key store.

Discussion:
Change the key format to return x and y values?

Add cmd to start Key-Manager

Create a command to start the Key-Manager

Part of this ticket consist in proposing the library for command line (cobra?)

Add Hashicorp Secret Store

To be implemented in core/store/secrets/hashicorp

  • Define type Config struct
  • Implement New(cfg *Config) *Store creating store from configuration
  • Implement Set(...)
  • Implement Get(...)
  • Implement Update(...)
  • Implement List(...)
  • All other methods should return NotImplementedError

Soft-delete in Hashicorp plugin

In order to align with best practices standard over key management Hashicorp should provide support for soft-delete on keys.

Improve error handling & logging

Acceptance criteria

  • Return custom error in stores
  • Add logging to stores (with Info/Warn/Error, etc. levels)
  • Mapping of Errors to correct HTTP codes in the service layer
  • Acceptance test & unit test of error returned

Fix the development environment

Currently the development environment fails to start when running the command make dev.

  • Fix the docker-compose network issues
  • Start The Dependencies (hashicorp only now)
  • Start key manager connected to hashicorp

Implement AWS secret store

Description

Implement the AWS secret store by following the specifications and by taking example from the other secret stores:

Specification

https://docs.google.com/document/d/1GkGUW79iKAhzbFnwY28TVizZGxxMiO8f2XQvZyE2zl4/edit?usp=sharing

Acceptance criteria

  • Complete the secret store implementation by:
  • Implementation AWS KMS client in infra layer
  • Implement the AWS KMS secret store in store layer by taking example from the hashicorp secret store (also AKV)
  • Implement the integration tests by adding AWS localstack: https://github.com/localstack/localstack

Add `manifest.Loader` which loads from filesystem

Implement a Manifest Loader that

  • loads manifest files from a filesystem folder
  • this is expected to be static (load only once)

As part of this task, we should define the type of file format json, yaml, toml...?

Vault plugin error handling

Improve error handling of the Vault plugin:

  • Remove dependency on Orchestrate errors and define custom errors in the vault plugin directly
  • Map errors to a HTTP response (400, 404, 422, 500)

Add JSON-RPC use-cases

Methods to implement

  • eth_sendTransaction
  • eth_sign
  • eth_signTypedData
  • eth_accounts
  • eth_signTransaction
  • eea_sendTransaction
  • personal_newAccount
  • personal_listWallets (does it makes sense to rename personal_listStores?)
  • personal_* (to be silence)
  • default (pass through)

Should this issue broken is smaller ones?

Implement token renewal for Hashicorp

Implement token renewal runnable service to renew token, following what has been implemented in Orchestrate (at least for this first version).

Decide between next options:

  • Runnable stores
  • Runnable client
  • Manage by store manager

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.