Skip to content

MPC: wrong output when using if #217

@sebw42

Description

@sebw42

Hi, I wanted to let you know that there seems to be an issue with the MPC compiler (on the mpc_aws branch) when using if-then-else.
Here is an example (with a set to 1 in the input file):

int main(__attribute__((private(0))) int a) {
    if ((a * 2) >= a) {
        return 0;
    }
    return a;
}

Build command:

export CARGO_MANIFEST_DIR="$PWD"; export RUST_BACKTRACE=1; ./target/release/examples/circ --parties 2 examples/C/mpc/program.c mpc  --cost-model "empirical"

Execution command:

/path/to/ABY/build/bin/aby_interpreter -m mpc -f ./scripts/aby_tests/tests/program_c -t ./scripts/aby_tests/test_inputs/program.txt -r 0 & /path/to/ABY/build/bin/aby_interpreter -m mpc -f ./scripts/aby_tests/tests/program_c -t ./scripts/aby_tests/test_inputs/program.txt -r 1

The output seems to be a random number (a different one with every execution).

I tried some things and found that the error disappears in the following cases:

  • the guard evaluates to false (e.g. (a * 2) >= (a * 3))
  • the left comparator in the guard does not contain secrets (e.g. 100 >= a)
  • we return a constant instead of a at the end

The error also vanishes if we use a second input for the comparison (a set to 1, b set to 3 in this example):

int main(__attribute__((private(0))) int a, __attribute__((private(1))) int b) {
    if ((4 * a) >= b) {
        return 0;
    }
    return a;
}

Thank you for looking into this!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions