diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index b434824..c3766e2 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -13,7 +13,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: - go-version: 1.23.4 + go-version: 1.23.5 - uses: golangci/golangci-lint-action@v6 with: version: v1.63.4 diff --git a/.github/workflows/tests-c.yaml b/.github/workflows/tests-c.yaml index 0d4440d..1c7df16 100644 --- a/.github/workflows/tests-c.yaml +++ b/.github/workflows/tests-c.yaml @@ -14,7 +14,7 @@ jobs: strategy: matrix: containers: - - 1.22.5-bookworm + - 1.23.5-bookworm runs-on: ubuntu-24.04 container: golang:${{matrix.containers}} steps: @@ -48,7 +48,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: - go-version: 1.22.5 + go-version: 1.23.5 - uses: actions/cache@v4 with: path: | diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index fa9b618..de1b9dc 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -11,8 +11,7 @@ jobs: strategy: matrix: go_version: - - "1.22.10" - - "1.23.4" + - "1.23.5" runs-on: ubuntu-24.04 env: IPFS_URL: http://localhost:5001 diff --git a/aadhaar.go b/aadhaar.go new file mode 100644 index 0000000..db054b7 --- /dev/null +++ b/aadhaar.go @@ -0,0 +1,15 @@ +package c_polygonid + +import ( + gocircuitexternal "github.com/0xPolygonID/go-circuit-external" +) + +type anonAadhaarV1Inputs struct { + QRData *jsonNumber `json:"qrData"` + gocircuitexternal.AnonAadhaarV1Inputs +} + +func (a *anonAadhaarV1Inputs) asAnonAadhaarV1Inputs() *gocircuitexternal.AnonAadhaarV1Inputs { + a.AnonAadhaarV1Inputs.QRData = a.QRData.toBitInt() + return &a.AnonAadhaarV1Inputs +} diff --git a/aadhaar_test.go b/aadhaar_test.go new file mode 100644 index 0000000..7c2876b --- /dev/null +++ b/aadhaar_test.go @@ -0,0 +1,49 @@ +package c_polygonid + +import ( + "encoding/json" + "math/big" + "os" + "testing" + + gocircuitexternal "github.com/0xPolygonID/go-circuit-external" + "github.com/stretchr/testify/require" +) + +func toBigInt(in string) *big.Int { + i, ok := new(big.Int).SetString(in, 10) + if !ok { + panic(in) + } + return i +} + +func TestAnonAadhaarV1Inputs_UnmarshalJSON(t *testing.T) { + d, err := os.ReadFile("testdata/anon_aadhaar_v1_inputs.json") + require.NoError(t, err) + + var inputs anonAadhaarV1Inputs + err = json.Unmarshal(d, &inputs) + require.NoError(t, err) + + want := &gocircuitexternal.AnonAadhaarV1Inputs{ + QRData: toBigInt("8259163575998395410294216884136380576185817320339145460288951755287582961380611852552428987321584902318624273479337130653734982789439199350807739714406680256506601030028361685736660257517232716829232450159251789263870750283214820475102793105777087762238893090228084052270739203426767272062178826235941508196284529472654271516164224874687419158221021213944829682919423174703783469927383220474654008065915029614141226522064062660593170425792840873655513538373377850112144063189928583588899889878172757870400281696669604010659786496608127700010264443115263361656744433002559396889060190428705316366290450741550935385486607346514118464415324976934593027192262025619948063647667007927187736245772179085671658409804311603784752615097922989017361163561315974008304022542448394278143245816470881130080719485003834016131185071765229491892891069788319670287394271744730364788949609836924781874523936880888005883165757273872375006288978183466996520618718348187182821516617721340861010989807614756396013627238651856164981477576514065364628430139194213240602981419233621531616776712580234318576148789862972873366521755587675635811636464535551028275057950562020714225333126426609311459495088802145911084644641596208432517247324679678535859879970296810837735288916946197174410518342751033634782712968162882714769666441813893046220965525694847349131353986974388432968669605721975441870936552792275255624723251162192468002453471184713983574359601113515796454264270501379717344206777921353459767049560942843350534472442799601294637063232419543855742825887931841338302499933012059977947394755335155868283405337181095220998277373266658634859632929226320059674299759100792654417315629048732480315019941928105082550091217622422743467170706956093632228513797781797454779203616427853022505097310749994766657051986303478622173767936568165644251615127773430128638507677775244195799780291921828512257290767451475181728141544788756907393883042588060697683541401090581157249784874529424005078918452607589129440476242749110421616270676359722523229311894327359615548588038186027827017569331332262329182564217789843145105509621002324556840213928256545454178891208004109769624959566302976213521762873815749009289995208912424872527724417047936432945498377307452190302923489092664437908497749093491199476080757200233878726847198496754472664256996743796092233459542884818717466621372105594672115988382565552756801323160697003960485232732393383241422077506009076922303757067128564302338914230360252223406874457414109774901980252709597099278192874164252010830754720603092419792069707099362278082792090307065378744856387301364608460967253691290230861162587170799141457093188189022390589265654613500974699477990974878105678883229707694455342266695530373994049224098435972125150350136428446936271698977517627416435999970351222450833295217051468307037908262231982382247410542334757724852032521780157518474618653527191342825230455100778913195115477763082159513429761573752871477695723697689470263993132596482716347199834315782099668846081963760553679915994617396376870314998926788197388410764535427795200340714967872713095483294486407886767431404892448155562283436571050452251042117926586451385682519188252281397"), + CredentialSubjectID: "did:iden3:privado:main:2Scn2RfosbkQDMQzQM5nCz3Nk5GnbzZCWzGCd3tc2G", + CredentialStatusRevocationNonce: 954548273, + CredentialStatusID: "https://issuer-node-core-api-demo.privado.id/v2/agent", + IssuerID: "did:iden3:privado:main:2Si3eZUE6XetYsmU5dyUK2Cvaxr1EEe65vdv2BML4L", + PubKey: `-----BEGIN PUBLIC KEY----- +MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAlegfdQZZXMJirdz93TXY +BAVbKt9G3HGcVrWO7hmZle+hoyVHEGIKx4Ael29E475FTbDxkOP31ONZiXIRc0Te +Uvz3gm+ElIipWaez0h623QNFFmLqiD7u796ImhSZuaR/lQTF8JbCYrltI9GXUDMt +npfrYUHSYd6XmU1MQWPKnL4+B3IhtEJT3PgWCUKLaDUe4+m2DSs1H9qm7owoqEUj +n5fefMD+XRROR0gT+0PsWD+BtO4yjCIWczSJjSELoBeibsaJQPBd8ivZzIa7w6Q1 +Q5I3LVZhZ3abc1uhLKNYD5GcG9i6cMTCqwrPKwm8L66YHzwClabh6fJI9QBzCU/6 +8QIDAQAB +-----END PUBLIC KEY-----`, + NullifierSeed: 12345678, + SignalHash: 1001, + } + + require.Equal(t, want, inputs.asAnonAadhaarV1Inputs()) +} diff --git a/cmd/polygonid/polygonid.go b/cmd/polygonid/polygonid.go index 1705a06..bdf6a68 100644 --- a/cmd/polygonid/polygonid.go +++ b/cmd/polygonid/polygonid.go @@ -288,6 +288,14 @@ func PLGNNewGenesisIDFromEth(jsonResponse **C.char, in *C.char, cfg *C.char, status) } +//export PLGNW3CCredentialToCoreClaim +func PLGNW3CCredentialToCoreClaim(jsonResponse **C.char, in *C.char, cfg *C.char, + status **C.PLGNStatus) bool { + + return callGenericFn(c_polygonid.W3CCredentialToCoreClaim, jsonResponse, in, + cfg, status) +} + //export PLGNCreateClaim func PLGNCreateClaim(jsonResponse **C.char, in *C.char, status **C.PLGNStatus) (ok bool) { @@ -926,6 +934,13 @@ func PLGNW3CCredentialFromOnchainHex(jsonResponse **C.char, in *C.char, return true } +//export PLGNW3CCredentialFromAnonAadhaarInputs +func PLGNW3CCredentialFromAnonAadhaarInputs(jsonResponse **C.char, in *C.char, + cfg *C.char, status **C.PLGNStatus) bool { + return callGenericFn(c_polygonid.W3cCredentialsFromAnonAadhaarInputsJson, + jsonResponse, in, cfg, status) +} + // PLGNDescribeID parses ID and return it in different representations. // Request example: // diff --git a/go.mod b/go.mod index 7929e52..17fe7a4 100644 --- a/go.mod +++ b/go.mod @@ -1,8 +1,9 @@ module github.com/0xPolygonID/c-polygonid -go 1.22 +go 1.23.5 require ( + github.com/0xPolygonID/go-circuit-external v0.0.0 github.com/dgraph-io/badger/v4 v4.5.0 github.com/ethereum/go-ethereum v1.14.12 github.com/iden3/go-circuits/v2 v2.4.1-0.20250116125441-51815c3526f8 @@ -10,7 +11,7 @@ require ( github.com/iden3/go-iden3-crypto v0.0.17 github.com/iden3/go-merkletree-sql/v2 v2.0.6 github.com/iden3/go-onchain-credential-adapter v0.0.0-20240425110009-4004ac8da50c - github.com/iden3/go-schema-processor/v2 v2.6.0 + github.com/iden3/go-schema-processor/v2 v2.6.1 github.com/iden3/iden3comm/v2 v2.7.0 github.com/iden3/merkletree-proof v0.3.0 github.com/piprate/json-gold v0.5.1-0.20241210232033-19254b3ec65b @@ -29,7 +30,7 @@ require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/dchest/blake512 v1.0.0 // indirect github.com/deckarep/golang-set/v2 v2.6.0 // indirect - github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect + github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 // indirect github.com/dgraph-io/ristretto/v2 v2.0.0 // indirect github.com/dustin/go-humanize v1.0.1 // indirect github.com/dustinxie/ecc v0.0.0-20210511000915-959544187564 // indirect @@ -37,7 +38,7 @@ require ( github.com/ethereum/go-verkle v0.1.1-0.20240829091221-dffa7562dbe9 // indirect github.com/fsnotify/fsnotify v1.6.0 // indirect github.com/go-ole/go-ole v1.3.0 // indirect - github.com/goccy/go-json v0.10.2 // indirect + github.com/goccy/go-json v0.10.3 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/google/flatbuffers v24.3.25+incompatible // indirect github.com/google/uuid v1.6.0 // indirect @@ -53,11 +54,13 @@ require ( github.com/iden3/go-rapidsnark/witness/v2 v2.0.0 // indirect github.com/iden3/go-rapidsnark/witness/wazero v0.0.0-20230524142950-0986cf057d4e // indirect github.com/klauspost/compress v1.17.11 // indirect - github.com/lestrrat-go/blackmagic v1.0.1 // indirect + github.com/lestrrat-go/blackmagic v1.0.2 // indirect github.com/lestrrat-go/httpcc v1.0.1 // indirect github.com/lestrrat-go/httprc v1.0.4 // indirect + github.com/lestrrat-go/httprc/v3 v3.0.0-beta1 // indirect github.com/lestrrat-go/iter v1.0.2 // indirect github.com/lestrrat-go/jwx/v2 v2.0.12 // indirect + github.com/lestrrat-go/jwx/v3 v3.0.0-alpha1 // indirect github.com/lestrrat-go/option v1.0.1 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect @@ -89,3 +92,4 @@ require ( //replace github.com/iden3/go-circuits => ../go-circuits //replace github.com/iden3/go-schema-processor/v2 => ../go-schema-processor +replace github.com/0xPolygonID/go-circuit-external => ../go-circuit-external diff --git a/go.sum b/go.sum index cfcaa40..fa697df 100644 --- a/go.sum +++ b/go.sum @@ -48,8 +48,9 @@ github.com/deckarep/golang-set/v2 v2.6.0 h1:XfcQbWM1LlMB8BsJ8N9vW5ehnnPVIw0je80N github.com/deckarep/golang-set/v2 v2.6.0/go.mod h1:VAky9rY/yGXJOLEDv3OMci+7wtDpOF4IN+y82NBOac4= github.com/decred/dcrd/crypto/blake256 v1.0.1 h1:7PltbUIQB7u/FfZ39+DGa/ShuMyJ5ilcvdfma9wOH6Y= github.com/decred/dcrd/crypto/blake256 v1.0.1/go.mod h1:2OfgNZ5wDpcsFmHmCK5gZTPcCXqlm2ArzUIkw9czNJo= -github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 h1:8UrgZ3GkP4i/CLijOJx79Yu+etlyjdBU4sfcs2WYQMs= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 h1:rpfIENRNNilwHwZeG5+P150SMrnNEcHYvcCuK6dPZSg= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0= github.com/dgraph-io/badger/v4 v4.5.0 h1:TeJE3I1pIWLBjYhIYCA1+uxrjWEoJXImFBMEBVSm16g= github.com/dgraph-io/badger/v4 v4.5.0/go.mod h1:ysgYmIeG8dS/E8kwxT7xHyc7MkmwNYLRoYnFbr7387A= github.com/dgraph-io/ristretto/v2 v2.0.0 h1:l0yiSOtlJvc0otkqyMaDNysg8E9/F/TYZwMbxscNOAQ= @@ -77,8 +78,9 @@ github.com/getsentry/sentry-go v0.27.0/go.mod h1:lc76E2QywIyW8WuBnwl8Lc4bkmQH4+w github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE= github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78= -github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= +github.com/goccy/go-json v0.10.3 h1:KZ5WoDbxAIgm2HNbYckL0se1fHD6rz5j4ywS6ebzDqA= +github.com/goccy/go-json v0.10.3/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M= github.com/gofrs/flock v0.8.1 h1:+gYjHKf32LDeiEEFhQaotPbLuUXjY5ZqxKgXy7n59aw= github.com/gofrs/flock v0.8.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= @@ -159,8 +161,8 @@ github.com/iden3/go-rapidsnark/witness/v2 v2.0.0 h1:mkY6VDfwKVJc83QGKmwVXY2LYepi github.com/iden3/go-rapidsnark/witness/v2 v2.0.0/go.mod h1:3JRjqUfW1hgI9hzLDO0v8z/DUkR0ZUehhYLlnIfRxnA= github.com/iden3/go-rapidsnark/witness/wazero v0.0.0-20230524142950-0986cf057d4e h1:WeiFCrpj5pLRtSA4Mg03yTrSZhHHqN/k5b6bwxd9/tY= github.com/iden3/go-rapidsnark/witness/wazero v0.0.0-20230524142950-0986cf057d4e/go.mod h1:UEBifEzw62T6VzIHJeHuUgeLg2U/J9ttf7hOwQEqnYk= -github.com/iden3/go-schema-processor/v2 v2.6.0 h1:5KWXtzwER/ftuTofuLJNEoQqRoX2UlnrmLvFmprgycs= -github.com/iden3/go-schema-processor/v2 v2.6.0/go.mod h1:MYrkk55aEx3ZBKz0d/0rfxa7lBH4x9TfKGI1T/WBlpw= +github.com/iden3/go-schema-processor/v2 v2.6.1 h1:KD33sTAu2xAyG94SmrUAMxI+MREFTmSsavYy70gkTW4= +github.com/iden3/go-schema-processor/v2 v2.6.1/go.mod h1:MYrkk55aEx3ZBKz0d/0rfxa7lBH4x9TfKGI1T/WBlpw= github.com/iden3/iden3comm/v2 v2.7.0 h1:VTFCUQXywXepB+3ylamHFibmOEU1yplBx9Q9zC1MQbA= github.com/iden3/iden3comm/v2 v2.7.0/go.mod h1:ZRnfFg4geX336Bp9+29ZQdSqchbsBoVcd7ARn6JXH5Y= github.com/iden3/merkletree-proof v0.3.0 h1:NVlvtUBEgn4Etxxn+RsOmXP/qlI+85BdN8oUDTf3mxI= @@ -179,16 +181,21 @@ github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0 github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7c= github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8= -github.com/lestrrat-go/blackmagic v1.0.1 h1:lS5Zts+5HIC/8og6cGHb0uCcNCa3OUt1ygh3Qz2Fe80= github.com/lestrrat-go/blackmagic v1.0.1/go.mod h1:UrEqBzIR2U6CnzVyUtfM6oZNMt/7O7Vohk2J0OGSAtU= +github.com/lestrrat-go/blackmagic v1.0.2 h1:Cg2gVSc9h7sz9NOByczrbUvLopQmXrfFx//N+AkAr5k= +github.com/lestrrat-go/blackmagic v1.0.2/go.mod h1:UrEqBzIR2U6CnzVyUtfM6oZNMt/7O7Vohk2J0OGSAtU= github.com/lestrrat-go/httpcc v1.0.1 h1:ydWCStUeJLkpYyjLDHihupbn2tYmZ7m22BGkcvZZrIE= github.com/lestrrat-go/httpcc v1.0.1/go.mod h1:qiltp3Mt56+55GPVCbTdM9MlqhvzyuL6W/NMDA8vA5E= github.com/lestrrat-go/httprc v1.0.4 h1:bAZymwoZQb+Oq8MEbyipag7iSq6YIga8Wj6GOiJGdI8= github.com/lestrrat-go/httprc v1.0.4/go.mod h1:mwwz3JMTPBjHUkkDv/IGJ39aALInZLrhBp0X7KGUZlo= +github.com/lestrrat-go/httprc/v3 v3.0.0-beta1 h1:pzDjP9dSONCFQC/AE3mWUnHILGiYPiMKzQIS+weKJXA= +github.com/lestrrat-go/httprc/v3 v3.0.0-beta1/go.mod h1:wdsgouffPvWPEYh8t7PRH/PidR5sfVqt0na4Nhj60Ms= github.com/lestrrat-go/iter v1.0.2 h1:gMXo1q4c2pHmC3dn8LzRhJfP1ceCbgSiT9lUydIzltI= github.com/lestrrat-go/iter v1.0.2/go.mod h1:Momfcq3AnRlRjI5b5O8/G5/BvpzrhoFTZcn06fEOPt4= github.com/lestrrat-go/jwx/v2 v2.0.12 h1:3d589+5w/b9b7S3DneICPW16AqTyYXB7VRjgluSDWeA= github.com/lestrrat-go/jwx/v2 v2.0.12/go.mod h1:Mq4KN1mM7bp+5z/W5HS8aCNs5RKZ911G/0y2qUjAQuQ= +github.com/lestrrat-go/jwx/v3 v3.0.0-alpha1 h1:IKsSdax3m7zsi4ooThn7YR74PMsx8fqcLcEeA6164nI= +github.com/lestrrat-go/jwx/v3 v3.0.0-alpha1/go.mod h1:JLWHVwLtN56LfSrlpyjhvKEdG00MTYOrmzLIJkrCeDw= github.com/lestrrat-go/option v1.0.0/go.mod h1:5ZHFbivi4xwXxhxY9XHDe2FHo6/Z7WWmtT7T5nBBp3I= github.com/lestrrat-go/option v1.0.1 h1:oAzP2fvZGQKWkvHa1/SAcFolBEca1oN+mQ7eooNBEYU= github.com/lestrrat-go/option v1.0.1/go.mod h1:5ZHFbivi4xwXxhxY9XHDe2FHo6/Z7WWmtT7T5nBBp3I= diff --git a/inputs_sig.go b/inputs_sig.go index 31e10e3..4e5fd8d 100644 --- a/inputs_sig.go +++ b/inputs_sig.go @@ -18,6 +18,7 @@ import ( "sync" "time" + gocircuitexternal "github.com/0xPolygonID/go-circuit-external" "github.com/dgraph-io/badger/v4" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/ethclient" @@ -1168,6 +1169,8 @@ func GenericInputsFromJson(ctx context.Context, cfg EnvConfig, return LinkedMultiQueryInputsFromJson(ctx, cfg, in) case circuits.AuthV2CircuitID: return AuthV2InputsFromJson(ctx, cfg, in) + case gocircuitexternal.AnonAadhaarV1: + return AnonAadhaarInputsFromJson(ctx, cfg, in) } return AtomicQueryInputsResponse{}, errors.New("unknown circuit") @@ -2657,3 +2660,93 @@ func AuthV2InputsFromJson(_ context.Context, _ EnvConfig, return out, nil } + +func AnonAadhaarInputsFromJson(ctx context.Context, cfg EnvConfig, + in []byte) (AtomicQueryInputsResponse, error) { + + var out AtomicQueryInputsResponse + var inputs anonAadhaarV1Inputs + err := json.Unmarshal(in, &inputs) + if err != nil { + return out, err + } + + out.Inputs = inputs.asAnonAadhaarV1Inputs() + return out, nil +} + +func W3cCredentialsFromAnonAadhaarInputsJson(ctx context.Context, cfg EnvConfig, + in []byte) (verifiable.W3CCredential, error) { + + var inputs anonAadhaarV1Inputs + err := json.Unmarshal(in, &inputs) + if err != nil { + return verifiable.W3CCredential{}, err + } + + w3cCred, err := inputs.asAnonAadhaarV1Inputs().W3CCredential() + if err != nil { + return verifiable.W3CCredential{}, err + } + + return *w3cCred, nil +} + +type CoreClaimResponse struct { + CoreClaim *core.Claim `json:"coreClaim"` + CoreClaimHex string `json:"coreClaimHex"` + CoreClaimIndexHash *JsonBigInt `json:"coreClaimHIndex"` + CoreClaimValueHash *JsonBigInt `json:"coreClaimHValue"` +} + +func W3CCredentialToCoreClaim(ctx context.Context, cfg EnvConfig, in []byte) (CoreClaimResponse, error) { + var req struct { + W3CCredential *verifiable.W3CCredential `json:"w3cCredential"` + CoreClaimOptions *verifiable.CoreClaimOptions `json:"coreClaimOptions"` + } + err := json.Unmarshal(in, &req) + if err != nil { + return CoreClaimResponse{}, err + } + if req.W3CCredential == nil { + return CoreClaimResponse{}, + errors.New("w3cCredential is not set in the request") + } + + if req.CoreClaimOptions == nil { + req.CoreClaimOptions = &verifiable.CoreClaimOptions{ + RevNonce: 0, + Version: 0, + SubjectPosition: verifiable.CredentialSubjectPositionIndex, + MerklizedRootPosition: verifiable.CredentialMerklizedRootPositionNone, + Updatable: false, + MerklizerOpts: nil, + } + } + + req.CoreClaimOptions.MerklizerOpts = append( + req.CoreClaimOptions.MerklizerOpts, + merklize.WithDocumentLoader(cfg.documentLoader())) + + var resp CoreClaimResponse + + resp.CoreClaim, err = req.W3CCredential.ToCoreClaim(ctx, + req.CoreClaimOptions) + if err != nil { + return CoreClaimResponse{}, err + } + + ih, vh, err := resp.CoreClaim.HiHv() + if err != nil { + return CoreClaimResponse{}, err + } + resp.CoreClaimIndexHash = NewJsonBigInt(ih) + resp.CoreClaimValueHash = NewJsonBigInt(vh) + + resp.CoreClaimHex, err = resp.CoreClaim.Hex() + if err != nil { + return CoreClaimResponse{}, err + } + + return resp, nil +} diff --git a/inputs_sig_test.go b/inputs_sig_test.go index 5c067a1..100f307 100644 --- a/inputs_sig_test.go +++ b/inputs_sig_test.go @@ -163,6 +163,16 @@ func TestPrepareInputs(t *testing.T) { nil, cfg, "") }) + t.Run("GenericInputsFromJson — AnonAadhaarV1", func(t *testing.T) { + defer httpmock.MockHTTPClient(t, map[string]string{})() + cfg := EnvConfig{} + + doTest(t, "anon_aadhaar_v1_inputs.json", + "anon_aadhaar_v1_output.json", + GenericInputsFromJson, + nil, cfg, "") + }) + t.Run("AtomicQueryMtpV2Onchain - no roots in identity tree store", func(t *testing.T) { defer httpmock.MockHTTPClient(t, map[string]string{ `http://localhost:8545%%%{"jsonrpc":"2.0","method":"eth_call","params":[{"from":"0x0000000000000000000000000000000000000000","input":"0xb4bdea55000e5102b2f7a54e61db03f6c656f65062f4b11b9dd52a1702c2bfdc379d1202","to":"0x134b1be34911e39a8397ec6289782989729807a4"},"latest"]}`: "testdata/httpresp_eth_state_2qKc2ns18nV6uDSfaR1RVd7zF1Nm9vfeNZuvuEXQ3X.json", @@ -1447,3 +1457,231 @@ func TestNewGenesysIDFromEth(t *testing.T) { } require.Equal(t, wantResp, resp) } + +func TestW3cCredentialsFromAnonAadhaarInputsJson(t *testing.T) { + defer httpmock.MockHTTPClient(t, map[string]string{})() + + ctx := context.Background() + var cfg EnvConfig + w3cCred, err := W3cCredentialsFromAnonAadhaarInputsJson(ctx, cfg, + readFixtureFile("anon_aadhaar_v1_inputs.json")) + require.NoError(t, err) + + expectedCredential := `{ + "@context":[ + "https://www.w3.org/2018/credentials/v1", + "https://schema.iden3.io/core/jsonld/iden3proofs.jsonld", + "ipfs://QmYcmkJeSDcaTSDfVkMMh7Xay83dJeEc9HDy2Mh8J7gLJA" + ], + "type": [ + "VerifiableCredential", + "AnonAadhaar" + ], + "issuanceDate": "2019-03-08T05:30:00Z", + "expirationDate": "2019-09-06T19:54:00Z", + "credentialSubject": { + "birthday": 19840101, + "gender": 77, + "id": "did:iden3:privado:main:2Scn2RfosbkQDMQzQM5nCz3Nk5GnbzZCWzGCd3tc2G", + "pinCode": 110051, + "state": 452723500356, + "type": "AnonAadhaar" + }, + "credentialStatus":{ + "id":"did:iden3:privado:main:2Scn2RfosbkQDMQzQM5nCz3Nk5GnbzZCWzGCd3tc2G/credentialStatus?revocationNonce=1051565438\u0026contractAddress=80001:0x2fCE183c7Fbc4EbB5DB3B0F5a63e0e02AE9a85d2\u0026state=a1abdb9f44c7b649eb4d21b59ef34bd38e054aa3e500987575a14fc92c49f42c", + "type":"Iden3OnchainSparseMerkleTreeProof2023", + "revocationNonce":0 + }, + "issuer": "did:iden3:privado:main:2Si3eZUE6XetYsmU5dyUK2Cvaxr1EEe65vdv2BML4L", + "credentialSchema": { + "id": "ipfs://QmeTNnum9CThm6f7eBSxWuDQBTZC7EQrawr3AD6UJw38GM", + "type": "JsonSchema2023" + } +}` + w3cCred.ID = "" // It's random generated UUID + w3cCredJ, err := json.Marshal(w3cCred) + t.Log(string(w3cCredJ)) + require.NoError(t, err) + require.JSONEq(t, expectedCredential, string(w3cCredJ)) + +} + +func TestW3CCredentialToCoreClaim_no_options(t *testing.T) { + in := []byte(`{ +"w3cCredential": { + "id": "urn:iden3:onchain:80001:0xc84e8ac5385E0813f01aA9C698ED44C831961670:0", + "@context": [ + "https://www.w3.org/2018/credentials/v1", + "https://schema.iden3.io/core/jsonld/iden3proofs.jsonld", + "https://gist.githubusercontent.com/ilya-korotya/660496c859f8d31a7d2a92ca5e970967/raw/6b5fc14fe630c17bfa52e05e08fdc8394c5ea0ce/non-merklized-non-zero-balance.jsonld", + "https://schema.iden3.io/core/jsonld/displayMethod.jsonld" + ], + "type": [ + "VerifiableCredential", + "Balance" + ], + "expirationDate": "2024-03-23T11:05:26Z", + "issuanceDate": "2024-02-22T11:05:26Z", + "credentialSubject": { + "address": "657065114158124047812701241180089030040156354062", + "balance": "174130123440549329", + "id": "did:polygonid:polygon:mumbai:2qJFtKfABTJi2yUAcUhuvUnDojuNwUJjhuXQDhUg3e", + "type": "Balance" + }, + "credentialStatus": { + "id": "did:polygonid:polygon:mumbai:2qCU58EJgrEMJvPfhUCnFCwuKQTkX8VmJX2sJCH6C8/credentialStatus?revocationNonce=0\u0026contractAddress=80001:0xc84e8ac5385E0813f01aA9C698ED44C831961670", + "type": "Iden3OnchainSparseMerkleTreeProof2023", + "revocationNonce": 0 + }, + "issuer": "did:polygonid:polygon:mumbai:2qCU58EJgrEMJvPfhUCnFCwuKQTkX8VmJX2sJCH6C8", + "credentialSchema": { + "id": "https://gist.githubusercontent.com/ilya-korotya/e10cd79a8cc26ab6e40400a11838617e/raw/575edc33d485e2a4c806baad97e21117f3c90a9f/non-merklized-non-zero-balance.json", + "type": "JsonSchema2023" + }, + "proof": [ + { + "type": "Iden3SparseMerkleTreeProof", + "issuerData": { + "id": "did:polygonid:polygon:mumbai:2qCU58EJgrEMJvPfhUCnFCwuKQTkX8VmJX2sJCH6C8", + "state": { + "rootOfRoots": "19a633fecfa2117672bbcfb65307e3bd73101cd3dd49b849ea231b5927afc70e", + "claimsTreeRoot": "3ca701ead4d7da0eb5c4950ac0950a7ae92f4acc853a24698489f5a9b08fc72e", + "revocationTreeRoot": "0000000000000000000000000000000000000000000000000000000000000000", + "value": "6f5dd91f13004cca5c8b31524239de77ce149a9073d7ace737a1b7cffb96ab26" + } + }, + "coreClaim": "f52f1795c533d7b4aa4e7ab02485f86f0a00000000000000000000000000000002127f89ff6f78c9637e437575d1123c3862b93876abb197b010ea1dad600d000eb6cb518d3dd33341899bcec9dcc68998d11773000000000000000000000000d16d5eb86ca26a02000000000000000000000000000000000000000000000000000000000000000076b7fe650000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "mtp": { + "existence": true, + "siblings": [ + "4692761366944891051814480185546124875872606319832740381039122455881379612023" + ] + } + } + ], + "displayMethod": { + "id": "ipfs://QmS8eY8ZCiAAW8qgx3T6SQ3HDGeddwLZsjPXNAZExQwRY4", + "type": "Iden3BasicDisplayMethodV1" + } +} +}`) + + cfg := cfgWithCacheDir(t, EnvConfig{}) + resp, err := W3CCredentialToCoreClaim(context.Background(), cfg, in) + require.NoError(t, err) + + j, err := json.Marshal(resp) + require.NoError(t, err) + + want := `{ +"coreClaim":[ + "3551658366829735292135739573638798979061", + "23636246712529601958450231201481253153358313547226024401161643230341566978", + "657065114158124047812701241180089030040156354062", + "174130123440549329", + "31565919519920133594379452416","0","0","0" +], +"coreClaimHex":"f52f1795c533d7b4aa4e7ab02485f86f0a00000000000000000000000000000002127f89ff6f78c9637e437575d1123c3862b93876abb197b010ea1dad600d000eb6cb518d3dd33341899bcec9dcc68998d11773000000000000000000000000d16d5eb86ca26a02000000000000000000000000000000000000000000000000000000000000000076b7fe650000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", +"coreClaimHIndex":"9830186757367035399211680064143074011271741678904507974796272761508415159201", +"coreClaimHValue":"17258652693603475311237387771556096220921552146872585410863362205406628125367" +}` + require.JSONEq(t, want, string(j)) +} + +func TestW3CCredentialToCoreClaim_with_options(t *testing.T) { + in := []byte(`{ +"w3cCredential": { + "id": "urn:iden3:onchain:80001:0xc84e8ac5385E0813f01aA9C698ED44C831961670:0", + "@context": [ + "https://www.w3.org/2018/credentials/v1", + "https://schema.iden3.io/core/jsonld/iden3proofs.jsonld", + "https://gist.githubusercontent.com/ilya-korotya/660496c859f8d31a7d2a92ca5e970967/raw/6b5fc14fe630c17bfa52e05e08fdc8394c5ea0ce/non-merklized-non-zero-balance.jsonld", + "https://schema.iden3.io/core/jsonld/displayMethod.jsonld" + ], + "type": [ + "VerifiableCredential", + "Balance" + ], + "expirationDate": "2024-03-23T11:05:26Z", + "issuanceDate": "2024-02-22T11:05:26Z", + "credentialSubject": { + "address": "657065114158124047812701241180089030040156354062", + "balance": "174130123440549329", + "id": "did:polygonid:polygon:mumbai:2qJFtKfABTJi2yUAcUhuvUnDojuNwUJjhuXQDhUg3e", + "type": "Balance" + }, + "credentialStatus": { + "id": "did:polygonid:polygon:mumbai:2qCU58EJgrEMJvPfhUCnFCwuKQTkX8VmJX2sJCH6C8/credentialStatus?revocationNonce=0\u0026contractAddress=80001:0xc84e8ac5385E0813f01aA9C698ED44C831961670", + "type": "Iden3OnchainSparseMerkleTreeProof2023", + "revocationNonce": 0 + }, + "issuer": "did:polygonid:polygon:mumbai:2qCU58EJgrEMJvPfhUCnFCwuKQTkX8VmJX2sJCH6C8", + "credentialSchema": { + "id": "https://gist.githubusercontent.com/ilya-korotya/e10cd79a8cc26ab6e40400a11838617e/raw/575edc33d485e2a4c806baad97e21117f3c90a9f/non-merklized-non-zero-balance.json", + "type": "JsonSchema2023" + }, + "proof": [ + { + "type": "Iden3SparseMerkleTreeProof", + "issuerData": { + "id": "did:polygonid:polygon:mumbai:2qCU58EJgrEMJvPfhUCnFCwuKQTkX8VmJX2sJCH6C8", + "state": { + "rootOfRoots": "19a633fecfa2117672bbcfb65307e3bd73101cd3dd49b849ea231b5927afc70e", + "claimsTreeRoot": "3ca701ead4d7da0eb5c4950ac0950a7ae92f4acc853a24698489f5a9b08fc72e", + "revocationTreeRoot": "0000000000000000000000000000000000000000000000000000000000000000", + "value": "6f5dd91f13004cca5c8b31524239de77ce149a9073d7ace737a1b7cffb96ab26" + } + }, + "coreClaim": "f52f1795c533d7b4aa4e7ab02485f86f0a00000000000000000000000000000002127f89ff6f78c9637e437575d1123c3862b93876abb197b010ea1dad600d000eb6cb518d3dd33341899bcec9dcc68998d11773000000000000000000000000d16d5eb86ca26a02000000000000000000000000000000000000000000000000000000000000000076b7fe650000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "mtp": { + "existence": true, + "siblings": [ + "4692761366944891051814480185546124875872606319832740381039122455881379612023" + ] + } + } + ], + "displayMethod": { + "id": "ipfs://QmS8eY8ZCiAAW8qgx3T6SQ3HDGeddwLZsjPXNAZExQwRY4", + "type": "Iden3BasicDisplayMethodV1" + } +}, +"coreClaimOptions": { + "revNonce": 100500, + "version": 10 +} +}`) + + cfg := cfgWithCacheDir(t, EnvConfig{}) + resp, err := W3CCredentialToCoreClaim(context.Background(), cfg, in) + require.NoError(t, err) + + j, err := json.Marshal(resp) + require.NoError(t, err) + + want := `{ +"coreClaim":[ + "14615016376860687548866583619298569770198124408821", + "23636246712529601958450231201481253153358313547226024401161643230341566978", + "657065114158124047812701241180089030040156354062", + "174130123440549329", + "31565919519920133594379552916","0","0","0" +], +"coreClaimHex":"f52f1795c533d7b4aa4e7ab02485f86f0a0000000a000000000000000000000002127f89ff6f78c9637e437575d1123c3862b93876abb197b010ea1dad600d000eb6cb518d3dd33341899bcec9dcc68998d11773000000000000000000000000d16d5eb86ca26a02000000000000000000000000000000000000000000000000948801000000000076b7fe650000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", +"coreClaimHIndex":"8248879511591962298487070528062416881268611626776654397983770791558299508439", +"coreClaimHValue":"6727479208098822222837416757591595696764728825200049195652465812007399726477" +}` + require.JSONEq(t, want, string(j)) +} + +func cfgWithCacheDir(t testing.TB, cfg EnvConfig) EnvConfig { + cacheDir, err := os.MkdirTemp("", "") + require.NoError(t, err) + t.Cleanup(func() { + err = os.RemoveAll(cacheDir) + require.NoError(t, err) + }) + + cfg.CacheDir = cacheDir + return cfg +} diff --git a/mt_storage_test.go b/mt_storage_test.go index a3f118b..c684978 100644 --- a/mt_storage_test.go +++ b/mt_storage_test.go @@ -3,6 +3,7 @@ package c_polygonid import ( "context" "encoding/json" + "os" "testing" httpmock "github.com/0xPolygonID/c-polygonid/testing" @@ -27,6 +28,15 @@ var w3cCredDoc = `{"id":"https://dd25-62-87-103-47.ngrok-free.app/api/v1/identit func TestInMemoryStorage_MarshalBinary(t *testing.T) { mockBadgerLog(t) + cacheDir, err := os.MkdirTemp("", "") + require.NoError(t, err) + t.Cleanup(func() { + err = os.RemoveAll(cacheDir) + require.NoError(t, err) + }) + + cfg := EnvConfig{CacheDir: cacheDir} + defer httpmock.MockHTTPClient(t, map[string]string{ "https://schema.iden3.io/core/jsonld/iden3proofs.jsonld": "testdata/httpresp_iden3proofs.jsonld", "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v3.json-ld": "testdata/httpresp_kyc-v3.json-ld", @@ -36,7 +46,6 @@ func TestInMemoryStorage_MarshalBinary(t *testing.T) { mtStorage := newInMemoryStorage() ctx := context.Background() var mt *merkletree.MerkleTree - var err error mt, err = merkletree.NewMerkleTree(ctx, mtStorage, mtLevels) if err != nil { return @@ -44,7 +53,7 @@ func TestInMemoryStorage_MarshalBinary(t *testing.T) { _, err = w3cCred.Merklize(ctx, merklize.WithMerkleTree(merklize.MerkleTreeSQLAdapter(mt)), - merklize.WithDocumentLoader(EnvConfig{}.documentLoader())) + merklize.WithDocumentLoader(cfg.documentLoader())) require.NoError(t, err) storageBytes, err := mtStorage.MarshalBinary() diff --git a/number.go b/number.go index 37da7b5..e7dbfb0 100644 --- a/number.go +++ b/number.go @@ -8,6 +8,10 @@ import ( type JsonBigInt big.Int +func NewJsonBigInt(i *big.Int) *JsonBigInt { + return (*JsonBigInt)(i) +} + func (j *JsonBigInt) UnmarshalJSON(bytes []byte) error { var s string if err := json.Unmarshal(bytes, &s); err != nil { diff --git a/testdata/anon_aadhaar_v1_inputs.json b/testdata/anon_aadhaar_v1_inputs.json new file mode 100644 index 0000000..58dfa58 --- /dev/null +++ b/testdata/anon_aadhaar_v1_inputs.json @@ -0,0 +1,13 @@ +{ + "qrData": "8259163575998395410294216884136380576185817320339145460288951755287582961380611852552428987321584902318624273479337130653734982789439199350807739714406680256506601030028361685736660257517232716829232450159251789263870750283214820475102793105777087762238893090228084052270739203426767272062178826235941508196284529472654271516164224874687419158221021213944829682919423174703783469927383220474654008065915029614141226522064062660593170425792840873655513538373377850112144063189928583588899889878172757870400281696669604010659786496608127700010264443115263361656744433002559396889060190428705316366290450741550935385486607346514118464415324976934593027192262025619948063647667007927187736245772179085671658409804311603784752615097922989017361163561315974008304022542448394278143245816470881130080719485003834016131185071765229491892891069788319670287394271744730364788949609836924781874523936880888005883165757273872375006288978183466996520618718348187182821516617721340861010989807614756396013627238651856164981477576514065364628430139194213240602981419233621531616776712580234318576148789862972873366521755587675635811636464535551028275057950562020714225333126426609311459495088802145911084644641596208432517247324679678535859879970296810837735288916946197174410518342751033634782712968162882714769666441813893046220965525694847349131353986974388432968669605721975441870936552792275255624723251162192468002453471184713983574359601113515796454264270501379717344206777921353459767049560942843350534472442799601294637063232419543855742825887931841338302499933012059977947394755335155868283405337181095220998277373266658634859632929226320059674299759100792654417315629048732480315019941928105082550091217622422743467170706956093632228513797781797454779203616427853022505097310749994766657051986303478622173767936568165644251615127773430128638507677775244195799780291921828512257290767451475181728141544788756907393883042588060697683541401090581157249784874529424005078918452607589129440476242749110421616270676359722523229311894327359615548588038186027827017569331332262329182564217789843145105509621002324556840213928256545454178891208004109769624959566302976213521762873815749009289995208912424872527724417047936432945498377307452190302923489092664437908497749093491199476080757200233878726847198496754472664256996743796092233459542884818717466621372105594672115988382565552756801323160697003960485232732393383241422077506009076922303757067128564302338914230360252223406874457414109774901980252709597099278192874164252010830754720603092419792069707099362278082792090307065378744856387301364608460967253691290230861162587170799141457093188189022390589265654613500974699477990974878105678883229707694455342266695530373994049224098435972125150350136428446936271698977517627416435999970351222450833295217051468307037908262231982382247410542334757724852032521780157518474618653527191342825230455100778913195115477763082159513429761573752871477695723697689470263993132596482716347199834315782099668846081963760553679915994617396376870314998926788197388410764535427795200340714967872713095483294486407886767431404892448155562283436571050452251042117926586451385682519188252281397", + "credentialSubjectID": "did:iden3:privado:main:2Scn2RfosbkQDMQzQM5nCz3Nk5GnbzZCWzGCd3tc2G", + "credentialStatusRevocationNonce": 0, + "credentialStatusID": "did:iden3:privado:main:2Scn2RfosbkQDMQzQM5nCz3Nk5GnbzZCWzGCd3tc2G/credentialStatus?revocationNonce=1051565438&contractAddress=80001:0x2fCE183c7Fbc4EbB5DB3B0F5a63e0e02AE9a85d2&state=a1abdb9f44c7b649eb4d21b59ef34bd38e054aa3e500987575a14fc92c49f42c", + "issuerID": "did:iden3:privado:main:2Si3eZUE6XetYsmU5dyUK2Cvaxr1EEe65vdv2BML4L", + "pubKey": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAlegfdQZZXMJirdz93TXY\nBAVbKt9G3HGcVrWO7hmZle+hoyVHEGIKx4Ael29E475FTbDxkOP31ONZiXIRc0Te\nUvz3gm+ElIipWaez0h623QNFFmLqiD7u796ImhSZuaR/lQTF8JbCYrltI9GXUDMt\nnpfrYUHSYd6XmU1MQWPKnL4+B3IhtEJT3PgWCUKLaDUe4+m2DSs1H9qm7owoqEUj\nn5fefMD+XRROR0gT+0PsWD+BtO4yjCIWczSJjSELoBeibsaJQPBd8ivZzIa7w6Q1\nQ5I3LVZhZ3abc1uhLKNYD5GcG9i6cMTCqwrPKwm8L66YHzwClabh6fJI9QBzCU/6\n8QIDAQAB\n-----END PUBLIC KEY-----", + "nullifierSeed": 12345678, + "signalHash": 1001, + "request": { + "circuitId": "anonAadhaarV1" + } +} diff --git a/testdata/anon_aadhaar_v1_output.json b/testdata/anon_aadhaar_v1_output.json new file mode 100644 index 0000000..302c856 --- /dev/null +++ b/testdata/anon_aadhaar_v1_output.json @@ -0,0 +1,1730 @@ +{ + "qrDataPadded": [ + "86", + "50", + "255", + "51", + "255", + "50", + "54", + "57", + "55", + "50", + "48", + "49", + "57", + "48", + "51", + "48", + "56", + "49", + "49", + "52", + "52", + "48", + "55", + "52", + "51", + "55", + "255", + "83", + "117", + "109", + "105", + "116", + "32", + "75", + "117", + "109", + "97", + "114", + "255", + "48", + "49", + "45", + "48", + "49", + "45", + "49", + "57", + "56", + "52", + "255", + "77", + "255", + "67", + "47", + "79", + "32", + "73", + "115", + "104", + "119", + "97", + "114", + "32", + "67", + "104", + "97", + "110", + "100", + "255", + "69", + "97", + "115", + "116", + "32", + "68", + "101", + "108", + "104", + "105", + "255", + "255", + "66", + "45", + "51", + "49", + "44", + "32", + "51", + "114", + "100", + "32", + "70", + "108", + "111", + "111", + "114", + "255", + "255", + "49", + "49", + "48", + "48", + "53", + "49", + "255", + "75", + "114", + "105", + "115", + "104", + "110", + "97", + "32", + "78", + "97", + "103", + "97", + "114", + "255", + "68", + "101", + "108", + "104", + "105", + "255", + "82", + "97", + "100", + "104", + "101", + "121", + "32", + "83", + "104", + "121", + "97", + "109", + "32", + "80", + "97", + "114", + "107", + "32", + "69", + "120", + "116", + "101", + "110", + "115", + "105", + "111", + "110", + "255", + "71", + "97", + "110", + "100", + "104", + "105", + "32", + "78", + "97", + "103", + "97", + "114", + "255", + "75", + "114", + "105", + "115", + "104", + "110", + "97", + "32", + "78", + "97", + "103", + "97", + "114", + "255", + "49", + "50", + "51", + "52", + "255", + "255", + "79", + "255", + "81", + "0", + "47", + "0", + "0", + "0", + "0", + "0", + "60", + "0", + "0", + "0", + "60", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "60", + "0", + "0", + "0", + "60", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "3", + "7", + "1", + "1", + "7", + "1", + "1", + "7", + "1", + "1", + "255", + "82", + "0", + "12", + "2", + "0", + "0", + "1", + "1", + "5", + "4", + "4", + "0", + "0", + "255", + "92", + "0", + "35", + "66", + "111", + "24", + "110", + "234", + "110", + "234", + "110", + "188", + "103", + "0", + "103", + "0", + "102", + "226", + "95", + "76", + "95", + "76", + "95", + "100", + "72", + "3", + "72", + "3", + "72", + "69", + "79", + "210", + "79", + "210", + "79", + "97", + "255", + "100", + "0", + "34", + "0", + "1", + "67", + "114", + "101", + "97", + "116", + "101", + "100", + "32", + "98", + "121", + "58", + "32", + "74", + "74", + "50", + "48", + "48", + "48", + "32", + "118", + "101", + "114", + "115", + "105", + "111", + "110", + "32", + "52", + "46", + "49", + "255", + "144", + "0", + "10", + "0", + "0", + "0", + "0", + "2", + "236", + "0", + "1", + "255", + "82", + "0", + "12", + "2", + "0", + "0", + "1", + "1", + "5", + "4", + "4", + "0", + "0", + "255", + "147", + "255", + "145", + "0", + "4", + "0", + "0", + "195", + "235", + "5", + "4", + "11", + "128", + "38", + "166", + "255", + "145", + "0", + "4", + "0", + "1", + "192", + "249", + "65", + "128", + "16", + "124", + "55", + "255", + "145", + "0", + "4", + "0", + "2", + "192", + "249", + "65", + "0", + "14", + "175", + "255", + "145", + "0", + "4", + "0", + "3", + "195", + "238", + "4", + "131", + "237", + "4", + "131", + "232", + "8", + "15", + "61", + "227", + "128", + "14", + "78", + "244", + "198", + "10", + "190", + "128", + "74", + "255", + "145", + "0", + "4", + "0", + "4", + "192", + "30", + "10", + "3", + "229", + "7", + "0", + "240", + "64", + "15", + "157", + "12", + "56", + "206", + "16", + "124", + "255", + "145", + "0", + "4", + "0", + "5", + "192", + "120", + "40", + "7", + "196", + "14", + "1", + "224", + "128", + "16", + "128", + "16", + "144", + "102", + "15", + "55", + "255", + "145", + "0", + "4", + "0", + "6", + "195", + "235", + "15", + "131", + "232", + "29", + "7", + "202", + "36", + "35", + "123", + "119", + "32", + "21", + "133", + "220", + "173", + "123", + "29", + "124", + "190", + "51", + "158", + "143", + "0", + "4", + "234", + "216", + "145", + "15", + "189", + "91", + "82", + "210", + "45", + "90", + "170", + "52", + "34", + "209", + "158", + "13", + "108", + "213", + "78", + "158", + "137", + "255", + "145", + "0", + "4", + "0", + "7", + "192", + "56", + "56", + "15", + "132", + "112", + "35", + "164", + "155", + "1", + "61", + "240", + "240", + "232", + "42", + "148", + "255", + "145", + "0", + "4", + "0", + "8", + "192", + "49", + "32", + "29", + "20", + "7", + "59", + "113", + "163", + "24", + "138", + "108", + "156", + "26", + "255", + "145", + "0", + "4", + "0", + "9", + "193", + "241", + "27", + "135", + "206", + "122", + "15", + "144", + "184", + "25", + "25", + "211", + "9", + "237", + "209", + "173", + "196", + "150", + "111", + "25", + "246", + "238", + "110", + "167", + "245", + "97", + "24", + "144", + "213", + "187", + "170", + "6", + "133", + "23", + "21", + "199", + "31", + "204", + "1", + "35", + "171", + "39", + "5", + "127", + "48", + "209", + "141", + "130", + "143", + "72", + "200", + "150", + "233", + "85", + "241", + "55", + "128", + "173", + "216", + "49", + "52", + "216", + "139", + "110", + "91", + "225", + "30", + "109", + "204", + "188", + "146", + "157", + "214", + "18", + "87", + "32", + "89", + "157", + "101", + "246", + "187", + "223", + "117", + "50", + "62", + "81", + "65", + "205", + "126", + "255", + "145", + "0", + "4", + "0", + "10", + "160", + "28", + "48", + "34", + "126", + "189", + "171", + "105", + "217", + "255", + "145", + "0", + "4", + "0", + "11", + "160", + "58", + "48", + "35", + "137", + "175", + "61", + "198", + "184", + "255", + "145", + "0", + "4", + "0", + "12", + "199", + "200", + "222", + "62", + "71", + "240", + "248", + "106", + "128", + "111", + "222", + "255", + "137", + "22", + "12", + "202", + "78", + "23", + "233", + "116", + "114", + "125", + "113", + "100", + "226", + "16", + "241", + "69", + "36", + "122", + "23", + "17", + "120", + "240", + "5", + "127", + "168", + "109", + "250", + "155", + "59", + "7", + "206", + "127", + "108", + "18", + "105", + "216", + "235", + "32", + "159", + "93", + "175", + "208", + "238", + "70", + "166", + "172", + "160", + "62", + "58", + "51", + "254", + "8", + "55", + "97", + "246", + "138", + "129", + "137", + "16", + "33", + "165", + "205", + "22", + "186", + "92", + "163", + "108", + "70", + "25", + "168", + "130", + "96", + "162", + "13", + "106", + "78", + "71", + "254", + "89", + "108", + "233", + "225", + "39", + "97", + "63", + "17", + "13", + "42", + "95", + "0", + "30", + "0", + "130", + "28", + "154", + "5", + "162", + "1", + "51", + "178", + "125", + "65", + "235", + "47", + "162", + "24", + "112", + "152", + "119", + "13", + "83", + "212", + "102", + "84", + "248", + "36", + "193", + "63", + "193", + "101", + "254", + "213", + "80", + "59", + "106", + "79", + "74", + "170", + "227", + "110", + "2", + "204", + "201", + "182", + "60", + "114", + "60", + "65", + "195", + "148", + "232", + "145", + "30", + "46", + "232", + "19", + "28", + "159", + "29", + "153", + "101", + "206", + "162", + "28", + "108", + "80", + "229", + "255", + "145", + "0", + "4", + "0", + "13", + "128", + "255", + "145", + "0", + "4", + "0", + "14", + "128", + "255", + "145", + "0", + "4", + "0", + "15", + "195", + "224", + "188", + "135", + "193", + "127", + "15", + "134", + "196", + "158", + "62", + "204", + "245", + "173", + "53", + "224", + "68", + "102", + "215", + "173", + "58", + "244", + "81", + "11", + "131", + "110", + "245", + "166", + "156", + "166", + "215", + "76", + "158", + "156", + "10", + "170", + "148", + "182", + "60", + "115", + "173", + "176", + "16", + "1", + "15", + "169", + "187", + "111", + "38", + "226", + "185", + "241", + "97", + "88", + "34", + "140", + "218", + "123", + "203", + "88", + "112", + "88", + "143", + "74", + "108", + "17", + "106", + "37", + "69", + "149", + "69", + "151", + "215", + "37", + "209", + "201", + "125", + "81", + "117", + "124", + "102", + "108", + "252", + "251", + "26", + "14", + "104", + "229", + "35", + "22", + "219", + "199", + "180", + "110", + "24", + "47", + "126", + "104", + "141", + "232", + "237", + "115", + "47", + "31", + "176", + "190", + "111", + "243", + "116", + "185", + "32", + "185", + "121", + "57", + "59", + "197", + "65", + "61", + "233", + "98", + "18", + "172", + "235", + "82", + "146", + "150", + "241", + "30", + "186", + "172", + "161", + "155", + "148", + "171", + "212", + "237", + "170", + "123", + "85", + "177", + "76", + "132", + "230", + "38", + "114", + "51", + "254", + "36", + "37", + "236", + "202", + "21", + "44", + "48", + "203", + "191", + "154", + "22", + "219", + "13", + "67", + "28", + "214", + "71", + "72", + "63", + "173", + "24", + "137", + "62", + "141", + "14", + "123", + "11", + "237", + "106", + "219", + "68", + "40", + "62", + "29", + "255", + "145", + "0", + "4", + "0", + "16", + "128", + "255", + "145", + "0", + "4", + "0", + "17", + "128", + "255", + "217", + "235", + "89", + "152", + "53", + "59", + "33", + "186", + "193", + "56", + "29", + "117", + "14", + "31", + "162", + "102", + "65", + "224", + "150", + "175", + "57", + "29", + "17", + "95", + "173", + "173", + "212", + "123", + "244", + "250", + "47", + "255", + "139", + "96", + "54", + "34", + "219", + "243", + "92", + "100", + "240", + "182", + "255", + "21", + "167", + "91", + "244", + "127", + "53", + "165", + "180", + "223", + "131", + "221", + "184", + "74", + "53", + "233", + "255", + "238", + "30", + "166", + "5", + "157", + "243", + "128", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "35", + "136", + "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", + "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", + "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", + "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", + "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", + "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", + "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", + "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", + "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", + "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", + "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", + "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", + "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", + "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", + "0", + "0", + "0", + "0", + "0", + "0" + ], + "qrDataPaddedLength": 1152, + "delimiterIndices": [ + 2, + 4, + 26, + 38, + 49, + 51, + 68, + 79, + 80, + 96, + 97, + 104, + 118, + 124, + 152, + 165, + 179, + 184 + ], + "signature": [ + "1701711880382226091007184066928914214", + "1676903129633812196986173915477597817", + "62075100894051246077071781094600429", + "187888940546771833730264140865498650", + "871606319925476360708324182672255138", + "406570283213407193926124227025860714", + "953195061789016094460313591105716498", + "1781789391247975637753539292851959342", + "6791165622133960028226326716742725", + "362492816226568389526418053843560098", + "1263450786365096782530343661652888668", + "2176823699668840441758370318389559567", + "2287112556558594309467106923469747706", + "658595679229623041112474445225408357", + "2110095324044920808155540402741632496", + "824993806648494484728658542180368863", + "1304836129534220655556344967179972" + ], + "pubKey": [ + "1640818228760052179859042244355947249", + "2556500785716576226415796061849734159", + "1773663274924506786300654122545997574", + "156007087115998107687088234502964965", + "1007983086444915868913459627234715796", + "1207907671574654908578158113785868692", + "661583974440108157749604450701607929", + "2294674184689511060148392370957342314", + "2125217202257742866740569471305663059", + "757604698857004563734075326539558731", + "200007885942223577865900248803094107", + "634836160982611096393054589936335825", + "1449711680328986902465274550271974011", + "203106953707476066515237197004426128", + "531393944197892908304277361531706813", + "2243235350875430237629201981240106035", + "3040469700157016219231660416032053" + ], + "nullifierSeed": 12345678, + "signalHash": 1001, + "revocationNonce": 0, + "credentialStatusID": "8639584887809663629106058915819143598372772994078727421962823642907007232233", + "credentialSubjectID": "18026946060490633582346941999242407265442400633018823452652749104672360129751", + "userID": "23747161200420134456844951198264139815921171975208487354806063665905574145", + "expirationTime": 15776640, + "issuer": "12146166192964646439780403715116050536535442384123009131510511003232108502337", + "templateRoot": "3760048933127269188109079349507397743444241277603345236696660118069105661581", + "siblings": [ + [ + "14870893589695058750062205245838665216304472525103560742606658908926245558704", + "7806218756418541346111934237132202219848683530029930652875544751894740478594", + "858918932185500987316407957982720868352723282364872812149253561654804984696", + "5201003769520092338325035000786341729880925977298634829424162375960668482196", + "0", + "0", + "0", + "0", + "0", + "0" + ], + [ + "14870893589695058750062205245838665216304472525103560742606658908926245558704", + "11774906351572976747438228731680105880096317637400751217173403160171630852495", + "9689690899956259796387240095510665788534635637885945686892345696736116906472", + "9578343039326714129781195514670624048229922350283480171048711971240077026001", + "0", + "0", + "4661085059433091925259811531153667377488268457571421502723323859953471446952", + "0", + "0", + "0" + ], + [ + "3939542688632210277432331509657242522905710788021599268494273708636353640436", + "5064729305733882453469875866445656607392853713921820016572216612523568252780", + "1416473921666832294831137513683934390969569806681457930449742341246996084745", + "0", + "0", + "0", + "3570874758596602175492518694866931512230120625556892774886449145861521290958", + "0", + "0", + "0" + ], + [ + "16270745779964363587072227117862064293280544213920962626785096396390307856975", + "11774906351572976747438228731680105880096317637400751217173403160171630852495", + "9689690899956259796387240095510665788534635637885945686892345696736116906472", + "20280074032826297060542775213326548534609345744817711448606372165415092336000", + "0", + "0", + "19353120442513595477552481976490911669137236331187802477548731700343191978479", + "0", + "0", + "0" + ], + [ + "2239154868882199103463087371020717789693284101904968959837345891145299260481", + "5064729305733882453469875866445656607392853713921820016572216612523568252780", + "6765717080500107858750594710782044080512217624802814657476103262984610177705", + "0", + "0", + "0", + "0", + "0", + "0", + "0" + ], + [ + "2239154868882199103463087371020717789693284101904968959837345891145299260481", + "5064729305733882453469875866445656607392853713921820016572216612523568252780", + "1416473921666832294831137513683934390969569806681457930449742341246996084745", + "0", + "0", + "0", + "7989343966498172677822007883875959440613832021276721565977456434643065954235", + "0", + "0", + "0" + ], + [ + "17595844982041770142583781812897203904989137538882657225091712088727893352493", + "11774906351572976747438228731680105880096317637400751217173403160171630852495", + "13002906918679717826402631313149040005179842938183670211872260914079728583916", + "0", + "13367109920870074301680021122864142814122449242507735579304099303150708019709", + "0", + "0", + "0", + "0", + "0" + ], + [ + "17595844982041770142583781812897203904989137538882657225091712088727893352493", + "17396036972136607172589862917911221527157155674219901180904599553854134139184", + "15793493909886249305992541610968197423138142225583173707314573613748609497932", + "0", + "0", + "0", + "0", + "0", + "0", + "0" + ], + [ + "17595844982041770142583781812897203904989137538882657225091712088727893352493", + "17396036972136607172589862917911221527157155674219901180904599553854134139184", + "2874173945974096908903635155271393549850333215172358782460623417474147565198", + "12338826892957879650568217091674066004114637413197423353701908864762592802264", + "0", + "0", + "0", + "0", + "0", + "0" + ], + [ + "17595844982041770142583781812897203904989137538882657225091712088727893352493", + "3106413201820995144899868014219997147914232490946002297438912107973297694724", + "12701776915999031715475423867599574965840396604543789339508648589209120235102", + "20280074032826297060542775213326548534609345744817711448606372165415092336000", + "0", + "0", + "1234478517262906285671033844311017463228471801885930105765036871005173556575", + "0", + "0", + "0" + ] + ] +} diff --git a/types.go b/types.go index 7a7bacc..b57b72e 100644 --- a/types.go +++ b/types.go @@ -123,6 +123,10 @@ func (j *jsonNumber) UnmarshalJSON(in []byte) error { return nil } +func (j *jsonNumber) toBitInt() *big.Int { + return (*big.Int)(j) +} + // function to fail a compilation if underlined type is not int32 func assertUnderlineTypeInt32[T ~int32](_ T) {}