Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

w&b error correction interpolation algorithm implemented #4

Closed
wants to merge 2 commits into from

Conversation

changxu2
Copy link

@changxu2 changxu2 commented Jul 27, 2018

Update with current miniviff
Not ready for merge

polynomial.py Outdated
@@ -17,7 +20,7 @@ def __init__(self, coeffs):
self.coeffs = strip_trailing_zeros(coeffs)
self.field = field

def isZero(self): return self.coeffs == []
def isZero(self): return self.coeffs == [] or (len(self.coeffs) == 1 and self.coeffs[0] == 0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be necessary if strip_trailing_zeros was called earlier

from polynomial import polynomialsOver

# n is the total number of messages send out == total number of nodes
# k is the total number of shared secret, k = t + 1 with degree t polinomial
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Slight terminology correct - this is Reed Solomon not secret share encoding. So k is not the number of shared secrets, but it could be called the number of code symbols.
Polinomial -> Polynomial

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed!

@codecov-io
Copy link

codecov-io commented Aug 2, 2018

Codecov Report

Merging #4 into miniviff will increase coverage by 4.95641%.
The diff coverage is 84.33735%.

@@                Coverage Diff                 @@
##           miniviff          #4         +/-   ##
==================================================
+ Coverage   58.7886%   63.74502%   +4.95641%     
==================================================
  Files            11          13          +2     
  Lines           842        1004        +162     
  Branches        131         182         +51     
==================================================
+ Hits            495         640        +145     
- Misses          330         336          +6     
- Partials         17          28         +11

@changxu2 changxu2 changed the title w&b error correction interpolation algorithm impletmented w&b error correction interpolation algorithm implemented Aug 2, 2018
return message


test_decoding()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do not need to explicitly invoke the test function (test_decoding) as pytest takes care of finding and executing the test functions and classes.

So, when you run

pytest test_wb_interpolate.py

all functions starting with test_ and classes starting with Test will be executed.

More information about this behavior can be found under https://docs.pytest.org/en/latest/goodpractices.html#conventions-for-python-test-discovery.

return random.randint(0, order)


def simple_router(N):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should import this simple_router from somewhere rather than copy-pasting it.

Copy link
Collaborator

@sbellem sbellem Aug 23, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could probably put it in a pytest fixture.

Right now it is defined in test-asyncio-simplerouter.py I think. We cannot import things from it I think because the module name contains "dashes/hyphens". A workaround is to use something like:

from importlib import  import_module                                                     
simple_router = getattr(
    import_module('honeybadgermpc.test-asyncio-simplerouter'), 'simple_router')

or in two steps, if you need more things from it

from importlib import  import_module                                                     
async_simple_router_test_module = import_module('honeybadgermpc.test-asyncio-simplerouter')
simple_router = async_simple_router_test_module.simple_router
Share = async_simple_router_test_module.Share
# etc

also note that the above will work only if the Runtime class is fixed, e.g.:

diff --git a/honeybadgermpc/test-asyncio-simplerouter.py b/honeybadgermpc/test-asyncio-simplerouter.py
index 90e64d5..14c8dee 100644
--- a/honeybadgermpc/test-asyncio-simplerouter.py
+++ b/honeybadgermpc/test-asyncio-simplerouter.py
@@ -51,7 +51,7 @@ class Runtime():
 
     async def _run(self):
         while True:
-            await   # noqa TODO fix: await ?; e.g.: await asyncio.sleep(1)
+            await asyncio.sleep(1)  # noqa TODO fix: await ?; e.g.: await asyncio.sleep(1)
 
     def createshare(self, val):
         s = Share(self)

In any case, I think we should spend the time to put such things in fixtures.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest the following:

  1. Move the test module test_batch_reconstruction.py under the tests dir.
  2. Add a simple_router fixture in tests/conftest.py, e.g.:
# tests/conftest.py
import asyncio
import random

from pytest import fixture


@fixture
def simple_router():

    def _simple_router(N):
        """
        Builds a set of connected channels
        @return (receives, sends)
        """
        # Create a mailbox for each party
        mbox = [asyncio.Queue() for _ in range(N)]

        def makeSend(i):
            def _send(j, o):
                # print('SEND %8s [%2d -> %2d]' % (o[0], i, j))
                # random delay
                asyncio.get_event_loop().call_later(
                    random.random()*1, mbox[j].put_nowait, (i, o))
            return _send

        def makeRecv(j):
            async def _recv():
                (i, o) = await mbox[j].get()
                # print('RECV %8s [%2d -> %2d]' % (o[0], i, j))
                return (i, o)
            return _recv

        sends = {}
        receives = {}
        for i in range(N):
            sends[i] = makeSend(i)
            receives[i] = makeRecv(i)
        return (sends, receives)

    return _simple_router
  1. Remove the simple_router function definition in tests/test_batch_reconstruction.py and use the simple_router fixture (defined in conftest.py) in the test like so:
def test(simple_router):
    N = 4
    p = 73
    t = 1

    async def _test():
        # Test with simple case: n = 4, t =1
        # After AVSS, poly1 = x + 2, poly2 = 3x + 4, secret1 = 2, secret2 = 4
        # Hard code the shared secret value as input into batch_reconstruction function
        # The final constructed polynomial should be p = 4x + 2
        sends, recvs = simple_router(N)
        towait = []
        for i in range(N):
            # ...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The above is demonstrated in 19737f7 (and 0768e06).

@amiller
Copy link
Contributor

amiller commented Aug 24, 2018

@changxu2 what is left to do before this can be merged? I think you need to add some integration with an MPC program, maybe online_active.py that uses the batch opening operations and that we can run with custom programs

@amiller
Copy link
Contributor

amiller commented Aug 24, 2018

@changxu2 One thing missing from batch_reconstruction is that if a fault is detected, we should return (along with the solution) a list of the player ids corresponding to any faults. Then we can ignore subsequent messages from them and effectively remove them from future comparisons

@changxu2
Copy link
Author

  1. For the simple_router issue: Thank you very much @sbellem ! I indeed encoutered the issue with module name containing "dashes", thank you for pointing out the direction for refactoring!
  2. Things to do before merging (that I can think of now): a) I will implement the evil nodes number in return b) some clean up work c) fft version of the algorithm d) active_online.py. For a) , b) and d) , I am planing on finishing before merging. For d) @amiller , do you think it would be better to merge first or implement first and then merge altogether?

@amiller
Copy link
Contributor

amiller commented Aug 24, 2018

@changxu2 I think you mean you'll leave c) the fft computation for after merging? If so yes that's fine

@amiller amiller mentioned this pull request Aug 25, 2018
4 tasks
@amiller
Copy link
Contributor

amiller commented Sep 3, 2018

What is the status of this @changxu2 it looks like a test is failing due to code style but that is it?

@amiller amiller closed this Sep 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants