---
title: llarp::PrivateKey
summary: PrivateKey is similar to SecretKey except that it only stores the private key value and a hash, unlike SecretKey which stores the seed from which the private key and hash value are generated. 

---

# llarp::PrivateKey



[PrivateKey]() is similar to [SecretKey](Classes/structllarp_1_1SecretKey.md) except that it only stores the private key value and a hash, unlike [SecretKey](Classes/structllarp_1_1SecretKey.md) which stores the seed from which the private key and hash value are generated.  [More...](#detailed-description)


`#include <types.hpp>`

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

## Public Functions

|                | Name           |
| -------------- | -------------- |
| | **[PrivateKey](Classes/structllarp_1_1PrivateKey.md#function-privatekey)**() =default |
| | **[PrivateKey](Classes/structllarp_1_1PrivateKey.md#function-privatekey)**(const byte_t * ptr) |
| | **[PrivateKey](Classes/structllarp_1_1PrivateKey.md#function-privatekey)**(const [AlignedBuffer](Classes/structllarp_1_1AlignedBuffer.md)< 64 > & key_and_hash) |
| const byte_t * | **[signingHash](Classes/structllarp_1_1PrivateKey.md#function-signinghash)**() const<br>Returns a pointer to the beginning of the 32-byte hash which is used for pseudorandomness when signing with this private key.  |
| byte_t * | **[signingHash](Classes/structllarp_1_1PrivateKey.md#function-signinghash)**()<br>Returns a pointer to the beginning of the 32-byte hash which is used for pseudorandomness when signing with this private key.  |
| std::string_view | **[ToString](Classes/structllarp_1_1PrivateKey.md#function-tostring)**() const |
| bool | **[toPublic](Classes/structllarp_1_1PrivateKey.md#function-topublic)**([PubKey](Classes/structllarp_1_1PubKey.md) & pubkey) const<br>Computes the public key.  |

## Additional inherited members

**Public Types inherited from [llarp::AlignedBuffer< 64 >](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< 64 >](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< 64 >](Classes/structllarp_1_1AlignedBuffer.md)**

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


## Detailed Description

```cpp
struct llarp::PrivateKey;
```

[PrivateKey]() is similar to [SecretKey](Classes/structllarp_1_1SecretKey.md) except that it only stores the private key value and a hash, unlike [SecretKey](Classes/structllarp_1_1SecretKey.md) which stores the seed from which the private key and hash value are generated. 

This is primarily intended for use with derived keys, where we can derive the private key but not the seed. 

## Public Functions Documentation

### function PrivateKey

```cpp
PrivateKey() =default
```


### function PrivateKey

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


### function PrivateKey

```cpp
inline explicit PrivateKey(
    const AlignedBuffer< 64 > & key_and_hash
)
```


### function signingHash

```cpp
inline const byte_t * signingHash() const
```

Returns a pointer to the beginning of the 32-byte hash which is used for pseudorandomness when signing with this private key. 

### function signingHash

```cpp
inline byte_t * signingHash()
```

Returns a pointer to the beginning of the 32-byte hash which is used for pseudorandomness when signing with this private key. 

### function ToString

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


### function toPublic

```cpp
bool toPublic(
    PubKey & pubkey
) const
```

Computes the public key. 

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

Updated on 2023-01-30 at 17:55:37 +0000