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
6a0752f6
Commit
6a0752f6
authored
Nov 18, 2020
by
madengji
Committed by
vipwzw
Sep 18, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add commit value calc
parent
928b3daf
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
171 additions
and
52 deletions
+171
-52
deposit_test.go
plugin/dapp/mix/cmd/gnark/circuit/deposit_test.go
+3
-0
util.go
plugin/dapp/mix/cmd/gnark/circuit/util.go
+2
-1
calc.go
plugin/dapp/mix/cmd/gnark/cmd/calc.go
+66
-6
read.go
plugin/dapp/mix/cmd/gnark/cmd/read.go
+0
-1
mix.go
plugin/dapp/mix/commands/mix.go
+56
-7
committree.go
plugin/dapp/mix/executor/committree.go
+4
-4
deposit.go
plugin/dapp/mix/executor/deposit.go
+7
-5
kv.go
plugin/dapp/mix/executor/kv.go
+10
-10
transfer.go
plugin/dapp/mix/executor/transfer.go
+7
-6
withdraw.go
plugin/dapp/mix/executor/withdraw.go
+2
-2
verify_test.go
plugin/dapp/mix/executor/zksnark/verify_test.go
+2
-1
mix.go
plugin/dapp/mix/types/mix.go
+6
-6
mix.pb.go
plugin/dapp/mix/types/mix.pb.go
+2
-1
type.go
plugin/dapp/mix/types/type.go
+4
-2
No files found.
plugin/dapp/mix/cmd/gnark/circuit/deposit_test.go
View file @
6a0752f6
...
@@ -35,6 +35,9 @@ func TestDeposit(t *testing.T) {
...
@@ -35,6 +35,9 @@ func TestDeposit(t *testing.T) {
//authorize prikey="17822967620457187568904804290291537271142779717280482398091401115827760898835"
//authorize prikey="17822967620457187568904804290291537271142779717280482398091401115827760898835"
//authorize pubkey="13519883267141251871527102103999205179714486518503885909948192364772977661583"
//authorize pubkey="13519883267141251871527102103999205179714486518503885909948192364772977661583"
//spend prikey="10407830929890509544473717262275616077696950294748419792758056545898949331744"
//spend pubkey="12419942056983622012214804185935674735538011812395392042541464417352183370586"
r1cs
:=
NewDeposit
()
r1cs
:=
NewDeposit
()
r1csBN256
:=
backend_bn256
.
Cast
(
r1cs
)
r1csBN256
:=
backend_bn256
.
Cast
(
r1cs
)
{
{
...
...
plugin/dapp/mix/cmd/gnark/circuit/util.go
View file @
6a0752f6
package
main
package
main
import
(
import
(
"strconv"
"github.com/consensys/gnark/frontend"
"github.com/consensys/gnark/frontend"
twistededwards_gadget
"github.com/consensys/gnark/gadgets/algebra/twistededwards"
twistededwards_gadget
"github.com/consensys/gnark/gadgets/algebra/twistededwards"
"github.com/consensys/gnark/gadgets/hash/mimc"
"github.com/consensys/gnark/gadgets/hash/mimc"
"github.com/consensys/gurvy"
"github.com/consensys/gurvy"
fr_bn256
"github.com/consensys/gurvy/bn256/fr"
fr_bn256
"github.com/consensys/gurvy/bn256/fr"
"strconv"
)
)
func
merkelPathPart
(
circuit
*
frontend
.
CS
,
mimc
mimc
.
MiMCGadget
,
noteHash
*
frontend
.
Constraint
)
{
func
merkelPathPart
(
circuit
*
frontend
.
CS
,
mimc
mimc
.
MiMCGadget
,
noteHash
*
frontend
.
Constraint
)
{
...
...
plugin/dapp/mix/cmd/gnark/cmd/calc.go
View file @
6a0752f6
...
@@ -25,6 +25,7 @@ import (
...
@@ -25,6 +25,7 @@ import (
mimcbn256
"github.com/consensys/gnark/crypto/hash/mimc/bn256"
mimcbn256
"github.com/consensys/gnark/crypto/hash/mimc/bn256"
fr_bn256
"github.com/consensys/gurvy/bn256/fr"
fr_bn256
"github.com/consensys/gurvy/bn256/fr"
"github.com/consensys/gurvy/bn256/twistededwards"
)
)
// verifyCmd represents the verify command
// verifyCmd represents the verify command
...
@@ -34,17 +35,29 @@ var calcCmd = &cobra.Command{
...
@@ -34,17 +35,29 @@ var calcCmd = &cobra.Command{
Version
:
Version
,
Version
:
Version
,
}
}
var
hashCmd
=
&
cobra
.
Command
{
var
(
Use
:
"hash ..."
,
fCommit
string
Short
:
"read strings to calc hash"
,
fRandom
string
Run
:
hash
,
)
Version
:
Version
,
}
func
init
()
{
func
init
()
{
calcCmd
.
AddCommand
(
hashCmd
)
calcCmd
.
AddCommand
(
hashCmd
)
calcCmd
.
AddCommand
(
commitCmd
)
rootCmd
.
AddCommand
(
calcCmd
)
rootCmd
.
AddCommand
(
calcCmd
)
commitCmd
.
PersistentFlags
()
.
StringVar
(
&
fCommit
,
"value"
,
""
,
"specifies commit value"
)
commitCmd
.
PersistentFlags
()
.
StringVar
(
&
fRandom
,
"random"
,
""
,
"specifies random value"
)
_
=
commitCmd
.
MarkPersistentFlagRequired
(
"value"
)
_
=
commitCmd
.
MarkPersistentFlagRequired
(
"random"
)
}
var
hashCmd
=
&
cobra
.
Command
{
Use
:
"hash ..."
,
Short
:
"read strings to calc hash"
,
Run
:
hash
,
Version
:
Version
,
}
}
func
hash
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
hash
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
...
@@ -72,3 +85,50 @@ func getFrString(v []byte) string {
...
@@ -72,3 +85,50 @@ func getFrString(v []byte) string {
f
.
SetBytes
(
v
)
f
.
SetBytes
(
v
)
return
f
.
String
()
return
f
.
String
()
}
}
var
commitCmd
=
&
cobra
.
Command
{
Use
:
"commit"
,
Short
:
"commit value"
,
Run
:
commit
,
Version
:
Version
,
}
func
commit
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
//if len(args) < 1 {
// fmt.Println("missing input strings")
// os.Exit(-1)
//}
var
basex
,
basey
,
baseHx
,
baseHy
fr_bn256
.
Element
basex
.
SetString
(
"5299619240641551281634865583518297030282874472190772894086521144482721001553"
)
basey
.
SetString
(
"16950150798460657717958625567821834550301663161624707787222815936182638968203"
)
baseHx
.
SetString
(
"10190477835300927557649934238820360529458681672073866116232821892325659279502"
)
baseHy
.
SetString
(
"7969140283216448215269095418467361784159407896899334866715345504515077887397"
)
basePoint
:=
twistededwards
.
NewPoint
(
basex
,
basey
)
baseHPoint
:=
twistededwards
.
NewPoint
(
baseHx
,
baseHy
)
var
frCommit
,
frRandom
fr_bn256
.
Element
frCommit
.
SetString
(
fCommit
)
.
FromMont
()
frRandom
.
SetString
(
fRandom
)
.
FromMont
()
fmt
.
Println
(
"commit"
,
fCommit
,
"random"
,
fRandom
)
var
commitPoint
,
randomPoint
,
finalPoint
twistededwards
.
Point
commitPoint
.
ScalarMul
(
&
basePoint
,
frCommit
)
randomPoint
.
ScalarMul
(
&
baseHPoint
,
frRandom
)
finalPoint
.
Add
(
&
commitPoint
,
&
randomPoint
)
fmt
.
Println
(
"finalPoint X:"
,
finalPoint
.
X
.
String
())
fmt
.
Println
(
"finalPoint Y:"
,
finalPoint
.
Y
.
String
())
//
//fmt.Println("commitX:",commitPoint.X.String())
//fmt.Println("commitY:",commitPoint.Y.String())
//
//fmt.Println("randomX:",randomPoint.X.String())
//fmt.Println("randomY:",randomPoint.Y.String())
}
plugin/dapp/mix/cmd/gnark/cmd/read.go
View file @
6a0752f6
...
@@ -52,7 +52,6 @@ var (
...
@@ -52,7 +52,6 @@ var (
func
init
()
{
func
init
()
{
rootCmd
.
AddCommand
(
readCmd
)
rootCmd
.
AddCommand
(
readCmd
)
readCmd
.
PersistentFlags
()
.
Int32VarP
(
&
fType
,
"type"
,
"t"
,
0
,
"0: proof or vk file, 1: input file, default 0"
)
readCmd
.
PersistentFlags
()
.
Int32VarP
(
&
fType
,
"type"
,
"t"
,
0
,
"0: proof or vk file, 1: input file, default 0"
)
_
=
readCmd
.
MarkPersistentFlagRequired
(
"type"
)
}
}
...
...
plugin/dapp/mix/commands/mix.go
View file @
6a0752f6
...
@@ -29,6 +29,7 @@ func ParcCmd() *cobra.Command {
...
@@ -29,6 +29,7 @@ func ParcCmd() *cobra.Command {
CreateWithdrawCmd
(),
CreateWithdrawCmd
(),
CreateConfigCmd
(),
CreateConfigCmd
(),
CreateAuthorizeCmd
(),
CreateAuthorizeCmd
(),
QueryCmd
(),
)
)
return
cmd
return
cmd
}
}
...
@@ -260,14 +261,14 @@ func mixConfigVerifyKeyParaCmd() *cobra.Command {
...
@@ -260,14 +261,14 @@ func mixConfigVerifyKeyParaCmd() *cobra.Command {
func
addVkConfigFlags
(
cmd
*
cobra
.
Command
)
{
func
addVkConfigFlags
(
cmd
*
cobra
.
Command
)
{
cmd
.
Flags
()
.
Uint32P
(
"action"
,
"a"
,
0
,
"0:add,1:delete"
)
cmd
.
Flags
()
.
Uint32P
(
"action"
,
"a"
,
0
,
"0:add,1:delete"
)
cmd
.
Flags
()
.
Uint32P
(
"curveid"
,
"i"
,
0
,
"zk curve id,1:bls377,2:bls381,3:bn256"
)
cmd
.
Flags
()
.
Uint32P
(
"curveid"
,
"i"
,
3
,
"zk curve id,1:bls377,2:bls381,3:bn256"
)
cmd
.
MarkFlagRequired
(
"curveid"
)
cmd
.
MarkFlagRequired
(
"curveid"
)
cmd
.
Flags
()
.
Uint32P
(
"circuit"
,
"c"
,
0
,
"mix circuit type,0:deposit,1:withdraw,2:spendinput,3:spendout,4:authorize"
)
cmd
.
Flags
()
.
Uint32P
(
"circuit"
,
"c"
,
0
,
"mix circuit type,0:deposit,1:withdraw,2:spendinput,3:spendout,4:authorize"
)
cmd
.
MarkFlagRequired
(
"circuit"
)
cmd
.
MarkFlagRequired
(
"circuit"
)
cmd
.
Flags
()
.
StringP
(
"
key"
,
"k
"
,
""
,
"zk proof verify key"
)
cmd
.
Flags
()
.
StringP
(
"
zkey"
,
"z
"
,
""
,
"zk proof verify key"
)
cmd
.
MarkFlagRequired
(
"key"
)
cmd
.
MarkFlagRequired
(
"
z
key"
)
}
}
...
@@ -276,7 +277,7 @@ func createConfigVerify(cmd *cobra.Command, args []string) {
...
@@ -276,7 +277,7 @@ func createConfigVerify(cmd *cobra.Command, args []string) {
action
,
_
:=
cmd
.
Flags
()
.
GetUint32
(
"action"
)
action
,
_
:=
cmd
.
Flags
()
.
GetUint32
(
"action"
)
curveid
,
_
:=
cmd
.
Flags
()
.
GetUint32
(
"curveid"
)
curveid
,
_
:=
cmd
.
Flags
()
.
GetUint32
(
"curveid"
)
circuit
,
_
:=
cmd
.
Flags
()
.
GetUint32
(
"circuit"
)
circuit
,
_
:=
cmd
.
Flags
()
.
GetUint32
(
"circuit"
)
key
,
_
:=
cmd
.
Flags
()
.
GetString
(
"key"
)
key
,
_
:=
cmd
.
Flags
()
.
GetString
(
"
z
key"
)
var
zkVk
mixTy
.
ZkVerifyKey
var
zkVk
mixTy
.
ZkVerifyKey
zkVk
.
Value
=
key
zkVk
.
Value
=
key
...
@@ -313,15 +314,15 @@ func mixConfigAuthPubKeyParaCmd() *cobra.Command {
...
@@ -313,15 +314,15 @@ func mixConfigAuthPubKeyParaCmd() *cobra.Command {
func
addPubKeyConfigFlags
(
cmd
*
cobra
.
Command
)
{
func
addPubKeyConfigFlags
(
cmd
*
cobra
.
Command
)
{
cmd
.
Flags
()
.
Uint32P
(
"action"
,
"a"
,
0
,
"0:add,1:delete"
)
cmd
.
Flags
()
.
Uint32P
(
"action"
,
"a"
,
0
,
"0:add,1:delete"
)
cmd
.
Flags
()
.
StringP
(
"
key"
,
"k
"
,
""
,
"zk proof verify key"
)
cmd
.
Flags
()
.
StringP
(
"
zkey"
,
"z
"
,
""
,
"zk proof verify key"
)
cmd
.
MarkFlagRequired
(
"key"
)
cmd
.
MarkFlagRequired
(
"
z
key"
)
}
}
func
createConfigPubKey
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
createConfigPubKey
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
paraName
,
_
:=
cmd
.
Flags
()
.
GetString
(
"paraName"
)
paraName
,
_
:=
cmd
.
Flags
()
.
GetString
(
"paraName"
)
action
,
_
:=
cmd
.
Flags
()
.
GetUint32
(
"action"
)
action
,
_
:=
cmd
.
Flags
()
.
GetUint32
(
"action"
)
key
,
_
:=
cmd
.
Flags
()
.
GetString
(
"key"
)
key
,
_
:=
cmd
.
Flags
()
.
GetString
(
"
z
key"
)
var
pubkey
mixTy
.
AuthorizePubKey
var
pubkey
mixTy
.
AuthorizePubKey
pubkey
.
Value
=
key
pubkey
.
Value
=
key
...
@@ -341,3 +342,51 @@ func createConfigPubKey(cmd *cobra.Command, args []string) {
...
@@ -341,3 +342,51 @@ func createConfigPubKey(cmd *cobra.Command, args []string) {
ctx
.
RunWithoutMarshal
()
ctx
.
RunWithoutMarshal
()
}
}
func
QueryCmd
()
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"query"
,
Short
:
"query cmd"
,
}
cmd
.
AddCommand
(
GetTreePathCmd
())
return
cmd
}
// GetParaInfoCmd get para chain status by height
func
GetTreePathCmd
()
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"path"
,
Short
:
"Get leaf tree path"
,
Run
:
treePath
,
}
addGetPathCmdFlags
(
cmd
)
return
cmd
}
func
addGetPathCmdFlags
(
cmd
*
cobra
.
Command
)
{
cmd
.
Flags
()
.
StringP
(
"root"
,
"r"
,
""
,
"tree root hash, null allowed"
)
cmd
.
Flags
()
.
StringP
(
"leaf"
,
"l"
,
""
,
"leaf hash"
)
cmd
.
MarkFlagRequired
(
"leaf"
)
}
func
treePath
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
root
,
_
:=
cmd
.
Flags
()
.
GetString
(
"root"
)
leaf
,
_
:=
cmd
.
Flags
()
.
GetString
(
"leaf"
)
var
params
rpctypes
.
Query4Jrpc
params
.
Execer
=
mixTy
.
MixX
params
.
FuncName
=
"GetTreePath"
req
:=
mixTy
.
TreePathReq
{
RootHash
:
root
,
LeafHash
:
leaf
,
}
params
.
Payload
=
types
.
MustPBToJSON
(
&
req
)
var
res
mixTy
.
CommitTreeProve
ctx
:=
jsonclient
.
NewRPCCtx
(
rpcLaddr
,
"Chain33.Query"
,
params
,
&
res
)
ctx
.
Run
()
}
plugin/dapp/mix/executor/committree.go
View file @
6a0752f6
...
@@ -108,10 +108,10 @@ func getNewCommitLeaves() (*mixTy.CommitTreeLeaves, *mixTy.CommitTreeRoots) {
...
@@ -108,10 +108,10 @@ func getNewCommitLeaves() (*mixTy.CommitTreeLeaves, *mixTy.CommitTreeRoots) {
return
leaves
,
roots
return
leaves
,
roots
}
}
func
initNewLeaves
(
leaf
[]
byte
)
*
types
.
Receipt
{
func
initNewLeaves
(
leaf
[]
[]
byte
)
*
types
.
Receipt
{
leaves
,
roots
:=
getNewCommitLeaves
()
leaves
,
roots
:=
getNewCommitLeaves
()
if
len
(
leaf
)
>
0
{
if
len
(
leaf
)
>
0
{
leaves
.
Data
=
append
(
leaves
.
Data
,
leaf
)
leaves
.
Data
=
append
(
leaves
.
Data
,
leaf
...
)
roots
.
Data
=
append
(
roots
.
Data
,
calcTreeRoot
(
leaves
))
roots
.
Data
=
append
(
roots
.
Data
,
calcTreeRoot
(
leaves
))
}
}
...
@@ -140,7 +140,7 @@ func archiveRoots(db dbm.KV, root []byte, leaves *mixTy.CommitTreeLeaves) (*type
...
@@ -140,7 +140,7 @@ func archiveRoots(db dbm.KV, root []byte, leaves *mixTy.CommitTreeLeaves) (*type
3. 归档同时初始化新的current leaves 和roots
3. 归档同时初始化新的current leaves 和roots
*/
*/
func
pushTree
(
db
dbm
.
KV
,
leaf
[]
byte
)
(
*
types
.
Receipt
,
error
)
{
func
pushTree
(
db
dbm
.
KV
,
leaf
[]
[]
byte
)
(
*
types
.
Receipt
,
error
)
{
leaves
,
err
:=
getCurrentCommitTreeLeaves
(
db
)
leaves
,
err
:=
getCurrentCommitTreeLeaves
(
db
)
if
isNotFound
(
errors
.
Cause
(
err
))
{
if
isNotFound
(
errors
.
Cause
(
err
))
{
//系统初始状态
//系统初始状态
...
@@ -160,7 +160,7 @@ func pushTree(db dbm.KV, leaf []byte) (*types.Receipt, error) {
...
@@ -160,7 +160,7 @@ func pushTree(db dbm.KV, leaf []byte) (*types.Receipt, error) {
return
nil
,
err
return
nil
,
err
}
}
leaves
.
Data
=
append
(
leaves
.
Data
,
leaf
)
leaves
.
Data
=
append
(
leaves
.
Data
,
leaf
...
)
currentRoot
:=
calcTreeRoot
(
leaves
)
currentRoot
:=
calcTreeRoot
(
leaves
)
roots
.
Data
=
append
(
roots
.
Data
,
currentRoot
)
roots
.
Data
=
append
(
roots
.
Data
,
currentRoot
)
r
:=
makeCurrentTreeReceipt
(
leaves
,
roots
)
r
:=
makeCurrentTreeReceipt
(
leaves
,
roots
)
...
...
plugin/dapp/mix/executor/deposit.go
View file @
6a0752f6
...
@@ -110,13 +110,15 @@ func (a *action) Deposit(deposit *mixTy.MixDepositAction) (*types.Receipt, error
...
@@ -110,13 +110,15 @@ func (a *action) Deposit(deposit *mixTy.MixDepositAction) (*types.Receipt, error
return
nil
,
errors
.
Wrapf
(
err
,
"ExecTransfer"
)
return
nil
,
errors
.
Wrapf
(
err
,
"ExecTransfer"
)
}
}
//push new commit to merkle tree
//push new commit to merkle tree
var
leaves
[][]
byte
for
_
,
h
:=
range
commitHashs
{
for
_
,
h
:=
range
commitHashs
{
rpt
,
err
:=
pushTree
(
a
.
db
,
h
)
leaves
=
append
(
leaves
,
h
)
if
err
!=
nil
{
}
return
nil
,
err
rpt
,
err
:=
pushTree
(
a
.
db
,
leaves
)
}
if
err
!=
nil
{
mergeReceipt
(
receipt
,
rpt
)
return
nil
,
err
}
}
mergeReceipt
(
receipt
,
rpt
)
return
receipt
,
nil
return
receipt
,
nil
...
...
plugin/dapp/mix/executor/kv.go
View file @
6a0752f6
...
@@ -24,16 +24,16 @@ var (
...
@@ -24,16 +24,16 @@ var (
)
)
func
setPrefix
()
{
func
setPrefix
()
{
verifyKeys
=
"mavl-mix
coin
-verify-keys-"
verifyKeys
=
"mavl-mix-verify-keys-"
authPubKeys
=
"mavl-mix
coin
-auth-pubkeys-"
authPubKeys
=
"mavl-mix-auth-pubkeys-"
commitTreeArchiveRoots
=
"mavl-mix
coin
-commitTree-roots-archive-"
commitTreeArchiveRoots
=
"mavl-mix-commitTree-roots-archive-"
commitTreeCurrentRoots
=
"mavl-mix
coin
-commitTree-current-roots"
commitTreeCurrentRoots
=
"mavl-mix-commitTree-current-roots"
commitTreeCurrentLeaves
=
"mavl-mix
coin
-commitTree-current-leaves-"
commitTreeCurrentLeaves
=
"mavl-mix-commitTree-current-leaves-"
commitTreeRootLeaves
=
"mavl-mix
coin
-commitTree-rootLeaves-"
commitTreeRootLeaves
=
"mavl-mix-commitTree-rootLeaves-"
authorizeHash
=
"mavl-mix
coin
-authorizeHash"
authorizeHash
=
"mavl-mix-authorizeHash"
authorizeSpendHash
=
"mavl-mix
coin
-authorizeHash-spend-"
authorizeSpendHash
=
"mavl-mix-authorizeHash-spend-"
nullifierHash
=
"mavl-mix
coin
-nullifierHash"
nullifierHash
=
"mavl-mix-nullifierHash"
}
}
...
...
plugin/dapp/mix/executor/transfer.go
View file @
6a0752f6
...
@@ -137,14 +137,15 @@ func (a *action) Transfer(transfer *mixTy.MixTransferAction) (*types.Receipt, er
...
@@ -137,14 +137,15 @@ func (a *action) Transfer(transfer *mixTy.MixTransferAction) (*types.Receipt, er
}
}
//push new commit to merkle tree
//push new commit to merkle tree
var
leaves
[][]
byte
for
_
,
h
:=
range
outputs
{
for
_
,
h
:=
range
outputs
{
rpt
,
err
:=
pushTree
(
a
.
db
,
transferFr2Bytes
(
h
.
NoteHash
))
leaves
=
append
(
leaves
,
transferFr2Bytes
(
h
.
NoteHash
))
if
err
!=
nil
{
return
nil
,
err
}
mergeReceipt
(
receipt
,
rpt
)
}
}
rpt
,
err
:=
pushTree
(
a
.
db
,
leaves
)
if
err
!=
nil
{
return
nil
,
err
}
mergeReceipt
(
receipt
,
rpt
)
return
receipt
,
nil
return
receipt
,
nil
}
}
plugin/dapp/mix/executor/withdraw.go
View file @
6a0752f6
...
@@ -33,8 +33,8 @@ func (a *action) spendVerify(treeRootHash, nulliferHash, authorizeSpendHash stri
...
@@ -33,8 +33,8 @@ func (a *action) spendVerify(treeRootHash, nulliferHash, authorizeSpendHash stri
}
}
// authorize should exist if needed
// authorize should exist if needed
if
len
(
authorizeSpendHash
)
>
0
{
if
len
(
authorizeSpendHash
)
>
1
{
authKey
:=
calcAuthorizeHashKey
(
authorizeSpendHash
)
authKey
:=
calcAuthorize
Spend
HashKey
(
authorizeSpendHash
)
_
,
err
=
a
.
db
.
Get
(
authKey
)
_
,
err
=
a
.
db
.
Get
(
authKey
)
if
err
!=
nil
{
if
err
!=
nil
{
return
errors
.
Wrapf
(
err
,
"authorize=%s"
,
authorizeSpendHash
)
return
errors
.
Wrapf
(
err
,
"authorize=%s"
,
authorizeSpendHash
)
...
...
plugin/dapp/mix/executor/zksnark/verify_test.go
View file @
6a0752f6
...
@@ -9,9 +9,10 @@ import (
...
@@ -9,9 +9,10 @@ import (
"encoding/hex"
"encoding/hex"
"encoding/json"
"encoding/json"
"fmt"
"fmt"
"github.com/33cn/plugin/plugin/dapp/mix/types"
"testing"
"testing"
"github.com/33cn/plugin/plugin/dapp/mix/types"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/assert"
)
)
...
...
plugin/dapp/mix/types/mix.go
View file @
6a0752f6
...
@@ -22,12 +22,12 @@ const (
...
@@ -22,12 +22,12 @@ const (
TyLogMixConfigVk
=
754
TyLogMixConfigVk
=
754
TyLogMixConfigAuth
=
755
TyLogMixConfigAuth
=
755
TyLogCurrentCommitTreeLeaves
=
756
TyLogCurrentCommitTreeLeaves
=
756
TyLogCurrentCommitTreeRoots
=
75
6
TyLogCurrentCommitTreeRoots
=
75
7
TyLogCommitTreeRootLeaves
=
75
7
TyLogCommitTreeRootLeaves
=
75
8
TyLogCommitTreeArchiveRoots
=
75
8
TyLogCommitTreeArchiveRoots
=
75
9
TyLogNulliferSet
=
7
59
TyLogNulliferSet
=
7
60
TyLogAuthorizeSet
=
76
0
TyLogAuthorizeSet
=
76
1
TyLogAuthorizeSpendSet
=
76
1
TyLogAuthorizeSpendSet
=
76
2
)
)
//action type
//action type
...
...
plugin/dapp/mix/types/mix.pb.go
View file @
6a0752f6
...
@@ -5,8 +5,9 @@ package types
...
@@ -5,8 +5,9 @@ package types
import
(
import
(
fmt
"fmt"
fmt
"fmt"
proto
"github.com/golang/protobuf/proto"
math
"math"
math
"math"
proto
"github.com/golang/protobuf/proto"
)
)
// Reference imports to suppress errors if they are not otherwise used.
// Reference imports to suppress errors if they are not otherwise used.
...
...
plugin/dapp/mix/types/type.go
View file @
6a0752f6
...
@@ -62,8 +62,10 @@ func (p *MixType) GetName() string {
...
@@ -62,8 +62,10 @@ func (p *MixType) GetName() string {
// GetLogMap get receipt log map
// GetLogMap get receipt log map
func
(
p
*
MixType
)
GetLogMap
()
map
[
int64
]
*
types
.
LogInfo
{
func
(
p
*
MixType
)
GetLogMap
()
map
[
int64
]
*
types
.
LogInfo
{
return
map
[
int64
]
*
types
.
LogInfo
{
return
map
[
int64
]
*
types
.
LogInfo
{
TyLogMixConfigVk
:
{
Ty
:
reflect
.
TypeOf
(
ZkVerifyKeys
{}),
Name
:
"LogMixConfigVk"
},
TyLogMixConfigVk
:
{
Ty
:
reflect
.
TypeOf
(
ZkVerifyKeys
{}),
Name
:
"LogMixConfigVk"
},
TyLogMixConfigAuth
:
{
Ty
:
reflect
.
TypeOf
(
AuthPubKeys
{}),
Name
:
"LogMixConfigAuthPubKey"
},
TyLogMixConfigAuth
:
{
Ty
:
reflect
.
TypeOf
(
AuthPubKeys
{}),
Name
:
"LogMixConfigAuthPubKey"
},
TyLogCurrentCommitTreeLeaves
:
{
Ty
:
reflect
.
TypeOf
(
CommitTreeLeaves
{}),
Name
:
"TyLogCommitTreeLeaves"
},
TyLogCurrentCommitTreeRoots
:
{
Ty
:
reflect
.
TypeOf
(
CommitTreeRoots
{}),
Name
:
"TyLogCommitTreeRoots"
},
}
}
}
}
...
...
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