-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from markkurossi/topic/streaming
Topic/streaming
- Loading branch information
Showing
45 changed files
with
2,705 additions
and
517 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
|
||
programs := $(wildcard examples/*.mpcl) | ||
circs := $(patsubst %.mpcl,%.circ,$(programs)) | ||
mpclcs := $(patsubst %.mpcl,%.mpclc,$(programs)) | ||
bristols := $(patsubst %.mpcl,%.bristol,$(programs)) | ||
ssas := $(patsubst %.mpcl,%.ssa,$(programs)) | ||
dots := $(patsubst %,%.dot,$(circs) $(ssas)) | ||
dots := $(patsubst %,%.dot,$(circs) $(mpclcs) $(bristols) $(ssas)) | ||
svgs := $(patsubst %.dot,%.svg,$(dots)) | ||
|
||
all: | ||
@echo $(svgs) | ||
|
||
clean: | ||
@rm -f $(circs) $(ssas) $(dots) $(svgs) | ||
@rm -f $(circs) $(mpclcs) $(bristols) $(ssas) $(dots) $(svgs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
package main | ||
|
||
type Size = uint42 | ||
type Size = uint32 | ||
|
||
type Applicant struct { | ||
male bool | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,6 @@ | |
|
||
package main | ||
|
||
func main(a, b uint64) uint { | ||
func main(a, b uint2048) uint { | ||
return a * b | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// | ||
// Copyright (c) 2020 Markku Rossi | ||
// | ||
// All rights reserved. | ||
// | ||
|
||
package main | ||
|
||
import ( | ||
"fmt" | ||
"io" | ||
"net" | ||
"strings" | ||
|
||
"github.com/markkurossi/mpc/circuit" | ||
"github.com/markkurossi/mpc/compiler" | ||
"github.com/markkurossi/mpc/compiler/utils" | ||
"github.com/markkurossi/mpc/p2p" | ||
) | ||
|
||
func streamEvaluatorMode(params *utils.Params, input input, once bool) error { | ||
ln, err := net.Listen("tcp", port) | ||
if err != nil { | ||
return err | ||
} | ||
fmt.Printf("Listening for connections at %s\n", port) | ||
|
||
for { | ||
nc, err := ln.Accept() | ||
if err != nil { | ||
return err | ||
} | ||
fmt.Printf("New connection from %s\n", nc.RemoteAddr()) | ||
|
||
conn := p2p.NewConn(nc) | ||
result, err := circuit.StreamEvaluator(conn, input, verbose) | ||
conn.Close() | ||
|
||
if err != nil && err != io.EOF { | ||
return err | ||
} | ||
|
||
printResult(result) | ||
if once { | ||
return nil | ||
} | ||
} | ||
} | ||
|
||
func streamGarblerMode(params *utils.Params, input input, args []string) error { | ||
if len(args) != 1 || !strings.HasSuffix(args[0], ".mpcl") { | ||
return fmt.Errorf("streaming mode takes single MPCL file") | ||
} | ||
nc, err := net.Dial("tcp", port) | ||
if err != nil { | ||
return err | ||
} | ||
conn := p2p.NewConn(nc) | ||
defer conn.Close() | ||
|
||
result, err := compiler.NewCompiler(params).StreamFile(conn, args[0], input) | ||
if err != nil { | ||
return err | ||
} | ||
printResult(result) | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.