---
title: llarp::SecretKey
summary: Stores a sodium "secret key" value, which is actually the seed concatenated with the public key. 

---

# llarp::SecretKey



Stores a sodium "secret key" value, which is actually the seed concatenated with the public key.  [More...](#detailed-description)


`#include <types.hpp>`

Inherits from [llarp::AlignedBuffer< SECKEYSIZE >](Classes/structllarp_1_1AlignedBuffer.md)

## Public Functions

|                | Name           |
| -------------- | -------------- |
| | **[SecretKey](Classes/structllarp_1_1SecretKey.md#function-secretkey)**() =default |
| | **[SecretKey](Classes/structllarp_1_1SecretKey.md#function-secretkey)**(const byte_t * ptr) |
| | **[SecretKey](Classes/structllarp_1_1SecretKey.md#function-secretkey)**(const [AlignedBuffer](Classes/structllarp_1_1AlignedBuffer.md)< SECKEYSIZE > & seed) |
| | **[SecretKey](Classes/structllarp_1_1SecretKey.md#function-secretkey)**(const [AlignedBuffer](Classes/structllarp_1_1AlignedBuffer.md)< 32 > & seed) |
| bool | **[Recalculate](Classes/structllarp_1_1SecretKey.md#function-recalculate)**()<br>recalculate public component  |
| std::string_view | **[ToString](Classes/structllarp_1_1SecretKey.md#function-tostring)**() const |
| [PubKey](Classes/structllarp_1_1PubKey.md) | **[toPublic](Classes/structllarp_1_1SecretKey.md#function-topublic)**() const |
| bool | **[toPrivate](Classes/structllarp_1_1SecretKey.md#function-toprivate)**([PrivateKey](Classes/structllarp_1_1PrivateKey.md) & key) const<br>Computes the private key from the secret key (which is actually the seed)  |
| bool | **[LoadFromFile](Classes/structllarp_1_1SecretKey.md#function-loadfromfile)**(const fs::path & fname) |
| bool | **[SaveToFile](Classes/structllarp_1_1SecretKey.md#function-savetofile)**(const fs::path & fname) const |

## Additional inherited members

**Public Types inherited from [llarp::AlignedBuffer< SECKEYSIZE >](Classes/structllarp_1_1AlignedBuffer.md)**

|                | Name           |
| -------------- | -------------- |
| using std::array< byte_t, SIZE > | **[Data](Classes/structllarp_1_1AlignedBuffer.md#using-data)**  |

**Public Functions inherited from [llarp::AlignedBuffer< SECKEYSIZE >](Classes/structllarp_1_1AlignedBuffer.md)**

|                | Name           |
| -------------- | -------------- |
| virtual | **[~AlignedBuffer](Classes/structllarp_1_1AlignedBuffer.md#function-~alignedbuffer)**() =default |
| | **[AlignedBuffer](Classes/structllarp_1_1AlignedBuffer.md#function-alignedbuffer)**() |
| | **[AlignedBuffer](Classes/structllarp_1_1AlignedBuffer.md#function-alignedbuffer)**(const byte_t * data) |
| | **[AlignedBuffer](Classes/structllarp_1_1AlignedBuffer.md#function-alignedbuffer)**(const Data & buf) |
| [AlignedBuffer](Classes/structllarp_1_1AlignedBuffer.md) & | **[operator=](Classes/structllarp_1_1AlignedBuffer.md#function-operator=)**(const byte_t * data) |
| [AlignedBuffer](Classes/structllarp_1_1AlignedBuffer.md)< sz > | **[operator~](Classes/structllarp_1_1AlignedBuffer.md#function-operator~)**() const<br>bitwise NOT  |
| bool | **[operator==](Classes/structllarp_1_1AlignedBuffer.md#function-operator==)**(const [AlignedBuffer](Classes/structllarp_1_1AlignedBuffer.md) & other) const |
| bool | **[operator!=](Classes/structllarp_1_1AlignedBuffer.md#function-operator!=)**(const [AlignedBuffer](Classes/structllarp_1_1AlignedBuffer.md) & other) const |
| bool | **[operator<](Classes/structllarp_1_1AlignedBuffer.md#function-operator<)**(const [AlignedBuffer](Classes/structllarp_1_1AlignedBuffer.md) & other) const |
| bool | **[operator>](Classes/structllarp_1_1AlignedBuffer.md#function-operator>)**(const [AlignedBuffer](Classes/structllarp_1_1AlignedBuffer.md) & other) const |
| bool | **[operator<=](Classes/structllarp_1_1AlignedBuffer.md#function-operator<=)**(const [AlignedBuffer](Classes/structllarp_1_1AlignedBuffer.md) & other) const |
| bool | **[operator>=](Classes/structllarp_1_1AlignedBuffer.md#function-operator>=)**(const [AlignedBuffer](Classes/structllarp_1_1AlignedBuffer.md) & other) const |
| [AlignedBuffer](Classes/structllarp_1_1AlignedBuffer.md) | **[operator^](Classes/structllarp_1_1AlignedBuffer.md#function-operator^)**(const [AlignedBuffer](Classes/structllarp_1_1AlignedBuffer.md) & other) const |
| [AlignedBuffer](Classes/structllarp_1_1AlignedBuffer.md) & | **[operator^=](Classes/structllarp_1_1AlignedBuffer.md#function-operator^=)**(const [AlignedBuffer](Classes/structllarp_1_1AlignedBuffer.md) & other) |
| byte_t & | **[operator[]](Classes/structllarp_1_1AlignedBuffer.md#function-operator[])**(size_t idx) |
| const byte_t & | **[operator[]](Classes/structllarp_1_1AlignedBuffer.md#function-operator[])**(size_t idx) const |
| void | **[Fill](Classes/structllarp_1_1AlignedBuffer.md#function-fill)**(byte_t f) |
| Data & | **[as_array](Classes/structllarp_1_1AlignedBuffer.md#function-as-array)**() |
| const Data & | **[as_array](Classes/structllarp_1_1AlignedBuffer.md#function-as-array)**() const |
| byte_t * | **[data](Classes/structllarp_1_1AlignedBuffer.md#function-data)**() |
| const byte_t * | **[data](Classes/structllarp_1_1AlignedBuffer.md#function-data)**() const |
| bool | **[IsZero](Classes/structllarp_1_1AlignedBuffer.md#function-iszero)**() const |
| void | **[Zero](Classes/structllarp_1_1AlignedBuffer.md#function-zero)**() |
| virtual void | **[Randomize](Classes/structllarp_1_1AlignedBuffer.md#function-randomize)**() |
| Data::iterator | **[begin](Classes/structllarp_1_1AlignedBuffer.md#function-begin)**() |
| Data::iterator | **[end](Classes/structllarp_1_1AlignedBuffer.md#function-end)**() |
| Data::const_iterator | **[begin](Classes/structllarp_1_1AlignedBuffer.md#function-begin)**() const |
| Data::const_iterator | **[end](Classes/structllarp_1_1AlignedBuffer.md#function-end)**() const |
| bool | **[FromBytestring](Classes/structllarp_1_1AlignedBuffer.md#function-frombytestring)**([llarp_buffer_t](Classes/structllarp__buffer__t.md) * buf) |
| bool | **[BEncode](Classes/structllarp_1_1AlignedBuffer.md#function-bencode)**([llarp_buffer_t](Classes/structllarp__buffer__t.md) * buf) const |
| bool | **[BDecode](Classes/structllarp_1_1AlignedBuffer.md#function-bdecode)**([llarp_buffer_t](Classes/structllarp__buffer__t.md) * buf) |
| std::string_view | **[ToView](Classes/structllarp_1_1AlignedBuffer.md#function-toview)**() const |
| std::string | **[ToHex](Classes/structllarp_1_1AlignedBuffer.md#function-tohex)**() const |
| std::string | **[ShortHex](Classes/structllarp_1_1AlignedBuffer.md#function-shorthex)**() const |
| bool | **[FromHex](Classes/structllarp_1_1AlignedBuffer.md#function-fromhex)**(std::string_view str) |
| constexpr size_t | **[size](Classes/structllarp_1_1AlignedBuffer.md#function-size)**() |

**Public Attributes inherited from [llarp::AlignedBuffer< SECKEYSIZE >](Classes/structllarp_1_1AlignedBuffer.md)**

|                | Name           |
| -------------- | -------------- |
| constexpr size_t | **[SIZE](Classes/structllarp_1_1AlignedBuffer.md#variable-size)**  |


## Detailed Description

```cpp
struct llarp::SecretKey;
```

Stores a sodium "secret key" value, which is actually the seed concatenated with the public key. 

Note that the seed is _not_ the private key value itself, but rather the seed from which it can be calculated. 

## Public Functions Documentation

### function SecretKey

```cpp
SecretKey() =default
```


### function SecretKey

```cpp
inline explicit SecretKey(
    const byte_t * ptr
)
```


### function SecretKey

```cpp
inline explicit SecretKey(
    const AlignedBuffer< SECKEYSIZE > & seed
)
```


### function SecretKey

```cpp
inline explicit SecretKey(
    const AlignedBuffer< 32 > & seed
)
```


### function Recalculate

```cpp
bool Recalculate()
```

recalculate public component 

### function ToString

```cpp
inline std::string_view ToString() const
```


### function toPublic

```cpp
inline PubKey toPublic() const
```


### function toPrivate

```cpp
bool toPrivate(
    PrivateKey & key
) const
```

Computes the private key from the secret key (which is actually the seed) 

### function LoadFromFile

```cpp
bool LoadFromFile(
    const fs::path & fname
)
```


### function SaveToFile

```cpp
bool SaveToFile(
    const fs::path & fname
) const
```


-------------------------------

Updated on 2022-11-04 at 14:36:38 +0000