diff options
author | Özgür Kesim <oec@kesim.org> | 2024-03-21 20:12:42 +0100 |
---|---|---|
committer | Özgür Kesim <oec@kesim.org> | 2024-03-21 20:12:42 +0100 |
commit | 3ba341e3c464e7a92bc99fd7d8bde65737c1aac9 (patch) | |
tree | 699c7215c1ce904591cc6a9fb2c8dd2e0265e20f /veto | |
parent | 8eeb35615f0483e21dc48f96877a2681cf48b1ec (diff) |
veto, curve: slight refactor
- Mult -> Mul
- newVoteWithRand uses input rand io.Reader again.
Diffstat (limited to 'veto')
-rw-r--r-- | veto/veto.go | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/veto/veto.go b/veto/veto.go index 6a64c82..2b164bc 100644 --- a/veto/veto.go +++ b/veto/veto.go @@ -83,7 +83,7 @@ func proof(x *Scalar, id *Point) (pr *Proof, e error) { } // Calculate r := v - x*h - xh := x.Mult(h) + xh := x.Mul(h) r := v.Sub(xh) pr.Sr = r @@ -130,7 +130,7 @@ func verifyProof(V *Point, Gx *Point, r *Scalar, id *Point) (ok bool) { gr := Curve.Exp(r) // Calculate g^r*g^(x*h) - grgxh := gr.Mult(gxh) + grgxh := gr.Mul(gxh) // Return true if g^v == g^r*g^(x*h) return V.Equal(grgxh) @@ -150,11 +150,16 @@ func newVoteWithRand(veto bool, rand io.Reader) (v *Vote, e error) { veto: veto, } - v.private.id = Curve.RandomScalar() - v.private.x = Curve.RandomScalar() - v.private.r = Curve.RandomScalar() + var e1, e2, e3 error - var e1, e2 error + v.private.id, e1 = Curve.ScalarFromReader(rand) + v.private.x, e2 = Curve.ScalarFromReader(rand) + v.private.r, e3 = Curve.ScalarFromReader(rand) + + e = combineErr(e1, e2, e3) + if e != nil { + return nil, e + } c := new(Commitment) v.com = c @@ -194,7 +199,7 @@ type coms []*Commitment func (coms coms) prod() (product *Point) { product = Curve.Identity() for _, com := range coms { - product = product.Mult(com.Points.X) + product = product.Mul(com.Points.X) } return product } @@ -204,7 +209,7 @@ func (coms coms) prod() (product *Point) { func (coms coms) computeGy(index int) *Point { gy1 := coms[:index].prod() gy2 := coms[index+1:].prod().Inv() - return gy1.Mult(gy2) + return gy1.Mul(gy2) } // Round2 implements the round 2 of the AV-Net protocol, where a participant @@ -249,4 +254,4 @@ func (pts points) IsVetoed() bool { product := Curve.Product(pts) one := Curve.Identity() return !one.Equal(product) -}
\ No newline at end of file +} |