Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
dfss
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
7
Issues
7
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mpcs
dfss
Commits
7db9f833
Commit
7db9f833
authored
May 21, 2016
by
Loïck Bonniot
Browse files
Options
Browse Files
Download
Plain Diff
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
Showing
8 changed files
with
40 additions
and
7 deletions
+40
-7
.gitlab-ci.yml
.gitlab-ci.yml
+0
-1
dfssc/cmd/root.go
dfssc/cmd/root.go
+4
-2
dfssc/cmd/sign.go
dfssc/cmd/sign.go
+4
-0
dfssc/sign/protocol.go
dfssc/sign/protocol.go
+18
-2
dfssd/gui/events.go
dfssd/gui/events.go
+7
-0
dfssd/gui/widget.ui
dfssd/gui/widget.ui
+1
-1
dfssd/gui/window.go
dfssd/gui/window.go
+5
-1
tests/new_test.go
tests/new_test.go
+1
-0
No files found.
.gitlab-ci.yml
View file @
7db9f833
...
...
@@ -73,7 +73,6 @@ Code lint:
stage
:
test
except
:
-
/^[0-9]+\./
allow_failure
:
True
tags
:
-
golang
-
lint
...
...
dfssc/cmd/root.go
View file @
7db9f833
...
...
@@ -3,7 +3,6 @@ package cmd
import
(
"dfss"
dapi
"dfss/dfssd/api"
"github.com/spf13/cobra"
"github.com/spf13/viper"
...
...
@@ -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
// we do not store their values
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
()
.
String
(
"ca"
,
"ca.pem"
,
"path to the root certificate"
)
RootCmd
.
PersistentFlags
()
.
String
(
"cert"
,
"cert.pem"
,
"path to the user's certificate"
)
...
...
@@ -40,6 +39,9 @@ func init() {
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"
)
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
_
=
viper
.
BindPFlag
(
"verbose"
,
RootCmd
.
PersistentFlags
()
.
Lookup
(
"verbose"
))
_
=
viper
.
BindPFlag
(
"file_ca"
,
RootCmd
.
PersistentFlags
()
.
Lookup
(
"ca"
))
...
...
dfssc/cmd/sign.go
View file @
7db9f833
...
...
@@ -6,6 +6,7 @@ import (
"dfss/dfssc/sign"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
var
signCmd
=
&
cobra
.
Command
{
...
...
@@ -17,6 +18,9 @@ var signCmd = &cobra.Command{
os
.
Exit
(
1
)
}
_
=
viper
.
BindPFlag
(
"slowdown"
,
cmd
.
Flags
()
.
Lookup
(
"slowdown"
))
_
=
viper
.
BindPFlag
(
"stopbefore"
,
cmd
.
Flags
()
.
Lookup
(
"stopbefore"
))
filename
:=
args
[
0
]
fmt
.
Println
(
"You are going to sign the following contract:"
)
showContract
(
cmd
,
args
)
...
...
dfssc/sign/protocol.go
View file @
7db9f833
...
...
@@ -6,6 +6,7 @@ import (
"errors"
"fmt"
"io/ioutil"
"os"
"time"
cAPI
"dfss/dfssc/api"
...
...
@@ -15,6 +16,7 @@ import (
"dfss/net"
"golang.org/x/net/context"
"google.golang.org/grpc"
"github.com/spf13/viper"
)
// Sign performs all the message exchanges for the contract to be signed
...
...
@@ -48,7 +50,9 @@ func (m *SignatureManager) Sign() error {
// Promess rounds
// Follow the sequence until there is no next occurence of me
for
m
.
currentIndex
>=
0
{
stopIfNeeded
(
m
.
currentIndex
)
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
))
// Set of promises we are waiting for
...
...
@@ -78,16 +82,17 @@ func (m *SignatureManager) Sign() error {
}
}
// Signature round
stopIfNeeded
(
-
1
)
m
.
OnProgressUpdate
(
seqLen
,
seqLen
+
1
)
dAPI
.
DLog
(
"entering signature round"
)
// Signature round
err
=
m
.
ExchangeAllSignatures
()
if
err
!=
nil
{
return
err
}
dAPI
.
DLog
(
"exiting signature round"
)
m
.
OnProgressUpdate
(
seqLen
+
1
,
seqLen
+
1
)
return
m
.
PersistSignaturesToFile
()
}
...
...
@@ -271,3 +276,14 @@ func (m *SignatureManager) checkPromise(expected []common.SequenceCoordinate, pr
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() {
w
.
timer
.
OnTimeout
(
func
()
{
nbEvents
:=
len
(
w
.
scene
.
Events
)
if
w
.
scene
.
currentEvent
>=
nbEvents
{
w
.
stopButton
.
Click
()
w
.
replayButton
.
Click
()
return
}
...
...
@@ -116,6 +117,7 @@ func (w *Window) initTimer() {
quantum
:=
time
.
Duration
(
w
.
quantumField
.
Value
())
*
time
.
Microsecond
endOfQuantum
:=
w
.
scene
.
currentTime
.
Add
(
quantum
)
drawnEvents
:=
0
for
i
:=
w
.
scene
.
currentEvent
;
i
<
nbEvents
;
i
++
{
e
:=
w
.
scene
.
Events
[
i
]
...
...
@@ -125,10 +127,15 @@ func (w *Window) initTimer() {
w
.
DrawEvent
(
&
e
)
w
.
scene
.
currentEvent
++
drawnEvents
++
}
w
.
PrintQuantumInformation
()
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 @@
<enum>
Qt::TabFocus
</enum>
</property>
<property
name=
"minimum"
>
<number>
1
</number>
<number>
0
</number>
</property>
<property
name=
"maximum"
>
<number>
20
</number>
...
...
dfssd/gui/window.go
View file @
7db9f833
...
...
@@ -122,7 +122,11 @@ func (w *Window) addActions() {
w
.
playButton
.
OnClicked
(
func
()
{
w
.
playButton
.
SetDisabled
(
true
)
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
)
})
...
...
tests/new_test.go
View file @
7db9f833
...
...
@@ -75,6 +75,7 @@ func TestNewContract(t *testing.T) {
assert
.
Equal
(
t
,
nil
,
err
)
// Check database²
time
.
Sleep
(
time
.
Second
)
// Allowed delay to let some time to propagate the contract readiness
contract
=
getContract
(
"contract.txt"
,
0
)
assert
.
Equal
(
t
,
true
,
contract
.
Ready
)
assert
.
True
(
t
,
len
(
contract
.
Signers
[
0
]
.
Hash
)
>
0
)
...
...
Write
Preview
Markdown
is supported
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