0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Quorum Key Manager(QKM)の構築

Last updated at Posted at 2024-04-26

1. 背景

実際の業務でブロックチェーンの鍵管理システムであるQuorum Key Manager(以下QKM)を構築したのでその時の手順などをまとめてみた。

2. 構築環境

ubuntu 20.04

3. 構築手順

QKMとは別にインストールするもの

  • Go
  • GCC
  • PostgreSQL

Go

  • ダウンロード&インストール
wget https://go.dev/dl/go1.20.4.linux-amd64.tar.gz
sudo tar -C /usr/local -xzf go1.20.4.linux-amd64.tar.gz
  • パスを通す
vim ~/.profile

以下を追記

export PATH=$PATH:/usr/local/go/bin
source ~./profile	#環境変数の反映
go version	#インストールできているか確認

GCC

  • インストール
sudo apt update
sudo apt install build-essential

PostgreSQL

  • インストール
sudo apt install postgresql-14

QKMのダウンロードとビルド

参考:https://github.com/ConsenSys/quorum-key-manager/blob/main/doc.quorum-key-manager-main/docs/Get-Started/Build-From-Source.md

git clone https://github.com/Consensys/quorum-key-manager.git
cd quorum-key-manager
go mod download
go build -o ./build/bin/key-manager

QKMの開始

PostgreSQLの設定

  • PostgreSQLのユーザpostgresにパスワードを設定する
psql -U postgres
# postgresqlと対話
alter role postgres with password 'postgres';
  • peerなんたらというエラーが出たとき
sudo vim /etc/postgresql/14/main/pg_hba.conf
# peerをtrustに書き換える
sudo reboot
  • qkmというデータベース作成
psql -U postgres
# postgresqlと対話
create database qkm;
  • マイグレーションディレクトリを準備
sudo mkdir -p /migrations
cd quorum-key-manager
sudo cp ./deps/migrations/* /migrations/.
  • 環境変数の設定
export DB_HOST=localhost
export DB_PORT=5432
export DB_DATABASE=qkm
export DB_USER=postgres
export DB_PASSWORD=postgres
  • マイグレーションの実行
./build/bin/key-manager migrate up
# 以下出力が出たら成功
2023-05-25T03:17:40.362Z        INFO    migrations executed successfully

QKMの実行

  • manifestファイルの準備
  • store.yml という名前のファイルで以下を作成
- kind: Store
  type: secret
  name: aws-secrets
  specs:
    vault: aws-vault

- kind: Store
  type: key
  name: my-key-store
  specs:
    vault: aws-vault

- kind: Store
  type: ethereum
  name: my-ethereum-store
  specs:
    key_store: my-key-store
  • vault.yml という名前のファイルで以下を作成
- kind: Vault
  type: aws
  name: aws-vault
  specs:
    access_id: AKIAWVRNZMOSJXXSCYUG
    secret_key: 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
    region: ap-northeast-1
    debug: true

manifestsというディレクトリを作成し上記の2つのファイルを配置する。

  • QKMの実行
./build/bin/key-manager run --manifest-path=[上記で置いたmanifestsディレクトリへのパス]
# 起動後はコンソールにいろいろ出力される
# API叩くと操作ログも出力される

4. まとめ

今回は簡易的な構築から起動までの手順を記載した。実際に使用するときはAWSのKMSなどと連携して鍵を保存するように設定して使用する。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?