code wiki / (root) / nx_mse_dh.nx

nx_mse_dh.nx

buildroot/runtime/nx_mse_dh.nx

5016 B77 linesdepth 4pulls 5 transitivereach 18 importersview sourcekind tooltopic mse
docsdependenciesstructsconstsfunctions

about

nx_mse_dh.nx -- MSE/PE Diffie-Hellman key exchange (BitTorrent Message Stream Encryption anti-throttle). MSE hides the BitTorrent handshake from ISP DPI so it can't be fingerprinted + throttled. Step 1 is a DH exchange over a FIXED 768-bit prime P (the MSE/PE spec's prime) with generator G=2: each side picks a private Xa, sends Ya = G^Xa mod P; the shared secret S = Yb^Xa mod P = Ya^Xb mod P feeds the RC4 handshake keys. Composes bi_modexp (nx_bigint_modexp). P is 24 u32 limbs (768 bits). PUBLIC params -> no secrecy in P/G. nx_mse_dh -- no-arg = GATE: two parties derive the SAME S (Sa==Sb), pubkeys differ, S != 0. license_tier: ORIGINAL module: nishi-core.torrent.mse_dh depends: nishi-core.crypto.bigint_modexp

dependencies 1 imports · 1 importers

nx_bigint_modexp.nx nx_mse_dh.nx nx_mse_keys.nx

imports: nx_bigint_modexp.nx

imported by: nx_mse_keys.nx

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main md_load_p md_hex2bytes md_hv bi_from_bytes_be bi_zero bi_zero ↻ md_p mse_dh_public bi_zero ↻ bi_modexp bi_zero ↻ bi_copy bi_mod bi_zero ↻ bi_shl1 bi_cmp bi_sub bi_mul bi_zero ↻ mse_dh_shared bi_modexp ↻ md_nonzero md_eq if_s

structs

none

consts

12const MSE_N: i64 = 24 // 768-bit / 32 = 24 limbs
14const MSE_P_HEX: *u8 = "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A63A36210000000000090563" as *u8

functions

16func if_s(b: i64) -> *u8 { if b==1 { return "1" as *u8 } return "0" as *u8 }
called by 2: mainmain
17func md_p(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
called by 4: mainmainmainmain
18func md_hv(c: i64) -> i64 { if c>=48 { if c<=57 { return c-48 } } if c>=97 { if c<=102 { return c-87 } } if c>=65 { if c<=70 { return c-55 } } return 0 }
called by 1: md_hex2bytes
20func md_hex2bytes(hex: *u8, nbytes: i64, out: *u8) -> i64
called by 1: md_load_p calls 1: md_hv
25func md_load_p(p: *i64) -> i64
32func md_nonzero(a: *i64, n: i64) -> i64 { var i: i64=0; while i<n { if (a[i] & 0xFFFFFFFF) != 0 { return 1 } i=i+1 } return 0 }
called by 1: main
33func md_eq(a: *i64, b: *i64, n: i64) -> i64 { var i: i64=0; while i<n { if (a[i]&0xFFFFFFFF) != (b[i]&0xFFFFFFFF) { return 0 } i=i+1 } return 1 }
called by 2: mainmain
36func mse_dh_public(x: *i64, p: *i64, out: *i64) -> i64
42func mse_dh_shared(peer_pub: *i64, x: *i64, p: *i64, out: *i64) -> i64
47func main() -> i64