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
DisSys Inc.
bsc-shamir
Commits
60d26dc2
Commit
60d26dc2
authored
Jun 05, 2020
by
Thomas Hoffmann
Browse files
Add config benchmarks
parent
207b8ed5
Pipeline
#21990
passed with stages
in 1 minute and 40 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
crypto/common/common.go
View file @
60d26dc2
...
...
@@ -31,7 +31,7 @@ type Params struct {
H
*
big
.
Int
// Generator for subgroup G of order q in Zp
}
func
p
arseNumber
(
number
string
)
*
big
.
Int
{
func
P
arseNumber
(
number
string
)
*
big
.
Int
{
n
,
success
:=
new
(
big
.
Int
)
.
SetString
(
number
,
16
)
if
!
success
{
panic
(
"Not a decimal number: "
+
number
)
...
...
@@ -41,19 +41,19 @@ func parseNumber(number string) *big.Int {
// DefaultParams returns the default parameters
func
DefaultParams
()
*
Params
{
p
:=
p
arseNumber
(
p
)
p
:=
P
arseNumber
(
p
)
if
!
p
.
ProbablyPrime
(
20
)
{
panic
(
"p is not prime"
)
}
q
:=
p
arseNumber
(
q
)
q
:=
P
arseNumber
(
q
)
if
!
q
.
ProbablyPrime
(
20
)
{
panic
(
"p is not prime"
)
}
zp
:=
zn
.
NewRing
(
p
)
zq
:=
zn
.
NewRing
(
q
)
g
:=
p
arseNumber
(
g
)
h
:=
p
arseNumber
(
h
)
g
:=
P
arseNumber
(
g
)
h
:=
P
arseNumber
(
h
)
if
zp
.
Exp
(
g
,
q
)
.
Cmp
(
big
.
NewInt
(
1
))
!=
0
{
panic
(
"g is not a generator for Gq"
)
...
...
election/election_test.go
View file @
60d26dc2
...
...
@@ -34,6 +34,38 @@ func benchConfig() *common.Params {
return
config
}
func
createConfig
(
p
,
q
string
)
*
common
.
Params
{
P
:=
common
.
ParseNumber
(
p
)
if
!
P
.
ProbablyPrime
(
20
)
{
panic
(
"p is not prime"
)
}
Q
:=
common
.
ParseNumber
(
q
)
if
!
Q
.
ProbablyPrime
(
20
)
{
panic
(
"p is not prime"
)
}
zp
:=
zn
.
NewRing
(
P
)
zq
:=
zn
.
NewRing
(
Q
)
g
:=
common
.
ParseNumber
(
"2"
)
h
:=
common
.
ParseNumber
(
"3"
)
if
zp
.
Exp
(
g
,
Q
)
.
Cmp
(
big
.
NewInt
(
1
))
!=
0
{
panic
(
"g is not a generator for Gq"
)
}
if
zp
.
Exp
(
h
,
Q
)
.
Cmp
(
big
.
NewInt
(
1
))
!=
0
{
panic
(
"h is not a generator for Gq"
)
}
return
&
common
.
Params
{
P
:
P
,
Q
:
Q
,
Zp
:
zp
,
Zq
:
zq
,
G
:
g
,
H
:
h
,
}
}
func
setupVote
(
votecount
int
)
[]
*
big
.
Int
{
votes
:=
make
([]
*
big
.
Int
,
votecount
)
for
i
:=
0
;
i
<
votecount
;
i
++
{
...
...
@@ -207,9 +239,9 @@ func BenchmarkTallyOptimal(b *testing.B) {
b
.
Run
(
"11 of 21 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkTally
(
config
,
10
,
21
,
11
,
b
)
})
}
///////////////////////////////
///////////////////////////////
//
///Server - Combine benchmarks///
///////////////////////////////
///////////////////////////////
//
var
resultcombine
*
big
.
Int
func
benchmarkCombine
(
params
*
common
.
Params
,
votecount
,
serverCount
,
reqServer
int
,
b
*
testing
.
B
)
{
...
...
@@ -310,6 +342,99 @@ func BenchmarkCombineOptimal(b *testing.B) {
}
///////////////////////
///Config benchmarks///
///////////////////////
//Vælg største 16-bit, 32-bit, ..., 512-bit primtal
func
BenchmarkClientConfig
(
b
*
testing
.
B
)
{
log
.
SetOutput
(
ioutil
.
Discard
)
//var config *common.Params
config
:=
createConfig
(
"DF37"
,
"6F9B"
)
b
.
Run
(
" 16-bit"
,
func
(
b
*
testing
.
B
)
{
benchmarkBallots
(
config
,
10
,
17
,
9
,
b
)
})
config
=
createConfig
(
"E0885DBF"
,
"70442EDF"
)
b
.
Run
(
" 32-bit"
,
func
(
b
*
testing
.
B
)
{
benchmarkBallots
(
config
,
10
,
17
,
9
,
b
)
})
config
=
createConfig
(
"D74913FAF3F964EF"
,
"6BA489FD79FCB277"
)
b
.
Run
(
" 64-bit"
,
func
(
b
*
testing
.
B
)
{
benchmarkBallots
(
config
,
10
,
17
,
9
,
b
)
})
config
=
createConfig
(
"EBDD3B1ADF5E595C977667F3CBDECD13"
,
"75EE9D8D6FAF2CAE4BBB33F9E5EF6689"
)
b
.
Run
(
"128-bit"
,
func
(
b
*
testing
.
B
)
{
benchmarkBallots
(
config
,
10
,
17
,
9
,
b
)
})
config
=
createConfig
(
"FB6E2B44AC03CE014942C38631E31810C18B97B8C1110DB6DC698CB71AE9A65F"
,
"7DB715A25601E700A4A161C318F18C0860C5CBDC608886DB6E34C65B8D74D32F"
)
b
.
Run
(
"256-bit"
,
func
(
b
*
testing
.
B
)
{
benchmarkBallots
(
config
,
10
,
17
,
9
,
b
)
})
config
=
createConfig
(
"E5F3ADA593237B17A587FCC4AF32F72DC75CAA3E97C256F599303EB1B855CC4229E0C80B20A361C44CF4F45E28828A734BA1AEFF0D90C6880E6A9DF640D058F7"
,
"72F9D6D2C991BD8BD2C3FE6257997B96E3AE551F4BE12B7ACC981F58DC2AE62114F064059051B0E2267A7A2F14414539A5D0D77F86C8634407354EFB20682C7B"
)
b
.
Run
(
"512-bit"
,
func
(
b
*
testing
.
B
)
{
benchmarkBallots
(
config
,
10
,
17
,
9
,
b
)
})
}
func
BenchmarkTallyConfig
(
b
*
testing
.
B
)
{
log
.
SetOutput
(
ioutil
.
Discard
)
//var config *common.Params
config
:=
createConfig
(
"E2D3"
,
"7169"
)
b
.
Run
(
" 16-bit"
,
func
(
b
*
testing
.
B
)
{
benchmarkTally
(
config
,
10
,
17
,
9
,
b
)
})
config
=
createConfig
(
"E0885DBF"
,
"70442EDF"
)
//b.Run(" 32-bit", func(b *testing.B) { benchmarkTally(config, 10, 17, 9, b) })
config
=
createConfig
(
"FB89DEBCFA04CC3F"
,
"7DC4EF5E7D02661F"
)
//b.Run(" 64-bit", func(b *testing.B) { benchmarkTally(config, 10, 17, 9, b) })
config
=
createConfig
(
"EBDD3B1ADF5E595C977667F3CBDECD13"
,
"75EE9D8D6FAF2CAE4BBB33F9E5EF6689"
)
//b.Run("128-bit", func(b *testing.B) { benchmarkTally(config, 10, 17, 9, b) })
config
=
createConfig
(
"FB6E2B44AC03CE014942C38631E31810C18B97B8C1110DB6DC698CB71AE9A65F"
,
"7DB715A25601E700A4A161C318F18C0860C5CBDC608886DB6E34C65B8D74D32F"
)
//b.Run("256-bit", func(b *testing.B) { benchmarkTally(config, 10, 17, 9, b) })
config
=
createConfig
(
"E5F3ADA593237B17A587FCC4AF32F72DC75CAA3E97C256F599303EB1B855CC4229E0C80B20A361C44CF4F45E28828A734BA1AEFF0D90C6880E6A9DF640D058F7"
,
"72F9D6D2C991BD8BD2C3FE6257997B96E3AE551F4BE12B7ACC981F58DC2AE62114F064059051B0E2267A7A2F14414539A5D0D77F86C8634407354EFB20682C7B"
)
//b.Run("512-bit", func(b *testing.B) { benchmarkTally(config, 10, 17, 9, b) })
}
func
BenchmarkCombineConfig
(
b
*
testing
.
B
)
{
log
.
SetOutput
(
ioutil
.
Discard
)
var
config
*
common
.
Params
config
=
createConfig
(
"DF37"
,
"6F9B"
)
b
.
Run
(
" 16-bit"
,
func
(
b
*
testing
.
B
)
{
benchmarkCombine
(
config
,
10
,
17
,
9
,
b
)
})
config
=
createConfig
(
"E0885DBF"
,
"70442EDF"
)
b
.
Run
(
" 32-bit"
,
func
(
b
*
testing
.
B
)
{
benchmarkCombine
(
config
,
10
,
17
,
9
,
b
)
})
config
=
createConfig
(
"EB8AB7FE77FF3663"
,
"75C55BFF3BFF9B31"
)
b
.
Run
(
" 64-bit"
,
func
(
b
*
testing
.
B
)
{
benchmarkCombine
(
config
,
10
,
17
,
9
,
b
)
})
config
=
createConfig
(
"EBDD3B1ADF5E595C977667F3CBDECD13"
,
"75EE9D8D6FAF2CAE4BBB33F9E5EF6689"
)
b
.
Run
(
"128-bit"
,
func
(
b
*
testing
.
B
)
{
benchmarkCombine
(
config
,
10
,
17
,
9
,
b
)
})
config
=
createConfig
(
"FB6E2B44AC03CE014942C38631E31810C18B97B8C1110DB6DC698CB71AE9A65F"
,
"7DB715A25601E700A4A161C318F18C0860C5CBDC608886DB6E34C65B8D74D32F"
)
b
.
Run
(
"256-bit"
,
func
(
b
*
testing
.
B
)
{
benchmarkCombine
(
config
,
10
,
17
,
9
,
b
)
})
config
=
createConfig
(
"E5F3ADA593237B17A587FCC4AF32F72DC75CAA3E97C256F599303EB1B855CC4229E0C80B20A361C44CF4F45E28828A734BA1AEFF0D90C6880E6A9DF640D058F7"
,
"72F9D6D2C991BD8BD2C3FE6257997B96E3AE551F4BE12B7ACC981F58DC2AE62114F064059051B0E2267A7A2F14414539A5D0D77F86C8634407354EFB20682C7B"
)
b
.
Run
(
"512-bit"
,
func
(
b
*
testing
.
B
)
{
benchmarkCombine
(
config
,
10
,
17
,
9
,
b
)
})
}
// Actual tests
func
setupElection
()
*
Election
{
// netConfig, err := network.LoadConfig()
...
...
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