---
title: "Class: RandomSecret"
canonical_url: "https://nimiq.dev/web-client/reference/classes/randomsecret"
---
# Class: RandomSecret

[@nimiq/core](../globals) / RandomSecret

Defined in: @nimiq/core/types/wasm/web.d.ts:2022

A random secret that proves a [Commitment](Commitment) for signing multisignature transactions.
It is supposed to be kept secret (similar to a private key).

## Constructors

### Constructor

> **new RandomSecret**(`bytes`): `RandomSecret`

Defined in: @nimiq/core/types/wasm/web.d.ts:2053

Creates a new random secret from a byte array.

Throws when the byte array is not exactly 32 bytes long.

#### Parameters

##### bytes

`Uint8Array`

#### Returns

`RandomSecret`

## Properties

### serializedSize

> `readonly` **serializedSize**: `number`

Defined in: @nimiq/core/types/wasm/web.d.ts:2062

---

### SIZE

> `readonly` `static` **SIZE**: `number`

Defined in: @nimiq/core/types/wasm/web.d.ts:2063

## Methods

### __getClassname()

> **__getClassname**(): `string`

Defined in: @nimiq/core/types/wasm/web.d.ts:2025

#### Returns

`string`

---

### [dispose]()

> **[dispose]**(): `void`

Defined in: @nimiq/core/types/wasm/web.d.ts:2024

#### Returns

`void`

---

### equals()

> **equals**(`other`): `boolean`

Defined in: @nimiq/core/types/wasm/web.d.ts:2035

Returns if this random secret is equal to the other random secret.

#### Parameters

##### other

`RandomSecret`

#### Returns

`boolean`

---

### free()

> **free**(): `void`

Defined in: @nimiq/core/types/wasm/web.d.ts:2023

#### Returns

`void`

---

### serialize()

> **serialize**(): `Uint8Array`

Defined in: @nimiq/core/types/wasm/web.d.ts:2057

Serializes the random secret to a byte array.

#### Returns

`Uint8Array`

---

### toHex()

> **toHex**(): `string`

Defined in: @nimiq/core/types/wasm/web.d.ts:2061

Formats the random secret into a hex string.

#### Returns

`string`

---

### deserialize()

> `static` **deserialize**(`bytes`): `RandomSecret`

Defined in: @nimiq/core/types/wasm/web.d.ts:2031

Deserializes a random secret from a byte array.

Throws when the byte array contains less than 32 bytes.

#### Parameters

##### bytes

`Uint8Array`

#### Returns

`RandomSecret`

---

### fromAny()

> `static` **fromAny**(`secret`): `RandomSecret`

Defined in: @nimiq/core/types/wasm/web.d.ts:2041

Parses a random secret from a RandomSecret instance, a hex string representation, or a byte array.

Throws when a RandomSecret cannot be parsed from the argument.

#### Parameters

##### secret

`string` | `Uint8Array`<`ArrayBufferLike`> | `RandomSecret`

#### Returns

`RandomSecret`

---

### fromHex()

> `static` **fromHex**(`hex`): `RandomSecret`

Defined in: @nimiq/core/types/wasm/web.d.ts:2047

Parses a random secret from its hex representation.

Throws when the string is not valid hex format or when it represents less than 32 bytes.

#### Parameters

##### hex

`string`

#### Returns

`RandomSecret`


## Sitemap

See the full [sitemap](https://nimiq.dev/sitemap.md) for all pages.
