Commit 5bcd3455 authored by pengjun's avatar pengjun

fix ci fmt

parent 970f40a2
......@@ -8,26 +8,22 @@ import (
"math/big"
"github.com/33cn/chain33/common"
"github.com/33cn/chain33/types"
)
func CiphertextAdd(ciphertext1, ciphertext2 string) (string, error) {
cipherbytes1, err := common.FromHex(ciphertext1)
if err != nil {
fmt.Errorf("CiphertextAdd.FromHex. ciphertext1:%s, error:%v", ciphertext1, err)
return "", err
return "", fmt.Errorf("CiphertextAdd.FromHex. ciphertext1:%s, error:%v", ciphertext1, err)
}
cipherbytes2, err := common.FromHex(ciphertext2)
if err != nil {
fmt.Errorf("CiphertextAdd.FromHex. ciphertext2:%s, error:%v", ciphertext2, err)
return "", err
return "", fmt.Errorf("CiphertextAdd.FromHex. ciphertext2:%s, error:%v", ciphertext2, err)
}
res, err := CiphertextAddBytes(cipherbytes1, cipherbytes2)
if err != nil {
fmt.Errorf("CiphertextAdd.CiphertextAddBytes. error:%v", err)
return "", nil
return "", fmt.Errorf("CiphertextAdd.CiphertextAddBytes. error:%v", err)
}
return hex.EncodeToString(res), nil
......@@ -36,8 +32,7 @@ func CiphertextAdd(ciphertext1, ciphertext2 string) (string, error) {
func CiphertextAddBytes(cipherbytes1, cipherbytes2 []byte) ([]byte, error) {
nlen1 := bytesToInt(cipherbytes1[0:2])
if nlen1 >= len(cipherbytes1)-2 {
fmt.Errorf("CiphertextAddBytes. error param length")
return nil, types.ErrInvalidParam
return nil, fmt.Errorf("CiphertextAddBytes. error param length")
}
nBytes1 := make([]byte, nlen1)
......@@ -45,16 +40,14 @@ func CiphertextAddBytes(cipherbytes1, cipherbytes2 []byte) ([]byte, error) {
nlen2 := bytesToInt(cipherbytes2[0:2])
if nlen2 >= len(cipherbytes2)-2 {
fmt.Errorf("CiphertextAddBytes. error param length")
return nil, types.ErrInvalidParam
return nil, fmt.Errorf("CiphertextAddBytes. error param length")
}
nBytes2 := make([]byte, nlen2)
copy(nBytes2, cipherbytes2[2:2+nlen2])
if !bytes.Equal(nBytes1, nBytes2) {
fmt.Errorf("CiphertextAddBytes. error: param error n1!=n2")
return nil, types.ErrInvalidParam
return nil, fmt.Errorf("CiphertextAddBytes. error: param error nBytes1!=nBytes2")
}
data1 := make([]byte, len(cipherbytes1)-nlen1-2)
......
......@@ -200,15 +200,13 @@ func (s *StorageAction) EncryptAdd(payload *ety.EncryptNotaryAdd) (*types.Receip
store, err := QueryStorage(s.db, s.localdb, payload.Key)
if err != nil {
fmt.Errorf("EncryptAdd.QueryStorage. err:%v", err)
return nil, err
return nil, fmt.Errorf("EncryptAdd.QueryStorage. err:%v", err)
}
cipherText := store.GetEncryptStorage().EncryptContent
res, err := paillier.CiphertextAddBytes(cipherText, payload.EncryptAdd)
if err != nil {
fmt.Errorf("EncryptAdd.CiphertextAddBytes. err:%v", err)
return nil, err
return nil, fmt.Errorf("EncryptAdd.CiphertextAddBytes. err:%v", err)
}
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