Skip to content

Commit

Permalink
Merge pull request #16 from iden3/upgrade_merkletree
Browse files Browse the repository at this point in the history
Upgrade github.com/iden3/go-merkletree-sql to v1.0.1
  • Loading branch information
olomix authored Apr 26, 2022
2 parents 47bf448 + f852124 commit 6c5db43
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/ethereum/go-ethereum v1.10.15
github.com/iden3/go-iden3-core v0.0.16
github.com/iden3/go-iden3-crypto v0.0.13
github.com/iden3/go-merkletree-sql v1.0.0-pre8
github.com/iden3/go-merkletree-sql v1.0.1
github.com/iden3/go-schema-registry-wrapper v0.0.7
github.com/ipfs/go-ipfs-api v0.3.0
github.com/pkg/errors v0.9.1
Expand Down
5 changes: 2 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -216,11 +216,10 @@ github.com/huin/goutil v0.0.0-20170803182201-1ca381bf3150/go.mod h1:PpLOETDnJ0o3
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/iden3/go-iden3-core v0.0.16 h1:BHNcRA+3Jbz0ur9VhQePP9u9o6cGvLBLB3Qs9OGoQlM=
github.com/iden3/go-iden3-core v0.0.16/go.mod h1:wJtcMK/bSazyW/JrQaRrbpUMgSMg79Pke3xgtfPxDnQ=
github.com/iden3/go-iden3-crypto v0.0.11/go.mod h1:yUBWcXgAUDZxa1PvRl0zIT4Q4/rQO5PacE52Z06i8kw=
github.com/iden3/go-iden3-crypto v0.0.13 h1:ixWRiaqDULNyIDdOWz2QQJG5t4PpNHkQk2P6GV94cok=
github.com/iden3/go-iden3-crypto v0.0.13/go.mod h1:swXIv0HFbJKobbQBtsB50G7IHr6PbTowutSew/iBEoo=
github.com/iden3/go-merkletree-sql v1.0.0-pre8 h1:ywL4VaBnpMGRLQUbSGgXXOjSHIo33KEEiBvrK2AnRa8=
github.com/iden3/go-merkletree-sql v1.0.0-pre8/go.mod h1:oYLAGBrr1/yNBZWhpE3JTxtbgDf6d56oRCbdjT1UX9A=
github.com/iden3/go-merkletree-sql v1.0.1 h1:zZMhhyV6FLoLL+pHQiiPoAI3ORSCTKOL32/n7Sb/+R4=
github.com/iden3/go-merkletree-sql v1.0.1/go.mod h1:NhLFvX01F/3QqS0FUkC6T2BXPksz+9EbRhKQ7abaBSE=
github.com/iden3/go-schema-registry-wrapper v0.0.7 h1:0/ONytPufxkLd1N8IQ3syfZBKjwQPdAUOqzZ5JjKFAI=
github.com/iden3/go-schema-registry-wrapper v0.0.7/go.mod h1:p+hycGXKKHtfn3wizEhJliZDz/SfljitkSQSDa5E8UI=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
Expand Down
26 changes: 21 additions & 5 deletions utils/claims.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package utils
import (
"encoding/json"
"fmt"
"github.com/iden3/go-merkletree-sql"
"math/big"

"github.com/ethereum/go-ethereum/crypto"
core "github.com/iden3/go-iden3-core"
"github.com/iden3/go-merkletree-sql"
"github.com/iden3/go-schema-processor/processor"
"github.com/iden3/go-schema-processor/verifiable"
"github.com/pkg/errors"
Expand Down Expand Up @@ -179,10 +179,18 @@ func VerifyClaimHash(credential *verifiable.Iden3Credential,
if err != nil {
return err
}
if basicProof.HIndex != merkletree.NewHashFromBigInt(hi).Hex() {
indexHash, err := merkletree.NewHashFromBigInt(hi)
if err != nil {
return err
}
if basicProof.HIndex != indexHash.Hex() {
return errIndexHashNotEqual
}
if basicProof.HValue != merkletree.NewHashFromBigInt(hv).Hex() {
valueHash, err := merkletree.NewHashFromBigInt(hv)
if err != nil {
return err
}
if basicProof.HValue != valueHash.Hex() {
return errValueHashNotEqual
}
}
Expand All @@ -197,10 +205,18 @@ func VerifyClaimHash(credential *verifiable.Iden3Credential,
return err
}

if basicProof.HIndex != merkletree.NewHashFromBigInt(hi).Hex() {
indexHash, err := merkletree.NewHashFromBigInt(hi)
if err != nil {
return err
}
if basicProof.HIndex != indexHash.Hex() {
return errIndexHashNotEqual
}
if basicProof.HValue != merkletree.NewHashFromBigInt(hv).Hex() {
valueHash, err := merkletree.NewHashFromBigInt(hv)
if err != nil {
return err
}
if basicProof.HValue != valueHash.Hex() {
return errValueHashNotEqual
}
default:
Expand Down

0 comments on commit 6c5db43

Please sign in to comment.