swisspost-evoting-go-poc/pkg/mixnet/starmap.go
saymrwulf e8b6f30871 Swiss Post E-Voting Go PoC
Proof-of-concept reimplementation of the Swiss Post e-voting
cryptographic protocol in Go. Single binary, 52 source files,
2 dependencies. Covers ElGamal encryption, Bayer-Groth verifiable
shuffles, zero-knowledge proofs, return codes, and a full
election ceremony demo.
2026-02-13 19:53:09 +01:00

25 lines
586 B
Go

package mixnet
import (
"math/big"
emath "github.com/user/evote/pkg/math"
)
// StarMap computes the bilinear star map: ★(a, b, y) = Σ_j (a_j * b_j * y^(j+1))
func StarMap(a, b *emath.ZqVector, y emath.ZqElement) emath.ZqElement {
if a.Size() != b.Size() {
panic("vectors must have same size")
}
group := y.Group()
result, _ := emath.NewZqElement(big.NewInt(0), group)
yPow := y // y^1
for j := 0; j < a.Size(); j++ {
// a_j * b_j * y^(j+1)
term := a.Get(j).Multiply(b.Get(j)).Multiply(yPow)
result = result.Add(term)
yPow = yPow.Multiply(y)
}
return result
}