Authentication
The DemosWebAuth
class provides methods for generating a KeyPair , storing it (in memory), signing messages and verifying them using a KeyPair.
You can create the DemosWebAuth
class as a singleton to manage your KeyPair across your application, as shown:
If you are not planning to use the class to manage your KeyPair, you can create a new instance directly.
Generating a KeyPair
With the web auth instance created, you can generate a KeyPair using .create
.
The .create
method generates a new KeyPair and saves it to identity
. The method returns a status and a stringified version of the KeyPair. If the KeyPair generation failed, the KeyPair returned will be an empty object.
Recovering a KeyPair from Mnemonics
You can recover your KeyPair from a mnemonic string as shown below:
If you have a bip39
seed, you can recover the keypair in a similar manner.
Logging in with a private key
You can login with a private key to the DemosWebInstance
as shown:
The private key can be a hex string, or a binary buffer representation of the key. The login
method returns a status and a status message.
Viewing your keys as Hex
You can view your keys as hex string as shown:
Signing messages
You can sign messages using your logged in KeyPair by calling .sign
Verifying signatures
You can verify signatures by passing your message, signature and public key to .verify
Logging out
Once you are done with your instance, remove your keypair.
API Reference
Last updated