Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
plugin
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
link33
plugin
Commits
5bcd3455
Commit
5bcd3455
authored
Oct 26, 2020
by
pengjun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix ci fmt
parent
970f40a2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
17 deletions
+8
-17
paillier.go
plugin/crypto/paillier/paillier.go
+6
-13
storagedb.go
plugin/dapp/storage/executor/storagedb.go
+2
-4
No files found.
plugin/crypto/paillier/paillier.go
View file @
5bcd3455
...
@@ -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
)
...
...
plugin/dapp/storage/executor/storagedb.go
View file @
5bcd3455
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment