---
title: llarp/layers/flow/flow_identity.hpp

---

# llarp/layers/flow/flow_identity.hpp



## Namespaces

| Name           |
| -------------- |
| **[llarp](Namespaces/namespacellarp.md)** <br>[crypto.hpp] |
| **[llarp::layers](Namespaces/namespacellarp_1_1layers.md)**  |
| **[llarp::layers::flow](Namespaces/namespacellarp_1_1layers_1_1flow.md)**  |
| **[std](Namespaces/namespacestd.md)** <br>STL namespace.  |

## Classes

|                | Name           |
| -------------- | -------------- |
| struct | **[llarp::layers::flow::FlowIdentityPrivateKeys](Classes/structllarp_1_1layers_1_1flow_1_1FlowIdentityPrivateKeys.md)** <br>private keys used at the flow layer that are persistable.  |
| class | **[llarp::layers::flow::FlowIdentity](Classes/classllarp_1_1layers_1_1flow_1_1FlowIdentity.md)** <br>the local end of a one to one flow to a remote given a flow isolation metric (flow_tag) flows do not change their source/destination address but may change their flow tag/convo tag.  |
| struct | **[std::hash< llarp::layers::flow::FlowIdentity >](Classes/structstd_1_1hash_3_01llarp_1_1layers_1_1flow_1_1FlowIdentity_01_4.md)**  |




## Source code

```cpp
#pragma once

#include <oxenc/bt_producer.h>
#include <oxenc/bt_serialize.h>
#include <llarp/crypto/types.hpp>
#include <llarp/dht/key.hpp>
#include <memory>
#include <string_view>

#include "flow_addr.hpp"
#include "flow_establish.hpp"
#include "flow_info.hpp"
#include "flow_state.hpp"
#include "flow_tag.hpp"
#include "flow_traffic.hpp"

namespace llarp::layers::flow
{

  class FlowLayer;

  struct FlowIdentityPrivateKeys
  {
    PQKeyPair sntrup;
    SecretKey identity;
    SecretKey encryption;
    PrivateKey derivedKey;

    static FlowIdentityPrivateKeys
    keygen();

    const FlowAddr&
    public_addr() const;

    const dht::Key_t&
    keyspace_location() const;

   private:
    mutable FlowAddr _root_pubkey;
    mutable dht::Key_t _derived_pubkey;
  };

  struct deprecated_path_ensure_handler;

  class FlowIdentity
  {
    FlowLayer& _parent;
    const FlowIdentityPrivateKeys& _local_privkeys;
    FlowState _state;

   protected:
    friend struct deprecated_path_ensure_handler;
    FlowInfo _flow_info;

   public:
    const FlowInfo& flow_info{_flow_info};

    FlowIdentity(const FlowIdentity&) = delete;
    FlowIdentity(FlowIdentity&&) = delete;

    FlowIdentity(
        FlowLayer& parent, FlowAddr remote_addr, const FlowIdentityPrivateKeys& local_keys);

    void
    async_ensure_flow(FlowEstablish handshaker);

    void
    send_to_remote(std::vector<byte_t> dataum, FlowDataKind kind);

    void
    update_flow_tags(const std::set<flow::FlowTag>& tag);

    void
    prune_flow_tags();

    const FlowState& state{_state};

    bool
    operator==(const FlowIdentity& other) const;
  };
}  // namespace llarp::layers::flow

namespace std
{
  template <>
  struct hash<llarp::layers::flow::FlowIdentity>
  {
    size_t
    operator()(const llarp::layers::flow::FlowIdentity& ident) const
    {
      return std::hash<llarp::layers::flow::FlowInfo>{}(ident.flow_info);
    }
  };
}  // namespace std
```


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

Updated on 2023-04-27 at 04:17:17 +0000
