Example #1
0
// +build experimental

package openssl

import (
	"testing"

	"github.com/dedis/crypto/test"
)

var testSuite = NewAES128SHA256P256()
var groupBench = test.NewGroupBench(testSuite)

func TestP224(t *testing.T) { test.TestGroup(new(curve).InitP224()) }
func TestP256(t *testing.T) { test.TestGroup(new(curve).InitP256()) }
func TestP384(t *testing.T) { test.TestGroup(new(curve).InitP384()) }
func TestP521(t *testing.T) { test.TestGroup(new(curve).InitP521()) }

func TestSuite(t *testing.T) { test.TestSuite(testSuite) }

func BenchmarkScalarAdd(b *testing.B)    { groupBench.ScalarAdd(b.N) }
func BenchmarkScalarSub(b *testing.B)    { groupBench.ScalarSub(b.N) }
func BenchmarkScalarNeg(b *testing.B)    { groupBench.ScalarNeg(b.N) }
func BenchmarkScalarMul(b *testing.B)    { groupBench.ScalarMul(b.N) }
func BenchmarkScalarDiv(b *testing.B)    { groupBench.ScalarDiv(b.N) }
func BenchmarkScalarInv(b *testing.B)    { groupBench.ScalarInv(b.N) }
func BenchmarkScalarPick(b *testing.B)   { groupBench.ScalarPick(b.N) }
func BenchmarkScalarEncode(b *testing.B) { groupBench.ScalarEncode(b.N) }
func BenchmarkScalarDecode(b *testing.B) { groupBench.ScalarDecode(b.N) }

func BenchmarkPointAdd(b *testing.B)     { groupBench.PointAdd(b.N) }
Example #2
0
func BenchmarkPointBaseMul(b *testing.B) {
	test.NewGroupBench(testSuite).PointBaseMul(b.N)
}
Example #3
0
func BenchmarkPointDecode(b *testing.B) {
	test.NewGroupBench(testSuite).PointDecode(b.N)
}
Example #4
0
func BenchmarkScalarDecode(b *testing.B) {
	test.NewGroupBench(testSuite).ScalarDecode(b.N)
}
Example #5
0
		}
		//println("")
	}
}

func TestElligator1(t *testing.T) {
	testHiding(new(ExtendedCurve).Init(Param1174(), true), 10)
}

func TestElligator2(t *testing.T) {
	testHiding(new(ExtendedCurve).Init(Param25519(), true), 10)
}

// Benchmark contrasting implementations of the Ed25519 curve

var projBench = test.NewGroupBench(new(ProjectiveCurve).Init(Param25519(), false))
var extBench = test.NewGroupBench(new(ExtendedCurve).Init(Param25519(), false))
var optBench = test.NewGroupBench(new(ed25519.Curve))

func BenchmarkPointAddProjective(b *testing.B) { projBench.PointAdd(b.N) }
func BenchmarkPointAddExtended(b *testing.B)   { extBench.PointAdd(b.N) }
func BenchmarkPointAddOptimized(b *testing.B)  { optBench.PointAdd(b.N) }

func BenchmarkPointMulProjective(b *testing.B) { projBench.PointMul(b.N) }
func BenchmarkPointMulExtended(b *testing.B)   { extBench.PointMul(b.N) }
func BenchmarkPointMulOptimized(b *testing.B)  { optBench.PointMul(b.N) }

func BenchmarkPointBaseMulProjective(b *testing.B) { projBench.PointBaseMul(b.N) }
func BenchmarkPointBaseMulExtended(b *testing.B)   { extBench.PointBaseMul(b.N) }
func BenchmarkPointBaseMulOptimized(b *testing.B)  { optBench.PointBaseMul(b.N) }
Example #6
0
package nist

import (
	"testing"

	"github.com/dedis/crypto/test"
)

var testQR512 = NewAES128SHA256QR512()

func TestQR512(t *testing.T) { test.TestSuite(testQR512) }

var testP256 = NewAES128SHA256P256()
var benchP256 = test.NewGroupBench(testP256)

func TestP256(t *testing.T) { test.TestSuite(testP256) }

func BenchmarkScalarAdd(b *testing.B)    { benchP256.ScalarAdd(b.N) }
func BenchmarkScalarSub(b *testing.B)    { benchP256.ScalarSub(b.N) }
func BenchmarkScalarNeg(b *testing.B)    { benchP256.ScalarNeg(b.N) }
func BenchmarkScalarMul(b *testing.B)    { benchP256.ScalarMul(b.N) }
func BenchmarkScalarDiv(b *testing.B)    { benchP256.ScalarDiv(b.N) }
func BenchmarkScalarInv(b *testing.B)    { benchP256.ScalarInv(b.N) }
func BenchmarkScalarPick(b *testing.B)   { benchP256.ScalarPick(b.N) }
func BenchmarkScalarEncode(b *testing.B) { benchP256.ScalarEncode(b.N) }
func BenchmarkScalarDecode(b *testing.B) { benchP256.ScalarDecode(b.N) }

func BenchmarkPointAdd(b *testing.B)     { benchP256.PointAdd(b.N) }
func BenchmarkPointSub(b *testing.B)     { benchP256.PointSub(b.N) }
func BenchmarkPointNeg(b *testing.B)     { benchP256.PointNeg(b.N) }
func BenchmarkPointMul(b *testing.B)     { benchP256.PointMul(b.N) }
Example #7
0
func TestCompareBasicProjective41417(t *testing.T) {
	if testing.Short() {
		t.Skip("skipping test in short mode.")
	} else {
		test.TestCompareGroups(testSuite,
			new(BasicCurve).Init(Param41417(), false),
			new(ProjectiveCurve).Init(Param41417(), false))
	}
}

func TestCompareBasicProjectiveE521(t *testing.T) {
	if testing.Short() {
		t.Skip("skipping test in short mode.")
	} else {
		test.TestCompareGroups(testSuite,
			new(BasicCurve).Init(ParamE521(), false),
			new(ProjectiveCurve).Init(ParamE521(), false))
	}
}

// Benchmark contrasting implementations of the Ed25519 curve

var basicBench = test.NewGroupBench(new(BasicCurve).Init(Param25519(), false))

func BenchmarkPointAddBasic(b *testing.B)     { basicBench.PointAdd(b.N) }
func BenchmarkPointMulBasic(b *testing.B)     { basicBench.PointMul(b.N) }
func BenchmarkPointBaseMulBasic(b *testing.B) { basicBench.PointBaseMul(b.N) }
func BenchmarkPointEncodeBasic(b *testing.B)  { basicBench.PointEncode(b.N) }
func BenchmarkPointDecodeBasic(b *testing.B)  { basicBench.PointDecode(b.N) }
func BenchmarkPointPickBasic(b *testing.B)    { basicBench.PointPick(b.N) }
Example #8
0
func BenchmarkSecretDecode(b *testing.B) {
	test.NewGroupBench(testSuite).SecretDecode(b.N)
}