Commit 3a7e9761 authored by mdj33's avatar mdj33 Committed by vipwzw

mimc hash seed update

parent 62f57dc9
This diff is collapsed.
......@@ -95,7 +95,7 @@ func getArchiveRoots(db dbm.KV, exec, symbol string, seq uint64) (*mixTy.CommitT
//TODO seed config
func getNewTree() *merkletree.Tree {
return merkletree.New(mimc.NewMiMC("seed"))
return merkletree.New(mimc.NewMiMC(mixTy.MimcHashSeed))
}
func calcTreeRoot(leaves *mixTy.CommitTreeLeaves) []byte {
......
......@@ -58,7 +58,7 @@ type AuthorizeCircuit struct {
// Define declares the circuit's constraints
func (circuit *AuthorizeCircuit) Define(curveID ecc.ID, cs *frontend.ConstraintSystem) error {
// hash function
h, _ := mimc.NewMiMC("seed", curveID, cs)
h, _ := mimc.NewMiMC(MimcHashSeed, curveID, cs)
mimc := &h
mimc.Write(circuit.AuthorizePriKey)
cs.AssertIsEqual(circuit.AuthorizePubKey, mimc.Sum())
......
......@@ -19,7 +19,7 @@ type DepositCircuit struct {
func (circuit *DepositCircuit) Define(curveID ecc.ID, cs *frontend.ConstraintSystem) error {
// hash function
mimc, _ := mimc.NewMiMC("seed", curveID, cs)
mimc, _ := mimc.NewMiMC(MimcHashSeed, curveID, cs)
mimc.Write(circuit.ReceiverPubKey, circuit.ReturnPubKey, circuit.AuthorizePubKey, circuit.Amount, circuit.NoteRandom)
cs.AssertIsEqual(circuit.NoteHash, mimc.Sum())
......
......@@ -13,6 +13,8 @@ var tlog = log15.New("module", MixX)
const (
//MaxTreeLeaves = 1024
TreeLevel = 10
//MimcHashSeed 电路不支持作为公共输入,设为全局常数
MimcHashSeed = "19172955941344617222923168298456110557655645809646772800021167670156933290312"
)
// 执行器的日志类型
......
......@@ -69,7 +69,7 @@ func (circuit *TransferInputCircuit) Define(curveID ecc.ID, cs *frontend.Constra
cs.AssertIsBoolean(circuit.AuthorizeFlag)
// hash function
h, _ := mimc.NewMiMC("seed", curveID, cs)
h, _ := mimc.NewMiMC(MimcHashSeed, curveID, cs)
mimc := &h
//verify spend private key
......
......@@ -26,7 +26,7 @@ type TransferOutputCircuit struct {
// Define declares the circuit's constraints
func (circuit *TransferOutputCircuit) Define(curveID ecc.ID, cs *frontend.ConstraintSystem) error {
// hash function
h, _ := mimc.NewMiMC("seed", curveID, cs)
h, _ := mimc.NewMiMC(MimcHashSeed, curveID, cs)
mimc := &h
mimc.Write(circuit.ReceiverPubKey, circuit.ReturnPubKey, circuit.AuthorizePubKey, circuit.Amount, circuit.NoteRandom)
cs.AssertIsEqual(circuit.NoteHash, mimc.Sum())
......
......@@ -64,7 +64,7 @@ func (circuit *WithdrawCircuit) Define(curveID ecc.ID, cs *frontend.ConstraintSy
cs.AssertIsBoolean(circuit.AuthorizeFlag)
// hash function
h, _ := mimc.NewMiMC("seed", curveID, cs)
h, _ := mimc.NewMiMC(MimcHashSeed, curveID, cs)
mimc := &h
mimc.Write(circuit.SpendPriKey)
targetSpendKey := cs.Select(circuit.SpendFlag, circuit.ReceiverPubKey, circuit.ReturnPubKey)
......
......@@ -140,7 +140,7 @@ func mimcHashByte(params [][]byte) []byte {
}
func mimcHashCalc(sum []byte) []byte {
h := mimc.NewMiMC("seed")
h := mimc.NewMiMC(mixTy.MimcHashSeed)
h.Write(sum)
return h.Sum(nil)
}
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