-
Notifications
You must be signed in to change notification settings - Fork 1
/
schnorr_test.go
37 lines (31 loc) · 955 Bytes
/
schnorr_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package schnorr
import (
"crypto/rand"
"fmt"
"testing"
"github.com/stretchr/testify/require"
"golang.org/x/crypto/sha3"
"github.com/coinbase/kryptology/pkg/core/curves"
)
func TestZKPOverMultipleCurves(t *testing.T) {
curveInstances := []*curves.Curve{
curves.K256(),
curves.P256(),
// TODO: the code fails on the following curves. Investigate if this is expected.
// curves.PALLAS(),
// curves.BLS12377G1(),
// curves.BLS12377G2(),
// curves.BLS12381G1(),
// curves.BLS12381G2(),
// curves.ED25519(),
}
for i, curve := range curveInstances {
uniqueSessionId := sha3.New256().Sum([]byte("random seed"))
prover := NewProver(curve, nil, uniqueSessionId)
secret := curve.Scalar.Random(rand.Reader)
proof, err := prover.Prove(secret)
require.NoError(t, err, fmt.Sprintf("failed in curve %d", i))
err = Verify(proof, curve, nil, uniqueSessionId)
require.NoError(t, err, fmt.Sprintf("failed in curve %d", i))
}
}