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
65407745
Commit
65407745
authored
Jul 25, 2019
by
jiangpeng
Committed by
33cn
Jul 29, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
privacy:update asset store key
parent
24d6635f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
11 deletions
+11
-11
exec.go
plugin/dapp/privacy/executor/exec.go
+5
-5
kv.go
plugin/dapp/privacy/executor/kv.go
+4
-4
privacy.go
plugin/dapp/privacy/executor/privacy.go
+2
-2
No files found.
plugin/dapp/privacy/executor/exec.go
View file @
65407745
...
...
@@ -38,7 +38,7 @@ func (p *privacy) Exec_Public2Privacy(payload *ty.Public2Privacy, tx *types.Tran
//executor中的临时数据库中,只需要将kv返回给blockchain就行
//即:一个块中产生的UTXO是不能够在同一个高度进行支付的
for
index
,
keyOutput
:=
range
output
{
key
:=
CalcPrivacyOutputKey
(
payload
.
Tokenname
,
keyOutput
.
Amount
,
txhash
,
index
)
key
:=
CalcPrivacyOutputKey
(
payload
.
AssetExec
,
payload
.
Tokenname
,
keyOutput
.
Amount
,
txhash
,
index
)
value
:=
types
.
Encode
(
keyOutput
)
receipt
.
KV
=
append
(
receipt
.
KV
,
&
types
.
KeyValue
{
Key
:
key
,
Value
:
value
})
}
...
...
@@ -65,7 +65,7 @@ func (p *privacy) Exec_Privacy2Privacy(payload *ty.Privacy2Privacy, tx *types.Tr
privacyInput
:=
payload
.
Input
for
_
,
keyInput
:=
range
privacyInput
.
Keyinput
{
value
:=
[]
byte
{
keyImageSpentAlready
}
key
:=
calcPrivacyKeyImageKey
(
payload
.
Tokenname
,
keyInput
.
KeyImage
)
key
:=
calcPrivacyKeyImageKey
(
payload
.
AssetExec
,
payload
.
Tokenname
,
keyInput
.
KeyImage
)
stateDB
:=
p
.
GetStateDB
()
stateDB
.
Set
(
key
,
value
)
receipt
.
KV
=
append
(
receipt
.
KV
,
&
types
.
KeyValue
{
Key
:
key
,
Value
:
value
})
...
...
@@ -77,7 +77,7 @@ func (p *privacy) Exec_Privacy2Privacy(payload *ty.Privacy2Privacy, tx *types.Tr
txhash
:=
common
.
ToHex
(
tx
.
Hash
())
output
:=
payload
.
GetOutput
()
.
GetKeyoutput
()
for
index
,
keyOutput
:=
range
output
{
key
:=
CalcPrivacyOutputKey
(
payload
.
Tokenname
,
keyOutput
.
Amount
,
txhash
,
index
)
key
:=
CalcPrivacyOutputKey
(
payload
.
AssetExec
,
payload
.
Tokenname
,
keyOutput
.
Amount
,
txhash
,
index
)
value
:=
types
.
Encode
(
keyOutput
)
receipt
.
KV
=
append
(
receipt
.
KV
,
&
types
.
KeyValue
{
Key
:
key
,
Value
:
value
})
}
...
...
@@ -113,7 +113,7 @@ func (p *privacy) Exec_Privacy2Public(payload *ty.Privacy2Public, tx *types.Tran
privacyInput
:=
payload
.
Input
for
_
,
keyInput
:=
range
privacyInput
.
Keyinput
{
value
:=
[]
byte
{
keyImageSpentAlready
}
key
:=
calcPrivacyKeyImageKey
(
payload
.
Tokenname
,
keyInput
.
KeyImage
)
key
:=
calcPrivacyKeyImageKey
(
payload
.
AssetExec
,
payload
.
Tokenname
,
keyInput
.
KeyImage
)
stateDB
:=
p
.
GetStateDB
()
stateDB
.
Set
(
key
,
value
)
receipt
.
KV
=
append
(
receipt
.
KV
,
&
types
.
KeyValue
{
Key
:
key
,
Value
:
value
})
...
...
@@ -125,7 +125,7 @@ func (p *privacy) Exec_Privacy2Public(payload *ty.Privacy2Public, tx *types.Tran
txhash
:=
common
.
ToHex
(
tx
.
Hash
())
output
:=
payload
.
GetOutput
()
.
GetKeyoutput
()
for
index
,
keyOutput
:=
range
output
{
key
:=
CalcPrivacyOutputKey
(
payload
.
Tokenname
,
keyOutput
.
Amount
,
txhash
,
index
)
key
:=
CalcPrivacyOutputKey
(
payload
.
AssetExec
,
payload
.
Tokenname
,
keyOutput
.
Amount
,
txhash
,
index
)
value
:=
types
.
Encode
(
keyOutput
)
receipt
.
KV
=
append
(
receipt
.
KV
,
&
types
.
KeyValue
{
Key
:
key
,
Value
:
value
})
}
...
...
plugin/dapp/privacy/executor/kv.go
View file @
65407745
...
...
@@ -22,12 +22,12 @@ const (
//CalcPrivacyOutputKey 该key对应的是types.KeyOutput
//该kv会在store中设置
func
CalcPrivacyOutputKey
(
token
string
,
amount
int64
,
txhash
string
,
outindex
int
)
(
key
[]
byte
)
{
return
[]
byte
(
fmt
.
Sprintf
(
privacyOutputKeyPrefix
+
"-%s-%
d-%s-%d"
,
token
,
amount
,
txhash
,
outindex
))
func
CalcPrivacyOutputKey
(
exec
,
token
string
,
amount
int64
,
txhash
string
,
outindex
int
)
(
key
[]
byte
)
{
return
[]
byte
(
fmt
.
Sprintf
(
privacyOutputKeyPrefix
+
"-%s-%
s-%d-%s-%d"
,
exec
,
token
,
amount
,
txhash
,
outindex
))
}
func
calcPrivacyKeyImageKey
(
token
string
,
keyimage
[]
byte
)
[]
byte
{
return
[]
byte
(
fmt
.
Sprintf
(
privacyKeyImagePrefix
+
"-%s-%s
"
,
token
,
common
.
ToHex
(
keyimage
)))
func
calcPrivacyKeyImageKey
(
exec
,
token
string
,
keyimage
[]
byte
)
[]
byte
{
return
[]
byte
(
fmt
.
Sprintf
(
privacyKeyImagePrefix
+
"-%s-%s
-%s"
,
exec
,
token
,
common
.
ToHex
(
keyimage
)))
}
//CalcPrivacyUTXOkeyHeight 在本地数据库中设置一条可以找到对应amount的对应的utxo的global index
...
...
plugin/dapp/privacy/executor/privacy.go
View file @
65407745
...
...
@@ -244,9 +244,9 @@ func (p *privacy) CheckTx(tx *types.Transaction, index int) error {
pubkeys
:=
make
([][]
byte
,
0
)
for
i
,
input
:=
range
keyinput
{
totalInput
+=
input
.
Amount
keyImages
[
i
]
=
calcPrivacyKeyImageKey
(
token
,
input
.
KeyImage
)
keyImages
[
i
]
=
calcPrivacyKeyImageKey
(
assertExec
,
token
,
input
.
KeyImage
)
for
j
,
globalIndex
:=
range
input
.
UtxoGlobalIndex
{
keys
=
append
(
keys
,
CalcPrivacyOutputKey
(
token
,
input
.
Amount
,
common
.
ToHex
(
globalIndex
.
Txhash
),
int
(
globalIndex
.
Outindex
)))
keys
=
append
(
keys
,
CalcPrivacyOutputKey
(
assertExec
,
token
,
input
.
Amount
,
common
.
ToHex
(
globalIndex
.
Txhash
),
int
(
globalIndex
.
Outindex
)))
pubkeys
=
append
(
pubkeys
,
ringSignature
.
Items
[
i
]
.
Pubkey
[
j
])
}
}
...
...
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