Skip to content

Commit

Permalink
Merge pull request #81 from Zilliqa/develop
Browse files Browse the repository at this point in the history
merge from master
  • Loading branch information
renlulu authored Dec 1, 2020
2 parents b84f5e8 + bf799eb commit dd0ecad
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 6 deletions.
2 changes: 1 addition & 1 deletion keytools/secp256k1.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func GeneratePrivateKey() (PrivateKey, error) {
}
}
}
return bytes,nil
return bytes, nil
}

func GetPublicKeyFromPrivateKey(privateKey []byte, compress bool) []byte {
Expand Down
6 changes: 2 additions & 4 deletions schnorr/schnorr.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package go_schnorr

import (
"bytes"
"encoding/hex"
"errors"
"fmt"
"github.com/Zilliqa/gozilliqa-sdk/util"
Expand Down Expand Up @@ -69,7 +68,7 @@ func TrySign(privateKey []byte, publicKey []byte, message []byte, k []byte) ([]b
//4. Compute s = k - r * prv
// 4a. Compute r * prv
_r := *r
s := new(big.Int).Mod(_r.Mul(&_r, priKey),keytools.Secp256k1.N)
s := new(big.Int).Mod(_r.Mul(&_r, priKey), keytools.Secp256k1.N)
s = new(big.Int).Mod(new(big.Int).Sub(bintK, s), keytools.Secp256k1.N)

if s.Cmp(big.NewInt(0)) == 0 {
Expand Down Expand Up @@ -117,8 +116,7 @@ func Verify(publicKey []byte, msg []byte, r []byte, s []byte) bool {
_r := hash(Q, publicKey, msg)

rn := new(big.Int).SetBytes(r)
_rn := new(big.Int).Mod(new(big.Int).SetBytes(_r),keytools.Secp256k1.N)
fmt.Printf("r = %s, _r = %s\n", hex.EncodeToString(r), hex.EncodeToString(_r))
_rn := new(big.Int).Mod(new(big.Int).SetBytes(_r), keytools.Secp256k1.N)
return rn.Cmp(_rn) == 0
}

Expand Down
1 change: 0 additions & 1 deletion schnorr/schnorr_signer_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ func VerifySignature(publicKey []byte, message []byte, signature []byte) bool {
sig := util.EncodeHex(signature)

if len(sig) != 128 {
fmt.Printf("invalid signature length: %v\n", len(sig))
return false
}

Expand Down

0 comments on commit dd0ecad

Please sign in to comment.