---
# System prepended metadata

title: Way to generate dnet_keys.bin

---

# Way to generate dnet_keys.bin

Comments from Daniel: 

```
The dnet_keys.bin file is already in the repository, it does not need to be generated every time. On a Linux system, this file is included in the program using assembler code:

asm (
".text \ n"
"g_xkeys: \ n"
".incbin" ../dnet/dnet_keys.bin "\ n"
);

I think the same can be done in other systems (Windows, MAC), but I don’t know how.

As for the algorithm for generating this file, it may be as follows:

as its first half (g_xkeys.priv and g_xkeys.pub), you can take any dnet_key.dat file generated by the first launch of xdag with a blank password;
memcpy (& g_xkeys.priv, & another_dnet_key.priv, sizeof (struct dnet_key));
memcpy (& g_xkeys.pub, & another_dnet_key.pub, sizeof (struct dnet_key));

The last part (g_xkeys.sect0) can be generated by the dnet_random_sector function;
dnet_random_sector (g_xkeys.sect0.word);

The middle part (g_xkeys.sect0_encoded) can be obtained as follows:
memcpy (g_xkeys.sect0_encoded.word, g_xkeys.sect0.word, SECTOR_SIZE);
dfsrsa_crypt (g_xkeys.sect0_encoded.word, SECTOR_SIZE / sizeof (dfsrsa_t), & g_xkeys.priv, DNET_KEYLEN);

But the generation process takes time, so a pre-generated file is inserted into the program.
```