Skip to content

Commit

Permalink
Merge pull request #10 from iden3/feature/go-circuits-new-auth-support
Browse files Browse the repository at this point in the history
support new auth schema
  • Loading branch information
vmidyllic authored Mar 22, 2022
2 parents 1452b6e + d75b359 commit 83e371b
Show file tree
Hide file tree
Showing 7 changed files with 134 additions and 115 deletions.
122 changes: 60 additions & 62 deletions communication/auth/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,33 +176,33 @@ func TestVerifyMessageWithAuthProof(t *testing.T) {

zkpProof.ProofData = &types.ProofData{
A: []string{
"14577550064175748450987375704393907421920901508189337703397431390342898280710",
"2281752636269477429337220624909079669171458815254340085790599145888707827099",
"2370534291294441687575434871070063634049522739054135650290327914016792634144",
"18704664440065881255248484392571034267692380947539795837185393466696768539729",
"1",
},
B: [][]string{
{
"9892278221584481651733833641195128428650577799176543444926759323141284833312",
"1103007638015861371033094865422242272258878990152036520161116288875574588192",
"1593753415597360514506439944675236073038159742598884104707775208490282580641",
"15142074894866083200293799148931702287457526593114838706672766340147139402722",
},
{
"6922883339265533985243846004584074932233489016641091062635255509045633402568",
"13255178914414615598816442349245796924909724461658223751280894796264625158328",
"19117825221840408597122339519717065920080389822558089367138595722092823743944",
"2706264472260224656022451103720565978368804964791420659255319627595448027435",
},
{
"1",
"0",
}},
C: []string{
"11256651752290988174373131607181262214002388090610491351693173357538447781404",
"17144378915804146123122006704789555643110248683444179479923585102094009244340",
"156766304977057264803138092945401446963129379605822159500567538377014916135",
"10031227231200820171929683445407743402234929438478965985477678284516420821593",
"1",
},
}
zkpProof.PubSignals = []string{
"1",
"15383795261052586569047113011994713909892315748410703061728793744343300034754",
"293373448908678327289599234275657468666604586273320428510206058753616052224",
"5816868615164565912277677884704888703982258184820398645933682814085602171910",
"286312392162647260160287083374160163061246635086990474403590223113720496128",
}
message.Data.Scope = []interface{}{zkpProof}

Expand All @@ -211,8 +211,8 @@ func TestVerifyMessageWithAuthProof(t *testing.T) {

token, err := ExtractMetadata(&message)
assert.Nil(t, err)
assert.Equal(t, "15383795261052586569047113011994713909892315748410703061728793744343300034754", token.State)
assert.Equal(t, "11B34yHEY4tbE57kGKKFCHezo7rUBgouajFHeNszQm", token.ID)
assert.Equal(t, "5816868615164565912277677884704888703982258184820398645933682814085602171910", token.State)
assert.Equal(t, "113Rq7d5grTGzqF7phKCRjxpC597eMa2USzm9rmpoj", token.ID)

state, err := token.VerifyState(context.Background(), os.Getenv("RPC_URL"), "0x035C4DBC897D203483D942696CE1dF5a9f933FcC")
assert.Nil(t, err)
Expand All @@ -233,72 +233,71 @@ func TestVerifyMessageWithAuthAndAtomicProofMTP(t *testing.T) {

zkpAuth.ProofData = &types.ProofData{
A: []string{
"14577550064175748450987375704393907421920901508189337703397431390342898280710",
"2281752636269477429337220624909079669171458815254340085790599145888707827099",
"2370534291294441687575434871070063634049522739054135650290327914016792634144",
"18704664440065881255248484392571034267692380947539795837185393466696768539729",
"1",
},
B: [][]string{
{
"9892278221584481651733833641195128428650577799176543444926759323141284833312",
"1103007638015861371033094865422242272258878990152036520161116288875574588192",
"1593753415597360514506439944675236073038159742598884104707775208490282580641",
"15142074894866083200293799148931702287457526593114838706672766340147139402722",
},
{
"6922883339265533985243846004584074932233489016641091062635255509045633402568",
"13255178914414615598816442349245796924909724461658223751280894796264625158328",
"19117825221840408597122339519717065920080389822558089367138595722092823743944",
"2706264472260224656022451103720565978368804964791420659255319627595448027435",
},
{
"1",
"0",
}},
C: []string{
"11256651752290988174373131607181262214002388090610491351693173357538447781404",
"17144378915804146123122006704789555643110248683444179479923585102094009244340",
"156766304977057264803138092945401446963129379605822159500567538377014916135",
"10031227231200820171929683445407743402234929438478965985477678284516420821593",
"1",
},
}
zkpAuth.PubSignals = []string{
"1",
"15383795261052586569047113011994713909892315748410703061728793744343300034754",
"293373448908678327289599234275657468666604586273320428510206058753616052224",
"5816868615164565912277677884704888703982258184820398645933682814085602171910",
"286312392162647260160287083374160163061246635086990474403590223113720496128",
}

zkpAtomic := types.ZeroKnowledgeProof{
Type: types.ZeroKnowledgeProofType,
CircuitID: circuits.AtomicQueryMTPCircuitID,
}

zkpAtomic.ProofData = &types.ProofData{
A: []string{
"5506321668056084995566756316563979609863466544082751774213294316102674533305",
"14953767264429305477125818853906091103980645084989726684457750827776640676615",
"6030766736698709207503235935723632085586029528521094738928233216811480909046",
"4437136509574400225154484002038044352118866895728605877220163266688442697592",
"1",
},
B: [][]string{
{
"19103650958780723801065944831191305079190180149691819542835496049446218906335",
"17534560604355011413989526409647614012373537349457111791454431679858237109154",
"15453350172140966014073430212249205778693880717093820193563857180042745981851",
"14488444741965254532105148685589475266981176437305146636275604446328498705645",
},
{
"9712667359455971127402748549074157460976344610250847735225630538121711047326",
"4322002797459735322294492009938604808948489079408641006763891377854475025088",
"13806971963548792566531398385681144495082522845543761509446816014383821923698",
"19957785137858923832827931038978551647136133568993960686008633889509690940365",
},
{
"1",
"0",
}},
C: []string{
"20688703552741093143493958140412714572788333103476633787069997722117141261405",
"18592642862090383976775514461741843322144971271040124751702366261452885879263",
"21292219848582385743964407300399360838478079150292968775627171001173922067285",
"75068403233603473513513911957593156375764622075671912015406661182104632457",
"1",
},
}
zkpAtomic.PubSignals = []string{
"293373448908678327289599234275657468666604586273320428510206058753616052224",
"15383795261052586569047113011994713909892315748410703061728793744343300034754",
"286312392162647260160287083374160163061246635086990474403590223113720496128",
"5816868615164565912277677884704888703982258184820398645933682814085602171910",
"1",
"274380136414749538182079640726762994055",
"3465800424177143196107127845857728750770736366457056414231195686681735039800",
"238622032992029818959027522035982899478798944063520057730894779896578244608",
"20606705619830543359176597576564222044873771515109680973150322899613614552596",
"296941560404583387587196218166209608454370683337298127000644446413747191808",
"2",
"10",
"0",
Expand Down Expand Up @@ -326,8 +325,8 @@ func TestVerifyMessageWithAuthAndAtomicProofMTP(t *testing.T) {

token, err := ExtractMetadata(&message)
assert.Nil(t, err)
assert.Equal(t, "15383795261052586569047113011994713909892315748410703061728793744343300034754", token.State)
assert.Equal(t, "11B34yHEY4tbE57kGKKFCHezo7rUBgouajFHeNszQm", token.ID)
assert.Equal(t, "5816868615164565912277677884704888703982258184820398645933682814085602171910", token.State)
assert.Equal(t, "113Rq7d5grTGzqF7phKCRjxpC597eMa2USzm9rmpoj", token.ID)
//
state, err := token.VerifyState(context.Background(), os.Getenv("RPC_URL"), "0x035C4DBC897D203483D942696CE1dF5a9f933FcC")
assert.Nil(t, err)
Expand All @@ -347,72 +346,71 @@ func TestVerifyMessageWithAuthAndAtomicProofSig(t *testing.T) {

zkpAuth.ProofData = &types.ProofData{
A: []string{
"14577550064175748450987375704393907421920901508189337703397431390342898280710",
"2281752636269477429337220624909079669171458815254340085790599145888707827099",
"2370534291294441687575434871070063634049522739054135650290327914016792634144",
"18704664440065881255248484392571034267692380947539795837185393466696768539729",
"1",
},
B: [][]string{
{
"9892278221584481651733833641195128428650577799176543444926759323141284833312",
"1103007638015861371033094865422242272258878990152036520161116288875574588192",
"1593753415597360514506439944675236073038159742598884104707775208490282580641",
"15142074894866083200293799148931702287457526593114838706672766340147139402722",
},
{
"6922883339265533985243846004584074932233489016641091062635255509045633402568",
"13255178914414615598816442349245796924909724461658223751280894796264625158328",
"19117825221840408597122339519717065920080389822558089367138595722092823743944",
"2706264472260224656022451103720565978368804964791420659255319627595448027435",
},
{
"1",
"0",
}},
C: []string{
"11256651752290988174373131607181262214002388090610491351693173357538447781404",
"17144378915804146123122006704789555643110248683444179479923585102094009244340",
"156766304977057264803138092945401446963129379605822159500567538377014916135",
"10031227231200820171929683445407743402234929438478965985477678284516420821593",
"1",
},
}
zkpAuth.PubSignals = []string{
"1",
"15383795261052586569047113011994713909892315748410703061728793744343300034754",
"293373448908678327289599234275657468666604586273320428510206058753616052224",
"5816868615164565912277677884704888703982258184820398645933682814085602171910",
"286312392162647260160287083374160163061246635086990474403590223113720496128",
}

zkpAtomic := types.ZeroKnowledgeProof{
Type: types.ZeroKnowledgeProofType,
CircuitID: circuits.AtomicQuerySigCircuitID,
}

zkpAtomic.ProofData = &types.ProofData{
A: []string{
"12465280670657365433226224865892529503207144574637894382962625493757619787626",
"15012207483558904264831416397131118851104733604705425903485749683243428936592",
"21178773137304249408018096919215793146186660193600590200162998171616690680862",
"16723112137222954968898173855229909328853328041073537712042644179394618395718",
"1",
},
B: [][]string{
{
"412439141377866952477454598567421950746655843813188995168944029814518872322",
"20374285325125505729620771508216643263107098565427696359959945753828046881044",
"8154027924267780522239744810441934681489939329198303707054340169107503503140",
"13896707211429361892074216485456946320669555884653797826533153207946250359049",
},
{
"159502947195186816187264391919796562797634494575152224596662561523049770296",
"6579733386760647990935012601251534427203050677950319412886163814171698063944",
"8812219892284825088614656710055314118836154185354535911423155023728785526230",
"1137286278173265884575737920332918824261782651899335984176084421710066567443",
},
{
"1",
"0",
}},
C: []string{
"5043807054708372330667044611751061592100238827693737126158931668103103940552",
"2575070150656991149720237647769246226682466751291936304769200529372393624695",
"21449679392663656551219603482072298649562605845908654459293574785782180912646",
"3048812808090764561109652462842759548958106605480847082632940766239677991498",
"1",
},
}
zkpAtomic.PubSignals = []string{
"293373448908678327289599234275657468666604586273320428510206058753616052224",
"15383795261052586569047113011994713909892315748410703061728793744343300034754",
"286312392162647260160287083374160163061246635086990474403590223113720496128",
"5816868615164565912277677884704888703982258184820398645933682814085602171910",
"1",
"274380136414749538182079640726762994055",
"238622032992029818959027522035982899478798944063520057730894779896578244608",
"17696575440410541956651452069150743140855295736867783485086107762348968115816",
"296941560404583387587196218166209608454370683337298127000644446413747191808",
"13850938450891658391727543833954835315278162931905851620922327407976321180678",
"2",
"10",
"0",
Expand Down Expand Up @@ -440,8 +438,8 @@ func TestVerifyMessageWithAuthAndAtomicProofSig(t *testing.T) {

token, err := ExtractMetadata(&message)
assert.Nil(t, err)
assert.Equal(t, "15383795261052586569047113011994713909892315748410703061728793744343300034754", token.State)
assert.Equal(t, "11B34yHEY4tbE57kGKKFCHezo7rUBgouajFHeNszQm", token.ID)
assert.Equal(t, "5816868615164565912277677884704888703982258184820398645933682814085602171910", token.State)
assert.Equal(t, "113Rq7d5grTGzqF7phKCRjxpC597eMa2USzm9rmpoj", token.ID)
//
state, err := token.VerifyState(context.Background(), os.Getenv("RPC_URL"), "0x035C4DBC897D203483D942696CE1dF5a9f933FcC")
assert.Nil(t, err)
Expand Down
46 changes: 24 additions & 22 deletions communication/credentials/fetch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,32 +20,33 @@ func TestVerifyCredentialFetchRequest(t *testing.T) {

zkpProof.ProofData = &types.ProofData{
A: []string{
"11130843150540789299458990586020000719280246153797882843214290541980522375072",
"1300841912943781723022032355836893831132920783788455531838254465784605762713",
"1"},
"2370534291294441687575434871070063634049522739054135650290327914016792634144",
"18704664440065881255248484392571034267692380947539795837185393466696768539729",
"1",
},
B: [][]string{
{
"20615768536988438336537777909042352056392862251785722796637590212160561351656",
"10371144806107778890538857700855108667622042215096971747203105997454625814080",
"1593753415597360514506439944675236073038159742598884104707775208490282580641",
"15142074894866083200293799148931702287457526593114838706672766340147139402722",
},
{
"19598541350804478549141207835028671111063915635580679694907635914279928677812",
"15264553045517065669171584943964322117397645147006909167427809837929458012913",
"19117825221840408597122339519717065920080389822558089367138595722092823743944",
"2706264472260224656022451103720565978368804964791420659255319627595448027435",
},
{
"1",
"0",
}},
C: []string{
"16443309279825508893086251290003936935077348754097470818523558082502364822049",
"2984180227766048100510120407150752052334571876681304999595544138155611963273",
"156766304977057264803138092945401446963129379605822159500567538377014916135",
"10031227231200820171929683445407743402234929438478965985477678284516420821593",
"1",
},
}
zkpProof.PubSignals = []string{
"1",
"18311560525383319719311394957064820091354976310599818797157189568621466950811",
"323416925264666217617288569742564703632850816035761084002720090377353297920",
"5816868615164565912277677884704888703982258184820398645933682814085602171910",
"286312392162647260160287083374160163061246635086990474403590223113720496128",
}
message.Data.Scope = []interface{}{zkpProof}

Expand All @@ -66,32 +67,33 @@ func TestExtractDataFromCredentialFetchRequest(t *testing.T) {

zkpProof.ProofData = &types.ProofData{
A: []string{
"11130843150540789299458990586020000719280246153797882843214290541980522375072",
"1300841912943781723022032355836893831132920783788455531838254465784605762713",
"1"},
"2370534291294441687575434871070063634049522739054135650290327914016792634144",
"18704664440065881255248484392571034267692380947539795837185393466696768539729",
"1",
},
B: [][]string{
{
"20615768536988438336537777909042352056392862251785722796637590212160561351656",
"10371144806107778890538857700855108667622042215096971747203105997454625814080",
"1593753415597360514506439944675236073038159742598884104707775208490282580641",
"15142074894866083200293799148931702287457526593114838706672766340147139402722",
},
{
"19598541350804478549141207835028671111063915635580679694907635914279928677812",
"15264553045517065669171584943964322117397645147006909167427809837929458012913",
"19117825221840408597122339519717065920080389822558089367138595722092823743944",
"2706264472260224656022451103720565978368804964791420659255319627595448027435",
},
{
"1",
"0",
}},
C: []string{
"16443309279825508893086251290003936935077348754097470818523558082502364822049",
"2984180227766048100510120407150752052334571876681304999595544138155611963273",
"156766304977057264803138092945401446963129379605822159500567538377014916135",
"10031227231200820171929683445407743402234929438478965985477678284516420821593",
"1",
},
}
zkpProof.PubSignals = []string{
"1",
"18311560525383319719311394957064820091354976310599818797157189568621466950811",
"323416925264666217617288569742564703632850816035761084002720090377353297920",
"5816868615164565912277677884704888703982258184820398645933682814085602171910",
"286312392162647260160287083374160163061246635086990474403590223113720496128",
}
message.Data.Scope = []interface{}{zkpProof}

Expand Down
Loading

0 comments on commit 83e371b

Please sign in to comment.