Integrating Proof of Key
The Proof of Key process has been designed in a very easy manner and can be easily integrated into an existing project. Only three functions are needed to complete a full implementation of the process. The following steps have to be done in the given order to complete the process.
Requesting a challenge
To request a challenge, the following function has to be used:
fetchChallenge(assetId, [config])
Following variables are accepted:
- assetID: The Asset ID that the balance has to be checked for.
- config: Optional configuration that are detailed in this page.
This will return a challenge that can be then further used in the next steps.
Signing the challenge
For this step, a private key of an Ethereum private key is needed. This is not provided by the Ambitorio SDK and has to be extracted and passed by the client itself. Please refer to your Ethereum wallet’s library documentation for further steps.
To sign a challenge, the following function has to be used:
signChallenge(challenge, walletPrivateKey)
Following variables are accepted:
- challenge: The challenge that has been received in the step “Requesting a challenge”
- walletPrivateKey: The private key of the Ethereum wallet. It must be in a hexadecimal string e.g. “0xa2bc3d4f5…”
This will return a signed challenge as a hexadecimal string e.g. “0xa2bc3d4f5…”
Sending the challenge
To send the challenge, the following function has to be used:
sendSignedChallengeToServer(challenge, signedChallenge, [config])
Following variables are accepted:
- challenge: The challenge that has been received in the step “Requesting a challenge”.
- signedChallenge: The signed challenge that has been received in the step “Signing the challenge”.
- config: Optional configuration that are detailed in this page.