Skip to content

Commit

Permalink
use github.com/vocdoni/vocdoni-z-sandbox/ecc/format instead deprecate…
Browse files Browse the repository at this point in the history
…d internal package
  • Loading branch information
lucasmenendez committed Nov 11, 2024
1 parent a9fc740 commit 32c548f
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 102 deletions.
5 changes: 2 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
module github.com/vocdoni/gnark-crypto-primitives

go 1.23.0

toolchain go1.23.2
go 1.23.2

require (
github.com/consensys/gnark v0.11.0
github.com/consensys/gnark-crypto v0.14.0
github.com/frankban/quicktest v1.14.6
github.com/iden3/go-iden3-crypto v0.0.17
github.com/vocdoni/vocdoni-z-sandbox v0.0.0-20241111130906-b8e8592696c6
go.vocdoni.io/dvote v1.10.2-0.20241024102542-c1ce6d744bc5
)

Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/syndtr/goleveldb v1.0.1-0.20220614013038-64ee5596c38a h1:1ur3QoCqvE5fl+nylMaIr9PVV1w343YRDtsy+Rwu7XI=
github.com/syndtr/goleveldb v1.0.1-0.20220614013038-64ee5596c38a/go.mod h1:RRCYJbIwD5jmqPI9XoAFR0OcDxqUctll6zUj/+B4S48=
github.com/vocdoni/vocdoni-z-sandbox v0.0.0-20241111130906-b8e8592696c6 h1:Lnikgc2rZsnxZDwGbPhlsmq0yiLRotKDOGnuOOYU37o=
github.com/vocdoni/vocdoni-z-sandbox v0.0.0-20241111130906-b8e8592696c6/go.mod h1:B43i83saYhSReG+jNAj0igxWcZYHGjF2AeXunaXnCQE=
github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM=
github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg=
github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c=
Expand Down
14 changes: 7 additions & 7 deletions hadd/homomorphic_add_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/consensys/gnark/std/algebra/native/twistededwards"
"github.com/consensys/gnark/test"
"github.com/iden3/go-iden3-crypto/babyjub"
tw "github.com/vocdoni/gnark-crypto-primitives/internal/twistededwards"
"github.com/vocdoni/vocdoni-z-sandbox/ecc/format"
)

type testHomomorphicAddCircuit struct {
Expand Down Expand Up @@ -57,8 +57,8 @@ func TestHomomorphicAdd(t *testing.T) {
msg1 := big.NewInt(3)
a1, a2 := encrypt(msg1, pubKey, k1)
// reduce the points to reduced twisted edwards form
xA1RTE, yA1RTE := tw.FromTEtoRTE(a1.X, a1.Y)
xA2RTE, yA2RTE := tw.FromTEtoRTE(a2.X, a2.Y)
xA1RTE, yA1RTE := format.FromTEtoRTE(a1.X, a1.Y)
xA2RTE, yA2RTE := format.FromTEtoRTE(a2.X, a2.Y)
// generate a second random k to encrypt a second message
k2, err := randomK()
if err != nil {
Expand All @@ -69,14 +69,14 @@ func TestHomomorphicAdd(t *testing.T) {
msg2 := big.NewInt(5)
b1, b2 := encrypt(msg2, pubKey, k2)
// reduce the points to reduced twisted edwards form
xB1RTE, yB1RTE := tw.FromTEtoRTE(b1.X, b1.Y)
xB2RTE, yB2RTE := tw.FromTEtoRTE(b2.X, b2.Y)
xB1RTE, yB1RTE := format.FromTEtoRTE(b1.X, b1.Y)
xB2RTE, yB2RTE := format.FromTEtoRTE(b2.X, b2.Y)
// calculate the sum of the encrypted messages to check the homomorphic property
c1 := new(babyjub.PointProjective).Add(a1.Projective(), b1.Projective()).Affine()
c2 := new(babyjub.PointProjective).Add(a2.Projective(), b2.Projective()).Affine()
// reduce the points to reduced twisted edwards form
xC1RTE, yC1RTE := tw.FromTEtoRTE(c1.X, c1.Y)
xC2RTE, yC2RTE := tw.FromTEtoRTE(c2.X, c2.Y)
xC1RTE, yC1RTE := format.FromTEtoRTE(c1.X, c1.Y)
xC2RTE, yC2RTE := format.FromTEtoRTE(c2.X, c2.Y)
// profiling the circuit compilation
p := profile.Start()
now := time.Now()
Expand Down
64 changes: 0 additions & 64 deletions internal/twistededwards/twistededwards.go

This file was deleted.

25 changes: 0 additions & 25 deletions internal/twistededwards/twistededwards_test.go

This file was deleted.

6 changes: 3 additions & 3 deletions twistededwards/twistededwards_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/consensys/gnark/frontend/cs/r1cs"
"github.com/consensys/gnark/profile"
"github.com/consensys/gnark/test"
"github.com/vocdoni/gnark-crypto-primitives/internal/twistededwards"
"github.com/vocdoni/vocdoni-z-sandbox/ecc/format"
)

type testFromTwistedEdwards struct {
Expand Down Expand Up @@ -41,7 +41,7 @@ func TestFromTwistedEdwards(t *testing.T) {
x, _ := new(big.Int).SetString("20284931487578954787250358776722960153090567235942462656834196519767860852891", 10)
y, _ := new(big.Int).SetString("21185575020764391300398134415668786804224896114060668011215204645513129497221", 10)

xRTE, yRTE := twistededwards.FromTEtoRTE(x, y)
xRTE, yRTE := format.FromTEtoRTE(x, y)
// profiling the circuit compilation
p := profile.Start()
now := time.Now()
Expand All @@ -67,7 +67,7 @@ func TestFromReducedTwistedEdwards(t *testing.T) {
x, _ := new(big.Int).SetString("20284931487578954787250358776722960153090567235942462656834196519767860852891", 10)
y, _ := new(big.Int).SetString("21185575020764391300398134415668786804224896114060668011215204645513129497221", 10)

xRTE, yRTE := twistededwards.FromTEtoRTE(x, y)
xRTE, yRTE := format.FromTEtoRTE(x, y)
// profiling the circuit compilation
p := profile.Start()
now := time.Now()
Expand Down

0 comments on commit 32c548f

Please sign in to comment.