Skip to content

Commit

Permalink
troubleshooting docker subgroup test
Browse files Browse the repository at this point in the history
  • Loading branch information
jmwample committed Jun 28, 2024
1 parent a67dbfc commit 263e31d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 61 deletions.
28 changes: 0 additions & 28 deletions crates/obfs4/src/common/x25519_elligator2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<Randomized>;
// // let elligator_direct_map2 = MontgomeryPoint::from_representative::<RFC9380>;

// 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}");
// }
// }

}
28 changes: 14 additions & 14 deletions internal/compatibility/docker-compose-ell2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: ../../
Expand All @@ -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
25 changes: 6 additions & 19 deletions internal/compatibility/ell2_bug_check/obfs4-subgroup-check.py
Original file line number Diff line number Diff line change
@@ -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.
#
Expand Down Expand Up @@ -258,7 +260,6 @@ def inv_sqrt(x):

# Elligator reference implementation by Loup Vaillant
# https://elligator.org/src/elligator

###########################################
# Fast Implementation (explicit formulas) #
###########################################
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 263e31d

Please sign in to comment.