Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ScalarMul on Bandersnatch #263

Merged
merged 33 commits into from
Mar 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
ee85623
perf(std/tEd): first bit in ScalarMul handled separately
yelhousni Feb 4, 2022
53f4c2b
perf(std/tEd): rearrange Double --> less constraints
yelhousni Feb 4, 2022
8ab558e
perf(std/EdDSA): rearrange eddsa verify (-1 addtion, -1 MustBeOnCurve)
yelhousni Feb 4, 2022
b400e56
perf(std/tEd): Lookup2 for first 2 bits in ScalarMulFixedBase
yelhousni Feb 4, 2022
cb10742
perf(std/tEd): FixedPoint should be hidden by the API
yelhousni Feb 4, 2022
f109fda
test(tEd): test scalarMul for all curves and schemes
yelhousni Feb 8, 2022
a78236d
fix(tEd): case when scalar size is odd
yelhousni Feb 9, 2022
368e153
fix(tEd): case when scalar size is odd
yelhousni Feb 9, 2022
5253c4c
refactor(eddsa): rearrange eddsa verif as cofactor clearing counts
yelhousni Feb 11, 2022
90be02e
feat(tEd): implements double-base scalar mul
yelhousni Feb 11, 2022
e37a645
perf(EdDSA): eddsa gadget using double-base scalar mul
yelhousni Feb 11, 2022
17c15e1
perf(bandersnatch): apply tEd perf changes to Bandersnatch
yelhousni Feb 14, 2022
9e7d3a9
fix: fixed wrong bigInt op in plonk api
ThomasPiellard Feb 14, 2022
5d35bfd
style(eddsa, tEd): no benchmarks
yelhousni Feb 14, 2022
cfaea83
style(eddsa, tEd): no benchmarks
yelhousni Feb 14, 2022
d6c3b3b
perf(bandersnatch): GLV scalar mul in-circuit
yelhousni Feb 16, 2022
5566b34
test(twistededwards): randomise test
yelhousni Feb 16, 2022
3bf7b54
Merge branch 'develop' into perf/EdDSA-Bandersnatch
yelhousni Feb 16, 2022
51c4544
refactor(bandersnatch): review PR 263
yelhousni Feb 17, 2022
a0acbdd
fix(bandersnatch): curveID in hint not checked
yelhousni Feb 17, 2022
fb60da2
fix(bandersnatch): check curveID for endomorphism availability
yelhousni Feb 18, 2022
0e9d9f7
style(bandersnatch): correct comment
yelhousni Feb 18, 2022
a96935c
Merge branch 'develop' into perf/EdDSA-Bandersnatch
yelhousni Feb 18, 2022
03ac556
style(bandersnatch): correct comment about negative scalars
yelhousni Feb 18, 2022
c34862d
fix(bandersnatch): increase scalars size bound to 129 + comments
yelhousni Feb 23, 2022
67c0845
Merge branch 'develop' into perf/EdDSA-Bandersnatch
gbotrel Mar 15, 2022
45dacc0
fix: hint signature in bandersnatch matches new format
gbotrel Mar 15, 2022
3adc130
refactor: eddsa factorizing and code cleaning (#285)
gbotrel Mar 22, 2022
d304d50
Merge branch 'develop' into perf/EdDSA-Bandersnatch
gbotrel Mar 22, 2022
4104a64
style: fix gosec errors in std/eddsa
gbotrel Mar 22, 2022
37f628d
Merge branch 'develop' into perf/EdDSA-Bandersnatch
gbotrel Mar 22, 2022
da77bc5
Merge branch 'develop' into perf/EdDSA-Bandersnatch
gbotrel Mar 23, 2022
6455247
feat: disable GLV mul in bandersnatch until #268 is fixed
gbotrel Mar 24, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 8 additions & 11 deletions examples/rollup/circuit.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package rollup

import (
tedwards "github.com/consensys/gnark-crypto/ecc/twistededwards"
"github.com/consensys/gnark/frontend"
"github.com/consensys/gnark/std/accumulator/merkle"
"github.com/consensys/gnark/std/algebra/twistededwards"
Expand Down Expand Up @@ -87,18 +88,8 @@ type TransferConstraints struct {
}

func (circuit *Circuit) postInit(api frontend.API) error {
// edward curve params
params, err := twistededwards.NewEdCurve(api.Compiler().Curve())
if err != nil {
return err
}

for i := 0; i < batchSize; i++ {
// setting sender public key
circuit.PublicKeysSender[i].Curve = params

// setting receiver public key
circuit.PublicKeysReceiver[i].Curve = params

// setting the sender accounts before update
circuit.SenderAccountsBefore[i].PubKey = circuit.PublicKeysSender[i]
Expand Down Expand Up @@ -163,7 +154,13 @@ func verifyTransferSignature(api frontend.API, t TransferConstraints, hFunc mimc
hFunc.Write(t.Nonce, t.Amount, t.SenderPubKey.A.X, t.SenderPubKey.A.Y, t.ReceiverPubKey.A.X, t.ReceiverPubKey.A.Y)
htransfer := hFunc.Sum()

err := eddsa.Verify(api, t.Signature, htransfer, t.SenderPubKey)
curve, err := twistededwards.NewEdCurve(api, tedwards.BN254)
if err != nil {
return err
}

hFunc.Reset()
err = eddsa.Verify(curve, t.Signature, htransfer, t.SenderPubKey, &hFunc)
if err != nil {
return err
}
Expand Down
7 changes: 6 additions & 1 deletion examples/rollup/rollup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,12 @@ func createAccount(i int) (Account, eddsa.PrivateKey) {
src := rand.NewSource(int64(i))
r := rand.New(src)

privkey, _ = eddsa.GenerateKey(r)
pkey, err := eddsa.GenerateKey(r)
if err != nil {
panic(err)
}
privkey = *pkey

acc.pubKey = privkey.PublicKey

return acc, privkey
Expand Down
1 change: 1 addition & 0 deletions frontend/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ func parseCircuit(builder Builder, circuit Circuit) (err error) {
// leafs are Constraints that need to be initialized in the context of compiling a circuit
var handler schema.LeafHandler = func(visibility schema.Visibility, name string, tInput reflect.Value) error {
if tInput.CanSet() {
// log.Trace().Str("name", name).Str("visibility", visibility.String()).Msg("init input wire")
switch visibility {
case schema.Secret:
tInput.Set(reflect.ValueOf(builder.AddSecretVariable(name)))
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ go 1.17

require (
github.com/consensys/bavard v0.1.10
github.com/consensys/gnark-crypto v0.6.1
github.com/fxamacker/cbor/v2 v2.4.0
github.com/consensys/gnark-crypto v0.6.2-0.20220317143658-fb0d80a11bf4
github.com/fxamacker/cbor/v2 v2.2.0
github.com/leanovate/gopter v0.2.9
github.com/rs/zerolog v1.26.1
github.com/stretchr/testify v1.7.1
Expand Down
9 changes: 4 additions & 5 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
github.com/consensys/bavard v0.1.9/go.mod h1:9ItSMtA/dXMAiL7BG6bqW2m3NdSEObYWoH223nGHukI=
github.com/consensys/bavard v0.1.10 h1:1I/IvY7bkX/O7QLNCEuV2+YBKdTetzw3gnBbvFaWiEE=
github.com/consensys/bavard v0.1.10/go.mod h1:9ItSMtA/dXMAiL7BG6bqW2m3NdSEObYWoH223nGHukI=
github.com/consensys/gnark-crypto v0.6.1 h1:MuWaJyWzSw8wQUOfiZOlRwYjfweIj8dM/u2NN6m0O04=
github.com/consensys/gnark-crypto v0.6.1/go.mod h1:s41Bl3YIpNgu/zdvlSzf/xZkyV8MUmoBY96RmuB8x70=
github.com/consensys/gnark-crypto v0.6.2-0.20220317143658-fb0d80a11bf4 h1:ZsuTwNqDe83xtYP8SplQ9iOoXgOoLg9WzP04VfqOjGc=
github.com/consensys/gnark-crypto v0.6.2-0.20220317143658-fb0d80a11bf4/go.mod h1:BnexKTAHX6j7zpGXR/s6E/R0tyYtbnXlbhIMQkNdcPs=
github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/fxamacker/cbor/v2 v2.4.0 h1:ri0ArlOR+5XunOP8CRUowT0pSJOwhW098ZCUyskZD88=
github.com/fxamacker/cbor/v2 v2.4.0/go.mod h1:TA1xS00nchWmaBnEIxPSE5oHLuJBAVvqrtAnWBwBCVo=
github.com/fxamacker/cbor/v2 v2.2.0 h1:6eXqdDDe588rSYAi1HfZKbx6YYQO4mxQ9eC6xYpU/JQ=
github.com/fxamacker/cbor/v2 v2.2.0/go.mod h1:TA1xS00nchWmaBnEIxPSE5oHLuJBAVvqrtAnWBwBCVo=
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
Expand Down
Binary file modified internal/stats/latest.stats
Binary file not shown.
76 changes: 0 additions & 76 deletions std/algebra/twistededwards/bandersnatch/curve.go

This file was deleted.

179 changes: 0 additions & 179 deletions std/algebra/twistededwards/bandersnatch/point.go

This file was deleted.

Loading