Vault
Use Case: Hand Holding without Key Holding
Our customers need to sign transactions with a cryptographic key. We do not want to be in possession of this key. But our customers can not easily be trained to manage keys themselves. We need the keys to be managed for them, without us holding the keys.
To accomplish this, we will give each user a vault that will hold their keys and sign their transactions. The user will authorize an API access token for each transaction, that will temporarily allow us to request that the vault sign the transaction with the key. The token will be scoped to the specific transaction to be signed.
What tools are involved?
Creating our own identity
Before we start helping others with identities and vaults, we need our own. We’ll need a user, an organization, and an application. We can do this through the Ident API, but it is more convenient to use the CLI. Follow the CLI instructions in Prerequisites and Installing from Source before continuing. You can run prvd --help
to verify the CLI is installed and to see what all it can do.
Create a user
The CLI conveniently prompts for the required input: First Name, Last Name, Email, Password.
After filing these in, the CLI returns the new User ID.
Create an organization
The CLI conveniently prompts for the required input: Organization Name.
After filing that in, the CLI returns the new Organization ID.
Create an application
The CLI returns the application ID, name, account, and address.
You can create your application on any network.
prvd networks list
will show your private networks andprvd networks list --public
will show available public networks.
Create an application API token
The CLI returns an access token and refresh token.
Creating customer identities
Now that we have our own identity, we can create identities for our customers. We have a lot of customers, so we will do this in an automated way using scripts. PRVD has helper libraries for many programming languages to more conveniently use the API. JavaScript is a popular language and can be used in either a front end proof of concept, or a back end NodeJS server.
Import the client factories
Set the account ID, application ID, and access token
Initialize an Ident client instance
Create a virtual user
The user ID should be persisted and associated with your record of your user.
Create a user access token
The refresh token is also returned. It should be persisted and used to create future access tokens.
Create an organization
The organization ID should be persisted and associated with your record of your user.
Create an organization access token
The refresh token is also returned. It should be persisted and used to create future access tokens.
Initialize a Vault client instance
Create a vault
The vault ID should be persisted and associated with your record of your user.
Create a key
The key ID should be persisted and associated with your record of your user.
Creating and signing transactions
Create a transaction
Use your preferred library of choice to construct a raw Ethereum transaction. To sign it, Vault will need its transaction hash.
Format transaction hash
If the transaction hash starts with "0x" we need to trim that off.
Sign a transaction
Mission Accomplished
As you can see, we have the user ID, organization ID, vault ID, key ID, and an access token, but we do not have the actual key. It is stored securely in the vault. Vault signs the message in a custodial or non-custodial manner, depending on if you (i) are relying on the commercially-supported managed Provide vault (custodial) or (ii) deployed Vault to your own infrastructure (non-custodial).
Last updated