From 263e31dd27194146e1242eba50cfec585df9f3cc Mon Sep 17 00:00:00 2001 From: jmwample <8297368+jmwample@users.noreply.github.com> Date: Fri, 28 Jun 2024 13:49:58 -0600 Subject: [PATCH] troubleshooting docker subgroup test --- crates/obfs4/src/common/x25519_elligator2.rs | 28 ------------------- .../compatibility/docker-compose-ell2.yaml | 28 +++++++++---------- .../ell2_bug_check/obfs4-subgroup-check.py | 25 ++++------------- 3 files changed, 20 insertions(+), 61 deletions(-) diff --git a/crates/obfs4/src/common/x25519_elligator2.rs b/crates/obfs4/src/common/x25519_elligator2.rs index cca1ad1..e749404 100644 --- a/crates/obfs4/src/common/x25519_elligator2.rs +++ b/crates/obfs4/src/common/x25519_elligator2.rs @@ -389,32 +389,4 @@ mod test { println!("pk_gen: {pk_off}, pk_255: {off_255}, pk_254: {off_254}"); } } - - // #[test] - // fn subgroups() { - // let order = curve25519_elligator2::Scalar::from_bytes_mod_order(BASEPOINT_ORDER_MINUS_ONE); - - // let elligator_direct_map1 = MontgomeryPoint::from_representative::; - // // let elligator_direct_map2 = MontgomeryPoint::from_representative::; - - // for _ in 0..100 { - // let e = EphemeralSecret::random(); - // let r = PublicRepresentative::from(&e); - - // let mut yr_255 = r.0.clone(); - // yr_255[31] &= 0xbf; - // let y_255 = elligator_direct_map1(&yr_255).expect("to_repr_255, should never fail"); - // let z = y_255 * order; - // let off_255 = !z.is_identity(); - - // let mut yr_254 = r.0.clone(); - // yr_254[31] &= 0x3f; - // let y_254 = elligator_direct_map1(&yr_254).expect("to_repr_254, should never fail"); - // let z = y_254 * order; - // let off_254 = !z.is_identity(); - - // println!("255: {off_255}, 254: {off_254}"); - // } - // } - } diff --git a/internal/compatibility/docker-compose-ell2.yaml b/internal/compatibility/docker-compose-ell2.yaml index 0eaa9fe..695d008 100644 --- a/internal/compatibility/docker-compose-ell2.yaml +++ b/internal/compatibility/docker-compose-ell2.yaml @@ -17,9 +17,22 @@ services: server-proxy: condition: service_started + # server-proxy: + # image: obfs4-compat + # command: fwd_go -a dev -x server echo + # tty: true + # build: + # context: ../../ + # dockerfile: Dockerfile + # expose: + # - 9001 + # networks: + # - trial + + server-proxy: image: obfs4-compat - command: fwd_go -a dev -x server echo + command: fwd_rs -a dev -x server echo tty: true build: context: ../../ @@ -30,19 +43,6 @@ services: - trial - # server-proxy: - # image: obfs4-compat - # command: fwd_rs -a dev -x server echo - # tty: true - # build: - # context: ../../ - # dockerfile: Dockerfile - # expose: - # - 9001 - # networks: - # - trial - - networks: trial: driver: bridge diff --git a/internal/compatibility/ell2_bug_check/obfs4-subgroup-check.py b/internal/compatibility/ell2_bug_check/obfs4-subgroup-check.py index baf3567..5ccf6f0 100755 --- a/internal/compatibility/ell2_bug_check/obfs4-subgroup-check.py +++ b/internal/compatibility/ell2_bug_check/obfs4-subgroup-check.py @@ -1,5 +1,7 @@ #!/usr/bin/env python3 +# original source: https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/-/issues/40007 + # Usage: obfs4-subgroup-check [-n NUM_TRIALS] [-t TIMEOUT] 192.95.36.142:443 qUVQ0srL1JI/vO6V6m/24anYXiJD3QP2HgzUKQtQ7GRqqUvs7P+tG43RtAqdhLOALP7DJQ # The second argument is the "cert" parameter from the bridge line. # @@ -258,7 +260,6 @@ def inv_sqrt(x): # Elligator reference implementation by Loup Vaillant # https://elligator.org/src/elligator - ########################################### # Fast Implementation (explicit formulas) # ########################################### @@ -364,7 +365,7 @@ def check(Yrb): Y_254 = elligator_dir_map(Yr_254)[0] off_subgroup_254 = Mt.scalarmult(Y_254, Mt.order).to_num() != 0 - print(" - 255: %r, 254: %r" % (off_subgroup_255, off_subgroup_254)) + print(" - 255: %r,\t254: %r" % (off_subgroup_255, off_subgroup_254)) return off_subgroup_255 and off_subgroup_254 @@ -393,24 +394,10 @@ def mac(msg): def main(): - network_trials() - # fixed_trials() - -def fixed_trials(): - low_order_points = [ - "0100000000000000000000000000000000000000000000000000000000000000", - "ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f", - "0000000000000000000000000000000000000000000000000000000000000000", - "0000000000000000000000000000000000000000000000000000000000000080", - "26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc05", - "26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc85", - "c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac037a", - "c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac03fa", - ] - for px in low_order_points: - p = bytes.fromhex(px) - check(p) + # network_trials() + random_trials() +def random_trials(): for _ in range(100): p = random.randbytes(32) check(p)