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
HoprSessionobject 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§
- 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
- 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 optionalIncomingPacketInfo. - Application
Data Out - Wrapper for outgoing
ApplicationDatawith optionalIncomingPacketInfo. - 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. - 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. The signature uses Keccak256 as the hash function.
- Challenge
- Contains the complete Proof-of-Relay challenge is a secp256k1 curve point.
- Channel
Entry - Overall description of a channel
- Channel
Parties - An immutable pair of addresses representing parties of a channel.
- Channel
Ticket Statistics - Contains ticket statistics for one or more channels.
- 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. - Dummy
Cover Traffic Type - 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.
- Hopr
- HOPR main object providing the entire HOPR node functionality
- Hopr
Keys - Hopr
Protocol Config - Complete configuration of the HOPR protocol stack.
- Hopr
Session - Represents the Session protocol socket over HOPR.
- 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 - 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.
- NoPath
Selector - A path selector that does not resolve any path, always returns
PathError::PathNotFound. - NoSumSMA
- Basic implementation of Simple Moving Average (SMA).
- 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.
- PeerId
- Identifier of a peer of the network.
- 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.
- Single
SumSMA - Basic implementation of Simple Moving Average (SMA).
- SrcDst
Pair - A pair of source and destination addresses representing a channel.
- Surb
Balancer Config - Configuration for the
SurbBalancer. - 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.
Enums§
- Account
Type - Type of the node account.
- Acknowledged
Ticket Status - Status of the acknowledged ticket.
- 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 - Core
Types Error - Enumeration of all core type related errors.
- Crypto
Error - Destination
Routing - Routing information containing forward or return routing options.
- 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 nework quality.
- 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. - Peer
Discovery - Processed indexer generated events.
- 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.- 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
Capability - Individual capabilities of a Session.
- 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.
- Telemetry
- Ticket
Event - Ticket events emitted from the packet processing pipeline.
- 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
- 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).
- 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.
- Into
Endian - 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.
- 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. - SMA
- Simple Moving Average trait.
- Saturating
Sub - A trait that adds an extension method to perform saturated substractions on
SystemTimeinstances. - ToHex
- A generic type that can be converted to a hexadecimal string.
- Traffic
Generation - A trait for types that can produce a stream of cover traffic routes.
- 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.
- 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_idcan decrypt it. - 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 - 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§
- 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 - 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 - Hopr
Pseudonym - Alias for the
Pseudonymused in the HOPR protocol. - 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
- 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
- U256
- XDai
Balance