Crate hopr_lib

Crate hopr_lib 

Source
Expand description

HOPR library creating a unified Hopr object that can be used on its own, as well as integrated into other systems and libraries.

The Hopr object is standalone, meaning that once it is constructed and run, it will perform its functionality autonomously. The API it offers serves as a high-level integration point for other applications and utilities, but offers a complete and fully featured HOPR node stripped from top level functionality such as the REST API, key management…

The intended way to use hopr_lib is for a specific tool to be built on top of it; should the default hoprd implementation not be acceptable.

For most of the practical use cases, the hoprd application should be a preferable choice.

Re-exports§

pub use crate::config::SafeModule;
pub use crate::constants::MIN_NATIVE_BALANCE;
pub use crate::constants::SUGGESTED_NATIVE_BALANCE;
pub use crate::errors::HoprLibError;
pub use crate::errors::HoprStatusError;
pub use crate::state::HoprLibProcess;
pub use crate::state::HoprState;
pub use crate::traits::chain::CloseChannelResult;
pub use crate::traits::chain::OpenChannelResult;

Modules§

config
Configuration-related public types
constants
Various public constants.
crypto_traits
Re-exports from the generic cryptographic traits.
errors
Lists all errors thrown from this library.
network_notifier
session
HoprSession object providing the session functionality over the HOPR transport
socket
state
Functionality related to the HOPR node state.
traits
Public traits for interactions with this library.
utils
Utility module with helper types and functionality over hopr-lib behavior.

Structs§

AbortableList
List of Abortable tasks with each task identified by a unique key of type T.
AccountEntry
Represents a node announcement entry on the blockchain. This contains the node’s public key and optional announcement information (multiaddress).
AcknowledgedTicket
Contains acknowledgment information and the respective ticket
Acknowledgement
Unverified packet acknowledgement.
Address
Represents an Ethereum address
AnnouncementData
Structure containing data used for an on-chain announcement. That is an optional decapsulated multiaddress (with the /p2p/{peer_id} suffix removed) and mandatory keybinding KeyBinding.
ApplicationData
Represents the to-be-sent or received decrypted packet carrying the application-layer data.
ApplicationDataIn
Wrapper for incoming ApplicationData with optional IncomingPacketInfo.
ApplicationDataOut
Wrapper for outgoing ApplicationData with optional IncomingPacketInfo.
Balance
Represents a non-negative balance of some Currency.
Blake3
An incremental hash state that can accept any number of writes.
Blake3Output
An incremental reader for extended output, returned by Hasher::finalize_xof.
ChainKeypair
Represents a keypair consisting of a secp256k1 private and public key
ChainPath
Represents a NonEmptyPath that completely specifies a route using Addresses.
ChainSignature
Represents an ECDSA signature based on the secp256k1 curve with a recoverable public key. The signature uses Keccak256 as the hash function.
Challenge
Contains the complete Proof-of-Relay challenge is a secp256k1 curve point.
ChannelEntry
Overall description of a channel
ChannelParties
An immutable pair of addresses representing parties of a channel.
ChannelTicketStatistics
Contains ticket statistics for one or more channels.
ConnectedUdpStream
Mimics TCP-like stream functionality on a UDP socket by restricting it to a single counterparty and implements [tokio::io::AsyncRead] and [tokio::io::AsyncWrite]. The instance must always be constructed using a UdpStreamBuilder.
CorruptedChannelEntry
A wrapper around ChannelId representing a Channel that is corrupted.
DummyCoverTrafficType
EthereumChallenge
Represents and Ethereum challenge.
HalfKey
Represents a half-key used for the Proof-of-Relay.
HalfKeyChallenge
Represents a challenge for the half-key in Proof of Relay.
HashBase
Represents a generic 256-bit hash value.
Hopr
HOPR main object providing the entire HOPR node functionality
HoprKeys
HoprProtocolConfig
Complete configuration of the HOPR protocol stack.
HoprSession
Represents the Session protocol socket over HOPR.
HoprTransport
Interface into the physical transport mechanism allowing all off-chain HOPR-related tasks on the transport.
IncomingSession
Wrapper for incoming HoprSession along with other information extracted from the Start protocol during the session establishment.
IvKey
Convenience container for IV and key of a given primitive T.
K256EcdsaSigningEngine
ECDSA signing engine based on the pure Rust k256 crate.
KeyBinding
Holds the signed binding of the chain key and the packet key.
KeyIdent
Identifier of public keys.
Multiaddr
Representation of a Multiaddr.
NativeEcdsaSigningEngine
ECDSA signing engine based on the fast secp256k1 crate.
NeighborTelemetry
Network
The network object storing information about the running observed state of the network, including peers, connection qualities, and updates for other parts of the system.
NoPathSelector
A path selector that does not resolve any path, always returns PathError::PathNotFound.
NoSumSMA
Basic implementation of Simple Moving Average (SMA).
OffchainKeypair
Represents a keypair consisting of an Ed25519 private and public key
OffchainPublicKey
Represents an Ed25519 public key.
OffchainSignature
Represents an EdDSA signature using the Ed25519 Edwards curve.
PeerId
Identifier of a peer of the network.
PingQueryReplier
Helper object allowing to send a ping query as a wrapped channel combination that can be filled up on the transport part and awaited locally by the Pinger.
Poly1305
The Poly1305 universal hash function.
PublicKey
Represents a secp256k1 public key.
RedeemableTicket
Represents a winning ticket that can be successfully redeemed on-chain.
Response
Contains a response upon ticket acknowledgement It is equivalent to a non-zero secret scalar on secp256k1 (EC private key).
SecretValue
Represents a secret value of a fixed length that is zeroized on drop. Secret values are always compared in constant time. The default value is all zeroes.
SerializableLog
A type containing selected fields from the eth_getLogs RPC calls.
SessionClientConfig
Configuration for the session.
SessionId
Unique ID of a specific Session in a certain direction.
SimplePseudonym
Represents a simple UUID-like pseudonym consisting of 10 bytes.
SingleSumSMA
Basic implementation of Simple Moving Average (SMA).
SrcDstPair
A pair of source and destination addresses representing a channel.
SurbBalancerConfig
Configuration for the SurbBalancer.
Ticket
Contains the overall description of a ticket with a signature.
TicketBuilder
Builder for the Ticket and VerifiedTicket.
TicketId
A ticket is uniquely identified by its channel id, ticket index and epoch.
TransferableWinningTicket
Represents a ticket that could be transferred over the wire and independently verified again by the other party.
TransportPath
A NonEmptyPath that can be used to route packets using OffchainPublicKey.
UdpStreamBuilder
Builder object for the ConnectedUdpStream.
UnacknowledgedTicket
Represents a VerifiedTicket with an unknown other part of the HalfKey. Once the other HalfKey is known (forming a Response), it can be acknowledged.
Utc
The UTC time zone. This is the most efficient time zone when you don’t need the local time. It is also used as an offset (which is also a dummy type).
ValidatedPath
Represents NonEmptyPath that has been resolved and validated.
VerifiedAcknowledgement
Represents packet acknowledgement whose signature has been already verified.
VerifiedTicket
Holds a ticket that has been already verified. This structure guarantees that Ticket::get_hash() of VerifiedTicket::verified_ticket() is always equal to VerifiedTicket::verified_hash
VrfParameters
Bundles values given to the smart contract to prove that a ticket is a win.
WinningProbability
Represents a ticket-winning probability.
WxHOPR
Represents wxHOPR token Currency.
XDai
Represents xDai coin Currency.

