Construction

Depending on your use-case and specific needs, constructing a LearnCard is likely as simple as the following code:

import { initLearnCard } from '@learncard/init';

const learnCard = await initLearnCard({ seed: 'abc123' });

For a full description of instantiating a LearnCard by configuration, check out the full documentation on the initLearnCard function:

Key Generation

There be dragons here. 🐉

In production environments, take great care and caution when generating and storing key material. Insufficient entropy or insecure storage, among other vectors, can easily compromise your data and identities.

How to generate and store keys is left to you, the consumer. However, if you'd like to simply generate a random key, you can do so with the following code:

const randomKey = Array.from(crypto.getRandomValues(new Uint8Array(32)), dec =>
  dec.toString(16).padStart(2, "0")
).join("");

To speed up instantiation of the wallet, you can host our didkit wasm binary yourself.

// Make sure you have the didkit plugin installed! pnpm i @learncard/didkit-plugin

import { initLearnCard } from '@learncard/init';
import didkit from '@learncard/didkit-plugin/dist/didkit/didkit_wasm_bg.wasm';

const learnCard = await initLearnCard({ seed: 'abc123', didkit });

If you're curious about what the above code is doing, read more here.

Next, refer to our documentation on Managing Seed Phrase:

Last updated