nx_mse_dh.nx
buildroot/runtime/nx_mse_dh.nx
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
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
structs
| none |
consts
| 12 | const MSE_N: i64 = 24 // 768-bit / 32 = 24 limbs |
| 14 | const MSE_P_HEX: *u8 = "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A63A36210000000000090563" as *u8 |
functions
| 16 | func if_s(b: i64) -> *u8 { if b==1 { return "1" as *u8 } return "0" as *u8 } |
| 17 | func 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 } |
| 18 | func 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 |
| 20 | func md_hex2bytes(hex: *u8, nbytes: i64, out: *u8) -> i64 |
| 25 | func md_load_p(p: *i64) -> i64 |
| 32 | func 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 |
| 33 | func 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 } |
| 36 | func mse_dh_public(x: *i64, p: *i64, out: *i64) -> i64 |
| 42 | func mse_dh_shared(peer_pub: *i64, x: *i64, p: *i64, out: *i64) -> i64 |
| 47 | func main() -> i64 |