Commit 60d26dc2 authored by Thomas Hoffmann's avatar Thomas Hoffmann
Browse files

Add config benchmarks

parent 207b8ed5
Pipeline #21990 passed with stages
in 1 minute and 40 seconds
......@@ -31,7 +31,7 @@ type Params struct {
H *big.Int // Generator for subgroup G of order q in Zp
}
func parseNumber(number string) *big.Int {
func ParseNumber(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 := parseNumber(p)
p := ParseNumber(p)
if !p.ProbablyPrime(20) {
panic("p is not prime")
}
q := parseNumber(q)
q := ParseNumber(q)
if !q.ProbablyPrime(20) {
panic("p is not prime")
}
zp := zn.NewRing(p)
zq := zn.NewRing(q)
g := parseNumber(g)
h := parseNumber(h)
g := ParseNumber(g)
h := ParseNumber(h)
if zp.Exp(g, q).Cmp(big.NewInt(1)) != 0 {
panic("g is not a generator for Gq")
......
......@@ -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()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment