Register and Generate Keys

Once you've initialised your NotVault library as detailed in the previous section, you're now ready to register an account and perform key generation.

To register an account and generate keys in a TypeScript environment, follow the steps below:

  1. Import the necessary libraries:

    import { NotVault } from '@notcentralised/notvault-sdk';
  2. Instantiate the NotVault class:

    const vault = new NotVault();
  3. Register the contact ID and keys:

    • Use the .register method of the vault instance to register the account. This method takes in several parameters and callback functions to facilitate the registration process.

    • The parameters for this method include the wallet address, email or 0xWallet, and the secret key.

    • The callback functions include retrieving the public key from the crypto wallet, decrypting with the crypto wallet, and a success callback that logs the public key and contact ID.

    await vault.register(
        '... Wallet Address ...', 
        '... Email or 0xWallet ...',
        '... Secret Key ...',
        async () => { return '... Public Key ...'; }, // Retrieve public key from crypto wallet    
        async (encryptedPrivateKey: string) => { return '... Private Key ...'; }, // Decrypt with crypt wallet
        async (publicKey: string, contactId: string) => { console.log('Success!', publicKey, contactId); } // Success

With these steps, your account is registered in NotVault and your keys are properly set up for further operations. This registration process is an essential step for successfully using NotVault to perform secure and confidential operations on your data and tokens.

Last updated