@@ -100,11 +100,13 @@ func GenerateSchnorrSignature(M string, X *big.Int, err error) (*bn256.G1, *bn25
100
100
return nil , nil , "" , nil , nil , err
101
101
} else {
102
102
P := new (bn256.G1 ).ScalarBaseMult (X )
103
+ P_point := NewCurvePoint (P )
103
104
k , _ := rand .Int (rand .Reader , bn256 .Order )
104
105
kG := new (bn256.G1 ).ScalarBaseMult (k )
106
+ kG_point := NewCurvePoint (kG )
105
107
h := sha3 .NewKeccak256 ()
106
108
h .Reset ()
107
- h .Write ([]byte (fmt .Sprintf ("%s%s%s" , M , P , kG )))
109
+ h .Write ([]byte (fmt .Sprintf ("%s%s%s%s%s " , M , P_point . X , P_point . Y , kG_point . X , kG_point . Y )))
108
110
e , _ := new (big.Int ).SetString (fmt .Sprintf ("%x" , h .Sum (nil )), 16 )
109
111
s := new (big.Int ).Mod (new (big.Int ).Add (k , new (big.Int ).Mul (e , X )), bn256 .Order )
110
112
return P , kG , M , e , s , nil
@@ -115,12 +117,14 @@ func VerifySchnorrSignature(P *bn256.G1, M string, E, S *big.Int, err error) (bo
115
117
if err != nil {
116
118
return false , err
117
119
} else {
120
+ P_point := NewCurvePoint (P )
118
121
sG := new (bn256.G1 ).ScalarBaseMult (S )
119
122
eP := new (bn256.G1 ).ScalarMult (P , E )
120
123
kG := new (bn256.G1 ).Add (sG , eP .Neg (eP ))
124
+ kG_point := NewCurvePoint (kG )
121
125
h := sha3 .NewKeccak256 ()
122
126
h .Reset ()
123
- h .Write ([]byte (fmt .Sprintf ("%s%s%s" , M , P , kG )))
127
+ h .Write ([]byte (fmt .Sprintf ("%s%s%s%s%s " , M , P_point . X , P_point . Y , kG_point . X , kG_point . Y )))
124
128
e , _ := new (big.Int ).SetString (fmt .Sprintf ("%x" , h .Sum (nil )), 16 )
125
129
return (e .Cmp (E ) == 0 ), nil
126
130
}
0 commit comments