diff --git a/.github/workflows/ci-test.yaml b/.github/workflows/ci-test.yaml index 454323a..5d45e5e 100644 --- a/.github/workflows/ci-test.yaml +++ b/.github/workflows/ci-test.yaml @@ -11,7 +11,7 @@ jobs: test: strategy: matrix: - containers: [ 1.17.2-bullseye ] + containers: [ 1.18 ] runs-on: ubuntu-latest container: golang:${{ matrix.containers }} steps: diff --git a/communication/auth/service_test.go b/communication/auth/service_test.go index ea37a7d..a7f1320 100644 --- a/communication/auth/service_test.go +++ b/communication/auth/service_test.go @@ -10,74 +10,15 @@ import ( "github.com/stretchr/testify/assert" ) -func TestVerify(t *testing.T) { - - var message types.AuthorizationMessageResponse - message.Type = AuthorizationResponseMessageType - message.Data = types.AuthorizationMessageResponseData{} - - zkpProof := types.ZeroKnowledgeProof{ - Type: types.ZeroKnowledgeProofType, - CircuitID: circuits.KycBySignaturesCircuitID, - } - - zkpProof.ProofData = &types.ProofData{ - A: []string{"10441536817202584897377823144827964642356918402871315490038163167310235469676", - "3188873104904010906845899057040012497857652125001996465924027367142766788060", - "1"}, - B: [][]string{{"10259767950868305572343651918722890484304440255374794205464892311274784569874", - "18113532891970083775734522192028652126404157383671158241782353379080674688210", - }, { - "20011188305329655231409527762393912898857036946232895893305954758470171745705", - "19212224402431449690017436050830610655559646158634403540885275057516508525272", - }, { - "1", - "0", - }}, - C: []string{"17410066358263445906462947561105622363737416663317734129930901016400750644236", - "10889346016675221860511647187111664354773325795907973404602900127856769668544", - "1", - }, - } - zkpProof.PubSignals = []string{"12345", "372902514040400364441393275265861152892555341750332828757240276565437644800", "19443506635601976434000063402326775248489014592264899338419890539515181882284", "840", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "372902514040400364441393275265861152892555341750332828757240276565437644800", "19443506635601976434000063402326775248489014592264899338419890539515181882284", "2021", "4", "25"} - message.Data.Scope = []interface{}{zkpProof} - - err := VerifyProofs(&message) - assert.Nil(t, err) -} - -func TestVerifyWrongMessage(t *testing.T) { - - var message types.AuthorizationMessageRequest - message.Type = AuthorizationRequestMessageType - message.Data = types.AuthorizationMessageRequestData{} - - zkpProofRequest := types.ZeroKnowledgeProofRequest{ - Type: types.ZeroKnowledgeProofType, - CircuitID: circuits.KycBySignaturesCircuitID, - Rules: map[string]interface{}{}, - } - message.Data.Scope = []types.TypedScope{zkpProofRequest} - - err := VerifyProofs(&message) - - assert.NotNil(t, err) -} - func TestCreateAuthorizationRequest(t *testing.T) { aud := "1125GJqgw6YEsKFwj63GY87MMxPL9kwDKxPUiwMLNZ" zkpProofRequest := types.ZeroKnowledgeProofRequest{ Type: types.ZeroKnowledgeProofType, - CircuitID: circuits.KycBySignaturesCircuitID, + CircuitID: circuits.AtomicQueryMTPCircuitID, Rules: map[string]interface{}{ - "challenge": 12345678, - "countryBlacklist": []int{840}, - "currentYear": 2021, - "currentMonth": 9, - "currentDay": 28, - "minAge": 18, - "audience": aud, + "challenge": 12345678, + "audience": aud, "allowedIssuers": []string{ "115zTGHKvFeFLPu3vF9Wx2gBqnxGnzvTpmkHPM2LCe", "115zTGHKvFeFLPu3vF9Wx2gBqnxGnzvTpmkHPM2LCe", @@ -91,78 +32,6 @@ func TestCreateAuthorizationRequest(t *testing.T) { assert.Equal(t, 2, len(request.Data.Scope)) } - -func TestExtractData(t *testing.T) { - - var message types.AuthorizationMessageResponse - message.Type = AuthorizationResponseMessageType - message.Data = types.AuthorizationMessageResponseData{} - - zkpProof := types.ZeroKnowledgeProof{ - Type: types.ZeroKnowledgeProofType, - CircuitID: circuits.KycBySignaturesCircuitID, - CircuitData: &types.CircuitData{ - ID: circuits.KycBySignaturesCircuitID, - Description: "test", - VerificationKey: circuits.KycBySignaturesVerificationKey, - Metadata: circuits.KycBySignaturesPublicSignalsSchema, - }, - } - zkpProof.PubSignals = []string{ - "26592849444054787445766572449338308165040390141345377877344569181291872256", - "12345", - "164414642845063686862221124543185217840281790633605788367384240953047711744", - "20826763141600863538041346956386832863527621891653741934199228821528372364336", - "840", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "164414642845063686862221124543185217840281790633605788367384240953047711744", - "20826763141600863538041346956386832863527621891653741934199228821528372364336", - "2021", - "4", - "25", - "18", - } - zkpProof.ProofData = &types.ProofData{ - A: []string{"15410252994758206156331933443865902387659457159831652500594192431349076893658", - "20150829872771081060142254046116588090324284033366663360366174697329414878949", - "1"}, - B: [][]string{{"9417153075860115376893693247142868897300054298656960914587138216866082643706", - "10202816620941554744739718000741718724240818496129635422271960203010394413915", - }, {"15503138617167966595249072003849677537923997283726290430496888985000900792650", - "6173958614668002844023250887062625456639056306855696879145959593623787348506", - }, { - "1", - "0", - }}, - C: []string{ - "14084349531001200150970271267870661180690655641091539571582685666559667846160", - "6506935406401708938070550600218341978561747347886649538986407400386963731317", - "1", - }, - } - - message.Data.Scope = []interface{}{zkpProof} - token, err := ExtractMetadata(&message) - assert.Nil(t, err) - - assert.Equal(t, "26592849444054787445766572449338308165040390141345377877344569181291872256", token.Challenge) - -} - func TestVerifyMessageWithAuthProof(t *testing.T) { var message types.AuthorizationMessageResponse @@ -176,33 +45,33 @@ func TestVerifyMessageWithAuthProof(t *testing.T) { zkpProof.ProofData = &types.ProofData{ A: []string{ - "2370534291294441687575434871070063634049522739054135650290327914016792634144", - "18704664440065881255248484392571034267692380947539795837185393466696768539729", + "6807142976568489254129987481389970790048870221943660648833750801722749769662", + "13811182779758948993435669124001052501939669904238445458453308627013829993881", "1", }, B: [][]string{ { - "1593753415597360514506439944675236073038159742598884104707775208490282580641", - "15142074894866083200293799148931702287457526593114838706672766340147139402722", + "1100658387420856656999617260396587549490320987275888589013664343574809180330", + "6271619554100652532302412650545865559102683218896584596952129504406572338279", }, { - "19117825221840408597122339519717065920080389822558089367138595722092823743944", - "2706264472260224656022451103720565978368804964791420659255319627595448027435", + "14732910796480272245291363689840710264816417845998668210234805961967222411399", + "697511497805383174761860295477525070010524578030535203059896030784240207952", }, { "1", "0", }}, C: []string{ - "156766304977057264803138092945401446963129379605822159500567538377014916135", - "10031227231200820171929683445407743402234929438478965985477678284516420821593", + "3322888400314063147927477851922827359406772099015587732727269650428166130415", + "11791447421105500417246293414158106577578665220990150855390594651727173683574", "1", }, } zkpProof.PubSignals = []string{ "1", - "5816868615164565912277677884704888703982258184820398645933682814085602171910", - "286312392162647260160287083374160163061246635086990474403590223113720496128", + "18656147546666944484453899241916469544090258810192803949522794490493271005313", + "379949150130214723420589610911161895495647789006649785264738141299135414272", } message.Data.Scope = []interface{}{zkpProof} @@ -211,15 +80,13 @@ func TestVerifyMessageWithAuthProof(t *testing.T) { token, err := ExtractMetadata(&message) assert.Nil(t, err) - assert.Equal(t, "5816868615164565912277677884704888703982258184820398645933682814085602171910", token.State) - assert.Equal(t, "113Rq7d5grTGzqF7phKCRjxpC597eMa2USzm9rmpoj", token.ID) + assert.Equal(t, "18656147546666944484453899241916469544090258810192803949522794490493271005313", token.State) + assert.Equal(t, "119tqceWdRd2F6WnAyVuFQRFjK3WUXq2LorSPyG9LJ", token.ID) - state, err := token.VerifyState(context.Background(), os.Getenv("RPC_URL"), "0x035C4DBC897D203483D942696CE1dF5a9f933FcC") + state, err := token.VerifyState(context.Background(), os.Getenv("RPC_URL"), "0xa36786C3E18225da7cc8FC69c6443ecD41827FF5") assert.Nil(t, err) assert.Equal(t, true, state.Latest) - } - func TestVerifyMessageWithAuthAndAtomicProofMTP(t *testing.T) { var message types.AuthorizationMessageResponse @@ -233,33 +100,33 @@ func TestVerifyMessageWithAuthAndAtomicProofMTP(t *testing.T) { zkpAuth.ProofData = &types.ProofData{ A: []string{ - "2370534291294441687575434871070063634049522739054135650290327914016792634144", - "18704664440065881255248484392571034267692380947539795837185393466696768539729", + "6807142976568489254129987481389970790048870221943660648833750801722749769662", + "13811182779758948993435669124001052501939669904238445458453308627013829993881", "1", }, B: [][]string{ { - "1593753415597360514506439944675236073038159742598884104707775208490282580641", - "15142074894866083200293799148931702287457526593114838706672766340147139402722", + "1100658387420856656999617260396587549490320987275888589013664343574809180330", + "6271619554100652532302412650545865559102683218896584596952129504406572338279", }, { - "19117825221840408597122339519717065920080389822558089367138595722092823743944", - "2706264472260224656022451103720565978368804964791420659255319627595448027435", + "14732910796480272245291363689840710264816417845998668210234805961967222411399", + "697511497805383174761860295477525070010524578030535203059896030784240207952", }, { "1", "0", }}, C: []string{ - "156766304977057264803138092945401446963129379605822159500567538377014916135", - "10031227231200820171929683445407743402234929438478965985477678284516420821593", + "3322888400314063147927477851922827359406772099015587732727269650428166130415", + "11791447421105500417246293414158106577578665220990150855390594651727173683574", "1", }, } zkpAuth.PubSignals = []string{ "1", - "5816868615164565912277677884704888703982258184820398645933682814085602171910", - "286312392162647260160287083374160163061246635086990474403590223113720496128", + "18656147546666944484453899241916469544090258810192803949522794490493271005313", + "379949150130214723420589610911161895495647789006649785264738141299135414272", } zkpAtomic := types.ZeroKnowledgeProof{ Type: types.ZeroKnowledgeProofType, @@ -268,37 +135,39 @@ func TestVerifyMessageWithAuthAndAtomicProofMTP(t *testing.T) { zkpAtomic.ProofData = &types.ProofData{ A: []string{ - "6030766736698709207503235935723632085586029528521094738928233216811480909046", - "4437136509574400225154484002038044352118866895728605877220163266688442697592", + "14563891483923817735351071227705334357482245819917832755440492751795326413295", + "20001980078286652597494447537480393118263491043298930761329275311111441096085", "1", }, B: [][]string{ { - "15453350172140966014073430212249205778693880717093820193563857180042745981851", - "14488444741965254532105148685589475266981176437305146636275604446328498705645", + "21460159041971667208875402098144855602171917038488503689296027024135429671707", + "9175445768113769703996084712672842329219702292512170837734652428035591323144", }, { - "13806971963548792566531398385681144495082522845543761509446816014383821923698", - "19957785137858923832827931038978551647136133568993960686008633889509690940365", + "10903477940480645465545606090437044024923801481176394282103911000841141137655", + "8424415251889807111172788947141884111799125271291264519130017760779659719833", }, { "1", "0", }}, C: []string{ - "21292219848582385743964407300399360838478079150292968775627171001173922067285", - "75068403233603473513513911957593156375764622075671912015406661182104632457", + "13152557649540629470947504987414571133512125556520386893434586449071845933586", + "10523070098476215003191956451600442017991123271856887288630451951750613360903", "1", }, } zkpAtomic.PubSignals = []string{ - "286312392162647260160287083374160163061246635086990474403590223113720496128", - "5816868615164565912277677884704888703982258184820398645933682814085602171910", + "379949150130214723420589610911161895495647789006649785264738141299135414272", + "18656147546666944484453899241916469544090258810192803949522794490493271005313", "1", - "274380136414749538182079640726762994055", - "20606705619830543359176597576564222044873771515109680973150322899613614552596", - "296941560404583387587196218166209608454370683337298127000644446413747191808", + "18605292738057394742004097311192572049290380262377486632479765119429313092475", + "26599707002460144379092755370384635496563807452878989192352627271768342528", + "1642074362", + "180410020913331409885634153623124536270", "2", + "0", "10", "0", "0", @@ -316,7 +185,53 @@ func TestVerifyMessageWithAuthAndAtomicProofMTP(t *testing.T) { "0", "0", "0", - "1642074362", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", } message.Data.Scope = []interface{}{zkpAuth, zkpAtomic} @@ -325,10 +240,10 @@ func TestVerifyMessageWithAuthAndAtomicProofMTP(t *testing.T) { token, err := ExtractMetadata(&message) assert.Nil(t, err) - assert.Equal(t, "5816868615164565912277677884704888703982258184820398645933682814085602171910", token.State) - assert.Equal(t, "113Rq7d5grTGzqF7phKCRjxpC597eMa2USzm9rmpoj", token.ID) + assert.Equal(t, "18656147546666944484453899241916469544090258810192803949522794490493271005313", token.State) + assert.Equal(t, "119tqceWdRd2F6WnAyVuFQRFjK3WUXq2LorSPyG9LJ", token.ID) // - state, err := token.VerifyState(context.Background(), os.Getenv("RPC_URL"), "0x035C4DBC897D203483D942696CE1dF5a9f933FcC") + state, err := token.VerifyState(context.Background(), os.Getenv("RPC_URL"), "0xa36786C3E18225da7cc8FC69c6443ecD41827FF5") assert.Nil(t, err) assert.Equal(t, true, state.Latest) @@ -346,72 +261,76 @@ func TestVerifyMessageWithAuthAndAtomicProofSig(t *testing.T) { zkpAuth.ProofData = &types.ProofData{ A: []string{ - "2370534291294441687575434871070063634049522739054135650290327914016792634144", - "18704664440065881255248484392571034267692380947539795837185393466696768539729", + "6807142976568489254129987481389970790048870221943660648833750801722749769662", + "13811182779758948993435669124001052501939669904238445458453308627013829993881", "1", }, B: [][]string{ { - "1593753415597360514506439944675236073038159742598884104707775208490282580641", - "15142074894866083200293799148931702287457526593114838706672766340147139402722", + "1100658387420856656999617260396587549490320987275888589013664343574809180330", + "6271619554100652532302412650545865559102683218896584596952129504406572338279", }, { - "19117825221840408597122339519717065920080389822558089367138595722092823743944", - "2706264472260224656022451103720565978368804964791420659255319627595448027435", + "14732910796480272245291363689840710264816417845998668210234805961967222411399", + "697511497805383174761860295477525070010524578030535203059896030784240207952", }, { "1", "0", }}, C: []string{ - "156766304977057264803138092945401446963129379605822159500567538377014916135", - "10031227231200820171929683445407743402234929438478965985477678284516420821593", + "3322888400314063147927477851922827359406772099015587732727269650428166130415", + "11791447421105500417246293414158106577578665220990150855390594651727173683574", "1", }, } zkpAuth.PubSignals = []string{ "1", - "5816868615164565912277677884704888703982258184820398645933682814085602171910", - "286312392162647260160287083374160163061246635086990474403590223113720496128", + "18656147546666944484453899241916469544090258810192803949522794490493271005313", + "379949150130214723420589610911161895495647789006649785264738141299135414272", } - zkpAtomic := types.ZeroKnowledgeProof{ + zkpAtomicSig := types.ZeroKnowledgeProof{ Type: types.ZeroKnowledgeProofType, CircuitID: circuits.AtomicQuerySigCircuitID, } - zkpAtomic.ProofData = &types.ProofData{ + zkpAtomicSig.ProofData = &types.ProofData{ A: []string{ - "21178773137304249408018096919215793146186660193600590200162998171616690680862", - "16723112137222954968898173855229909328853328041073537712042644179394618395718", + "1488456198277173867661803167279729032792624154299809535479139810450208085804", + "9811034571283288656264374082369091089294184381655818490061981465520280644099", "1", }, B: [][]string{ { - "8154027924267780522239744810441934681489939329198303707054340169107503503140", - "13896707211429361892074216485456946320669555884653797826533153207946250359049", + "13681354712371365579602068955518190907734292243300799145386142304285387190248", + "19642020020503110008281046192437788751455352298111438354251429185186525636938", }, { - "8812219892284825088614656710055314118836154185354535911423155023728785526230", - "1137286278173265884575737920332918824261782651899335984176084421710066567443", + "18027737448042663605647662927822589790701241972444434677331650112736257064866", + "18923462657673777837321044737582380572508740613132447083192792887982785512304", }, { "1", "0", }}, C: []string{ - "21449679392663656551219603482072298649562605845908654459293574785782180912646", - "3048812808090764561109652462842759548958106605480847082632940766239677991498", + "828611771379429881138968663246435638713557278809347995796848761749026576833", + "15003422674439031650056257919485333677483689815727200225661349760606202441045", "1", }, } - zkpAtomic.PubSignals = []string{ - "286312392162647260160287083374160163061246635086990474403590223113720496128", - "5816868615164565912277677884704888703982258184820398645933682814085602171910", + zkpAtomicSig.PubSignals = []string{ + "6317996369756476782464660619835940615734517981889733696047139451453239145426", + "379949150130214723420589610911161895495647789006649785264738141299135414272", + "18656147546666944484453899241916469544090258810192803949522794490493271005313", "1", - "274380136414749538182079640726762994055", - "296941560404583387587196218166209608454370683337298127000644446413747191808", - "13850938450891658391727543833954835315278162931905851620922327407976321180678", + "26599707002460144379092755370384635496563807452878989192352627271768342528", + "6317996369756476782464660619835940615734517981889733696047139451453239145426", + "18605292738057394742004097311192572049290380262377486632479765119429313092475", + "1642074362", + "180410020913331409885634153623124536270", "2", + "0", "10", "0", "0", @@ -429,19 +348,65 @@ func TestVerifyMessageWithAuthAndAtomicProofSig(t *testing.T) { "0", "0", "0", - "1642074362", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", } - message.Data.Scope = []interface{}{zkpAuth, zkpAtomic} + message.Data.Scope = []interface{}{zkpAuth, zkpAtomicSig} err := VerifyProofs(&message) assert.Nil(t, err) token, err := ExtractMetadata(&message) assert.Nil(t, err) - assert.Equal(t, "5816868615164565912277677884704888703982258184820398645933682814085602171910", token.State) - assert.Equal(t, "113Rq7d5grTGzqF7phKCRjxpC597eMa2USzm9rmpoj", token.ID) + assert.Equal(t, "18656147546666944484453899241916469544090258810192803949522794490493271005313", token.State) + assert.Equal(t, "119tqceWdRd2F6WnAyVuFQRFjK3WUXq2LorSPyG9LJ", token.ID) // - state, err := token.VerifyState(context.Background(), os.Getenv("RPC_URL"), "0x035C4DBC897D203483D942696CE1dF5a9f933FcC") + state, err := token.VerifyState(context.Background(), os.Getenv("RPC_URL"), "0xa36786C3E18225da7cc8FC69c6443ecD41827FF5") assert.Nil(t, err) assert.Equal(t, true, state.Latest) diff --git a/communication/credentials/fetch_test.go b/communication/credentials/fetch_test.go index 9bbac95..46b447f 100644 --- a/communication/credentials/fetch_test.go +++ b/communication/credentials/fetch_test.go @@ -17,36 +17,35 @@ func TestVerifyCredentialFetchRequest(t *testing.T) { Type: types.ZeroKnowledgeProofType, CircuitID: circuits.AuthCircuitID, } - zkpProof.ProofData = &types.ProofData{ A: []string{ - "2370534291294441687575434871070063634049522739054135650290327914016792634144", - "18704664440065881255248484392571034267692380947539795837185393466696768539729", + "6807142976568489254129987481389970790048870221943660648833750801722749769662", + "13811182779758948993435669124001052501939669904238445458453308627013829993881", "1", }, B: [][]string{ { - "1593753415597360514506439944675236073038159742598884104707775208490282580641", - "15142074894866083200293799148931702287457526593114838706672766340147139402722", + "1100658387420856656999617260396587549490320987275888589013664343574809180330", + "6271619554100652532302412650545865559102683218896584596952129504406572338279", }, { - "19117825221840408597122339519717065920080389822558089367138595722092823743944", - "2706264472260224656022451103720565978368804964791420659255319627595448027435", + "14732910796480272245291363689840710264816417845998668210234805961967222411399", + "697511497805383174761860295477525070010524578030535203059896030784240207952", }, { "1", "0", }}, C: []string{ - "156766304977057264803138092945401446963129379605822159500567538377014916135", - "10031227231200820171929683445407743402234929438478965985477678284516420821593", + "3322888400314063147927477851922827359406772099015587732727269650428166130415", + "11791447421105500417246293414158106577578665220990150855390594651727173683574", "1", }, } zkpProof.PubSignals = []string{ "1", - "5816868615164565912277677884704888703982258184820398645933682814085602171910", - "286312392162647260160287083374160163061246635086990474403590223113720496128", + "18656147546666944484453899241916469544090258810192803949522794490493271005313", + "379949150130214723420589610911161895495647789006649785264738141299135414272", } message.Data.Scope = []interface{}{zkpProof} @@ -67,33 +66,33 @@ func TestExtractDataFromCredentialFetchRequest(t *testing.T) { zkpProof.ProofData = &types.ProofData{ A: []string{ - "2370534291294441687575434871070063634049522739054135650290327914016792634144", - "18704664440065881255248484392571034267692380947539795837185393466696768539729", + "6807142976568489254129987481389970790048870221943660648833750801722749769662", + "13811182779758948993435669124001052501939669904238445458453308627013829993881", "1", }, B: [][]string{ { - "1593753415597360514506439944675236073038159742598884104707775208490282580641", - "15142074894866083200293799148931702287457526593114838706672766340147139402722", + "1100658387420856656999617260396587549490320987275888589013664343574809180330", + "6271619554100652532302412650545865559102683218896584596952129504406572338279", }, { - "19117825221840408597122339519717065920080389822558089367138595722092823743944", - "2706264472260224656022451103720565978368804964791420659255319627595448027435", + "14732910796480272245291363689840710264816417845998668210234805961967222411399", + "697511497805383174761860295477525070010524578030535203059896030784240207952", }, { "1", "0", }}, C: []string{ - "156766304977057264803138092945401446963129379605822159500567538377014916135", - "10031227231200820171929683445407743402234929438478965985477678284516420821593", + "3322888400314063147927477851922827359406772099015587732727269650428166130415", + "11791447421105500417246293414158106577578665220990150855390594651727173683574", "1", }, } zkpProof.PubSignals = []string{ "1", - "5816868615164565912277677884704888703982258184820398645933682814085602171910", - "286312392162647260160287083374160163061246635086990474403590223113720496128", + "18656147546666944484453899241916469544090258810192803949522794490493271005313", + "379949150130214723420589610911161895495647789006649785264738141299135414272", } message.Data.Scope = []interface{}{zkpProof} diff --git a/communication/packer/plain_test.go b/communication/packer/plain_test.go index 910018f..5d40bd4 100644 --- a/communication/packer/plain_test.go +++ b/communication/packer/plain_test.go @@ -20,7 +20,7 @@ func TestPlainMessagePacker_Pack(t *testing.T) { zkpProofRequest := types.ZeroKnowledgeProofRequest{ Type: types.ZeroKnowledgeProofType, - CircuitID: circuits.KycBySignaturesCircuitID, + CircuitID: circuits.AtomicQueryMTPCircuitID, Rules: map[string]interface{}{ "challenge": "1234567", }, @@ -39,7 +39,7 @@ func TestPlainMessagePacker_Pack(t *testing.T) { func TestPlainMessagePacker_Unpack(t *testing.T) { packer := PlainMessagePacker{} - msgBytes := []byte(`{"type":"https://iden3-communication.io/authorization-response/v1","data":{"scope":[{"type":"zeroknowledge","circuit_id":"auth","pub_signals":["1","5816868615164565912277677884704888703982258184820398645933682814085602171910","286312392162647260160287083374160163061246635086990474403590223113720496128"],"proof_data":{"pi_a":["2370534291294441687575434871070063634049522739054135650290327914016792634144","18704664440065881255248484392571034267692380947539795837185393466696768539729","1"],"pi_b":[["1593753415597360514506439944675236073038159742598884104707775208490282580641","15142074894866083200293799148931702287457526593114838706672766340147139402722"],["19117825221840408597122339519717065920080389822558089367138595722092823743944","2706264472260224656022451103720565978368804964791420659255319627595448027435"],["1","0"]],"pi_c":["156766304977057264803138092945401446963129379605822159500567538377014916135","10031227231200820171929683445407743402234929438478965985477678284516420821593","1"],"protocol":""}}]}}`) + msgBytes := []byte(`{"type":"https://iden3-communication.io/authorization-response/v1","data":{"scope":[{"type":"zeroknowledge","circuit_id":"auth","pub_signals":["1","18656147546666944484453899241916469544090258810192803949522794490493271005313","379949150130214723420589610911161895495647789006649785264738141299135414272"],"proof_data":{"pi_a":["6807142976568489254129987481389970790048870221943660648833750801722749769662","13811182779758948993435669124001052501939669904238445458453308627013829993881","1"],"pi_b":[["1100658387420856656999617260396587549490320987275888589013664343574809180330","6271619554100652532302412650545865559102683218896584596952129504406572338279"],["14732910796480272245291363689840710264816417845998668210234805961967222411399","697511497805383174761860295477525070010524578030535203059896030784240207952"],["1","0"]],"pi_c":["3322888400314063147927477851922827359406772099015587732727269650428166130415","11791447421105500417246293414158106577578665220990150855390594651727173683574","1"],"protocol":""}}]}}`) message, err := packer.Unpack(msgBytes) assert.Nil(t, err) assert.Equal(t, auth.AuthorizationResponseMessageType, message.GetType()) @@ -49,7 +49,7 @@ func TestPlainMessagePacker_Unpack(t *testing.T) { token, err := auth.ExtractMetadata(message) assert.Nil(t, err) - assert.Equal(t, "113Rq7d5grTGzqF7phKCRjxpC597eMa2USzm9rmpoj", token.ID) + assert.Equal(t, "119tqceWdRd2F6WnAyVuFQRFjK3WUXq2LorSPyG9LJ", token.ID) } func TestPlainMessagePacker_PackAuthorizationResponse(t *testing.T) { diff --git a/go.mod b/go.mod index 2ece152..c5af6bf 100644 --- a/go.mod +++ b/go.mod @@ -1,14 +1,37 @@ module github.com/iden3/go-iden3-auth -go 1.17 +go 1.18 require ( - github.com/ethereum/go-ethereum v1.10.13 + github.com/ethereum/go-ethereum v1.10.17 github.com/golang/mock v1.3.1 - github.com/iden3/go-circuits v0.0.27 - github.com/iden3/go-iden3-core v0.0.12 - github.com/iden3/go-merkletree-sql v1.0.0-pre8 - github.com/mitchellh/mapstructure v1.4.3 // indirect + github.com/iden3/go-circuits v0.0.41 + github.com/iden3/go-iden3-core v0.0.16 + github.com/iden3/go-merkletree-sql v1.0.1 github.com/pkg/errors v0.9.1 github.com/stretchr/testify v1.7.0 ) + +require ( + github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 // indirect + github.com/btcsuite/btcd v0.20.1-beta // indirect + github.com/btcsuite/btcd/btcec/v2 v2.1.2 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/dchest/blake512 v1.0.0 // indirect + github.com/deckarep/golang-set v1.8.0 // indirect + github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect + github.com/go-ole/go-ole v1.2.1 // indirect + github.com/go-stack/stack v1.8.0 // indirect + github.com/gorilla/websocket v1.4.2 // indirect + github.com/iden3/go-iden3-crypto v0.0.13 // indirect + github.com/mitchellh/mapstructure v1.4.3 // indirect + github.com/mr-tron/base58 v1.2.0 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect + github.com/tklauser/go-sysconf v0.3.5 // indirect + github.com/tklauser/numcpus v0.2.2 // indirect + golang.org/x/crypto v0.0.0-20211117183948-ae814b36b871 // indirect + golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect + gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect + gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect +) diff --git a/go.sum b/go.sum index 3f1a099..1b73f90 100644 --- a/go.sum +++ b/go.sum @@ -18,19 +18,9 @@ cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiy cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos= collectd.org v0.3.0/go.mod h1:A/8DzQBkF6abtvrT2j/AU/4tiBgJWYyh0y/oB/4MlWE= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= -github.com/Azure/azure-pipeline-go v0.2.1/go.mod h1:UGSo8XybXnIGZ3epmeBw7Jdz+HiUVpqIlpz/HKHylF4= -github.com/Azure/azure-pipeline-go v0.2.2/go.mod h1:4rQ/NZncSvGqNkkOsNpOU1tgoNuIlp9AfUH5G1tvCHc= -github.com/Azure/azure-storage-blob-go v0.7.0/go.mod h1:f9YQKtsG1nMisotuTPpO0tjNuEjKRYAcJU8/ydDI++4= -github.com/Azure/go-autorest/autorest v0.9.0/go.mod h1:xyHB1BMZT0cuDHU7I0+g046+BFDTQ8rEZB0s4Yfa6bI= -github.com/Azure/go-autorest/autorest/adal v0.5.0/go.mod h1:8Z9fGy2MpX0PvDjB1pEgQTmVqjGhiHBW7RJJEciWzS0= -github.com/Azure/go-autorest/autorest/adal v0.8.0/go.mod h1:Z6vX6WXXuyieHAXwMj0S6HY6e6wcHn37qQMBQlvY3lc= -github.com/Azure/go-autorest/autorest/date v0.1.0/go.mod h1:plvfp3oPSKwf2DNjlBjWF/7vwR+cUD/ELuzDCXwHUVA= -github.com/Azure/go-autorest/autorest/date v0.2.0/go.mod h1:vcORJHLJEh643/Ioh9+vPmf1Ij9AEBM5FuBIXLmIy0g= -github.com/Azure/go-autorest/autorest/mocks v0.1.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0= -github.com/Azure/go-autorest/autorest/mocks v0.2.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0= -github.com/Azure/go-autorest/autorest/mocks v0.3.0/go.mod h1:a8FDP3DYzQ4RYfVAxAN3SVSiiO77gL2j2ronKKP0syM= -github.com/Azure/go-autorest/logger v0.1.0/go.mod h1:oExouG+K6PryycPJfVSxi/koC6LSNgds39diKLz7Vrc= -github.com/Azure/go-autorest/tracing v0.5.0/go.mod h1:r/s2XiOKccPW3HrqB+W0TQzfbtp2fGCgRFtBroKn4Dk= +github.com/Azure/azure-sdk-for-go/sdk/azcore v0.21.1/go.mod h1:fBF9PQNqB8scdgpZ3ufzaLntG0AG7C1WjPMsiFOmfHM= +github.com/Azure/azure-sdk-for-go/sdk/internal v0.8.3/go.mod h1:KLF4gFr6DcKFZwSuH8w8yEK6DpFl3LP5rhdvAb7Yz5I= +github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v0.3.0/go.mod h1:tPaiy8S5bQ+S5sOiDlINkp7+Ef339+Nz5L5XO+cnOHo= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= @@ -61,6 +51,9 @@ github.com/bmizerany/pat v0.0.0-20170815010413-6226ea591a40/go.mod h1:8rLXio+Wji github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx27Ps= github.com/btcsuite/btcd v0.20.1-beta h1:Ik4hyJqN8Jfyv3S4AGBOmyouMsYE3EdYODkMbQjwPGw= github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ= +github.com/btcsuite/btcd/btcec/v2 v2.1.2 h1:YoYoC9J0jwfukodSBMzZYUVQ8PTiYg4BnOWiJVzTmLs= +github.com/btcsuite/btcd/btcec/v2 v2.1.2/go.mod h1:ctjw4H1kknNJmRN4iP1R7bTQ+v3GJkZBd6mui8ZsAZE= +github.com/btcsuite/btcd/chaincfg/chainhash v1.0.0/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA= github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg= github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd/go.mod h1:HHNXQzUsZCxOoE+CPiyCTO6x34Zs86zZUiwtpXoGdtg= @@ -92,14 +85,20 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dchest/blake512 v1.0.0 h1:oDFEQFIqFSeuA34xLtXZ/rWxCXdSjirjzPhey5EUvmA= github.com/dchest/blake512 v1.0.0/go.mod h1:FV1x7xPPLWukZlpDpWQ88rF/SFwZ5qbskrzhLMB92JI= -github.com/deckarep/golang-set v0.0.0-20180603214616-504e848d77ea h1:j4317fAZh7X6GqbFowYdYdI0L9bwxL07jyPZIdepyZ0= -github.com/deckarep/golang-set v0.0.0-20180603214616-504e848d77ea/go.mod h1:93vsz/8Wt4joVM7c2AVqh+YRMiUSc14yDtF28KmMOgQ= +github.com/deckarep/golang-set v1.8.0 h1:sk9/l/KqpunDwP7pSjUg0keiOOLEnOBHzykLrsPppp4= +github.com/deckarep/golang-set v1.8.0/go.mod h1:5nI87KwE7wgsBU1F4GKAw2Qod7p5kyS383rP6+o6qqo= +github.com/decred/dcrd/crypto/blake256 v1.0.0 h1:/8DMNYp9SGi5f0w7uCm6d6M4OU2rGFK09Y2A4Xv7EE0= +github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 h1:YLtO71vCjJRCBcrPMtQ9nqBsqpA1m5sE92cU+pd5Mcc= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs= github.com/deepmap/oapi-codegen v1.6.0/go.mod h1:ryDa9AgbELGeB+YEXE1dR53yAjHwFvE9iAUlWl9Al3M= github.com/deepmap/oapi-codegen v1.8.2/go.mod h1:YLgSKSDv/bZQB7N4ws6luhozi3cEdRktEqrX88CvjIw= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dgryski/go-bitstream v0.0.0-20180413035011-3522498ce2c8/go.mod h1:VMaSuZ+SZcx/wljOQKvp5srsbCiKDEb6K2wC4+PiBmQ= github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= github.com/dlclark/regexp2 v1.4.1-0.20201116162257-a2a8dda75c91/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc= +github.com/dnaeon/go-vcr v1.1.0/go.mod h1:M7tiix8f0r6mKKJ3Yq/kqU1OYf3MnfmBWVbPx/yU9ko= +github.com/dnaeon/go-vcr v1.2.0/go.mod h1:R4UdLID7HZT3taECzJs4YgbbH6PIGXB6W/sc5OLb6RQ= github.com/docker/docker v1.4.2-0.20180625184442-8e610b2b55bf/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/dop251/goja v0.0.0-20211011172007-d99e4b8cbf48/go.mod h1:R9ET47fwRVRPZnOGvHxxhuZcbrMCuiqOz3Rlrh4KSnk= github.com/dop251/goja_nodejs v0.0.0-20210225215109-d91c329300e7/go.mod h1:hn7BA7c8pLvoGndExHudxTDKZ84Pyvv+90pbBjbTz0Y= @@ -108,8 +107,8 @@ github.com/edsrzf/mmap-go v1.0.0 h1:CEBF7HpRnUCSJgGUb5h1Gm7e3VkmVDrR8lvWVLtrOFw= github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/ethereum/go-ethereum v1.10.13 h1:DEYFP9zk+Gruf3ae1JOJVhNmxK28ee+sMELPLgYTXpA= -github.com/ethereum/go-ethereum v1.10.13/go.mod h1:W3yfrFyL9C1pHcwY5hmRHVDaorTiQxhYBkKyu5mEDHw= +github.com/ethereum/go-ethereum v1.10.17 h1:XEcumY+qSr1cZQaWsQs5Kck3FHB0V2RiMHPdTBJ+oT8= +github.com/ethereum/go-ethereum v1.10.17/go.mod h1:Lt5WzjM07XlXc95YzrhosmR4J9Ahd6X2wyEV2SvGhk0= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5 h1:FtmdgXiUlNeRsoNMFlKLDt+S+6hbjVMEW6RGQ7aUf7c= github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0= @@ -140,6 +139,8 @@ github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/me github.com/gofrs/uuid v3.3.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= +github.com/golang-jwt/jwt/v4 v4.3.0 h1:kHL1vqdqWNfATmA0FNMdmZNMyZI1U6O31X4rlIPoBog= +github.com/golang-jwt/jwt/v4 v4.3.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg= github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= github.com/golang/geo v0.0.0-20190916061304-5b978397cfec/go.mod h1:QZ0nwyI2jOfgRAoBvP+ab5aRr7c9x7lhGEJrKvBwjWI= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= @@ -179,15 +180,15 @@ github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OI github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= -github.com/google/uuid v1.1.5 h1:kxhtnfFVi+rYdOALN0B3k9UT86zVJKfBimRaciULW4I= -github.com/google/uuid v1.1.5/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.2.0 h1:qJYtXnJRWmpe7m/3XlyhrsLrEURqHRM2kxzoxXqyUDs= +github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= -github.com/graph-gophers/graphql-go v0.0.0-20201113091052-beb923fada29/go.mod h1:9CQHMSxwO4MprSdzoIEobiHpoLtHm77vfxsvsIN5Vuc= +github.com/graph-gophers/graphql-go v1.3.0/go.mod h1:9CQHMSxwO4MprSdzoIEobiHpoLtHm77vfxsvsIN5Vuc= github.com/hashicorp/go-bexpr v0.1.10 h1:9kuI5PFotCboP3dkDYFr/wi0gg0QVbSNz5oFRpxn4uE= github.com/hashicorp/go-bexpr v0.1.10/go.mod h1:oxlubA2vC/gFVfX1A6JGp7ls7uCDlfJn732ehYYg+g0= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= @@ -199,18 +200,18 @@ github.com/holiman/bloomfilter/v2 v2.0.3/go.mod h1:zpoh+gs7qcpqrHr3dB55AMiJwo0iU github.com/holiman/uint256 v1.2.0 h1:gpSYcPLWGv4sG43I2mVLiDZCNDh/EpGjSk8tmtxitHM= github.com/holiman/uint256 v1.2.0/go.mod h1:y4ga/t+u+Xwd7CpDgZESaRcWy0I7XMlTMA25ApIH5Jw= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= -github.com/huin/goupnp v1.0.2 h1:RfGLP+h3mvisuWEyybxNq5Eft3NWhHLPeUN72kpKZoI= -github.com/huin/goupnp v1.0.2/go.mod h1:0dxJBVBHqTMjIUMkESDTNgOOx/Mw5wYIfyFmdzSamkM= +github.com/huin/goupnp v1.0.3-0.20220313090229-ca81a64b4204 h1:+EYBkW+dbi3F/atB+LSQZSWh7+HNrV3A/N0y6DSoy9k= +github.com/huin/goupnp v1.0.3-0.20220313090229-ca81a64b4204/go.mod h1:ZxNlw5WqJj6wSsRK5+YfflQGXYfccj5VgQsMNixHM7Y= github.com/huin/goutil v0.0.0-20170803182201-1ca381bf3150/go.mod h1:PpLOETDnJ0o3iZrZfqZzyLl6l7F3c6L1oWn7OICBi6o= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= -github.com/iden3/go-circuits v0.0.27 h1:vGIo4lv0PhvY17cz2enmHB4KELK1t8wqSElU0DexzlQ= -github.com/iden3/go-circuits v0.0.27/go.mod h1:CJdD8SAPhkWQLR8TBOTLKi8IuZvjp4XIZkPvQbk0v3k= -github.com/iden3/go-iden3-core v0.0.12 h1:wmDZU2e5Z7iMrCUCQQWzeUqBE8X4wl3t41DeyhnHpL8= -github.com/iden3/go-iden3-core v0.0.12/go.mod h1:Ou51YR716WqeBJ3Z4BkGVAJROgSYgfnl4i8x3mfLOeY= -github.com/iden3/go-iden3-crypto v0.0.11 h1:5cFQ/BIqH9gjwe9Z68Hmc5jOTGqmMYnewIaTGCeO+6A= -github.com/iden3/go-iden3-crypto v0.0.11/go.mod h1:yUBWcXgAUDZxa1PvRl0zIT4Q4/rQO5PacE52Z06i8kw= -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-circuits v0.0.41 h1:zqfWL6FtJI0aAO8O8mxsZhFqjgtiEPDr2fZV5AC7NUg= +github.com/iden3/go-circuits v0.0.41/go.mod h1:Is4eMPGPUlO+2Lg2P4k/vRLRmwJAGBQcHki4NoHv80o= +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.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.1 h1:zZMhhyV6FLoLL+pHQiiPoAI3ORSCTKOL32/n7Sb/+R4= +github.com/iden3/go-merkletree-sql v1.0.1/go.mod h1:NhLFvX01F/3QqS0FUkC6T2BXPksz+9EbRhKQ7abaBSE= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/influxdata/flux v0.65.1/go.mod h1:J754/zds0vvpfwuq7Gc2wRdVwEodfpCFM7mYlOw2LqY= github.com/influxdata/influxdb v1.8.3/go.mod h1:JugdFhsvvI8gadxOI6noqNeeBHvWNTbfYGtiAn+2jhI= @@ -223,8 +224,8 @@ github.com/influxdata/promql/v2 v2.12.0/go.mod h1:fxOPu+DY0bqCTCECchSRtWfc+0X19y github.com/influxdata/roaring v0.4.13-0.20180809181101-fc520f41fab6/go.mod h1:bSgUQ7q5ZLSO+bKBGqJiCBGAl+9DxyW63zLTujjUlOE= github.com/influxdata/tdigest v0.0.0-20181121200506-bf2b5ad3c0a9/go.mod h1:Js0mqiSBE6Ffsg94weZZ2c+v/ciT8QRHFOap7EKDrR0= github.com/influxdata/usage-client v0.0.0-20160829180054-6d3895376368/go.mod h1:Wbbw6tYNvwa5dlB6304Sd+82Z3f7PmVZHVKU637d4po= -github.com/jackpal/go-nat-pmp v1.0.2-0.20160603034137-1fa385a6f458 h1:6OvNmYgJyexcZ3pYbTI9jWx5tHo1Dee/tWbLMfPe2TA= -github.com/jackpal/go-nat-pmp v1.0.2-0.20160603034137-1fa385a6f458/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc= +github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus= +github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc= github.com/jedisct1/go-minisign v0.0.0-20190909160543-45766022959e/go.mod h1:G1CVv03EnqU1wYL2dFwXxW2An0az9JTl/ZsqXQeBlkU= github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= @@ -238,7 +239,7 @@ github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfV github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/jung-kurt/gofpdf v1.0.3-0.20190309125859-24315acbbda5/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes= github.com/jwilder/encoding v0.0.0-20170811194829-b4e1701a28ef/go.mod h1:Ct9fl0F6iIOGgxJ5npU/IUOhOhqlVrGjyIZc8/MagT0= -github.com/karalabe/usb v0.0.0-20211005121534-4c5740d64559/go.mod h1:Od972xHfMJowv7NGVDiWVxk2zxnWgjLlJzE+F4F7AGU= +github.com/karalabe/usb v0.0.2/go.mod h1:Od972xHfMJowv7NGVDiWVxk2zxnWgjLlJzE+F4F7AGU= github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4= @@ -258,6 +259,7 @@ github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/labstack/echo/v4 v4.2.1/go.mod h1:AA49e0DZ8kk5jTOOCKNuPR6oTnBS0dYiM4FW1e6jwpg= github.com/labstack/gommon v0.3.0/go.mod h1:MULnywXg0yavhxWKc+lOruYdAhDwPK9wf0OL7NoOu+k= +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/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= @@ -268,8 +270,6 @@ github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVc github.com/mattn/go-colorable v0.1.7/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-colorable v0.1.8 h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ0s8= github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= -github.com/mattn/go-ieproxy v0.0.0-20190610004146-91bb50d98149/go.mod h1:31jz6HNzdxOmlERGGEc4v/dMssOfmp2p5bT/okiKFFc= -github.com/mattn/go-ieproxy v0.0.0-20190702010315-6dee0af9227d/go.mod h1:31jz6HNzdxOmlERGGEc4v/dMssOfmp2p5bT/okiKFFc= github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ= @@ -288,6 +288,7 @@ github.com/mitchellh/pointerstructure v1.2.0 h1:O+i9nHnXS3l/9Wu7r4NrEdwA2VFTicjU github.com/mitchellh/pointerstructure v1.2.0/go.mod h1:BRAsLI5zgXmw97Lf6s25bs8ohIXc3tViBH44KcwB2g4= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5/go.mod h1:caMODM3PzxT8aQXRPkAt8xlV/e7d7w8GM5g0fa5F0D8= github.com/mr-tron/base58 v1.2.0 h1:T/HDJBh4ZCPbU39/+c3rRvE0uKBQlU27+QI8LJ4t64o= github.com/mr-tron/base58 v1.2.0/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc= github.com/mschoch/smat v0.0.0-20160514031455-90eadee771ae/go.mod h1:qAyveg+e4CE+eKJXWVjKXM4ck2QobLqTDytGJbLLhJg= @@ -444,10 +445,12 @@ golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20201010224723-4f7140c49acb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210220033124-5f55cee0dc0d/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20210610132358-84b48f89b13b/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -461,7 +464,6 @@ golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -502,8 +504,9 @@ golang.org/x/sys v0.0.0-20210324051608-47abb6519492/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210420205809-ac73e9fd8988/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210816183151-1e6c022a8912 h1:uCLL3g5wH2xjxVREVuAbP9JM5PPKjRbXKRa6IBjkzmU= golang.org/x/sys v0.0.0-20210816183151-1e6c022a8912/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM= +golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -512,8 +515,9 @@ golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20201208040808-7e3f01d25324/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -613,8 +617,9 @@ gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/proofs/zeroknowledge/handlers/metadata.go b/proofs/zeroknowledge/handlers/metadata.go index 4f402c7..999693f 100644 --- a/proofs/zeroknowledge/handlers/metadata.go +++ b/proofs/zeroknowledge/handlers/metadata.go @@ -10,9 +10,9 @@ import ( ) const ( - identifierAttribute string = "user_identifier" + identifierAttribute string = "userID" challengeAttribute string = "challenge" - stateAttribute string = "user_state" + stateAttribute string = "userState" ) // MetadataProofHandler is handler to extract metadata of the provided proof diff --git a/proofs/zeroknowledge/handlers/verification.go b/proofs/zeroknowledge/handlers/verification.go index fa81d51..6661fa5 100644 --- a/proofs/zeroknowledge/handlers/verification.go +++ b/proofs/zeroknowledge/handlers/verification.go @@ -1,7 +1,7 @@ package handlers import ( - "fmt" + "github.com/iden3/go-circuits" "github.com/iden3/go-iden3-auth/types" "github.com/iden3/go-iden3-auth/verification" ) @@ -14,12 +14,14 @@ type VerificationHandler struct { // Process applies handler logic on provided message func (h *VerificationHandler) Process(m *types.ZeroKnowledgeProof) (err error) { - err = verification.VerifyProof(*m.ProofData, m.PubSignals, []byte(m.CircuitData.VerificationKey)) + key, err := circuits.GetVerificationKey(m.CircuitID) + if err != nil { + return err + } + err = verification.VerifyProof(*m.ProofData, m.PubSignals, key) if err != nil { return err } - fmt.Println("proofs verified") - if h.next != nil { err = h.next.Process(m) if err != nil { diff --git a/proofs/zeroknowledge/proof.go b/proofs/zeroknowledge/proof.go index a070bac..c83a0dc 100644 --- a/proofs/zeroknowledge/proof.go +++ b/proofs/zeroknowledge/proof.go @@ -7,29 +7,23 @@ import ( ) var supportedCircuits = map[circuits.CircuitID]types.CircuitData{ - circuits.KycBySignaturesCircuitID: { - ID: circuits.KycBySignaturesCircuitID, - Description: "circuit for kyc claims verification", - VerificationKey: circuits.KycBySignaturesVerificationKey, - Metadata: circuits.KycBySignaturesPublicSignalsSchema, - }, + circuits.AuthCircuitID: { - ID: circuits.AuthCircuitID, - Description: "circuit for verification of basic authentication", - VerificationKey: circuits.AuthenticationVerificationKey, - Metadata: circuits.AuthenticationPublicSignalsSchema, + ID: circuits.AuthCircuitID, + Description: "circuit for verification of basic authentication", + Metadata: `{"challenge":0,"userState":1,"userID":2}`, }, circuits.AtomicQueryMTPCircuitID: { - ID: circuits.AtomicQueryMTPCircuitID, - Description: "circuit for atomic query on standard iden3 credential", - VerificationKey: circuits.AtomicQueryMTPVerificationKey, - Metadata: circuits.AtomicQueryMTPPublicSignalsSchema, + ID: circuits.AtomicQueryMTPCircuitID, + Description: "circuit for atomic query on standard iden3 credential", + Metadata: `{"userID":0, "userState":1,"challenge":2,"issuerClaimIdenState":3, +"issuerID":4,"timestamp":5,"claimSchema":6,"slotIndex":7, "operator":8, "value_0": 9, "value_1": 10, "value_2": 11, "value_3": 12, "value_4": 13, "value_5": 14, "value_6": 15, "value_7": 16, "value_8": 17, "value_9": 18, "value_10": 19, "value_11": 20, "value_12": 21, "value_13": 22, "value_14": 23, "value_15": 24, "value_16": 25, "value_17": 26, "value_18": 27, "value_19": 28, "value_20": 29, "value_21": 30, "value_22": 31, "value_23": 32, "value_24": 33, "value_25": 34, "value_26": 35, "value_27": 36, "value_28": 37, "value_29": 38, "value_30": 39, "value_31": 40, "value_32": 41, "value_33": 42, "value_34": 43, "value_35": 44, "value_36": 45, "value_37": 46, "value_38": 47, "value_39": 48, "value_40": 49, "value_41": 50, "value_42": 51, "value_43": 52, "value_44": 53, "value_45": 54, "value_46": 55, "value_47": 56, "value_48": 57, "value_49": 58, "value_50": 59, "value_51": 60, "value_52": 61, "value_53": 62, "value_54": 63, "value_55": 64, "value_56": 65, "value_57": 66, "value_58": 67, "value_59": 68, "value_60": 69, "value_61": 70, "value_62": 71, "value_63": 72}`, }, circuits.AtomicQuerySigCircuitID: { - ID: circuits.AtomicQuerySigCircuitID, - Description: "circuit for atomic query on standard iden3 credential", - VerificationKey: circuits.AtomicQuerySigVerificationKey, - Metadata: circuits.AtomicQuerySigPublicSignalsSchema, + ID: circuits.AtomicQuerySigCircuitID, + Description: "circuit for atomic query on standard iden3 credential", + Metadata: `{"IssuerAuthState": 0, "userID": 1, "userState": 2, "challenge": 3, + "issuerID": 4,"issuerState":5,"issuerClaimNonRevState": 6, "timestamp": 7, "claimSchema": 8, "slotIndex":9, "operator": 10, "value_0": 11, "value_1": 12, "value_2": 13, "value_3": 14, "value_4": 15, "value_5": 16, "value_6": 17, "value_7": 18, "value_8": 19, "value_9": 20, "value_10": 21, "value_11": 22, "value_12": 23, "value_13": 24, "value_14": 25, "value_15": 26, "value_16": 27, "value_17": 28, "value_18": 29, "value_19": 30, "value_20": 31, "value_21": 32, "value_22": 33, "value_23": 34, "value_24": 35, "value_25": 36, "value_26": 37, "value_27": 38, "value_28": 39, "value_29": 40, "value_30": 41, "value_31": 42, "value_32": 43, "value_33": 44, "value_34": 45, "value_35": 46, "value_36": 47, "value_37": 48, "value_38": 49, "value_39": 50, "value_40": 51, "value_41": 52, "value_42": 53, "value_43": 54, "value_44": 55, "value_45": 56, "value_46": 57, "value_47": 58, "value_48": 59, "value_49": 60, "value_50": 61, "value_51": 62, "value_52": 63, "value_53": 64, "value_54": 65, "value_55": 66, "value_56": 67, "value_57": 68, "value_58": 69, "value_59": 70, "value_60": 71, "value_61": 72, "value_62": 73, "value_63": 74}`, }, } diff --git a/proofs/zeroknowledge/proof_test.go b/proofs/zeroknowledge/proof_test.go index 029724a..d7c878b 100644 --- a/proofs/zeroknowledge/proof_test.go +++ b/proofs/zeroknowledge/proof_test.go @@ -15,33 +15,33 @@ func TestVerifyProof(t *testing.T) { proofMessage.ProofData = &types.ProofData{ A: []string{ - "2370534291294441687575434871070063634049522739054135650290327914016792634144", - "18704664440065881255248484392571034267692380947539795837185393466696768539729", + "6807142976568489254129987481389970790048870221943660648833750801722749769662", + "13811182779758948993435669124001052501939669904238445458453308627013829993881", "1", }, B: [][]string{ { - "1593753415597360514506439944675236073038159742598884104707775208490282580641", - "15142074894866083200293799148931702287457526593114838706672766340147139402722", + "1100658387420856656999617260396587549490320987275888589013664343574809180330", + "6271619554100652532302412650545865559102683218896584596952129504406572338279", }, { - "19117825221840408597122339519717065920080389822558089367138595722092823743944", - "2706264472260224656022451103720565978368804964791420659255319627595448027435", + "14732910796480272245291363689840710264816417845998668210234805961967222411399", + "697511497805383174761860295477525070010524578030535203059896030784240207952", }, { "1", "0", }}, C: []string{ - "156766304977057264803138092945401446963129379605822159500567538377014916135", - "10031227231200820171929683445407743402234929438478965985477678284516420821593", + "3322888400314063147927477851922827359406772099015587732727269650428166130415", + "11791447421105500417246293414158106577578665220990150855390594651727173683574", "1", }, } proofMessage.PubSignals = []string{ "1", - "5816868615164565912277677884704888703982258184820398645933682814085602171910", - "286312392162647260160287083374160163061246635086990474403590223113720496128", + "18656147546666944484453899241916469544090258810192803949522794490493271005313", + "379949150130214723420589610911161895495647789006649785264738141299135414272", } proofMessage.Type = "zeroknowledge" diff --git a/types/circuits.go b/types/circuits.go index c76cd94..f4bfd31 100644 --- a/types/circuits.go +++ b/types/circuits.go @@ -4,8 +4,7 @@ import "github.com/iden3/go-circuits" // CircuitData represents data that describes circuit type CircuitData struct { - ID circuits.CircuitID - Description string - VerificationKey circuits.VerificationKeyJSON - Metadata circuits.PublicSchemaJSON + ID circuits.CircuitID + Description string + Metadata string } diff --git a/verification/data.go b/verification/data.go index 9ec78e2..c0769fe 100644 --- a/verification/data.go +++ b/verification/data.go @@ -6,10 +6,12 @@ import ( "github.com/pkg/errors" ) +// State is state from contract type State struct { *big.Int } +// Unmarshal parses contract data to state struct func (s *State) Unmarshal(data []interface{}) error { if len(data) == 0 { return errors.New("invalid data") @@ -26,6 +28,7 @@ func (s *State) Unmarshal(data []interface{}) error { return nil } +// TransitionInfo is a state transition info type TransitionInfo struct { ReplacedAtTimestamp *big.Int CreatedAtTimestamp *big.Int @@ -35,6 +38,7 @@ type TransitionInfo struct { ReplacedBy *big.Int } +// Unmarshal parse contract result to TransitionInfo struct func (ti *TransitionInfo) Unmarshal(data []interface{}) error { if len(data) < 6 { return errors.New("invalid data") diff --git a/verification/proof_test.go b/verification/proof_test.go index 86f12e9..d731ec8 100644 --- a/verification/proof_test.go +++ b/verification/proof_test.go @@ -11,13 +11,43 @@ import ( func TestVerify(t *testing.T) { // verifyGroth16 the proofs - vkJSON := []byte(circuits.AuthenticationVerificationKey) + vkJSON, err := circuits.GetVerificationKey(circuits.AuthCircuitID) + assert.NoError(t, err) - publicJSON := []string{"1", "5816868615164565912277677884704888703982258184820398645933682814085602171910", "286312392162647260160287083374160163061246635086990474403590223113720496128"} - p := `{"pi_a":["2370534291294441687575434871070063634049522739054135650290327914016792634144","18704664440065881255248484392571034267692380947539795837185393466696768539729","1"],"pi_b":[["1593753415597360514506439944675236073038159742598884104707775208490282580641","15142074894866083200293799148931702287457526593114838706672766340147139402722"],["19117825221840408597122339519717065920080389822558089367138595722092823743944","2706264472260224656022451103720565978368804964791420659255319627595448027435"],["1","0"]],"pi_c":["156766304977057264803138092945401446963129379605822159500567538377014916135","10031227231200820171929683445407743402234929438478965985477678284516420821593","1"],"protocol":""}` + publicJSON := []string{"1", + "18656147546666944484453899241916469544090258810192803949522794490493271005313", + "379949150130214723420589610911161895495647789006649785264738141299135414272"} + p := `{ + "pi_a": [ + "6807142976568489254129987481389970790048870221943660648833750801722749769662", + "13811182779758948993435669124001052501939669904238445458453308627013829993881", + "1" + ], + "pi_b": [ + [ + "1100658387420856656999617260396587549490320987275888589013664343574809180330", + "6271619554100652532302412650545865559102683218896584596952129504406572338279" + ], + [ + "14732910796480272245291363689840710264816417845998668210234805961967222411399", + "697511497805383174761860295477525070010524578030535203059896030784240207952" + ], + [ + "1", + "0" + ] + ], + "pi_c": [ + "3322888400314063147927477851922827359406772099015587732727269650428166130415", + "11791447421105500417246293414158106577578665220990150855390594651727173683574", + "1" + ], + "protocol": "groth16", + "curve": "bn128" + }` var pd types.ProofData - err := json.Unmarshal([]byte(p), &pd) + err = json.Unmarshal([]byte(p), &pd) assert.NoError(t, err) err = VerifyProof(pd, publicJSON, vkJSON) diff --git a/verification/state.go b/verification/state.go index 461422c..65cf486 100644 --- a/verification/state.go +++ b/verification/state.go @@ -20,11 +20,13 @@ const ( errCallArgumentEncodedErrorMessage = "wrong arguments were provided" ) +// BlockchainCaller is an interfact to call smart contract type BlockchainCaller interface { // Call smart contract. For read operation. CallContract(context.Context, ethereum.CallMsg, *big.Int) ([]byte, error) } +// Unmarshaler converts contrcat data to provided interface type Unmarshaler interface { Unmarshal([]interface{}) error } @@ -111,15 +113,17 @@ func contractCall(ctx context.Context, c BlockchainCaller, contractAddress, cont func checkGenesisStateID(id, state *big.Int) error { - stateHash := merkletree.NewHashFromBigInt(state) - IDFromState := core.IdGenesisFromIdenState(stateHash).String() + IDFromState, err := core.IdGenesisFromIdenState(core.TypeDefault, state) + if err != nil { + return err + } elemBytes := merkletree.NewElemBytesFromBigInt(id) IDFromParam, err := core.IDFromBytes(elemBytes[:31]) if err != nil { return err } - if IDFromState != IDFromParam.String() { + if IDFromState.String() != IDFromParam.String() { return errors.Errorf("ID from genesis state (%s) and provided (%s) don't match", IDFromState, IDFromParam.String()) } return nil