Skip to content
This repository has been archived by the owner on Oct 8, 2020. It is now read-only.

Commit

Permalink
Merge pull request #31 from ldsec/dev
Browse files Browse the repository at this point in the history
MedCo v0.3.0
  • Loading branch information
mickmis authored Feb 11, 2020
2 parents 6d706e2 + d6303ce commit c636e7b
Show file tree
Hide file tree
Showing 22 changed files with 1,304 additions and 641 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ before_install:

install:
- go get -t ./...
- go get github.com/mattn/goveralls

script:
- make test
Expand Down
9 changes: 8 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ test_local:
test_codecov:
./coveralls.sh

test_loop:
for i in $$( seq 100 ); \
do echo "******* Run $$i"; echo; \
go test -v -short -p=1 -run Agg -count 10 ./services/ > run.log || \
( cat run.log; exit 1 ) || exit 1; \
done

test: test_fmt test_lint test_codecov

local: test_fmt test_lint test_local
local: test_fmt test_lint test_local
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[![Build Status](https://travis-ci.org/lca1/medco-unlynx.svg?branch=master)](https://travis-ci.org/lca1/medco-unlynx)
[![Go Report Card](https://goreportcard.com/badge/github.com/lca1/medco-unlynx)](https://goreportcard.com/report/github.com/lca1/medco-unlynx)
[![Coverage Status](https://coveralls.io/repos/github/lca1/medco-unlynx/badge.svg?branch=master)](https://coveralls.io/github/lca1/medco-unlynx?branch=master)
[![Build Status](https://travis-ci.org/ldsec/medco-unlynx.svg?branch=master)](https://travis-ci.org/ldsec/medco-unlynx)
[![Go Report Card](https://goreportcard.com/badge/github.com/ldsec/medco-unlynx)](https://goreportcard.com/report/github.com/ldsec/medco-unlynx)
[![Coverage Status](https://coveralls.io/repos/github/ldsec/medco-unlynx/badge.svg?branch=master)](https://coveralls.io/github/ldsec/medco-unlynx?branch=master)

## Documentation
MedCo documentation is centralized on the following website:
Expand Down
4 changes: 2 additions & 2 deletions app/data_decryption.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ package main

import (
"errors"
"github.com/lca1/unlynx/lib"
"github.com/ldsec/unlynx/lib"
"github.com/urfave/cli"
"go.dedis.ch/onet/v3/log"
"gopkg.in/urfave/cli.v1"
"io"
"os"
"strconv"
Expand Down
4 changes: 2 additions & 2 deletions app/data_encryption.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package main

import (
"errors"
"github.com/lca1/unlynx/lib"
"github.com/ldsec/unlynx/lib"
"github.com/urfave/cli"
"go.dedis.ch/onet/v3/app"
"go.dedis.ch/onet/v3/log"
"gopkg.in/urfave/cli.v1"
"io"
"os"
"strconv"
Expand Down
6 changes: 3 additions & 3 deletions app/generate_tagging_secrets.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ package main

import (
"errors"
"github.com/lca1/medco-unlynx/services"
libunlynx "github.com/lca1/unlynx/lib"
"github.com/ldsec/medco-unlynx/services"
libunlynx "github.com/ldsec/unlynx/lib"
"github.com/urfave/cli"
"go.dedis.ch/kyber/v3"
"go.dedis.ch/onet/v3/app"
"go.dedis.ch/onet/v3/log"
"gopkg.in/urfave/cli.v1"
"os"
"path"
"strconv"
Expand Down
2 changes: 1 addition & 1 deletion app/get_aggregate_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package main
import (
"encoding/base64"
"errors"
"github.com/urfave/cli"
"go.dedis.ch/onet/v3/app"
"go.dedis.ch/onet/v3/log"
"gopkg.in/urfave/cli.v1"
"os"
"path"
)
Expand Down
4 changes: 2 additions & 2 deletions app/key_generation.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ package main

import (
"errors"
"github.com/lca1/unlynx/lib"
"github.com/ldsec/unlynx/lib"
"github.com/urfave/cli"
"go.dedis.ch/onet/v3/log"
"gopkg.in/urfave/cli.v1"
"io"
"os"
)
Expand Down
109 changes: 109 additions & 0 deletions app/mapping_table_generation.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
package main

import (
"errors"
"github.com/urfave/cli"
"go.dedis.ch/kyber/v3"
"go.dedis.ch/kyber/v3/suites"
"go.dedis.ch/onet/v3/log"
"os"
"strconv"
)

func mappingTableGenFromApp(c *cli.Context) error {

var PointToInt = make(map[string]int64, 0)
var suite = suites.MustFind("Ed25519")

// cli arguments
outputFile := c.String("outputFile") // mandatory
outputFormat := c.String("outputFormat") // typescript
nbMappings := c.Int64("nbMappings") // optional default to 1000
checkNeg := c.Bool("checkNeg") // optional default to false

var Bi kyber.Point
B := suite.Point().Base()
var m int64

// generate mapping in memory
for Bi, m = suite.Point().Null(), 0; m < nbMappings; Bi, m = Bi.Add(Bi, B), m+1 {
PointToInt[Bi.String()] = m

if checkNeg {
neg := suite.Point().Mul(suite.Scalar().SetInt64(int64(-m)), B)
PointToInt[neg.String()] = -m
}
}

// open file
file, err := os.Create(outputFile)
if err != nil {
return cli.NewExitError(err, 1)
}
defer file.Close()

// write mapping to disk
switch outputFormat {
case "typescript":
err = writeMapToTSFile(file, PointToInt)
case "go":
err = writeMapToGoFile(file, PointToInt)
default:
err = errors.New("format selected is incorrect: " + outputFormat)
}

if err != nil {
return cli.NewExitError(err, 2)
}

log.Info("Successfully generated mapping file with ", nbMappings, " mappings to ", outputFile)
return nil
}

func writeMapToTSFile(file *os.File, pointToInt map[string]int64) (err error) {
//export let PointToInt: Record<string, number> = {
// "edc876d6831fd2105d0b4389ca2e283166469289146e2ce06faefe98b22548df": 5,
// "f47e49f9d07ad2c1606b4d94067c41f9777d4ffda709b71da1d88628fce34d85": 6,
//}

_, err = file.WriteString("export let PointToInt: Record<string, number> = {\n")
if err != nil {
return
}
for k, v := range pointToInt {
_, err = file.WriteString("\t" + `"` + k + `": ` + strconv.FormatInt(v, 10) + ",\n")
if err != nil {
return
}
}
_, err = file.WriteString("};")
if err != nil {
return
}
return
}

func writeMapToGoFile(file *os.File, pointToInt map[string]int64) (err error) {
//package main
//var PointToInt = map[string]int64{
// "00022ddff3737fda59ef096dae2ea2876a5893510442fde25cb37486ed8b97c3": 7414,
//}

_, err = file.WriteString("package main \nvar PointToInt = map[string]int64{\n")
if err != nil {
return
}

for k, v := range pointToInt {
_, err = file.WriteString("\t" + `"` + k + `": ` + strconv.FormatInt(v, 10) + ",\n")
if err != nil {
return
}
}

_, err = file.WriteString("}")
if err != nil {
return
}
return
}
48 changes: 46 additions & 2 deletions app/medco.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import (
"errors"
"os"

"github.com/lca1/unlynx/lib"
"github.com/ldsec/unlynx/lib"
"github.com/urfave/cli"
"go.dedis.ch/onet/v3/app"
"go.dedis.ch/onet/v3/log"
"go.dedis.ch/onet/v3/network"
"gopkg.in/urfave/cli.v1"
)

const (
Expand All @@ -24,6 +24,9 @@ const (
optionConfig = "config"
optionConfigShort = "c"

optionTimeout = "timeout"
optionTimeoutShort = "t"

optionGroupFile = "file"
optionGroupFileShort = "f"

Expand Down Expand Up @@ -92,11 +95,42 @@ func main() {
},
}

mappingTableGenFlags := []cli.Flag{
cli.StringFlag{
Name: "outputFile",
Usage: "Path to the file that will be generated.",
Required: true,
},
cli.StringFlag{
Name: "outputFormat",
Usage: "Format of the output file. Value: go|typescript. Default: typescript.",
Required: false,
Value: "typescript",
},
cli.Int64Flag{
Name: "nbMappings",
Usage: "Number of mappings to generate. Default: 1000.",
Required: false,
Value: 1000,
},
cli.BoolFlag{
Name: "checkNeg",
Usage: "Whether to check for negative values. Default: false.",
Required: false,
},
}

serverFlags := []cli.Flag{
cli.StringFlag{
Name: optionConfig + ", " + optionConfigShort,
Usage: "Configuration file of the server",
},
cli.Int64Flag{
Name: optionTimeout + ", " + optionTimeoutShort,
Usage: "Communication timeout (in minutes)",
Required: false,
Value: 20,
},
}

nonInteractiveSetupFlags := []cli.Flag{
Expand Down Expand Up @@ -172,6 +206,16 @@ func main() {
},
// CLIENT END: KEY GENERATION ------------

// BEGIN CLIENT: MAPPING TABLE GENERATION ----------
{
Name: "mappingtablegen",
Aliases: []string{"m"},
Usage: "Generate a point-integer mapping table.",
Action: mappingTableGenFromApp,
Flags: mappingTableGenFlags,
},
// CLIENT END: MAPPING TABLE GENERATION ------------

// BEGIN SERVER --------
{
Name: "server",
Expand Down
4 changes: 2 additions & 2 deletions app/non_interactive_setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ package main

import (
"errors"
"github.com/lca1/unlynx/lib"
"github.com/ldsec/unlynx/lib"
"github.com/urfave/cli"
"go.dedis.ch/kyber/v3/util/encoding"
"go.dedis.ch/kyber/v3/util/key"
"go.dedis.ch/onet/v3/app"
"go.dedis.ch/onet/v3/log"
"go.dedis.ch/onet/v3/network"
"gopkg.in/urfave/cli.v1"
)

// NonInteractiveSetup is used to setup the cothority node for unlynx in a non-interactive way (and without error checks)
Expand Down
10 changes: 7 additions & 3 deletions app/server.go
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
package main

import (
"gopkg.in/urfave/cli.v1"
servicesmedco "github.com/ldsec/medco-unlynx/services"
"time"

// Empty imports to have the init-functions called which should
// register the protocol
_ "github.com/lca1/medco-unlynx/services"
_ "github.com/lca1/unlynx/protocols"
_ "github.com/ldsec/medco-unlynx/services"
_ "github.com/ldsec/unlynx/protocols"
"github.com/urfave/cli"
"go.dedis.ch/onet/v3/app"
)

func runServer(ctx *cli.Context) error {
// first check the options
config := ctx.String("config")
timeout := ctx.Int64("timeout")

app.RunServer(config)

servicesmedco.TimeoutService = time.Duration(timeout) * time.Minute
return nil
}
2 changes: 1 addition & 1 deletion coveralls.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ echo "mode: atomic" > profile.cov
for dir in ${DIR_SOURCE}; do
echo ${dir}
if ! echo ${DIR_EXCLUDE} | grep -q ${dir}; then
go test -short -p=1 -covermode=atomic -coverprofile=${dir}/profile.tmp ${dir}
go test -v -short -p=1 -covermode=atomic -coverprofile=${dir}/profile.tmp ${dir}

if [ $? -ne 0 ]; then
all_tests_passed=false
Expand Down
4 changes: 2 additions & 2 deletions deployment/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.12 as build
FROM golang:1.13 as build

COPY ./ /src
WORKDIR /src
Expand All @@ -21,7 +21,7 @@ RUN CGO_ENABLED=0 go build -v ./... && \
mv /go/bin/app /go/bin/medco-unlynx

# -------------------------------------------
FROM golang:1.12-alpine as release
FROM golang:1.13-alpine as release

# run time environment variables
ENV NODE_IDX="0" \
Expand Down
31 changes: 17 additions & 14 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
module github.com/lca1/medco-unlynx
module github.com/ldsec/medco-unlynx

go 1.13

require (
github.com/BurntSushi/toml v0.3.1
github.com/btcsuite/goleveldb v1.0.0
github.com/cpuguy83/go-md2man/v2 v2.0.0 // indirect
github.com/fanliao/go-concurrentMap v0.0.0-20141114143905-7d2d7a5ea67b
github.com/gopherjs/gopherjs v0.0.0-20190430165422-3e4dfb77656c // indirect
github.com/lca1/unlynx v1.3.1
github.com/satori/go.uuid v1.2.0
github.com/smartystreets/assertions v0.0.0-20190401211740-f487f9de1cd3 // indirect
github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a // indirect
github.com/stretchr/testify v1.3.0
go.dedis.ch/kyber/v3 v3.0.3
go.dedis.ch/onet/v3 v3.0.14
golang.org/x/crypto v0.0.0-20190513172903-22d7a77e9e5f // indirect
golang.org/x/net v0.0.0-20190522155817-f3200d17e092 // indirect
golang.org/x/sys v0.0.0-20190528183647-3626398d7749 // indirect
golang.org/x/text v0.3.2 // indirect
gopkg.in/urfave/cli.v1 v1.20.0
github.com/gorilla/websocket v1.4.1 // indirect
github.com/ldsec/unlynx v1.4.0
github.com/smartystreets/goconvey v1.6.4 // indirect
github.com/stretchr/testify v1.4.0
github.com/urfave/cli v1.22.2
go.dedis.ch/kyber/v3 v3.0.12
go.dedis.ch/onet/v3 v3.1.0
golang.org/x/crypto v0.0.0-20200210222208-86ce3cb69678 // indirect
golang.org/x/net v0.0.0-20191126235420-ef20fe5d7933 // indirect
golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5 // indirect
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
gopkg.in/yaml.v2 v2.2.7 // indirect
)
Loading

0 comments on commit c636e7b

Please sign in to comment.