Thetaskofazero-knowledgeproofsystemisto"proveafactwithoutrevealingknowledge."Let'sstartwithanimage:Therearenumerouspenguinsinit.However,apuffinlookslikeapenguin(below).Thesituationisthatyouknowwherethispuffinishiding,butyoudon'twanttotellothersexactlywhereitis.Whatcanyoudotoprovetoothersthatyouknowt
Themidlifecrisis,particularlythe35-year-oldproblem,appearstohavebecomeawidespreadworryinChina'sInternetbusiness,wheremanyprogrammershavebeguntoexperienceit.ThisissuehasgainedevenmoreattentionasZhouHongyi,thefounderandCEOofChinesecybersecuritycompanyQihoo360,declaredinavideothatthe35-year-olddilemmaf
Themidlifecrisis,particularlythe35-year-oldproblem,appearstohavebecomeawidespreadworryinChina'sInternetbusiness,wheremanyprogrammershavebeguntoexperienceit.ThisissuehasgainedevenmoreattentionasZhouHongyi,thefounderandCEOofChinesecybersecuritycompanyQihoo360,declaredinavideothatthe35-year-olddilemmaf
首先,让我们定义一个规则:用户只能访问自己创建的文章。facades.Gate.Define("update-post",func(ctxcontext.Context,argumentsmap[string]any)*access.Response{user:=ctx.Value("user").(models.User)post:=arguments["post"].(models.Post)ifuser.ID==post.UserID{returnaccess.NewAllowResponse()}else{returnaccess.NewDenyResponse("error")}})
首先,让我们定义一个规则:用户只能访问自己创建的文章。facades.Gate.Define("update-post",func(ctxcontext.Context,argumentsmap[string]any)*access.Response{user:=ctx.Value("user").(models.User)post:=arguments["post"].(models.Post)ifuser.ID==post.UserID{returnaccess.NewAllowResponse()}else{returnaccess.NewDenyResponse("error")}})