lschoe / mpyc

MPyC: Multiparty Computation in Python
MIT License
367 stars 76 forks source link

Fix and test the integral propery with np_vstack #69

Closed MarcT0K closed 1 year ago

MarcT0K commented 1 year ago

This PR adds unit tests to check the consistency of the integral property for various operations on secure fixed-point numbers. The current tests covers the basic arithmetic operations (additions and multiplications) and the array stacking operations (np_vstack, np_hstack, np_stack, np_column_stack).

It also fixes the inconsistency in np_vstack.

See #67 for more details.

codecov-commenter commented 1 year ago

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.07% :tada:

Comparison is base (1636d55) 92.88% compared to head (8e61824) 92.95%.

:exclamation: Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the GitHub App Integration for your organization. Read more.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #69 +/- ## ========================================== + Coverage 92.88% 92.95% +0.07% ========================================== Files 16 16 Lines 8869 8874 +5 ========================================== + Hits 8238 8249 +11 + Misses 631 625 -6 ``` | [Files Changed](https://app.codecov.io/gh/lschoe/mpyc/pull/69?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Berry+Schoenmakers) | Coverage Δ | | |---|---|---| | [mpyc/runtime.py](https://app.codecov.io/gh/lschoe/mpyc/pull/69?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Berry+Schoenmakers#diff-bXB5Yy9ydW50aW1lLnB5) | `91.53% <100.00%> (+0.21%)` | :arrow_up: |

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

MarcT0K commented 1 year ago

Also, I've shortened the syntax for the tests to make it more like the other tests.

Looking at your commit, I've just discovered that there was some sort of aliases between np.* and mpc.np_*. I hadn't seen the trick in sectypes.py to overload the functions for secure arrays. This will simplify my own codes :sweat_smile:

I'll now prepare a few other PRs to cover all numpy operations.

lschoe commented 1 year ago

OK! And yes the use of np.* calls is the intended way and can be used in most cases. Check out the demos listed in np-run-all and other unit tests to see all kinds of examples. Only in a few cases the use of mpc.np_* calls is needed.