diff --git a/blockutil.go b/blockutil.go index 0cb70dc..f93625b 100644 --- a/blockutil.go +++ b/blockutil.go @@ -11,6 +11,7 @@ package main import ( "crypto/dsa" "crypto/rand" + "crypto/sha256" "encoding/json" "fmt" "io" @@ -91,7 +92,8 @@ func Send(receiver string, amount string) { key := GetKey() sender := key.PublicKey.Y parametersString := fmt.Sprintf("&%s&%s&%s", key.PublicKey.Parameters.P, key.PublicKey.Parameters.Q, key.PublicKey.Parameters.G) - r, s, err := dsa.Sign(rand.Reader, &key, []byte(fmt.Sprintf("%s:%s:%s", sender, receiver, amount))) + hash := sha256.Sum256([]byte(fmt.Sprintf("%s:%s:%s", sender, receiver, amount))) + r, s, err := dsa.Sign(rand.Reader, &key, hash[:]) if err != nil { panic(err) } diff --git a/builds/node/node_darwin-amd64 b/builds/node/node_darwin-amd64 index 732783c..7286437 100755 Binary files a/builds/node/node_darwin-amd64 and b/builds/node/node_darwin-amd64 differ diff --git a/builds/node/node_darwin-arm64 b/builds/node/node_darwin-arm64 index 84db7c0..027f445 100755 Binary files a/builds/node/node_darwin-arm64 and b/builds/node/node_darwin-arm64 differ diff --git a/builds/node/node_linux-386 b/builds/node/node_linux-386 index 87e84b8..0ff8b39 100755 Binary files a/builds/node/node_linux-386 and b/builds/node/node_linux-386 differ diff --git a/builds/node/node_linux-amd64 b/builds/node/node_linux-amd64 index 4d03521..bdc0c71 100755 Binary files a/builds/node/node_linux-amd64 and b/builds/node/node_linux-amd64 differ diff --git a/builds/node/node_linux-arm b/builds/node/node_linux-arm index f195af8..f021080 100755 Binary files a/builds/node/node_linux-arm and b/builds/node/node_linux-arm differ diff --git a/builds/node/node_linux-arm64 b/builds/node/node_linux-arm64 index 56b2249..bab081a 100755 Binary files a/builds/node/node_linux-arm64 and b/builds/node/node_linux-arm64 differ diff --git a/builds/node/node_windows-386 b/builds/node/node_windows-386 index 9c0d990..352a5b5 100755 Binary files a/builds/node/node_windows-386 and b/builds/node/node_windows-386 differ diff --git a/builds/node/node_windows-amd64 b/builds/node/node_windows-amd64 index 7c08a6c..3db2462 100755 Binary files a/builds/node/node_windows-amd64 and b/builds/node/node_windows-amd64 differ diff --git a/builds/node/node_windows-arm b/builds/node/node_windows-arm index e6d8b03..9537004 100755 Binary files a/builds/node/node_windows-arm and b/builds/node/node_windows-arm differ diff --git a/builds/node/node_windows-arm64 b/builds/node/node_windows-arm64 index 8a16342..957410e 100755 Binary files a/builds/node/node_windows-arm64 and b/builds/node/node_windows-arm64 differ diff --git a/verify.go b/verify.go index 16ba1cf..c9d0774 100644 --- a/verify.go +++ b/verify.go @@ -10,6 +10,7 @@ package main import ( "crypto/dsa" + "crypto/sha256" "encoding/binary" "fmt" "math/big" @@ -21,7 +22,8 @@ func VerifyTransaction(senderKey dsa.PublicKey, recipientKey dsa.PublicKey, amou if err != nil { panic(err) } - isValid := dsa.Verify(&senderKey, []byte(fmt.Sprintf("%s:%s:%s", senderKey.Y, recipientKey.Y, strconv.FormatFloat(amountFloat, 'f', -1, 64))), &r, &s) + hash := sha256.Sum256([]byte(fmt.Sprintf("%s:%s:%f", senderKey.Y, recipientKey.Y, amountFloat))) + isValid := dsa.Verify(&senderKey, hash[:], &r, &s) if !isValid { return false }