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 hopr_api as api;
Modules§
- api
- hopr-api
- builder
- Builder module for the
Hoprobject. Type-state builder for constructing aHoprnode. - 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.
- helpers 🔒
- Helper functions.
- session
HoprSessionobject providing the session functionality over the HOPR transport- socket
- utils
- Utility module with helper types and functionality over hopr-lib behavior.
Structs§
- Abortable
List - List of
Abortabletasks with each task identified by a unique key of typeT. - Account
Entry - Represents a node announcement entry on the blockchain. This contains the node’s public key and optional announcement information (multiaddress).
- Acknowledged
Ticket - Contains acknowledgment information and the respective ticket
- Acknowledgement
- Unverified packet acknowledgement.
- Address
- Represents an Ethereum address
- Announced
Peer - A peer that has been announced and discovered by the node.
- Announcement
Data - Structure containing data used for an on-chain announcement.
That is an optional decapsulated multiaddress (with the
/p2p/{peer_id}suffix removed) and mandatory keybindingKeyBinding. - Application
Data - Represents the to-be-sent or received decrypted packet carrying the application-layer data.
- Application
Data In - Wrapper for incoming
ApplicationDatawith optional [IncomingPacketInfo]. - Application
Data Out - Wrapper for outgoing
ApplicationDatawith optional [IncomingPacketInfo]. - Balance
- Represents a non-negative balance of some
Currency. - Blake3
- An incremental hash state that can accept any number of writes.
- Blake3
Output - An incremental reader for extended output, returned by
Hasher::finalize_xof. - Bounded
Vec - Wrapper for
Vecthat has an explicit upper bound on the number of elements. The Structure remains heap-allocated to avoid blowing up the size of types where it is used. - Chain
Keypair - Represents a keypair consisting of a secp256k1 private and public key
- Chain
Path - Represents a
NonEmptyPaththat completely specifies a route usingAddresses. - Chain
Signature - Represents an ECDSA signature based on the secp256k1 curve with a recoverable public key.
When signing messages, Keccak256 is used as the hash function;
sign_hashoperates on an arbitrary pre-computed hash. - Challenge
- Contains the complete Proof-of-Relay challenge is a secp256k1 curve point.
- Channel
Builder - Builder for
ChannelEntry. - Channel
Entry - Overall description of a channel
- Channel
Parties - An immutable pair of addresses representing parties of a channel.
- Channel
Stats - Contains ticket statistics for an incoming channel.
- Connected
UdpStream - 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 aUdpStreamBuilder. - Corrupted
Channel Entry - A wrapper around
ChannelIdrepresenting a Channel that is corrupted. - Ethereum
Challenge - Represents and Ethereum challenge.
- HalfKey
- Represents a half-key used for the Proof-of-Relay.
- Half
KeyChallenge - Represents a challenge for the half-key in Proof of Relay.
- Hash
Base - Represents a generic 256-bit hash value.
- HopRouting
- Public routing configuration for session opening in
hopr-lib. - Hopr
- HOPR main object providing the entire HOPR node functionality
- Hopr
Keys - Hopr
Protocol Config - Complete configuration of the HOPR protocol stack.
- Hopr
Sender Id - Identifier of a single packet sender.
- Hopr
Session - Represents the Session protocol socket over HOPR.
- Hopr
Session Client Config - Session client configuration for
hopr-lib. - Hopr
Session Configurator - Allows configuration of one specific
HoprSession. - Hopr
Transport - Interface into the physical transport mechanism allowing all off-chain HOPR-related tasks on the transport.
- Incoming
Session - Wrapper for incoming
HoprSessionalong with other information extracted from the Start protocol during the session establishment. - IvKey
- Convenience container for IV and key of a given primitive
T. - K256
Ecdsa Signing Engine - ECDSA signing engine based on the pure Rust
k256crate. - KeyBinding
- Holds the signed binding of the chain key and the packet key.
- KeyIdent
- Identifier of public keys.
- Multiaddr
- Representation of a Multiaddr.
- Native
Ecdsa Signing Engine - ECDSA signing engine based on the fast
secp256k1crate. - Neighbor
Telemetry - Intermediate neighbor telemetry object.
- NoPath
Selector - A path selector that does not resolve any path, always returns
PathError::PathNotFound. - Node
Component Statuses - Per-component status report for the HOPR node.
- Offchain
Keypair - Represents a keypair consisting of an Ed25519 private and public key
- Offchain
Public Key - Represents an Ed25519 public key.
- Offchain
Signature - Represents an EdDSA signature using the Ed25519 Edwards curve.
- Path
Telemetry - Path telemetry data for multi-hop loopback probing.
- PeerId
- Identifier of a peer of the network.
- Peer
Protocol Counter Registry - Thread-safe registry of per-peer protocol conformance counters.
- Ping
Query Replier - 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.
- Public
Key - Represents a secp256k1 public key.
- Redeemable
Ticket - 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).
- Secret
Value - 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.
- Serializable
Log - A type containing selected fields from the
eth_getLogsRPC calls. - Session
Client Config - Configuration for the session.
- Session
Id - Unique ID of a specific Session in a certain direction.
- Simple
Pseudonym - Represents a simple UUID-like pseudonym consisting of 10 bytes.
- SrcDst
Pair - A pair of source and destination addresses representing a channel.
- Surb
Balancer Config - Configuration for the
SurbBalancer. - TagAllocator
Config - Configuration for the tag allocator partitions.
- Ticket
- Contains the overall description of a ticket with a signature.
- Ticket
Builder - Builder for the
TicketandVerifiedTicket. - Ticket
Id - A ticket is uniquely identified by its channel id, ticket index and epoch.
- Transferable
Winning Ticket - Represents a ticket that could be transferred over the wire and independently verified again by the other party.
- Transport
Path - A
NonEmptyPaththat can be used to route packets usingOffchainPublicKey. - UdpStream
Builder - Builder object for the
ConnectedUdpStream. - Unacknowledged
Ticket - Represents a
VerifiedTicketwith an unknown other part of theHalfKey. Once the otherHalfKeyis known (forming aResponse), 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).
- Validated
Path - Represents
NonEmptyPaththat has been resolved and validated. - Verified
Acknowledgement - Represents packet acknowledgement whose signature has been already verified.
- Verified
Ticket - Holds a ticket that has been already verified.
This structure guarantees that
Ticket::get_hash()ofVerifiedTicket::verified_ticket()is always equal toVerifiedTicket::verified_hash - VrfParameters
- Bundles values given to the smart contract to prove that a ticket is a win.
- Winning
Probability - Represents a ticket-winning probability.
- WxHOPR
- Represents wxHOPR token
Currency. - XDai
- Represents xDai coin
Currency. - XHOPR
- Represents xHOPR token
Currency.
Enums§
- Account
Type - Type of the node account.
- Acknowledged
Ticket Status - Status of the acknowledged ticket.
- Announcement
Origin - Origin of a peer announcement — how the node learned about this peer.
- Channel
Change - Lists possible changes on a channel entry update
- Channel
Direction - Describes a direction of node’s own channel. The direction of a channel that is not own is undefined.
- Channel
Status - Describes status of a channel
- Channel
Status Discriminants - Auto-generated discriminant enum variants
- Core
Types Error - Enumeration of all core type related errors.
- Crypto
Error - Enumeration of all cryptography-related errors in this crate.
- Destination
Routing - Routing information containing forward or return routing options.
- Either
Err - Allows combining two errors
LandRinto a single error type that acts transparently. - Foreign
Data Mode - Defines what happens when data from another
SocketAddrarrives into theConnectedUdpStream(other than the one that is considered a counterparty for that instance). - General
Error - 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 network quality.
- Hopr
LibProcess 🔒 - Long-running tasks that are spawned by the HOPR node.
- Hopr
State - An enum representing the current state of the HOPR node.
- Hopr
Transport Process - Identity
Retrieval Modes - IpOr
Host - 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
AddressorOffchainPublicKey. - Pending
Acknowledgement - 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.
- Probe
Error - Protocol
Protocoldescribes all possible multiaddress protocols.- Redemption
Result - Indicates a non-error result of ticket redemption.
- Resolved
Transport Routing - Contains the resolved routing information for the packet.
- Routing
Options - Represents routing options in a mixnet with a maximum number of hops.
- Sealed
Host - Contains optionally encrypted
IpOrHost. - Session
AckMode - Session
Capability - Individual capabilities of a Session.
- Session
Lifecycle State - Session
Manager Error - Session
Target - 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. - Surb
Matcher - Allows finding saved SURBs based on different criteria.
- Tag
- Tags distinguishing different application-layer protocols.
- Transport
Session Error - Enumeration of errors thrown from this library.
- UdpStream
Parallelism - 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
- MIN_
BATCH_ SIZE - Minimum batch size of acknowledgements to use EdDSA batch verification algorithm.
- NODE_
READY_ 🔒TIMEOUT - Time to wait until the node’s keybinding appears on-chain
- 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_
ID_ SIZE - Size of the
HoprSurbIdin bytes. - SURB_
SIZE - Size of the HOPR SURB in bytes.
Traits§
- Abortable
- Abstraction over tasks that can be aborted (such as join or abort handles).
- AsUnix
Timestamp - A trait that’s added an extension method to represent a time object as
Durationsince Unix epoch. - Bytes
Encodable - Represents a type that can be encoded to/decoded from a fixed-sized byte array of size
N. - Bytes
Representable - 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.
- Ecdsa
Engine - Trait for ECDSA signature engines.
- Edge
Link Observable - Trait for recording and querying transport-level link quality metrics for a transport link.
- Hopr
Node Operations - General operations performed by a HOPR node.
- Hopr
Session Client Operations - Trait for establishing HOPR sessions to remote destinations.
- Incentive
Channel Operations - Channel management, balance queries, withdrawals, and chain info.
- Incentive
Redeem Operations - Ticket redemption and statistics.
- Into
Endian - Extension trait for fixed size numbers to allow conversion to/from endian representations.
- KeyId
Mapping - Trait that defines 1:1 mapper between key identifiers and public keys.
- 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.
- Network
Stream Control - Control object for the opening and receiving of network connections in the form of network streams.
- Network
View - Trait representing a read-only view of the network state.
- NonEmpty
Path - A
Paththat is guaranteed to have at least one hop - the destination. - Path
- Base implementation of an abstract path.
- Path
Address Resolver - Allows resolution of
OffchainPublicKeyfor a givenAddressor vice versa and retrieval ofChannelEntrybased on the parties. - Path
Selector - Trait for implementing a custom path selection algorithm from the channel graph.
- Pseudonym
- Pseudonym used to identify the creator of a
SURB. This allows indexingSURBandLocalSURBEntryat both parties. - Saturating
Sub - A trait that adds an extension method to perform saturated substractions on
SystemTimeinstances. - Ticket
Management - API for managing winning (redeemable) tickets in incoming channels.
- Ticket
Management Ext - Asynchronous extension trait for
TicketManagementthat adds convenience methods for ticket management. - ToHex
- A generic type that can be converted to a hexadecimal string.
- Transport
Operations - Minimal transport operations that require the full transport stack.
- Unitary
Float Ops - 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
sourceanddestinationaddresses. - 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.
- network_
health_ 🔒to_ status - Maps
Healthinto aComponentStatusfor a named component. - peer_
id_ to_ offchain_ key - Converts a PeerId to an OffchainPublicKey.
- peer_
id_ to_ public_ key - PeerId -> OffchainPublicKey is a CPU-intensive blocking operation.
- 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 - CURRENTLY NOT IMPLEMENTED, see https://github.com/hoprnet/hoprnet/issues/7172
- to_
hex_ shortened - Converts the given
datainto a hex string, removing the middle part of the string if it is longer thanMof hex characters. - transfer_
session - Convenience function to copy data in both directions between a
Sessionand arbitrary async IO stream. This function is only available with Tokio and will panic with other runtimes. - unseal_
data - CURRENTLY NOT IMPLEMENTED, see https://github.com/hoprnet/hoprnet/issues/7172
- 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§
- Aes128
Ctr - AES with 128-bit key in counter-mode (with big-endian counter).
- ChaCha20
- ChaCha20 stream cipher (RFC 8439 version with 96-bit nonce)
- Channel
Id - Alias for the
Hashrepresenting a channel ID. - Channel
Path - A path of
Addresses representing intermediate hops in a payment channel route. - Encoded
WinProb - Winning probability encoded in 7-byte representation
- Hash
- Represents an Ethereum 256-bit hash value.
- Hash
Fast - Represents an alternative 256-bit hash value computed via a faster hashing algorithm.
- Hopr
Balance - Balance denominated in wxHOPR (wrapped xHOPR) tokens.
- Hopr
Pseudonym - Alias for the
Pseudonymused in the HOPR protocol. - Hopr
Surb Id - An ID that uniquely identifies SURB for a certain pseudonym.
- Hopr
TransportIO - Type alias used to send and receive transport data via a running HOPR node.
- Keccak256
- Keccak-256 hasher state.
- Packet
Tag - Represents a fixed size packet verification tag
- PathId
- Identifier for a path traversed using an allowed
DestinationRoutingover the network. - Secret
Key - Represents a 256-bit secret key of fixed length. The value is auto-zeroized on drop.
- Secret
Key16 - Represents a 128-bit secret key of fixed length. The value is auto-zeroized on drop.
- Service
Id - Describes a node service target.
These are specialized
SessionTargetsthat are local to the Exit node and have different purposes, such as Cover Traffic. - Session
Capabilities - Set of Session capabilities.
- Sha3_
256 - SHA-3-256 hasher state.
- Signature
- Default ECDSA signature type using the native secp256k1 signing engine.
- Ticket
Events 🔒 - U256
- 256-bit unsigned integer type alias for [
primitive_types::U256]. - XDai
Balance - Balance denominated in xDai (native gas token).
- XHopr
Balance - Balance denominated in xHOPR tokens.