From de25fb5e53a1ec363e7a1f3b4b45d6005bc54d00 Mon Sep 17 00:00:00 2001 From: NoelBright Date: Thu, 15 Nov 2018 18:38:58 +0800 Subject: [PATCH] [bugfix] panic when creating wallet 1. fixbug : 'panic: crypto/cipher: input not full blocks' Cause of the byte length of private key generated by crypto.GenKeyPair is not equal to 32. Signed-off-by: NoelBright --- crypto/crypto.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crypto/crypto.go b/crypto/crypto.go index 453b1c8e8..178ee471e 100644 --- a/crypto/crypto.go +++ b/crypto/crypto.go @@ -49,9 +49,13 @@ func GenKeyPair() ([]byte, PubKey, error) { return nil, *mPubKey, err } + privkey := make([]byte, util.PRIVATEKEYLEN) + copy(privkey[util.PRIVATEKEYLEN-len(privateD):], privateD) + mPubKey.X = new(big.Int).Set(X) mPubKey.Y = new(big.Int).Set(Y) - return privateD, *mPubKey, nil + + return privkey, *mPubKey, nil } func Sign(privateKey []byte, data []byte) ([]byte, error) {