Initialisation of SDK Client

Web & Electron: npm install @cruxpay/js-sdk

Initialize the SDK

import { CruxPay } from "@cruxpay/js-sdk";

// Manual key management
let cruxClient = new CruxPay.CruxClient({
    walletClientName: 'cruxdev',
    privateKey: "6bd397dc89272e71165a0e7d197b280c7a88ed5b1e44e1928c25455506f1968f" 
});


// Automatic key management
let cruxClient = new CruxPay.CruxClient({
    walletClientName: 'cruxdev',
    getEncryptionKey: () => getUserPassword() 
});

CruxClient takes in an ICruxPayPeerOptions object as input. This must contain walletClientName. You can get create and manage your walletClientName at CRUX Wallet Dashboard. Please feel free to contact us at [email protected] for any registration related queries.

Key Management

Key Management can be automatic or manual

In Automatic mode, getEncryptionKey is mandatory:

  • getEncryptionKey - For effective security of keys , CRUX requires integrators to implement a method getEncryptionKey which must return a user-specific encryption key. For maximum security, this key should ideally be derived from user input - password, PIN, fingerprint etc.

In Manual mode, privateKey is mandatory:

  • privateKey - Since responsibility of managing user's key is with the integrating wallet and not the CRUX SDK, privateKey must be injected. SDK will try to restore any existing ID linked to the privateKey automatically. If not, it will bind new ID creation (via registerCruxID method) to this privateKey.
ManualAutomatic
DefaultNOYES
StorageNo persistent storage used by SDK. Wallets store private key themselves.ICruxPayPeerOptions.storage is used to store key.
UsageInitialise SDK with privateKey option in ICruxPayPeerOptions.

We strongly recommend to derive from path m/889'/0'/0' for CRUX ID keys for easy portability of IDs.
Initialise SDK without privateKey option in ICruxPayPeerOptions.

Now when a new ID is registered, private key will be stored by the SDK inside ICruxPayPeerOptions.storage

📘

Storage

In manual key management mode, CRUX does not need any storage. The user's private key is injected into the SDK's constructor at runtime.

In automatic key management mode, CRUX needs some persistent storage. Our SDK automatically falls back to localStorage on web platforms.
You can override the storage using the storage parameter of ICruxPayPeerOptions if required.