Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
20 changes: 20 additions & 0 deletions std/signature/eddsa/eddsa.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
tedwards "github.com/consensys/gnark-crypto/ecc/twistededwards"

edwardsbls12377 "github.com/consensys/gnark-crypto/ecc/bls12-377/twistededwards"
edwardsbandersnatch "github.com/consensys/gnark-crypto/ecc/bls12-381/bandersnatch"
edwardsbls12381 "github.com/consensys/gnark-crypto/ecc/bls12-381/twistededwards"
edwardsbn254 "github.com/consensys/gnark-crypto/ecc/bn254/twistededwards"
edwardsbw6761 "github.com/consensys/gnark-crypto/ecc/bw6-761/twistededwards"
Expand Down Expand Up @@ -118,6 +119,7 @@ func parseSignature(curveID tedwards.ID, buf []byte) ([]byte, []byte, []byte, er

var pointbn254 edwardsbn254.PointAffine
var pointbls12381 edwardsbls12381.PointAffine
var pointbandersnatch edwardsbandersnatch.PointAffine
var pointbls12377 edwardsbls12377.PointAffine
var pointbw6761 edwardsbw6761.PointAffine

Expand All @@ -142,6 +144,16 @@ func parseSignature(curveID tedwards.ID, buf []byte) ([]byte, []byte, []byte, er
}
s := buf[32:]
return a, b, s, nil
case tedwards.BLS12_381_BANDERSNATCH:
if _, err := pointbandersnatch.SetBytes(buf[:32]); err != nil {
return nil, nil, nil, err
}
a, b, err := parsePoint(curveID, buf)
if err != nil {
return nil, nil, nil, err
}
s := buf[32:]
return a, b, s, nil
case tedwards.BLS12_377:
if _, err := pointbls12377.SetBytes(buf[:32]); err != nil {
return nil, nil, nil, err
Expand Down Expand Up @@ -171,6 +183,7 @@ func parseSignature(curveID tedwards.ID, buf []byte) ([]byte, []byte, []byte, er
func parsePoint(curveID tedwards.ID, buf []byte) ([]byte, []byte, error) {
var pointbn254 edwardsbn254.PointAffine
var pointbls12381 edwardsbls12381.PointAffine
var pointbandersnatch edwardsbandersnatch.PointAffine
var pointbls12377 edwardsbls12377.PointAffine
var pointbw6761 edwardsbw6761.PointAffine
switch curveID {
Expand All @@ -188,6 +201,13 @@ func parsePoint(curveID tedwards.ID, buf []byte) ([]byte, []byte, error) {
a := pointbls12381.X.Bytes()
b := pointbls12381.Y.Bytes()
return a[:], b[:], nil
case tedwards.BLS12_381_BANDERSNATCH:
if _, err := pointbandersnatch.SetBytes(buf[:32]); err != nil {
return nil, nil, err
}
a := pointbandersnatch.X.Bytes()
b := pointbandersnatch.Y.Bytes()
return a[:], b[:], nil
case tedwards.BLS12_377:
if _, err := pointbls12377.SetBytes(buf[:32]); err != nil {
return nil, nil, err
Expand Down
4 changes: 3 additions & 1 deletion std/signature/eddsa/eddsa_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ func forge(id tedwards.ID, sig []byte) ([]byte, error) {
offset = 32
case tedwards.BLS12_381:
offset = 32
case tedwards.BLS12_381_BANDERSNATCH:
offset = 32
case tedwards.BLS12_377:
offset = 32
case tedwards.BW6_761:
Expand Down Expand Up @@ -89,7 +91,7 @@ func TestEddsa(t *testing.T) {
confs := []testData{
{hash.MIMC_BN254, tedwards.BN254},
{hash.MIMC_BLS12_381, tedwards.BLS12_381},
// {hash.MIMC_BLS12_381, tedwards.BLS12_381_BANDERSNATCH},
{hash.MIMC_BLS12_381, tedwards.BLS12_381_BANDERSNATCH},
{hash.MIMC_BLS12_377, tedwards.BLS12_377},
{hash.MIMC_BW6_761, tedwards.BW6_761},
}
Expand Down