Commit 5bcd3455 authored by pengjun's avatar pengjun

fix ci fmt

parent 970f40a2
...@@ -8,26 +8,22 @@ import ( ...@@ -8,26 +8,22 @@ import (
"math/big" "math/big"
"github.com/33cn/chain33/common" "github.com/33cn/chain33/common"
"github.com/33cn/chain33/types"
) )
func CiphertextAdd(ciphertext1, ciphertext2 string) (string, error) { func CiphertextAdd(ciphertext1, ciphertext2 string) (string, error) {
cipherbytes1, err := common.FromHex(ciphertext1) cipherbytes1, err := common.FromHex(ciphertext1)
if err != nil { if err != nil {
fmt.Errorf("CiphertextAdd.FromHex. ciphertext1:%s, error:%v", ciphertext1, err) return "", fmt.Errorf("CiphertextAdd.FromHex. ciphertext1:%s, error:%v", ciphertext1, err)
return "", err
} }
cipherbytes2, err := common.FromHex(ciphertext2) cipherbytes2, err := common.FromHex(ciphertext2)
if err != nil { if err != nil {
fmt.Errorf("CiphertextAdd.FromHex. ciphertext2:%s, error:%v", ciphertext2, err) return "", fmt.Errorf("CiphertextAdd.FromHex. ciphertext2:%s, error:%v", ciphertext2, err)
return "", err
} }
res, err := CiphertextAddBytes(cipherbytes1, cipherbytes2) res, err := CiphertextAddBytes(cipherbytes1, cipherbytes2)
if err != nil { if err != nil {
fmt.Errorf("CiphertextAdd.CiphertextAddBytes. error:%v", err) return "", fmt.Errorf("CiphertextAdd.CiphertextAddBytes. error:%v", err)
return "", nil
} }
return hex.EncodeToString(res), nil return hex.EncodeToString(res), nil
...@@ -36,8 +32,7 @@ func CiphertextAdd(ciphertext1, ciphertext2 string) (string, error) { ...@@ -36,8 +32,7 @@ func CiphertextAdd(ciphertext1, ciphertext2 string) (string, error) {
func CiphertextAddBytes(cipherbytes1, cipherbytes2 []byte) ([]byte, error) { func CiphertextAddBytes(cipherbytes1, cipherbytes2 []byte) ([]byte, error) {
nlen1 := bytesToInt(cipherbytes1[0:2]) nlen1 := bytesToInt(cipherbytes1[0:2])
if nlen1 >= len(cipherbytes1)-2 { if nlen1 >= len(cipherbytes1)-2 {
fmt.Errorf("CiphertextAddBytes. error param length") return nil, fmt.Errorf("CiphertextAddBytes. error param length")
return nil, types.ErrInvalidParam
} }
nBytes1 := make([]byte, nlen1) nBytes1 := make([]byte, nlen1)
...@@ -45,16 +40,14 @@ func CiphertextAddBytes(cipherbytes1, cipherbytes2 []byte) ([]byte, error) { ...@@ -45,16 +40,14 @@ func CiphertextAddBytes(cipherbytes1, cipherbytes2 []byte) ([]byte, error) {
nlen2 := bytesToInt(cipherbytes2[0:2]) nlen2 := bytesToInt(cipherbytes2[0:2])
if nlen2 >= len(cipherbytes2)-2 { if nlen2 >= len(cipherbytes2)-2 {
fmt.Errorf("CiphertextAddBytes. error param length") return nil, fmt.Errorf("CiphertextAddBytes. error param length")
return nil, types.ErrInvalidParam
} }
nBytes2 := make([]byte, nlen2) nBytes2 := make([]byte, nlen2)
copy(nBytes2, cipherbytes2[2:2+nlen2]) copy(nBytes2, cipherbytes2[2:2+nlen2])
if !bytes.Equal(nBytes1, nBytes2) { if !bytes.Equal(nBytes1, nBytes2) {
fmt.Errorf("CiphertextAddBytes. error: param error n1!=n2") return nil, fmt.Errorf("CiphertextAddBytes. error: param error nBytes1!=nBytes2")
return nil, types.ErrInvalidParam
} }
data1 := make([]byte, len(cipherbytes1)-nlen1-2) data1 := make([]byte, len(cipherbytes1)-nlen1-2)
......
...@@ -200,15 +200,13 @@ func (s *StorageAction) EncryptAdd(payload *ety.EncryptNotaryAdd) (*types.Receip ...@@ -200,15 +200,13 @@ func (s *StorageAction) EncryptAdd(payload *ety.EncryptNotaryAdd) (*types.Receip
store, err := QueryStorage(s.db, s.localdb, payload.Key) store, err := QueryStorage(s.db, s.localdb, payload.Key)
if err != nil { if err != nil {
fmt.Errorf("EncryptAdd.QueryStorage. err:%v", err) return nil, fmt.Errorf("EncryptAdd.QueryStorage. err:%v", err)
return nil, err
} }
cipherText := store.GetEncryptStorage().EncryptContent cipherText := store.GetEncryptStorage().EncryptContent
res, err := paillier.CiphertextAddBytes(cipherText, payload.EncryptAdd) res, err := paillier.CiphertextAddBytes(cipherText, payload.EncryptAdd)
if err != nil { if err != nil {
fmt.Errorf("EncryptAdd.CiphertextAddBytes. err:%v", err) return nil, fmt.Errorf("EncryptAdd.CiphertextAddBytes. err:%v", err)
return nil, err
} }
store.GetEncryptStorage().EncryptContent = res store.GetEncryptStorage().EncryptContent = res
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment