Skip to content

Commit 880af5e

Browse files
committed
fix already sum canonical ed25519 private key
1 parent eb5b774 commit 880af5e

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

transaction.go

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -396,19 +396,24 @@ func verifyRawTransactionBySequencer(ctx context.Context, traceId string, ver *c
396396
return verified[0], nil
397397
}
398398

399-
func signRawTransaction(ver *common.VersionedTransaction, views []string, spendKey string, isSum bool) (*common.VersionedTransaction, error) {
399+
func signRawTransaction(ver *common.VersionedTransaction, views []string, spendKey string, isSumAlready bool) (*common.VersionedTransaction, error) {
400400
msg := ver.PayloadHash()
401401
spent, err := crypto.KeyFromString(spendKey)
402402
if err != nil {
403403
return nil, err
404404
}
405-
spenty := sha512.Sum512(spent[:])
406-
if isSum {
407-
copy(spenty[:], spent[:])
408-
}
409-
y, err := edwards25519.NewScalar().SetBytesWithClamping(spenty[:32])
410-
if err != nil {
411-
return nil, err
405+
var y *edwards25519.Scalar
406+
if isSumAlready {
407+
y, err = edwards25519.NewScalar().SetCanonicalBytes(spent[:])
408+
if err != nil {
409+
return nil, err
410+
}
411+
} else {
412+
spenty := sha512.Sum512(spent[:])
413+
y, err = edwards25519.NewScalar().SetBytesWithClamping(spenty[:32])
414+
if err != nil {
415+
return nil, err
416+
}
412417
}
413418
signaturesMap := make([]map[uint16]*crypto.Signature, len(ver.Inputs))
414419
for i := range ver.Inputs {

0 commit comments

Comments
 (0)