or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

address.mdbase-encoding.mdcrypto-init.mdethereum.mdhashing.mdindex.mdjson-encryption.mdkey-derivation-pbkdf.mdkey-derivation.mdkeypairs.mdmnemonic.mdrandom.mdsignatures.md

crypto-init.mddocs/

0

# Crypto Initialization

1

2

Core initialization functions to prepare the WebAssembly crypto backend before using cryptographic operations.

3

4

## Capabilities

5

6

### Crypto Wait Ready

7

8

Waits for the crypto WebAssembly backend to initialize and returns a promise indicating success or failure.

9

10

```typescript { .api }

11

/**

12

* Wait for the crypto WebAssembly backend to initialize

13

* @returns Promise that resolves to true on success, false on failure

14

*/

15

function cryptoWaitReady(): Promise<boolean>;

16

```

17

18

**Usage Example:**

19

20

```typescript

21

import { cryptoWaitReady } from "@polkadot/util-crypto";

22

23

// Wait for crypto to be ready before performing operations

24

const isReady = await cryptoWaitReady();

25

if (isReady) {

26

// Safe to use crypto functions

27

console.log("Crypto backend is ready");

28

} else {

29

console.error("Failed to initialize crypto backend");

30

}

31

```

32

33

### Crypto Is Ready

34

35

Synchronously checks if the crypto WebAssembly backend is ready for use.

36

37

```typescript { .api }

38

/**

39

* Check if the crypto WebAssembly backend is ready

40

* @returns true if ready, false otherwise

41

*/

42

function cryptoIsReady(): boolean;

43

```

44

45

**Usage Example:**

46

47

```typescript

48

import { cryptoIsReady, cryptoWaitReady } from "@polkadot/util-crypto";

49

50

// Check if already ready

51

if (cryptoIsReady()) {

52

// Use crypto functions immediately

53

} else {

54

// Need to wait

55

await cryptoWaitReady();

56

}

57

```

58

59

## Notes

60

61

- Always call `cryptoWaitReady()` before using any cryptographic functions

62

- The WebAssembly backend provides performance-critical implementations

63

- In browser environments, the backend may take time to load and compile

64

- Functions will throw errors if used before the backend is ready