- Add ratchet/ with ECIES-X25519-AEAD-Ratchet (Proposal 144), Garlic cloves, and ECIES DatabaseLookup replies - Add streaming/ with Ed25519-signed I2P Streaming (SYN/ACK/NACK/CLOSE/RESET, retransmit, window) and Repliable/Raw Datagrams - Add common/su3.mbt to parse and verify reseed .su3 bundles - Add Elligator2 encoding in crypto/ and OfflineSignature support in LeaseSet2 (flags bit 0) - Router: NTCP2 peer pool, floodfill NetDB crawl, transit tunnel relay, and Garlic/Streaming bridge - cmd/router: add --peer-dir, --su3, --reseed, --floodfill, --no-clock-skew - cmd/client: add --dest for persistent destination keys - Mark Phase 6 complete in README and document the transport scope (NTCP2 only, no SSU2)
161 lines
4.7 KiB
Plaintext
161 lines
4.7 KiB
Plaintext
// Generated using `moon info`, DON'T EDIT IT
|
|
package "experiments/moon_i2p/tunnel"
|
|
|
|
import {
|
|
"experiments/moon_i2p/common",
|
|
"experiments/moon_i2p/crypto",
|
|
"experiments/moon_i2p/encoding",
|
|
"experiments/moon_i2p/noise",
|
|
"moonbitlang/core/debug",
|
|
}
|
|
|
|
// Values
|
|
pub fn build_short_tunnel_request(Int32, Array[ShortHopBuildSpec], Array[Bytes]) -> (Array[Bytes], Array[(Int32, HopKeys)]) raise TunnelError
|
|
|
|
pub fn decrypt_short_build_record(Bytes, @common.Hash, @noise.KeyPair) -> (ShortBuildRequestRecord, HopKeys) raise TunnelError
|
|
|
|
pub fn decrypt_short_build_reply(HopKeys, Int32, Bytes) -> Byte raise TunnelError
|
|
|
|
pub fn decrypt_short_tunnel_replies(Array[Bytes], Array[(Int32, HopKeys)]) -> Array[Byte] raise TunnelError
|
|
|
|
pub fn encrypt_short_build_record(ShortBuildRequestRecord, @common.Hash, Bytes, @noise.KeyPair, padding? : Bytes) -> (Bytes, HopKeys) raise TunnelError
|
|
|
|
pub fn encrypt_short_build_reply(HopKeys, Int32, Byte, padding? : Bytes) -> Bytes raise TunnelError
|
|
|
|
pub fn fragment_message_to_cells(DeliveryTarget, UInt32, Bytes, Bytes, padding? : Bytes) -> Array[Bytes] raise TunnelError
|
|
|
|
pub fn make_slot_nonce(Int32) -> Bytes
|
|
|
|
pub fn pack_tunnel_cell(Bytes, Array[TunnelFragment], padding? : Bytes) -> Bytes raise TunnelError
|
|
|
|
pub fn process_short_tunnel_build_hop(Array[Bytes], @common.Hash, @noise.KeyPair, Byte, reply_padding? : Bytes) -> (ShortBuildRequestRecord, HopKeys, Int32, Array[Bytes]) raise TunnelError
|
|
|
|
pub fn tunnel_layer_decrypt(Bytes, Bytes, Bytes) -> Bytes raise TunnelError
|
|
|
|
pub fn tunnel_layer_encrypt(Bytes, Bytes, Bytes) -> Bytes raise TunnelError
|
|
|
|
pub fn unpack_tunnel_cell(Bytes) -> Array[TunnelFragment] raise TunnelError
|
|
|
|
// Errors
|
|
#derive(Eq, @debug.Debug)
|
|
pub suberror TunnelError {
|
|
Crypto(@crypto.CryptoError)
|
|
Encoding(@encoding.EncodingError)
|
|
Common(@common.CommonError)
|
|
Noise(@noise.NoiseError)
|
|
InvalidLength(String)
|
|
InvalidFormat(String)
|
|
ChecksumMismatch
|
|
RecordNotForUs
|
|
}
|
|
|
|
// Types and methods
|
|
#derive(Eq, @debug.Debug)
|
|
pub(all) enum DeliveryTarget {
|
|
Local
|
|
Tunnel(tunnel_id~ : UInt32, gateway~ : @common.Hash)
|
|
Router(router_hash~ : @common.Hash)
|
|
}
|
|
|
|
pub struct FragmentReassembler {
|
|
// private fields
|
|
}
|
|
pub fn FragmentReassembler::new() -> Self
|
|
pub fn FragmentReassembler::push(Self, TunnelFragment) -> (DeliveryTarget, Bytes)?
|
|
|
|
#derive(Eq, @debug.Debug)
|
|
pub(all) struct HopKeys {
|
|
reply_key : Bytes
|
|
layer_key : Bytes
|
|
iv_key : Bytes
|
|
handshake_hash : Bytes
|
|
garlic_key : Bytes?
|
|
garlic_tag : Bytes?
|
|
}
|
|
|
|
#derive(Eq, @debug.Debug)
|
|
pub(all) struct ShortBuildRequestRecord {
|
|
receive_tunnel_id : UInt32
|
|
next_tunnel_id : UInt32
|
|
next_ident : @common.Hash
|
|
flag : Byte
|
|
layer_enc_type : Byte
|
|
request_time_min : UInt32
|
|
request_expiration_sec : UInt32
|
|
send_message_id : UInt32
|
|
options : @common.Mapping
|
|
}
|
|
pub fn ShortBuildRequestRecord::decode_154(Bytes) -> Self raise TunnelError
|
|
pub fn ShortBuildRequestRecord::encode_154(Self, padding? : Bytes) -> Bytes raise TunnelError
|
|
|
|
#derive(Eq, @debug.Debug)
|
|
pub(all) struct ShortHopBuildSpec {
|
|
slot_idx : Int32
|
|
hop_ident : @common.Hash
|
|
hop_static_pub : Bytes
|
|
ephemeral : @noise.KeyPair
|
|
record : ShortBuildRequestRecord
|
|
padding : Bytes
|
|
}
|
|
|
|
#derive(Eq, @debug.Debug)
|
|
pub(all) struct TransitHop {
|
|
receive_tunnel_id : UInt32
|
|
next_tunnel_id : UInt32
|
|
next_router : @common.Hash
|
|
layer_key : Bytes
|
|
iv_key : Bytes
|
|
is_obep : Bool
|
|
expires_sec : UInt32
|
|
}
|
|
|
|
#derive(Eq, @debug.Debug)
|
|
pub(all) struct Tunnel {
|
|
id : UInt32
|
|
direction : TunnelDirection
|
|
hops : Array[TunnelHop]
|
|
created_sec : UInt32
|
|
expires_sec : UInt32
|
|
}
|
|
pub fn Tunnel::decrypt_inbound_cell(Self, Bytes) -> Bytes raise TunnelError
|
|
pub fn Tunnel::prepare_outbound_cell(Self, Bytes) -> Bytes raise TunnelError
|
|
|
|
#derive(Eq, @debug.Debug)
|
|
pub(all) enum TunnelDirection {
|
|
Inbound
|
|
Outbound
|
|
}
|
|
|
|
#derive(Eq, @debug.Debug)
|
|
pub(all) enum TunnelFragment {
|
|
First(target~ : DeliveryTarget, fragmented~ : Bool, msg_id~ : UInt32, data~ : Bytes)
|
|
FollowOn(frag_num~ : Int32, is_last~ : Bool, msg_id~ : UInt32, data~ : Bytes)
|
|
}
|
|
|
|
#derive(Eq, @debug.Debug)
|
|
pub(all) struct TunnelHop {
|
|
router_hash : @common.Hash
|
|
receive_tunnel_id : UInt32
|
|
next_tunnel_id : UInt32
|
|
layer_key : Bytes
|
|
iv_key : Bytes
|
|
}
|
|
|
|
pub struct TunnelManager {
|
|
inbound : Array[Tunnel]
|
|
outbound : Array[Tunnel]
|
|
transit : Array[TransitHop]
|
|
}
|
|
pub fn TunnelManager::add_transit_hop(Self, TransitHop) -> Unit
|
|
pub fn TunnelManager::add_tunnel(Self, Tunnel) -> Unit
|
|
pub fn TunnelManager::inbound_count(Self) -> Int32
|
|
pub fn TunnelManager::new() -> Self
|
|
pub fn TunnelManager::outbound_count(Self) -> Int32
|
|
pub fn TunnelManager::prune_expired(Self, UInt32) -> Int32
|
|
pub fn TunnelManager::relay_cell(Self, UInt32, Bytes) -> (@common.Hash, UInt32, Bytes, Bool)? raise TunnelError
|
|
pub fn TunnelManager::transit_count(Self) -> Int32
|
|
|
|
// Type aliases
|
|
|
|
// Traits
|