https://homes.esat.kuleuven.be/~nsmart/SCALE/
https://github.com/KULeuven-COSIC/SCALE-MAMBA

I opted to use their Nix shell file to avoid tainting the rest of my system with potentially incompatible junk. Feel free to use whatever other hazmat quarantine procedures strike your fancy (Docker, VMs, whatever). (EDIT: this doesn't completely work, sadly, as some of its build scripts call cargo, which touches your home directory. Alas.)

  • Due to the presence of (P)CLMUL—(polynomial) carry-less multiplication—instructions in the source code, you (for now) cannot run this software on Intel Nehalem, AMD 10h/K10, AMD Bobcat, or older CPUs. 😩
    • If you have such a CPU, apply my patch to src/Math/gf2n.h@mul128 immediately after cloning the main repo:
      git fetch --depth=50
      "https://github.com/JamesTheAwesomeDude/SCALE-MAMBA.git"
      "feature/nehalem_k10":"feature/nehalem_k10" && git -c
      "user.name=Anonymous" -c "user.email=nobody@localhost" merge --no-commit
      "feature/nehalem_k10"

      • As of 2023-01-14, the patch is necessary and sufficient to run the Rust player binary!
      • As of 2023-01-14, the patch is insufficient to run the classic player binary! (It seems to be making calls to GMP that screw everything up.)
  • Nix without root was achieved via the static binary at https://github.com/nix-community/nix-user-chroot/releases/latest
    • After you've got this installed and set up, the oneshot to open a Nix session is:
      exec nix-user-chroot ~/.nix bash -l
  • Regardless of how you use Nix—system, OS, singleuser, multiuser, or chrooted—the development environment can be entered via:
    nix-shell ./shell.nix

    • On my machine, this took about 11 minutes the first time, and less than 5 seconds on subsequent runs.
    • NOTE that this step allows you to SKIP installing Rustc, MPIR, OpenSSL, and Crypto++!
    • The remaining steps assume you're using Nix and have the nix-shell session open.
  • You have to create and edit CONFIG.mine; I used CONFIG as a template, inserting “..” for the first variable and commenting out the second, per the documentation.
    sed < CONFIG -e 's/^\(ROOT \?= \?\).*/\1'"..# $(pwd | sed -e 's_/_\\\/_g')"'/;s*^#\?\(OSSL \?= \+\).\**#\1'"$(echo "$NIX_CFLAGS_COMPILE" | sed -e 's*.\*\(\('"${NIX_STORE-/nix/store}"'/[^ \:]\*\(openssl[^ :]\*\)-dev\)/include\).\**\2*')"'*' > CONFIG.mine
  • Be sure to follow the “Idiot's Installation” section if you can't be bothered to set up a CA for peer authentication during testing:
    cp -v Auto-Test-Data/Cert-Store/* Cert-Store/; cp -v Auto-Test-Data/1/* Data/
  • Compile:
    time ( set -e; export USE_RUST=1; if [ -n "${NIX_STORE+1}" ]; then export NIX_OS_BUILD="${NIX_OS_BUILD-WORKAROUND for https://github.com/KULeuven-COSIC/SCALE-MAMBA/blob/6449e807c99c68203f6584166a7130055da52adb/src/build.rs#L72}"; fi; make -j"$(nproc || echo 1)" progs; ./compile.sh Programs/tutorial; cargo build -j"$(nproc || echo 1)" --verbose --bin player )
  • Execute:
    time ( for n in $(grep -oP '^(\d+)(?=.*(P\d+)$)' < Data/NetworkData.txt | uniq); do USE_RUST=$(( $RANDOM % 2 )) ./Player.x "$n" Programs/tutorial & done; wait )

    • To get a stack trace for the old binary:
      time ( for n in $(grep -oP '^(\d+)(?=.*(P\d+)$)' < Data/NetworkData.txt | uniq); do gdb PlayerBinary.x -batch -ex "run 0 Programs/tutorial" -ex "bt" -ex "disassemble" | grep -C5 -P '^(?=\S)' & done; wait )
    • To get a stack trace for the Rust binary:
      time ( export RUST_BACKTRACE=1; for n in $(grep -oP '^(\d+)(?=.*(P\d+)$)' < Data/NetworkData.txt | uniq); do cargo run --bin player "$n" Programs/tutorial & done; wait )

Leave a Reply

Your email address will not be published. Required fields are marked *

Warning: This site uses Akismet to filter spam. Until or unless I can find a suitable replacement anti-spam solution, this means that (per their indemnification document) all commenters' IP addresses will be sent to Automattic, Inc., who may choose to share such with 3rd parties.
If this is unacceptable to you, I highly recommend using an anonymous proxy or public Wi-Fi connection when commenting.