From 4adec77feea7e9ec45ca43084383d85de450518b Mon Sep 17 00:00:00 2001 From: Özgür Kesim Date: Mon, 11 Nov 2024 21:28:12 +0100 Subject: refactoring in progress --- common/common.go | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 common/common.go (limited to 'common/common.go') 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 +} -- cgit v1.2.3