jchrisweaver / smp

Socialist Millionaire Protocol implementation in C
The Unlicense
5 stars 1 forks source link

Thanks for doing this #1

Closed fletcher closed 9 years ago

fletcher commented 9 years ago

I've been exploring the SMP, and was looking for an actual implementation to play with. Thanks for sharing this!

I'm having trouble getting it to work though...

1) I don't use python, and don't have M2Crypto installed, so...

2) I figured I would learn a couple of things by hacking the c version to act as a server.

3) I modified the code to run in either "server" or "client" mode, based on whether an ip address is provided in the arguments

4) Two copies (1 server, 1 client) seem to connect ok and send data back and forth

5) I modified the server to perform steps 2 & 4 instead of 1,3,5.

6) I get lots of unpackAndCompare: Failed errors on the server side, and Proof x check failed!(x=3,4,5) or segfaults (or both) on the client side. I included the output (including some extra debugging statements that I added)

Server:

fletcher% ./smp
Enter a shared secret: foo
await step 1
received step 1: 856
unpackAndCompare: Failed
unpackAndCompare: Failed
unpackAndCompare: Failed
unpackAndCompare: Failed
unpackAndCompare: Failed
unpackAndCompare: Failed
send step 2: 1676
await step 3
received step 3: 1248
Segmentation fault

Client:

fletcher% ./smp localhost
Enter a shared secret: foo
send step 1: 856
await step 2
received step 2: 1676
send step 3: 1248
await step 4
Segmentation fault

It appears that the server fails in step4, which breaks the connection and causes the client to fail. But this could also be because of the errors on the server when receiving step 1.

If I skip step4 (and just resend the holder unchanged), then both instances complete, but report that the secrets don't match (which is the correct outcome since I skipped a step).

Are there any known gotchas that should prevent me from making this work? Is there something in setup() that needs to be changed on the server side? Something else I could be doing that causes step1 or step4 to fail?

Thanks!!!

Fletcher

jchrisweaver commented 9 years ago

Fletcher-

Sorry for the delay on this. I just saw the notification!

Thanks for checking this out and digging in. Let me check into this and see if I can figure out what's going on.

jchrisweaver commented 9 years ago

Ah, had forgotten about this but it's documented in the TODOs in the readme:

TODO: Complete the Python-as-client to C-as-server code path. As of now, this code only works one way. While fairly trivial to complete, I haven't done it yet

I'll see if I can add this to my list sooner rather than later.

fletcher commented 9 years ago

I clearly was not seeing the specific parts that are broken. I'm happy to take a look if you have any pointers as to where I should be looking. Do you remember what parts needed to be completed?

jchrisweaver commented 9 years ago

It's been waaay too long to recall. Feel free to look into it. I'll check into this weekend and either let you know or just fix it, depending on what needs to be done. Not very useful if it doesn't work both ways w/ o zeee python.

jchrisweaver commented 9 years ago

Fixed the C server. Now the C code alone can act as server and client.

fletcher commented 9 years ago

Thanks -- it seems to work for me. I'll play around with it.

Not directly related to the smp, but I was experimenting with Shamir's Secret Sharing and created a c version of the javascript example from wikipedia:

https://github.com/fletcher/c-sss

I think doing that helped me better understand a little bit of the math going on in your project (well, perhaps understand is a bit strong...)

Anyway, thanks again for fixing this!!

jchrisweaver commented 9 years ago

Glad it is helpful. :) If you find any other issues, let me know.

I'll check out Shamir's stuff. That looks interesting!