Skip to main content

Fulfill requests from CLI

Overview

This is a step-by-step guide explaining how to fulfill key and signature requests with your Keychain from the command line.

For generating keys and signing messages, you'll use the CLIChain (clichain) tool.

Learn more:

Prerequisites

Before you start, complete the following prerequisites:

1. Install CLIChain

To install CLIChain, navigate to the wardenprotocol directory and run this:

go install ./cmd/clichain

2. Export variables

In the next steps, you'll use the following values:

Export them as environment variables:

export CHAIN_ID=chain_123-1 
export KEYCHAIN_ID=1
export KEYCHAIN_WRITER_NAME=my-keychain-writer-name

3. Fulfill a key request

When a user requests a new key, the Keychain generates a new private key, stores it securely, and submits the public key to the chain.

  1. Use SpaceWard or the command line to create a new Space and request a new key.

  2. Get all key requests:

    wardend query warden key-requests --keychain-id $KEYCHAIN_ID

    Your key request ID will be returned in the id field of the output:

    id=1
  3. Export the request ID:

    export KEY_REQUEST_ID=1  # replace with the actual key request ID
  4. Use the CLIChain generate command to generate the key:

    clichain generate -o private_$KEY_REQUEST_ID.key
  5. Export the public key, derived with the CLIChain public-key command:

    export PUBLIC_KEY=$(go run ./cmd/clichain public-key -k private_$KEY_REQUEST_ID.key -o base64)
  6. Fulfill the key request by submitting a transaction from the Keychain Writer account:

    wardend tx warden fulfill-key-request $KEY_REQUEST_ID $PUBLIC_KEY /
    --from $KEYCHAIN_WRITER_NAME --chain-id $CHAIN_ID

4. Fulfill a signature request

When a user requests a new key, the Keychain signs a message with the private key and submits the signature to the chain.

  1. Use SpaceWard or the command line to create a new signature request.

  2. Get all signature requests:

    wardend query warden sign-requests --keychain-id $KEYCHAIN_ID

    Your signature request ID and data for signing will be returned in the id and data_for_signing fields of the output:

    id: 1
    data_for_signing: rx3uiUeGwwRgSgObBBRjyauN77OTQD6gPPLIWx64y/0=
  3. Export your signature request data:

    export DATA=rx3uiUeGwwRgSgObBBRjyauN77OTQD6gPPLIWx64y/0= # replace with the actual data
    export SIGN_REQUEST_ID=1 # replace with the actual signature request ID
  4. Use the CLIChain sign command to sign the message with the key generated in Step 3 and export the signature:

    export SIGNATURE=$(echo -n $DATA | base64 -d | clichain sign -k /tmp/key -o base64)
  5. Fulfill the signature request by submitting a transaction from the Keychain Writer account:

    wardend tx warden fulfill-sign-request $SIGNATURE_REQUEST_ID $SIGNATURE \
    --from $KEYCHAIN_WRITER_NAME --chain-id $CHAIN_ID