Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mpcs
dfss
Commits
7db9f833
Commit
7db9f833
authored
May 21, 2016
by
Loïck Bonniot
Browse files
Merge branch 'master' into 218_promesses_client
parents
8ade9e29
af6a6448
Pipeline
#1923
passed with stage
Changes
8
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
.gitlab-ci.yml
View file @
7db9f833
...
@@ -73,7 +73,6 @@ Code lint:
...
@@ -73,7 +73,6 @@ Code lint:
stage
:
test
stage
:
test
except
:
except
:
-
/^[0-9]+\./
-
/^[0-9]+\./
allow_failure
:
True
tags
:
tags
:
-
golang
-
golang
-
lint
-
lint
...
...
dfssc/cmd/root.go
View file @
7db9f833
...
@@ -3,7 +3,6 @@ package cmd
...
@@ -3,7 +3,6 @@ package cmd
import
(
import
(
"dfss"
"dfss"
dapi
"dfss/dfssd/api"
dapi
"dfss/dfssd/api"
"github.com/spf13/cobra"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/spf13/viper"
...
@@ -31,7 +30,7 @@ A tool to sign multiparty contract using a secure cryptographic protocol`,
...
@@ -31,7 +30,7 @@ A tool to sign multiparty contract using a secure cryptographic protocol`,
// All of the flags will be gathered by viper, this is why
// All of the flags will be gathered by viper, this is why
// we do not store their values
// we do not store their values
func
init
()
{
func
init
()
{
// Bind flags to the dfss
t
command
// Bind flags to the dfss
c
command
RootCmd
.
PersistentFlags
()
.
BoolP
(
"verbose"
,
"v"
,
false
,
"print verbose messages"
)
RootCmd
.
PersistentFlags
()
.
BoolP
(
"verbose"
,
"v"
,
false
,
"print verbose messages"
)
RootCmd
.
PersistentFlags
()
.
String
(
"ca"
,
"ca.pem"
,
"path to the root certificate"
)
RootCmd
.
PersistentFlags
()
.
String
(
"ca"
,
"ca.pem"
,
"path to the root certificate"
)
RootCmd
.
PersistentFlags
()
.
String
(
"cert"
,
"cert.pem"
,
"path to the user's certificate"
)
RootCmd
.
PersistentFlags
()
.
String
(
"cert"
,
"cert.pem"
,
"path to the user's certificate"
)
...
@@ -40,6 +39,9 @@ func init() {
...
@@ -40,6 +39,9 @@ func init() {
RootCmd
.
PersistentFlags
()
.
String
(
"host"
,
"localhost:9000"
,
"host of the dfss platform"
)
RootCmd
.
PersistentFlags
()
.
String
(
"host"
,
"localhost:9000"
,
"host of the dfss platform"
)
RootCmd
.
PersistentFlags
()
.
IntP
(
"port"
,
"p"
,
9005
,
"port to use for P2P communication between clients"
)
RootCmd
.
PersistentFlags
()
.
IntP
(
"port"
,
"p"
,
9005
,
"port to use for P2P communication between clients"
)
signCmd
.
Flags
()
.
Duration
(
"slowdown"
,
0
,
"delay between each promises round (test only)"
)
signCmd
.
Flags
()
.
Int
(
"stopbefore"
,
0
,
"stop signature just before the promises round n, -1 to stop right before signature round (test only)"
)
// Store flag values into viper
// Store flag values into viper
_
=
viper
.
BindPFlag
(
"verbose"
,
RootCmd
.
PersistentFlags
()
.
Lookup
(
"verbose"
))
_
=
viper
.
BindPFlag
(
"verbose"
,
RootCmd
.
PersistentFlags
()
.
Lookup
(
"verbose"
))
_
=
viper
.
BindPFlag
(
"file_ca"
,
RootCmd
.
PersistentFlags
()
.
Lookup
(
"ca"
))
_
=
viper
.
BindPFlag
(
"file_ca"
,
RootCmd
.
PersistentFlags
()
.
Lookup
(
"ca"
))
...
...
dfssc/cmd/sign.go
View file @
7db9f833
...
@@ -6,6 +6,7 @@ import (
...
@@ -6,6 +6,7 @@ import (
"dfss/dfssc/sign"
"dfss/dfssc/sign"
"github.com/spf13/cobra"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
)
var
signCmd
=
&
cobra
.
Command
{
var
signCmd
=
&
cobra
.
Command
{
...
@@ -17,6 +18,9 @@ var signCmd = &cobra.Command{
...
@@ -17,6 +18,9 @@ var signCmd = &cobra.Command{
os
.
Exit
(
1
)
os
.
Exit
(
1
)
}
}
_
=
viper
.
BindPFlag
(
"slowdown"
,
cmd
.
Flags
()
.
Lookup
(
"slowdown"
))
_
=
viper
.
BindPFlag
(
"stopbefore"
,
cmd
.
Flags
()
.
Lookup
(
"stopbefore"
))
filename
:=
args
[
0
]
filename
:=
args
[
0
]
fmt
.
Println
(
"You are going to sign the following contract:"
)
fmt
.
Println
(
"You are going to sign the following contract:"
)
showContract
(
cmd
,
args
)
showContract
(
cmd
,
args
)
...
...
dfssc/sign/protocol.go
View file @
7db9f833
...
@@ -6,6 +6,7 @@ import (
...
@@ -6,6 +6,7 @@ import (
"errors"
"errors"
"fmt"
"fmt"
"io/ioutil"
"io/ioutil"
"os"
"time"
"time"
cAPI
"dfss/dfssc/api"
cAPI
"dfss/dfssc/api"
...
@@ -15,6 +16,7 @@ import (
...
@@ -15,6 +16,7 @@ import (
"dfss/net"
"dfss/net"
"golang.org/x/net/context"
"golang.org/x/net/context"
"google.golang.org/grpc"
"google.golang.org/grpc"
"github.com/spf13/viper"
)
)
// Sign performs all the message exchanges for the contract to be signed
// Sign performs all the message exchanges for the contract to be signed
...
@@ -48,7 +50,9 @@ func (m *SignatureManager) Sign() error {
...
@@ -48,7 +50,9 @@ func (m *SignatureManager) Sign() error {
// Promess rounds
// Promess rounds
// Follow the sequence until there is no next occurence of me
// Follow the sequence until there is no next occurence of me
for
m
.
currentIndex
>=
0
{
for
m
.
currentIndex
>=
0
{
stopIfNeeded
(
m
.
currentIndex
)
m
.
OnProgressUpdate
(
m
.
currentIndex
,
seqLen
+
1
)
m
.
OnProgressUpdate
(
m
.
currentIndex
,
seqLen
+
1
)
time
.
Sleep
(
viper
.
GetDuration
(
"slowdown"
))
dAPI
.
DLog
(
"starting round at index ["
+
fmt
.
Sprintf
(
"%d"
,
m
.
currentIndex
)
+
"] with nextIndex="
+
fmt
.
Sprintf
(
"%d"
,
nextIndex
))
dAPI
.
DLog
(
"starting round at index ["
+
fmt
.
Sprintf
(
"%d"
,
m
.
currentIndex
)
+
"] with nextIndex="
+
fmt
.
Sprintf
(
"%d"
,
nextIndex
))
// Set of promises we are waiting for
// Set of promises we are waiting for
...
@@ -78,16 +82,17 @@ func (m *SignatureManager) Sign() error {
...
@@ -78,16 +82,17 @@ func (m *SignatureManager) Sign() error {
}
}
}
}
// Signature round
stopIfNeeded
(
-
1
)
m
.
OnProgressUpdate
(
seqLen
,
seqLen
+
1
)
m
.
OnProgressUpdate
(
seqLen
,
seqLen
+
1
)
dAPI
.
DLog
(
"entering signature round"
)
dAPI
.
DLog
(
"entering signature round"
)
// Signature round
err
=
m
.
ExchangeAllSignatures
()
err
=
m
.
ExchangeAllSignatures
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
dAPI
.
DLog
(
"exiting signature round"
)
dAPI
.
DLog
(
"exiting signature round"
)
m
.
OnProgressUpdate
(
seqLen
+
1
,
seqLen
+
1
)
m
.
OnProgressUpdate
(
seqLen
+
1
,
seqLen
+
1
)
return
m
.
PersistSignaturesToFile
()
return
m
.
PersistSignaturesToFile
()
}
}
...
@@ -271,3 +276,14 @@ func (m *SignatureManager) checkPromise(expected []common.SequenceCoordinate, pr
...
@@ -271,3 +276,14 @@ func (m *SignatureManager) checkPromise(expected []common.SequenceCoordinate, pr
return
false
,
0
return
false
,
0
}
}
func
stopIfNeeded
(
index
int
)
{
s
:=
viper
.
GetInt
(
"stopbefore"
)
if
s
==
0
{
return
}
if
index
==
-
1
&&
s
==
-
1
||
index
+
1
==
s
{
os
.
Exit
(
0
)
}
}
\ No newline at end of file
dfssd/gui/events.go
View file @
7db9f833
...
@@ -91,6 +91,7 @@ func (w *Window) initTimer() {
...
@@ -91,6 +91,7 @@ func (w *Window) initTimer() {
w
.
timer
.
OnTimeout
(
func
()
{
w
.
timer
.
OnTimeout
(
func
()
{
nbEvents
:=
len
(
w
.
scene
.
Events
)
nbEvents
:=
len
(
w
.
scene
.
Events
)
if
w
.
scene
.
currentEvent
>=
nbEvents
{
if
w
.
scene
.
currentEvent
>=
nbEvents
{
w
.
stopButton
.
Click
()
w
.
replayButton
.
Click
()
w
.
replayButton
.
Click
()
return
return
}
}
...
@@ -116,6 +117,7 @@ func (w *Window) initTimer() {
...
@@ -116,6 +117,7 @@ func (w *Window) initTimer() {
quantum
:=
time
.
Duration
(
w
.
quantumField
.
Value
())
*
time
.
Microsecond
quantum
:=
time
.
Duration
(
w
.
quantumField
.
Value
())
*
time
.
Microsecond
endOfQuantum
:=
w
.
scene
.
currentTime
.
Add
(
quantum
)
endOfQuantum
:=
w
.
scene
.
currentTime
.
Add
(
quantum
)
drawnEvents
:=
0
for
i
:=
w
.
scene
.
currentEvent
;
i
<
nbEvents
;
i
++
{
for
i
:=
w
.
scene
.
currentEvent
;
i
<
nbEvents
;
i
++
{
e
:=
w
.
scene
.
Events
[
i
]
e
:=
w
.
scene
.
Events
[
i
]
...
@@ -125,10 +127,15 @@ func (w *Window) initTimer() {
...
@@ -125,10 +127,15 @@ func (w *Window) initTimer() {
w
.
DrawEvent
(
&
e
)
w
.
DrawEvent
(
&
e
)
w
.
scene
.
currentEvent
++
w
.
scene
.
currentEvent
++
drawnEvents
++
}
}
w
.
PrintQuantumInformation
()
w
.
PrintQuantumInformation
()
w
.
scene
.
currentTime
=
endOfQuantum
w
.
scene
.
currentTime
=
endOfQuantum
if
w
.
speedSlider
.
Value
()
==
0
&&
drawnEvents
>
0
{
w
.
stopButton
.
Click
()
// step-by-step
}
})
})
}
}
...
...
dfssd/gui/widget.ui
View file @
7db9f833
...
@@ -187,7 +187,7 @@
...
@@ -187,7 +187,7 @@
<enum>
Qt::TabFocus
</enum>
<enum>
Qt::TabFocus
</enum>
</property>
</property>
<property
name=
"minimum"
>
<property
name=
"minimum"
>
<number>
1
</number>
<number>
0
</number>
</property>
</property>
<property
name=
"maximum"
>
<property
name=
"maximum"
>
<number>
20
</number>
<number>
20
</number>
...
...
dfssd/gui/window.go
View file @
7db9f833
...
@@ -122,7 +122,11 @@ func (w *Window) addActions() {
...
@@ -122,7 +122,11 @@ func (w *Window) addActions() {
w
.
playButton
.
OnClicked
(
func
()
{
w
.
playButton
.
OnClicked
(
func
()
{
w
.
playButton
.
SetDisabled
(
true
)
w
.
playButton
.
SetDisabled
(
true
)
w
.
stopButton
.
SetDisabled
(
false
)
w
.
stopButton
.
SetDisabled
(
false
)
speed
:=
2000
/
w
.
speedSlider
.
Value
()
s
:=
w
.
speedSlider
.
Value
()
if
s
==
0
{
s
=
100
// step-by-step arbitrary speed value
}
speed
:=
2000
/
s
w
.
timer
.
StartWithMsec
(
speed
)
w
.
timer
.
StartWithMsec
(
speed
)
})
})
...
...
tests/new_test.go
View file @
7db9f833
...
@@ -75,6 +75,7 @@ func TestNewContract(t *testing.T) {
...
@@ -75,6 +75,7 @@ func TestNewContract(t *testing.T) {
assert
.
Equal
(
t
,
nil
,
err
)
assert
.
Equal
(
t
,
nil
,
err
)
// Check database²
// Check database²
time
.
Sleep
(
time
.
Second
)
// Allowed delay to let some time to propagate the contract readiness
contract
=
getContract
(
"contract.txt"
,
0
)
contract
=
getContract
(
"contract.txt"
,
0
)
assert
.
Equal
(
t
,
true
,
contract
.
Ready
)
assert
.
Equal
(
t
,
true
,
contract
.
Ready
)
assert
.
True
(
t
,
len
(
contract
.
Signers
[
0
]
.
Hash
)
>
0
)
assert
.
True
(
t
,
len
(
contract
.
Signers
[
0
]
.
Hash
)
>
0
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment