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
928b3daf
Commit
928b3daf
authored
Nov 17, 2020
by
madengji
Committed by
vipwzw
Sep 18, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add util common circuit
parent
9ff24cd5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
284 additions
and
137 deletions
+284
-137
authorize.go
plugin/dapp/mix/cmd/gnark/circuit/authorize.go
+0
-54
transferInput.go
plugin/dapp/mix/cmd/gnark/circuit/transferInput.go
+0
-40
transferOutput.go
plugin/dapp/mix/cmd/gnark/circuit/transferOutput.go
+1
-1
transferinput_test.go
plugin/dapp/mix/cmd/gnark/circuit/transferinput_test.go
+67
-1
util.go
plugin/dapp/mix/cmd/gnark/circuit/util.go
+101
-0
calc.go
plugin/dapp/mix/cmd/gnark/cmd/calc.go
+74
-0
verifystr.go
plugin/dapp/mix/cmd/gnark/cmd/verifystr.go
+0
-0
depositInput
plugin/dapp/mix/cmd/gnark/input/depositInput
+1
-1
transferOutput
plugin/dapp/mix/cmd/gnark/input/transferOutput
+1
-1
deposit.go
plugin/dapp/mix/executor/deposit.go
+1
-1
transfer.go
plugin/dapp/mix/executor/transfer.go
+1
-1
verify_test.go
plugin/dapp/mix/executor/zksnark/verify_test.go
+0
-0
mix.proto
plugin/dapp/mix/proto/mix.proto
+2
-2
mix.pb.go
plugin/dapp/mix/types/mix.pb.go
+35
-35
No files found.
plugin/dapp/mix/cmd/gnark/circuit/authorize.go
View file @
928b3daf
...
...
@@ -5,7 +5,6 @@ import (
"github.com/consensys/gnark/frontend"
"github.com/consensys/gnark/gadgets/hash/mimc"
"github.com/consensys/gurvy"
"strconv"
)
func
main
()
{
...
...
@@ -75,56 +74,3 @@ func NewAuth() *frontend.R1CS {
return
r1cs
}
func
merkelPathPart
(
circuit
*
frontend
.
CS
,
mimc
mimc
.
MiMCGadget
,
noteHash
*
frontend
.
Constraint
)
{
var
proofSet
,
helper
,
valid
[]
*
frontend
.
Constraint
merkleRoot
:=
circuit
.
PUBLIC_INPUT
(
"treeRootHash"
)
proofSet
=
append
(
proofSet
,
noteHash
)
//helper[0],valid[0]占位, 方便接口只设置有效值
helper
=
append
(
helper
,
circuit
.
ALLOCATE
(
"1"
))
valid
=
append
(
valid
,
circuit
.
ALLOCATE
(
"1"
))
//depth:10, path num need be 9
for
i
:=
1
;
i
<
10
;
i
++
{
proofSet
=
append
(
proofSet
,
circuit
.
SECRET_INPUT
(
"path"
+
strconv
.
Itoa
(
i
)))
helper
=
append
(
helper
,
circuit
.
SECRET_INPUT
(
"helper"
+
strconv
.
Itoa
(
i
)))
valid
=
append
(
valid
,
circuit
.
SECRET_INPUT
(
"valid"
+
strconv
.
Itoa
(
i
)))
}
VerifyMerkleProof
(
circuit
,
mimc
,
merkleRoot
,
proofSet
,
helper
,
valid
)
}
func
VerifyMerkleProof
(
circuit
*
frontend
.
CS
,
h
mimc
.
MiMCGadget
,
merkleRoot
*
frontend
.
Constraint
,
proofSet
,
helper
,
valid
[]
*
frontend
.
Constraint
)
{
sum
:=
leafSum
(
circuit
,
h
,
proofSet
[
0
])
for
i
:=
1
;
i
<
len
(
proofSet
);
i
++
{
circuit
.
MUSTBE_BOOLEAN
(
helper
[
i
])
d1
:=
circuit
.
SELECT
(
helper
[
i
],
sum
,
proofSet
[
i
])
d2
:=
circuit
.
SELECT
(
helper
[
i
],
proofSet
[
i
],
sum
)
rst
:=
nodeSum
(
circuit
,
h
,
d1
,
d2
)
sum
=
circuit
.
SELECT
(
valid
[
i
],
rst
,
sum
)
}
// Compare our calculated Merkle root to the desired Merkle root.
circuit
.
MUSTBE_EQ
(
sum
,
merkleRoot
)
}
// nodeSum returns the hash created from data inserted to form a leaf.
// Without domain separation.
func
nodeSum
(
circuit
*
frontend
.
CS
,
h
mimc
.
MiMCGadget
,
a
,
b
*
frontend
.
Constraint
)
*
frontend
.
Constraint
{
res
:=
h
.
Hash
(
circuit
,
a
,
b
)
return
res
}
// leafSum returns the hash created from data inserted to form a leaf.
// Without domain separation.
func
leafSum
(
circuit
*
frontend
.
CS
,
h
mimc
.
MiMCGadget
,
data
*
frontend
.
Constraint
)
*
frontend
.
Constraint
{
res
:=
h
.
Hash
(
circuit
,
data
)
return
res
}
plugin/dapp/mix/cmd/gnark/circuit/transferInput.go
View file @
928b3daf
...
...
@@ -3,10 +3,8 @@ package main
import
(
"github.com/consensys/gnark/encoding/gob"
"github.com/consensys/gnark/frontend"
twistededwards_gadget
"github.com/consensys/gnark/gadgets/algebra/twistededwards"
"github.com/consensys/gnark/gadgets/hash/mimc"
"github.com/consensys/gurvy"
fr_bn256
"github.com/consensys/gurvy/bn256/fr"
)
func
main
()
{
...
...
@@ -95,41 +93,3 @@ func NewTransferInput() *frontend.R1CS {
return
r1cs
}
func
commitValuePart
(
circuit
*
frontend
.
CS
,
spendValue
*
frontend
.
Constraint
)
{
//cmt=transfer_value*G + random_value*H
cmtvalueX
:=
circuit
.
PUBLIC_INPUT
(
"commitValueX"
)
cmtvalueY
:=
circuit
.
PUBLIC_INPUT
(
"commitValueY"
)
// set curve parameters
edgadget
,
_
:=
twistededwards_gadget
.
NewEdCurveGadget
(
gurvy
.
BN256
)
// set point G in the circuit
pointGSnark
:=
twistededwards_gadget
.
NewPointGadget
(
circuit
,
nil
,
nil
)
//scalar := circuit.ALLOCATE("-1")
circuit
.
MUSTBE_LESS_OR_EQ
(
spendValue
,
10000000000
,
256
)
// set point G in the circuit
pointGSnark
.
ScalarMulFixedBase
(
circuit
,
edgadget
.
BaseX
,
edgadget
.
BaseY
,
spendValue
,
edgadget
)
pointGSnark
.
X
.
Tag
(
"xg"
)
pointGSnark
.
Y
.
Tag
(
"yg"
)
transfer_random
:=
circuit
.
SECRET_INPUT
(
"spendRandom"
)
//circuit.MUSTBE_LESS_OR_EQ(random_value,10000000000,256)
//H is not G, H should be a point that no one know the prikey
var
baseX_H
,
baseY_H
fr_bn256
.
Element
baseX_H
.
SetString
(
"10190477835300927557649934238820360529458681672073866116232821892325659279502"
)
baseY_H
.
SetString
(
"7969140283216448215269095418467361784159407896899334866715345504515077887397"
)
pointHSnark
:=
twistededwards_gadget
.
NewPointGadget
(
circuit
,
nil
,
nil
)
// add points in circuit (the method updates the underlying plain points as well)
pointHSnark
.
ScalarMulFixedBase
(
circuit
,
baseX_H
,
baseY_H
,
transfer_random
,
edgadget
)
pointHSnark
.
X
.
Tag
(
"xh"
)
pointHSnark
.
Y
.
Tag
(
"yh"
)
pointSumSnark
:=
twistededwards_gadget
.
NewPointGadget
(
circuit
,
nil
,
nil
)
pointSumSnark
.
AddGeneric
(
circuit
,
&
pointGSnark
,
&
pointHSnark
,
edgadget
)
//cmtvalue=transfer_value*G + random_value*H
circuit
.
MUSTBE_EQ
(
cmtvalueX
,
pointSumSnark
.
X
)
circuit
.
MUSTBE_EQ
(
cmtvalueY
,
pointSumSnark
.
Y
)
}
plugin/dapp/mix/cmd/gnark/circuit/transferOutput.go
View file @
928b3daf
...
...
@@ -48,7 +48,7 @@ func NewTransferOutput() *frontend.R1CS {
//通过merkle tree保证noteHash存在,即便return,auth都是null也是存在的,则可以不经过授权即可消费
//preImage=hash(spendPubkey, returnPubkey,AuthPubkey,spendValue,noteRandom)
noteHash
:=
circuit
.
SECRET
_INPUT
(
"noteHash"
)
noteHash
:=
circuit
.
PUBLIC
_INPUT
(
"noteHash"
)
// specify note hash constraint
preImage
:=
mimc
.
Hash
(
&
circuit
,
spendPubkey
,
returnPubkey
,
authPubkey
,
spendValue
,
noteRandom
)
circuit
.
MUSTBE_EQ
(
noteHash
,
preImage
)
...
...
plugin/dapp/mix/cmd/gnark/circuit/transferinput_test.go
View file @
928b3daf
...
...
@@ -119,8 +119,9 @@ func TestTransferInputReturnKey(t *testing.T) {
good
.
Assign
(
backend
.
Secret
,
"authorizePubKey"
,
"13519883267141251871527102103999205179714486518503885909948192364772977661583"
)
good
.
Assign
(
backend
.
Secret
,
"spendPriKey"
,
"7969140283216448215269095418467361784159407896899334866715345504515077887397"
)
//returnkey spend notehash
good
.
Assign
(
backend
.
Secret
,
"spendFlag"
,
"0"
)
//not need authorize
good
.
Assign
(
backend
.
Secret
,
"authorizeFlag"
,
"1"
)
good
.
Assign
(
backend
.
Secret
,
"noteRandom"
,
"2824204835"
)
...
...
@@ -162,3 +163,68 @@ func TestTransferInputReturnKey(t *testing.T) {
}
}
func
TestTransferInputNoAuthorize
(
t
*
testing
.
T
)
{
assert
:=
groth16
.
NewAssert
(
t
)
r1cs
:=
NewTransferInput
()
r1csBN256
:=
backend_bn256
.
Cast
(
r1cs
)
{
good
:=
backend
.
NewAssignment
()
good
.
Assign
(
backend
.
Public
,
"treeRootHash"
,
"12759256930628441934094267209403003086804595141527597228422519500766117029056"
)
good
.
Assign
(
backend
.
Public
,
"commitValueX"
,
"14087975867275911077371231345227824611951436822132762463787130558957838320348"
)
good
.
Assign
(
backend
.
Public
,
"commitValueY"
,
"15113519960384204624879642069520481336224311978035289236693658603675385299879"
)
good
.
Assign
(
backend
.
Public
,
"authorizeSpendHash"
,
"0"
)
good
.
Assign
(
backend
.
Public
,
"nullifierHash"
,
"6747518781649068310795677405858353007442326529625450860668944156162052335195"
)
good
.
Assign
(
backend
.
Secret
,
"spendAmount"
,
"28242048"
)
good
.
Assign
(
backend
.
Secret
,
"spendRandom"
,
"35"
)
good
.
Assign
(
backend
.
Secret
,
"spendPubKey"
,
"13735985067536865723202617343666111332145536963656464451727087263423649028705"
)
good
.
Assign
(
backend
.
Secret
,
"returnPubKey"
,
"0"
)
good
.
Assign
(
backend
.
Secret
,
"authorizePubKey"
,
"0"
)
good
.
Assign
(
backend
.
Secret
,
"spendPriKey"
,
"10190477835300927557649934238820360529458681672073866116232821892325659279502"
)
good
.
Assign
(
backend
.
Secret
,
"spendFlag"
,
"1"
)
//not need authorize
good
.
Assign
(
backend
.
Secret
,
"authorizeFlag"
,
"0"
)
good
.
Assign
(
backend
.
Secret
,
"noteRandom"
,
"2824204835"
)
good
.
Assign
(
backend
.
Secret
,
"noteHash"
,
"8225571890661960751046682712125507843232543630686326316665478955306869111251"
)
good
.
Assign
(
backend
.
Secret
,
"path1"
,
"14187514855908861960780770215596905690354960378277143432325960729637725182251"
)
good
.
Assign
(
backend
.
Secret
,
"path2"
,
"6182134257436688306324731906502075484313942414837318361329615447955128796497"
)
good
.
Assign
(
backend
.
Secret
,
"path3"
,
"11546648745105756958663742750618707757021496913774959001736226397442926254652"
)
good
.
Assign
(
backend
.
Secret
,
"path4"
,
"0"
)
good
.
Assign
(
backend
.
Secret
,
"path5"
,
"0"
)
good
.
Assign
(
backend
.
Secret
,
"path6"
,
"0"
)
good
.
Assign
(
backend
.
Secret
,
"path7"
,
"0"
)
good
.
Assign
(
backend
.
Secret
,
"path8"
,
"0"
)
good
.
Assign
(
backend
.
Secret
,
"path9"
,
"0"
)
good
.
Assign
(
backend
.
Secret
,
"helper1"
,
"1"
)
good
.
Assign
(
backend
.
Secret
,
"helper2"
,
"1"
)
good
.
Assign
(
backend
.
Secret
,
"helper3"
,
"1"
)
good
.
Assign
(
backend
.
Secret
,
"helper4"
,
"0"
)
good
.
Assign
(
backend
.
Secret
,
"helper5"
,
"0"
)
good
.
Assign
(
backend
.
Secret
,
"helper6"
,
"0"
)
good
.
Assign
(
backend
.
Secret
,
"helper7"
,
"0"
)
good
.
Assign
(
backend
.
Secret
,
"helper8"
,
"0"
)
good
.
Assign
(
backend
.
Secret
,
"helper9"
,
"0"
)
good
.
Assign
(
backend
.
Secret
,
"valid1"
,
"1"
)
good
.
Assign
(
backend
.
Secret
,
"valid2"
,
"1"
)
good
.
Assign
(
backend
.
Secret
,
"valid3"
,
"1"
)
good
.
Assign
(
backend
.
Secret
,
"valid4"
,
"0"
)
good
.
Assign
(
backend
.
Secret
,
"valid5"
,
"0"
)
good
.
Assign
(
backend
.
Secret
,
"valid6"
,
"0"
)
good
.
Assign
(
backend
.
Secret
,
"valid7"
,
"0"
)
good
.
Assign
(
backend
.
Secret
,
"valid8"
,
"0"
)
good
.
Assign
(
backend
.
Secret
,
"valid9"
,
"0"
)
assert
.
Solved
(
&
r1csBN256
,
good
,
nil
)
}
}
plugin/dapp/mix/cmd/gnark/circuit/util.go
0 → 100644
View file @
928b3daf
package
main
import
(
"github.com/consensys/gnark/frontend"
twistededwards_gadget
"github.com/consensys/gnark/gadgets/algebra/twistededwards"
"github.com/consensys/gnark/gadgets/hash/mimc"
"github.com/consensys/gurvy"
fr_bn256
"github.com/consensys/gurvy/bn256/fr"
"strconv"
)
func
merkelPathPart
(
circuit
*
frontend
.
CS
,
mimc
mimc
.
MiMCGadget
,
noteHash
*
frontend
.
Constraint
)
{
var
proofSet
,
helper
,
valid
[]
*
frontend
.
Constraint
merkleRoot
:=
circuit
.
PUBLIC_INPUT
(
"treeRootHash"
)
proofSet
=
append
(
proofSet
,
noteHash
)
//helper[0],valid[0]占位, 方便接口只设置有效值
helper
=
append
(
helper
,
circuit
.
ALLOCATE
(
"1"
))
valid
=
append
(
valid
,
circuit
.
ALLOCATE
(
"1"
))
//depth:10, path num need be 9
for
i
:=
1
;
i
<
10
;
i
++
{
proofSet
=
append
(
proofSet
,
circuit
.
SECRET_INPUT
(
"path"
+
strconv
.
Itoa
(
i
)))
helper
=
append
(
helper
,
circuit
.
SECRET_INPUT
(
"helper"
+
strconv
.
Itoa
(
i
)))
valid
=
append
(
valid
,
circuit
.
SECRET_INPUT
(
"valid"
+
strconv
.
Itoa
(
i
)))
}
verifyMerkleProof
(
circuit
,
mimc
,
merkleRoot
,
proofSet
,
helper
,
valid
)
}
func
verifyMerkleProof
(
circuit
*
frontend
.
CS
,
h
mimc
.
MiMCGadget
,
merkleRoot
*
frontend
.
Constraint
,
proofSet
,
helper
,
valid
[]
*
frontend
.
Constraint
)
{
sum
:=
leafSum
(
circuit
,
h
,
proofSet
[
0
])
for
i
:=
1
;
i
<
len
(
proofSet
);
i
++
{
circuit
.
MUSTBE_BOOLEAN
(
helper
[
i
])
d1
:=
circuit
.
SELECT
(
helper
[
i
],
sum
,
proofSet
[
i
])
d2
:=
circuit
.
SELECT
(
helper
[
i
],
proofSet
[
i
],
sum
)
rst
:=
nodeSum
(
circuit
,
h
,
d1
,
d2
)
sum
=
circuit
.
SELECT
(
valid
[
i
],
rst
,
sum
)
}
// Compare our calculated Merkle root to the desired Merkle root.
circuit
.
MUSTBE_EQ
(
sum
,
merkleRoot
)
}
// nodeSum returns the hash created from data inserted to form a leaf.
// Without domain separation.
func
nodeSum
(
circuit
*
frontend
.
CS
,
h
mimc
.
MiMCGadget
,
a
,
b
*
frontend
.
Constraint
)
*
frontend
.
Constraint
{
res
:=
h
.
Hash
(
circuit
,
a
,
b
)
return
res
}
// leafSum returns the hash created from data inserted to form a leaf.
// Without domain separation.
func
leafSum
(
circuit
*
frontend
.
CS
,
h
mimc
.
MiMCGadget
,
data
*
frontend
.
Constraint
)
*
frontend
.
Constraint
{
res
:=
h
.
Hash
(
circuit
,
data
)
return
res
}
func
commitValuePart
(
circuit
*
frontend
.
CS
,
spendValue
*
frontend
.
Constraint
)
{
//cmt=transfer_value*G + random_value*H
cmtvalueX
:=
circuit
.
PUBLIC_INPUT
(
"commitValueX"
)
cmtvalueY
:=
circuit
.
PUBLIC_INPUT
(
"commitValueY"
)
// set curve parameters
edgadget
,
_
:=
twistededwards_gadget
.
NewEdCurveGadget
(
gurvy
.
BN256
)
// set point G in the circuit
pointGSnark
:=
twistededwards_gadget
.
NewPointGadget
(
circuit
,
nil
,
nil
)
//scalar := circuit.ALLOCATE("-1")
circuit
.
MUSTBE_LESS_OR_EQ
(
spendValue
,
10000000000
,
256
)
// set point G in the circuit
pointGSnark
.
ScalarMulFixedBase
(
circuit
,
edgadget
.
BaseX
,
edgadget
.
BaseY
,
spendValue
,
edgadget
)
pointGSnark
.
X
.
Tag
(
"xg"
)
pointGSnark
.
Y
.
Tag
(
"yg"
)
transfer_random
:=
circuit
.
SECRET_INPUT
(
"spendRandom"
)
//circuit.MUSTBE_LESS_OR_EQ(random_value,10000000000,256)
//H is not G, H should be a point that no one know the prikey
var
baseX_H
,
baseY_H
fr_bn256
.
Element
baseX_H
.
SetString
(
"10190477835300927557649934238820360529458681672073866116232821892325659279502"
)
baseY_H
.
SetString
(
"7969140283216448215269095418467361784159407896899334866715345504515077887397"
)
pointHSnark
:=
twistededwards_gadget
.
NewPointGadget
(
circuit
,
nil
,
nil
)
// add points in circuit (the method updates the underlying plain points as well)
pointHSnark
.
ScalarMulFixedBase
(
circuit
,
baseX_H
,
baseY_H
,
transfer_random
,
edgadget
)
pointHSnark
.
X
.
Tag
(
"xh"
)
pointHSnark
.
Y
.
Tag
(
"yh"
)
pointSumSnark
:=
twistededwards_gadget
.
NewPointGadget
(
circuit
,
nil
,
nil
)
pointSumSnark
.
AddGeneric
(
circuit
,
&
pointGSnark
,
&
pointHSnark
,
edgadget
)
//cmtvalue=transfer_value*G + random_value*H
circuit
.
MUSTBE_EQ
(
cmtvalueX
,
pointSumSnark
.
X
)
circuit
.
MUSTBE_EQ
(
cmtvalueY
,
pointSumSnark
.
Y
)
}
plugin/dapp/mix/cmd/gnark/cmd/calc.go
0 → 100644
View file @
928b3daf
/*
Copyright © 2020 ConsenSys
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package
cmd
import
(
"fmt"
"github.com/spf13/cobra"
"os"
mimcbn256
"github.com/consensys/gnark/crypto/hash/mimc/bn256"
fr_bn256
"github.com/consensys/gurvy/bn256/fr"
)
// verifyCmd represents the verify command
var
calcCmd
=
&
cobra
.
Command
{
Use
:
"calc"
,
Short
:
"calc"
,
Version
:
Version
,
}
var
hashCmd
=
&
cobra
.
Command
{
Use
:
"hash ..."
,
Short
:
"read strings to calc hash"
,
Run
:
hash
,
Version
:
Version
,
}
func
init
()
{
calcCmd
.
AddCommand
(
hashCmd
)
rootCmd
.
AddCommand
(
calcCmd
)
}
func
hash
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
if
len
(
args
)
<
1
{
fmt
.
Println
(
"missing input strings"
)
os
.
Exit
(
-
1
)
}
var
sum
[]
byte
for
_
,
k
:=
range
args
{
fmt
.
Println
(
"input:"
,
k
)
sum
=
append
(
sum
,
getByte
(
k
)
...
)
}
hash
:=
mimcbn256
.
Sum
(
"seed"
,
sum
)
fmt
.
Println
(
"hash="
,
getFrString
(
hash
))
}
func
getByte
(
v
string
)
[]
byte
{
var
fr
fr_bn256
.
Element
fr
.
SetString
(
v
)
return
fr
.
Bytes
()
}
func
getFrString
(
v
[]
byte
)
string
{
var
f
fr_bn256
.
Element
f
.
SetBytes
(
v
)
return
f
.
String
()
}
plugin/dapp/mix/cmd/gnark/cmd/verify
input
.go
→
plugin/dapp/mix/cmd/gnark/cmd/verify
str
.go
View file @
928b3daf
File moved
plugin/dapp/mix/cmd/gnark/input/depositInput
View file @
928b3daf
public, no
d
eHash,16308793397024662832064523892418908145900866571524124093537199035808550255649
public, no
t
eHash,16308793397024662832064523892418908145900866571524124093537199035808550255649
public, amount,28242048
...
...
plugin/dapp/mix/cmd/gnark/input/transferOutput
View file @
928b3daf
public, commitValueX,14087975867275911077371231345227824611951436822132762463787130558957838320348
public, commitValueY,15113519960384204624879642069520481336224311978035289236693658603675385299879
public, no
d
eHash,16308793397024662832064523892418908145900866571524124093537199035808550255649
public, no
t
eHash,16308793397024662832064523892418908145900866571524124093537199035808550255649
secret, spendAmount,28242048
...
...
plugin/dapp/mix/executor/deposit.go
View file @
928b3daf
...
...
@@ -70,7 +70,7 @@ func (a *action) depositVerify(proof *mixTy.ZkProofInfo) ([]byte, uint64, error)
return
nil
,
0
,
err
}
return
transferFr2Bytes
(
input
.
No
d
eHash
),
val
,
nil
return
transferFr2Bytes
(
input
.
No
t
eHash
),
val
,
nil
}
...
...
plugin/dapp/mix/executor/transfer.go
View file @
928b3daf
...
...
@@ -138,7 +138,7 @@ func (a *action) Transfer(transfer *mixTy.MixTransferAction) (*types.Receipt, er
//push new commit to merkle tree
for
_
,
h
:=
range
outputs
{
rpt
,
err
:=
pushTree
(
a
.
db
,
transferFr2Bytes
(
h
.
No
d
eHash
))
rpt
,
err
:=
pushTree
(
a
.
db
,
transferFr2Bytes
(
h
.
No
t
eHash
))
if
err
!=
nil
{
return
nil
,
err
}
...
...
plugin/dapp/mix/executor/zksnark/verify_test.go
View file @
928b3daf
This diff is collapsed.
Click to expand it.
plugin/dapp/mix/proto/mix.proto
View file @
928b3daf
...
...
@@ -102,7 +102,7 @@ message MixAction {
message
DepositPublicInput
{
string
no
d
eHash
=
1
;
string
no
t
eHash
=
1
;
string
amount
=
2
;
}
...
...
@@ -124,7 +124,7 @@ message TransferInputPublicInput {
}
message
TransferOutputPublicInput
{
string
no
d
eHash
=
1
;
string
no
t
eHash
=
1
;
string
commitValueX
=
2
;
string
commitValueY
=
3
;
...
...
plugin/dapp/mix/types/mix.pb.go
View file @
928b3daf
...
...
@@ -767,7 +767,7 @@ func (*MixAction) XXX_OneofWrappers() []interface{} {
}
type
DepositPublicInput
struct
{
No
deHash
string
`protobuf:"bytes,1,opt,name=nodeHash,proto3" json:"nod
eHash,omitempty"`
No
teHash
string
`protobuf:"bytes,1,opt,name=noteHash,proto3" json:"not
eHash,omitempty"`
Amount
string
`protobuf:"bytes,2,opt,name=amount,proto3" json:"amount,omitempty"`
XXX_NoUnkeyedLiteral
struct
{}
`json:"-"`
XXX_unrecognized
[]
byte
`json:"-"`
...
...
@@ -799,9 +799,9 @@ func (m *DepositPublicInput) XXX_DiscardUnknown() {
var
xxx_messageInfo_DepositPublicInput
proto
.
InternalMessageInfo
func
(
m
*
DepositPublicInput
)
GetNo
d
eHash
()
string
{
func
(
m
*
DepositPublicInput
)
GetNo
t
eHash
()
string
{
if
m
!=
nil
{
return
m
.
No
d
eHash
return
m
.
No
t
eHash
}
return
""
}
...
...
@@ -948,7 +948,7 @@ func (m *TransferInputPublicInput) GetNullifierHash() string {
}
type
TransferOutputPublicInput
struct
{
No
deHash
string
`protobuf:"bytes,1,opt,name=nodeHash,proto3" json:"nod
eHash,omitempty"`
No
teHash
string
`protobuf:"bytes,1,opt,name=noteHash,proto3" json:"not
eHash,omitempty"`
CommitValueX
string
`protobuf:"bytes,2,opt,name=commitValueX,proto3" json:"commitValueX,omitempty"`
CommitValueY
string
`protobuf:"bytes,3,opt,name=commitValueY,proto3" json:"commitValueY,omitempty"`
XXX_NoUnkeyedLiteral
struct
{}
`json:"-"`
...
...
@@ -981,9 +981,9 @@ func (m *TransferOutputPublicInput) XXX_DiscardUnknown() {
var
xxx_messageInfo_TransferOutputPublicInput
proto
.
InternalMessageInfo
func
(
m
*
TransferOutputPublicInput
)
GetNo
d
eHash
()
string
{
func
(
m
*
TransferOutputPublicInput
)
GetNo
t
eHash
()
string
{
if
m
!=
nil
{
return
m
.
No
d
eHash
return
m
.
No
t
eHash
}
return
""
}
...
...
@@ -1369,33 +1369,33 @@ var fileDescriptor_5c21d519a9be369a = []byte{
0x89
,
0x4e
,
0x60
,
0xef
,
0x4e
,
0x96
,
0x4c
,
0x4e
,
0xa1
,
0x1e
,
0x47
,
0xa5
,
0x8b
,
0xd9
,
0xcd
,
0xe0
,
0x08
,
0xcb
,
0xe2
,
0xa8
,
0xec
,
0xaa
,
0x5e
,
0xd8
,
0x8e
,
0x4b
,
0xf7
,
0x9b
,
0xc5
,
0x85
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
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