Enums§

AccountType
Type of the node account.
AcknowledgedTicketStatus
Status of the acknowledged ticket.
ChannelChange
Lists possible changes on a channel entry update
ChannelDirection
Describes a direction of node’s own channel. The direction of a channel that is not own is undefined.
ChannelStatus
Describes status of a channel
ChannelStatusDiscriminants
CoreTypesError
Enumeration of all core type related errors.
CryptoError
DestinationRouting
Routing information containing forward or return routing options.
ForeignDataMode
Defines what happens when data from another SocketAddr arrives into the ConnectedUdpStream (other than the one that is considered a counterparty for that instance).
GeneralError
Listing of some general re-usable errors
Health
Network health represented with colors, where green is the best and red is the worst possible observed nework quality.
HoprTransportProcess
IdentityRetrievalModes
IpOrHost
Implements a host name with port. This could be either a DNS name with port or an IP address with port represented by std::net::SocketAddr.
IpProtocol
Lists some of the IP protocols.
NodeId
Uniquely identifies a HOPR node either by its Address or OffchainPublicKey.
PeerDiscovery
Processed indexer generated events.
PendingAcknowledgement
Contains either unacknowledged ticket if we’re waiting for the acknowledgement as a relayer or information if we wait for the acknowledgement as a sender.
ProbeError
Protocol
Protocol describes all possible multiaddress protocols.
ResolvedTransportRouting
Contains the resolved routing information for the packet.
RoutingOptions
Represents routing options in a mixnet with a maximum number of hops.
SealedHost
Contains optionally encrypted IpOrHost.
SessionCapability
Individual capabilities of a Session.
SessionManagerError
SessionTarget
Defines what should happen with the data at the recipient where the data from the established session are supposed to be forwarded to some target.
SurbMatcher
Allows finding saved SURBs based on different criteria.
Tag
Tags distinguishing different application-layer protocols.
Telemetry
TicketEvent
Ticket events emitted from the packet processing pipeline.
TransportSessionError
Enumeration of errors thrown from this library.
UdpStreamParallelism
Determines how many parallel readers or writer sockets should be bound in ConnectedUdpStream.

Constants§

