diff options
author | Özgür Kesim <oec@kesim.org> | 2024-11-11 21:28:12 +0100 |
---|---|---|
committer | Özgür Kesim <oec@kesim.org> | 2024-11-11 21:28:12 +0100 |
commit | 4adec77feea7e9ec45ca43084383d85de450518b (patch) | |
tree | 446ecf80204c6a1b755547e121f1f8450c99f6ae /common/common.go | |
parent | 7813100e5429ca486d6310f8a04d7a0d11325f2e (diff) |
refactoring in progress
Diffstat (limited to 'common/common.go')
-rw-r--r-- | common/common.go | 36 |
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 +} |