Skip to content

MPC: unexpected results when comparing negative and positive numbers #216

@sebw42

Description

@sebw42

Hello,
I've noticed that the MPC compiler returns unexpected results when both negative and positive numbers are used in a comparison.

Here is an example:

int main(__attribute__((private(0))) int x, __attribute__((private(1))) int y) {
    if (x < y) {
        return 1;
    }
    return 0;
}

When setting x to -1 and y to 0, x < y should be true, but the program returns 0.
With x = -2 and y = -1, it works as expected and returns 1.

Here are the compilation/execution steps I've used (executed in the circ root dir):

export CARGO_MANIFEST_DIR="$PWD"; export RUST_BACKTRACE=1; ./target/release/examples/circ --parties 2 examples/C/mpc/program.c mpc --cost-model "empirical"
/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

Thank you for having a look!

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