APPLICATION_TAG_RANGE
DEFAULT_MAXIMUM_INCOMING_TICKET_WIN_PROB
Default maximum incoming ticket winning probability, above which tickets will not be accepted due to privacy.
DEFAULT_MINIMUM_INCOMING_TICKET_WIN_PROB
Default required minimum incoming ticket winning probability
INTERMEDIATE_HOPS
Number of intermediate hops: 3 relayers and 1 destination
PACKET_TAG_LENGTH
Length of a packet tag
REDEEM_CALL_SELECTOR
Define the selector for the redeemTicketCall to avoid importing the entire hopr-bindings crate for one single constant. This value should be updated with the function interface changes.
SESSION_MTU
Number of bytes that can be sent in a single Session protocol payload.
SURB_SIZE
Size of the HOPR SURB in bytes.

Traits§

Abortable
Abstraction over tasks that can be aborted (such as join or abort handles).
AsUnixTimestamp
A trait that’s added an extension method to represent a time object as Duration since Unix epoch.
BytesEncodable
Represents a type that can be encoded to/decoded from a fixed-sized byte array of size N.
BytesRepresentable
Represents a type already internally represented by a fixed size byte array, and therefore requires no memory allocation to represent the type in binary encoding.
Currency
Represents a general currency - like a token or a coin.
EcdsaEngine
Trait for ECDSA signature engines.
IntoEndian
Extension trait for fixed size numbers to allow conversion to/from endian representations.
Keypair
Represents a generic key pair The keypair contains a private key and public key. Must be comparable in constant time and zeroized on drop.
NonEmptyPath
A Path that is guaranteed to have at least one hop - the destination.
Path
Base implementation of an abstract path.
PathAddressResolver
Allows resolution of OffchainPublicKey for a given Address or vice versa and retrieval of ChannelEntry based on the parties.
PathSelector
Trait for implementing a custom path selection algorithm from the channel graph.
Pseudonym
Pseudonym used to identify the creator of a SURB. This allows indexing SURB and LocalSURBEntry at both parties.
SMA
Simple Moving Average trait.
SaturatingSub
A trait that adds an extension method to perform saturated substractions on SystemTime instances.
ToHex
A generic type that can be converted to a hexadecimal string.
TrafficGeneration
A trait for types that can produce a stream of cover traffic routes.
UnitaryFloatOps
Allows type to be multiplied and divided by a float in range [0.0, 1.0].

Functions§

blake3_hash
The default hash function.
decapsulate_multiaddress
Decapsulates the multiaddress (= strips the /p2p/<peer_id> suffix). If it is already decapsulated, the function is an identity.
derive_vrf_parameters
Takes a private key, the corresponding Ethereum address and a payload and creates all parameters that are required by the smart contract to prove that a ticket is a win.
f64_approx_eq
Approximately compares two double-precision floats.
generate_channel_id
Generates channel ID hash from source and destination addresses.
is_public
Check if an IP address is a public/routable one.
is_public_address
Check if a multiaddress contains a public/routable IP address.
k256_scalar_from_bytes
Creates secp256k1 secret scalar from the given bytes. Note that this function allows zero scalars.
prepare_tokio_runtime
Prepare an optimized version of the tokio runtime setup for hopr-lib specifically.
sample_secp256k1_field_element
Sample a random secp256k1 field element that can represent a valid secp256k1 point.
seal_data
Performs randomized encryption of the given data, so that only the recipient with the given peer_id can decrypt it.
to_hex_shortened
Converts the given data into a hex string, removing the middle part of the string if it is longer than M of hex characters.
transfer_session
Convenience function to copy data in both directions between a Session and arbitrary async IO stream. This function is only available with Tokio and will panic with other runtimes.
unseal_data
Decrypts a data previously encrypted with seal_data.
x25519_scalar_from_bytes
Creates X25519 secret scalar (also compatible with Ed25519 scalar) from the given bytes. This function ensures the value is pre-multiplied by the curve’s co-factor and already reduced mod 2^255-19.

Type Aliases§

Aes128Ctr
AES with 128-bit key in counter-mode (with big-endian counter).
ChaCha20
ChaCha20 stream cipher (RFC 8439 version with 96-bit nonce)
ChannelId
Alias for the Hash representing a channel ID.
ChannelPath
EncodedWinProb
Winning probability encoded in 7-byte representation
Hash
Represents an Ethereum 256-bit hash value.
HashFast
Represents an alternative 256-bit hash value computed via a faster hashing algorithm.
HoprBalance
HoprPseudonym
Alias for the Pseudonym used in the HOPR protocol.
HoprTransportIO
Type alias used to send and receive transport data via a running HOPR node.
Keccak256
Keccak-256 hasher state.
PacketTag
Represents a fixed size packet verification tag
SecretKey
Represents a 256-bit secret key of fixed length. The value is auto-zeroized on drop.
SecretKey16
Represents a 128-bit secret key of fixed length. The value is auto-zeroized on drop.
ServiceId
Describes a node service target. These are specialized SessionTargets that are local to the Exit node and have different purposes, such as Cover Traffic.
SessionCapabilities
Set of Session capabilities.
Sha3_256
SHA-3-256 hasher state.
Signature
U256
XDaiBalance