aboutsummaryrefslogtreecommitdiff
path: root/common/common.go
diff options
context:
space:
mode:
Diffstat (limited to 'common/common.go')
-rw-r--r--common/common.go36
1 files changed, 36 insertions, 0 deletions
diff --git a/common/common.go b/common/common.go
new file mode 100644
index 0000000..d72daaf
--- /dev/null
+++ b/common/common.go
@@ -0,0 +1,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
+}