Skip to content

Commit

Permalink
Merge pull request #35 from 0xPolygonID/feature/update-go-merkletree-sql
Browse files Browse the repository at this point in the history
update go-merkletree-sql to v2.0.6
  • Loading branch information
demonsh authored Jul 6, 2023
2 parents 3ef54da + 0d0a2cc commit 27ea06c
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 7 deletions.
2 changes: 1 addition & 1 deletion examples/testdata/proof_from_smart_contract_out.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"root":"17039823904837071705763545555283546217751326723169195059364451777353741017328","proof":{"existence":false,"siblings":["14989532119404983961115670288381063073891118401716735992353404523801340288158","15817549995119513546413395894800310537308858548528902759332598606866792105384","20955911300871905860419417343337237575819647673394656670247178513070221579793","7345857457589225232320640926291449425076936633178262764678572453063445218154","13941064550735375985967548290421702932981128763694428458881182266843384273940","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"node_aux":{"key":"10","value":"20"}}}
{"root":"17039823904837071705763545555283546217751326723169195059364451777353741017328","proof":{"existence":false,"siblings":["14989532119404983961115670288381063073891118401716735992353404523801340288158","15817549995119513546413395894800310537308858548528902759332598606866792105384","20955911300871905860419417343337237575819647673394656670247178513070221579793","7345857457589225232320640926291449425076936633178262764678572453063445218154","13941064550735375985967548290421702932981128763694428458881182266843384273940"],"node_aux":{"key":"10","value":"20"}}}
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ go 1.19

require (
github.com/ethereum/go-ethereum v1.12.0
github.com/iden3/contracts-abi/onchain-credential-status-resolver/go/abi v0.0.0-20230623092404-d47a0a434f65
github.com/iden3/contracts-abi/state/go/abi v0.0.0-20230405152923-4a25f6f1f0f4
github.com/iden3/go-circuits v1.0.2
github.com/iden3/go-iden3-core v1.0.2
github.com/iden3/go-iden3-crypto v0.0.15
github.com/iden3/go-merkletree-sql/v2 v2.0.4
github.com/iden3/go-merkletree-sql/v2 v2.0.6
github.com/iden3/go-schema-processor v1.3.1
github.com/iden3/merkletree-proof v0.0.2
github.com/ipfs/go-ipfs-api v0.6.0
Expand All @@ -31,7 +32,6 @@ require (
github.com/google/uuid v1.3.0 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/holiman/uint256 v1.2.2-0.20230321075855-87b91420868c // indirect
github.com/iden3/contracts-abi/onchain-credential-status-resolver/go/abi v0.0.0-20230623092404-d47a0a434f65 // indirect
github.com/ipfs/boxo v0.8.0 // indirect
github.com/ipfs/go-cid v0.4.0 // indirect
github.com/klauspost/cpuid/v2 v2.2.3 // indirect
Expand Down
6 changes: 2 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ github.com/holiman/uint256 v1.2.2-0.20230321075855-87b91420868c h1:DZfsyhDK1hnSS
github.com/holiman/uint256 v1.2.2-0.20230321075855-87b91420868c/go.mod h1:SC8Ryt4n+UBbPbIBKaG9zbbDlp4jOru9xFZmPzLUTxw=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/huin/goupnp v1.0.3 h1:N8No57ls+MnjlB+JPiCVSOyy/ot7MJTqlo7rn+NYSqQ=
github.com/iden3/contracts-abi/identityBase/go/abi v0.0.0-20230621153633-7549c4edaf16 h1:ZK0P87QMoUejpFAJ3egkAKj3IpSCtRRf/ztgZGcFQW4=
github.com/iden3/contracts-abi/identityBase/go/abi v0.0.0-20230621153633-7549c4edaf16/go.mod h1:VazDjFNz60ZVIZ0twlDRbW+4xp3IE+rLTbJQWSm11cQ=
github.com/iden3/contracts-abi/onchain-credential-status-resolver/go/abi v0.0.0-20230623092404-d47a0a434f65 h1:K8dUsVWB2FMSK/4+Vyg3U6khNGkGFzJChJmcGNjm/KY=
github.com/iden3/contracts-abi/onchain-credential-status-resolver/go/abi v0.0.0-20230623092404-d47a0a434f65/go.mod h1:8fkd2xyUG/V7ovpvZRyD2LyK2zZ4ALbgf5vJGyhzKdg=
github.com/iden3/contracts-abi/state/go/abi v0.0.0-20230405152923-4a25f6f1f0f4 h1:iPvYa/AhhGo3juoUFDm/fBE2CZKy4WfQu7JY90tRf9Q=
Expand All @@ -85,8 +83,8 @@ github.com/iden3/go-iden3-core v1.0.2 h1:HwNDFeqcUv4ybZj5tH+58JKWKarn/qqBpNCqTLx
github.com/iden3/go-iden3-core v1.0.2/go.mod h1:X4PjlJG8OsEQEsSbzzYqqAk2olYGZ2nuGqiUPyEYjOo=
github.com/iden3/go-iden3-crypto v0.0.15 h1:4MJYlrot1l31Fzlo2sF56u7EVFeHHJkxGXXZCtESgK4=
github.com/iden3/go-iden3-crypto v0.0.15/go.mod h1:dLpM4vEPJ3nDHzhWFXDjzkn1qHoBeOT/3UEhXsEsP3E=
github.com/iden3/go-merkletree-sql/v2 v2.0.4 h1:Dp089P3YNX1BE8+T1tKQHWTtnk84Y/Kr7ZAGTqwscoY=
github.com/iden3/go-merkletree-sql/v2 v2.0.4/go.mod h1:kRhHKYpui5DUsry5RpveP6IC4XMe6iApdV9VChRYuEk=
github.com/iden3/go-merkletree-sql/v2 v2.0.6 h1:vsVDImnvnHf7Ggr45ptFOXJyWNA/8IwVQO1jzRLUlY8=
github.com/iden3/go-merkletree-sql/v2 v2.0.6/go.mod h1:kRhHKYpui5DUsry5RpveP6IC4XMe6iApdV9VChRYuEk=
github.com/iden3/go-schema-processor v1.3.1 h1:LJfFInfYGMOp0bTKKC17R8q4XI+VtqhFLPTEqnOIvlM=
github.com/iden3/go-schema-processor v1.3.1/go.mod h1:NwJ1nuGdRlCFaN1/V6mS0AOAdvpLcGf4KKq0mluLG7U=
github.com/iden3/merkletree-proof v0.0.2 h1:a6At2Mm/fEnC8MjsgAmTSrgVsTsKuWGNwdsDU0otJC4=
Expand Down
44 changes: 44 additions & 0 deletions proof_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package c_polygonid

import (
"encoding/json"
"math/big"
"testing"

Expand Down Expand Up @@ -61,3 +62,46 @@ func TestSmartContractProof_UnmarshalJSON(t *testing.T) {
require.NoError(t, err)
require.Equal(t, want, res)
}

func TestProofFromSmartContract(t *testing.T) {
in := `{
"root": "17039823904837071705763545555283546217751326723169195059364451777353741017328",
"existence": false,
"siblings": [
"14989532119404983961115670288381063073891118401716735992353404523801340288158",
"15817549995119513546413395894800310537308858548528902759332598606866792105384",
"20955911300871905860419417343337237575819647673394656670247178513070221579793",
"7345857457589225232320640926291449425076936633178262764678572453063445218154",
"13941064550735375985967548290421702932981128763694428458881182266843384273940",
"0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0",
"0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0"
],
"auxExistence": true,
"auxIndex": "10",
"auxValue": "20",
"index": "13625694351531357880063798347796487002182037278253017013343168668336623401886",
"value": "0"
}`
var scp SmartContractProof
err := scp.UnmarshalJSON([]byte(in))
require.NoError(t, err)

proof, _, err := ProofFromSmartContract(scp)
require.NoError(t, err)

proofJson, err := json.Marshal(proof)
require.NoError(t, err)

wantResponse := `{
"existence": false,
"siblings": [
"14989532119404983961115670288381063073891118401716735992353404523801340288158",
"15817549995119513546413395894800310537308858548528902759332598606866792105384",
"20955911300871905860419417343337237575819647673394656670247178513070221579793",
"7345857457589225232320640926291449425076936633178262764678572453063445218154",
"13941064550735375985967548290421702932981128763694428458881182266843384273940"
],
"node_aux": {"key": "10", "value": "20"}
}`
require.JSONEq(t, wantResponse, string(proofJson))
}

0 comments on commit 27ea06c

Please sign in to comment.