aboutsummaryrefslogtreecommitdiff
path: root/common/common.go
blob: d72daaf2e6839f055cd752ee126a0ff076bfb8da (plain)
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
package common

import (
	"crypto/sha512"

	"kesim.org/seal/curve"
)

// Common functions for the various proofs

type Scalar = curve.Curve25519Scalar
type Point = curve.Curve25519Point

var Curve = curve.Curve25519
var G = Curve.Generator()
var One = Curve.ScalarOne()

type Bytes interface {
	Bytes() []byte
}

type Bites []byte

func (b Bites) Bytes() []byte { return b }

func Challenge(bs ...Bytes) *Scalar {
	h512 := sha512.New()
	for _, p := range bs {
		h512.Write(p.Bytes())
	}
	ch, e := Curve.ScalarFromBytes(h512.Sum(nil))
	if e != nil {
		panic(e)
	}
	return ch
}