Skip to content

Commit 4cf0150

Browse files
committedAug 31, 2022
Moves dleq to new top-level zero-knowledge package.
1 parent 00fa63c commit 4cf0150

File tree

6 files changed

+20
-13
lines changed

6 files changed

+20
-13
lines changed
 

‎oprf/client.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"crypto/rand"
55

66
"github.com/cloudflare/circl/group"
7-
"github.com/cloudflare/circl/group/dleq"
7+
"github.com/cloudflare/circl/zk/dleq"
88
)
99

1010
type client struct{ params }

‎oprf/oprf.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ import (
5656
"math"
5757

5858
"github.com/cloudflare/circl/group"
59-
"github.com/cloudflare/circl/group/dleq"
59+
"github.com/cloudflare/circl/zk/dleq"
6060
)
6161

6262
const (

‎oprf/server.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"crypto/subtle"
66

77
"github.com/cloudflare/circl/group"
8-
"github.com/cloudflare/circl/group/dleq"
8+
"github.com/cloudflare/circl/zk/dleq"
99
)
1010

1111
type server struct {

‎oprf/vectors_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import (
1313
"testing"
1414

1515
"github.com/cloudflare/circl/group"
16-
"github.com/cloudflare/circl/group/dleq"
1716
"github.com/cloudflare/circl/internal/test"
17+
"github.com/cloudflare/circl/zk/dleq"
1818
)
1919

2020
type vector struct {

‎group/dleq/dleq.go renamed to ‎zk/dleq/dleq.go

+15-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
// Package dleq provides zero-knowledge proofs of Discrete-Logarithm Equivalence (DLEQ).
2+
//
3+
// This implementation is compatible with the one used for VOPRFs [1].
4+
// It supports batching proofs to amortize the cost of the proof generation and
5+
// verification.
6+
//
7+
// References:
8+
//
9+
// [1] draft-irtf-cfrg-voprf: https://datatracker.ietf.org/doc/draft-irtf-cfrg-voprf
210
package dleq
311

412
import (
@@ -23,7 +31,6 @@ type Params struct {
2331
}
2432

2533
type Proof struct {
26-
g group.Group
2734
c, s group.Scalar
2835
}
2936

@@ -84,7 +91,7 @@ func (p Prover) ProveBatchWithRandomness(
8491
ss.Mul(cc, k)
8592
ss.Sub(rnd, ss)
8693

87-
return &Proof{p.G, cc, ss}, nil
94+
return &Proof{cc, ss}, nil
8895
}
8996

9097
func (p Params) computeComposites(
@@ -223,7 +230,8 @@ func (v Verifier) VerifyBatch(a, ka group.Element, bi, kbi []group.Element, p *P
223230
}
224231

225232
func (p *Proof) MarshalBinary() ([]byte, error) {
226-
scalarSize := int(p.g.Params().ScalarLength)
233+
g := p.c.Group()
234+
scalarSize := int(g.Params().ScalarLength)
227235
output := make([]byte, 0, 2*scalarSize)
228236

229237
serC, err := p.c.MarshalBinary()
@@ -242,19 +250,18 @@ func (p *Proof) MarshalBinary() ([]byte, error) {
242250
}
243251

244252
func (p *Proof) UnmarshalBinary(g group.Group, data []byte) error {
245-
p.g = g
246-
scalarSize := int(p.g.Params().ScalarLength)
253+
scalarSize := int(g.Params().ScalarLength)
247254
if len(data) < 2*scalarSize {
248255
return io.ErrShortBuffer
249256
}
250257

251-
c := p.g.NewScalar()
258+
c := g.NewScalar()
252259
err := c.UnmarshalBinary(data[:scalarSize])
253260
if err != nil {
254261
return err
255262
}
256263

257-
s := p.g.NewScalar()
264+
s := g.NewScalar()
258265
err = s.UnmarshalBinary(data[scalarSize : 2*scalarSize])
259266
if err != nil {
260267
return err
@@ -272,6 +279,6 @@ func mustWrite(h io.Writer, bytes []byte) {
272279
panic(err)
273280
}
274281
if len(bytes) != bytesLen {
275-
panic("failed to write on hash")
282+
panic("dleq: failed to write on hash")
276283
}
277284
}

‎group/dleq/dleq_test.go renamed to ‎zk/dleq/dleq_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import (
88
"testing"
99

1010
"github.com/cloudflare/circl/group"
11-
"github.com/cloudflare/circl/group/dleq"
1211
"github.com/cloudflare/circl/internal/test"
12+
"github.com/cloudflare/circl/zk/dleq"
1313
)
1414

1515
func TestDLEQ(t *testing.T) {

0 commit comments

Comments
 (0)