# Cryptography

### Wallet

The wallet data is stored inside a `KeyStore`

`AES-256-GCM` for symmetric encryption

`Argon2.IDkey` as Key Derivation Function

* time: `1`
* memory: `64 * 1024`
* threads: `4`
* key\_length: `32`

An encrypted `KeyStore` is referred to as `KeyVault`.

### KeyVault Example

{% code overflow="wrap" %}

```json
{
  "baseAddress":"z1qqjnwjjpnue8xmmpanz6csze6tcmtzzdtfsww7",
  "crypto":{
    "argon2Params": {
      "salt":"0x1563f86f7afa59dd0be150ffeac10896"
    },
    "cipherData":"0xe81dbb96f5b9839f3741ceff8362e1ebf09e05a8311354658ddf979577ffd0dd34df55757d1fd37e677e3ae7d055b2ed",
    "cipherName":"aes-256-gcm",
    "kdf":"argon2.IDKey",
    "nonce":"0xb7cc39120d5b87a3b7af58b7"
  },
  "timestamp":1633548746,
  "version":1
}
```

{% endcode %}

### Digital Signing Algorithm

`Ed25519` is a deterministic signature scheme using `curve25519`

### Key Derivation

`Ed25519` which is compatible with `BIP44`

* key parameter: `ed25519 seed`
* hardened offset: `0x80000000`

### BIP44 Format

{% code overflow="wrap" %}

```
m / purpose' / coin_type' / account' / change / address_index
```

{% endcode %}

Alphanet (Network of Momentum Phase 0) uses `coin_type` value `73404`

### Alphanet Address Format

`bech32`

* human readable part: `z`

`data`

* user account prefix byte: `0`
* embedded contract prefix byte: `1`
* core: first `19` bytes of `sha3(pubKey)`

address: `bech32(hrp, data)`

#### Example

#### Entropy

{% code overflow="wrap" %}

```
bc827d0a00a72354dce4c44a59485288500b49382f9ba88a016351787b7b15ca
```

{% endcode %}

#### Mnemonic

{% code overflow="wrap" %}

```
route become dream access impulse price inform obtain engage ski believe awful absent pig thing vibrant possible exotic flee pepper marble rural fire fancy
```

{% endcode %}

#### BIP44 Path

```
m/44'/73404'/0'
```

#### Private Key

{% code overflow="wrap" %}

```
d6b01f96b566d7df9b5b53b1971e4baeb74cc64167a9843f82d04b2194ca4863
```

{% endcode %}

#### Public Key

{% code overflow="wrap" %}

```
3e13d7238d0e768a567dce84b54915f2323f2dcd0ef9a716d9c61abed631ba10
```

{% endcode %}

#### User Prefix Byte

```
00
```

#### Core Bytes

{% code overflow="wrap" %}

```
25374a419f32736f61ecc5ac4059d2f1b5884d
```

{% endcode %}

#### Address

{% code overflow="wrap" %}

```
z1qqjnwjjpnue8xmmpanz6csze6tcmtzzdtfsww7
```

{% endcode %}

### Zenon Dart SDK Example

#### Code

```dart
import 'package:hex/hex.dart';
import 'package:znn_sdk_dart/znn_sdk_dart.dart';

Future<void> main() async {
  final mnemonic =
      'route become dream access impulse price inform obtain engage ski believe awful absent pig thing vibrant possible exotic flee pepper marble rural fire fancy';

  var keyStore = KeyStore.fromMnemonic(mnemonic);
  var keyPair = keyStore.getKeyPair(0);
  var privateKey = keyPair.getPrivateKey();
  var publicKey = await keyPair.getPublicKey();
  var address = await keyPair.address;

  print('Entropy: \n${keyStore.entropy}\n');
  print('Mnemonic: \n${keyStore.mnemonic}\n');
  print('BIP44 path: \n${Derivation.getDerivationAccount(0)}\n');
  print('Private key: \n${HEX.encode(privateKey!)}\n');
  print('Public key: \n${HEX.encode(publicKey!)}\n');
  print('User & Core bytes: \n${HEX.encode(address!.core!)}\n');
  print('Address: \n$address');
}
```

#### Output

{% code overflow="wrap" %}

```
Entropy:
bc827d0a00a72354dce4c44a59485288500b49382f9ba88a016351787b7b15ca

Mnemonic:
route become dream access impulse price inform obtain engage ski believe awful absent pig thing vibrant possible exotic flee pepper marble rural fire fancy

BIP44 path:
m/44'/73404'/0'

Private key:
d6b01f96b566d7df9b5b53b1971e4baeb74cc64167a9843f82d04b2194ca4863

Public key:
3e13d7238d0e768a567dce84b54915f2323f2dcd0ef9a716d9c61abed631ba10

User & Core bytes:
0025374a419f32736f61ecc5ac4059d2f1b5884d

Address:
z1qqjnwjjpnue8xmmpanz6csze6tcmtzzdtfsww7
```

{% endcode %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.zenon.org/hypercore/technical/legacy/cryptography.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
