From 5ec1e146c13b511f93d4e387016b3b30c5c22fe4 Mon Sep 17 00:00:00 2001 From: Maksym Hrynenko Date: Wed, 5 Jun 2024 19:21:46 +0300 Subject: [PATCH 1/2] update: zkverifier kit version, verify proof with decoded rarimo addr --- go.mod | 2 +- go.sum | 10 ++-------- internal/service/handlers/create_airdrop.go | 13 ++++++++++++- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/go.mod b/go.mod index 797d42c..f79589b 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/go-ozzo/ozzo-validation/v4 v4.3.0 github.com/iden3/go-rapidsnark/types v0.0.3 github.com/rarimo/rarimo-core v0.0.0-20231004143803-6b209428ecbf - github.com/rarimo/zkverifier-kit v0.2.2-rc.2 + github.com/rarimo/zkverifier-kit v0.2.2-rc.3 github.com/rubenv/sql-migrate v1.6.1 gitlab.com/distributed_lab/ape v1.7.1 gitlab.com/distributed_lab/figure/v3 v3.1.4 diff --git a/go.sum b/go.sum index fd36ecb..c4553c4 100644 --- a/go.sum +++ b/go.sum @@ -2106,14 +2106,8 @@ github.com/rarimo/cosmos-sdk v0.46.7 h1:jU2PiWzc+19SF02cXM0O0puKPeH1C6Q6t2lzJ9s1 github.com/rarimo/cosmos-sdk v0.46.7/go.mod h1:fqKqz39U5IlEFb4nbQ72951myztsDzFKKDtffYJ63nk= github.com/rarimo/rarimo-core v0.0.0-20231004143803-6b209428ecbf h1:NvYhOErW0d7ohn2YzGxQYKssrgVrKOvjrKL1OBQgCB4= github.com/rarimo/rarimo-core v0.0.0-20231004143803-6b209428ecbf/go.mod h1:Onkd0EJP94hw4dT/2KH7QXRwDG4eIGeaMffSjA1i6/s= -github.com/rarimo/zkverifier-kit v0.2.1-rc.4 h1:ZpCY2toKFroHK6lpttrkZ0wvb27JbZU5L15N8KSfblc= -github.com/rarimo/zkverifier-kit v0.2.1-rc.4/go.mod h1:3YDg5dTkDRr4IdfaDHGYetopd6gS/2SuwSeseYTWwNw= -github.com/rarimo/zkverifier-kit v0.2.1-rc.5 h1:NN7iW40q3p6EIfAd7bxF0XdisV8AyrMQJ3g28FUstZw= -github.com/rarimo/zkverifier-kit v0.2.1-rc.5/go.mod h1:3YDg5dTkDRr4IdfaDHGYetopd6gS/2SuwSeseYTWwNw= -github.com/rarimo/zkverifier-kit v0.2.1 h1:t/5L27RIKQEtXmocPcNeta3XV5oxz891g8NFCLeIsao= -github.com/rarimo/zkverifier-kit v0.2.1/go.mod h1:3YDg5dTkDRr4IdfaDHGYetopd6gS/2SuwSeseYTWwNw= -github.com/rarimo/zkverifier-kit v0.2.2-rc.2 h1:jjdbYH33yzsb0NHGm9TXkG9yKVBYX3GrX8XIc/Z2rAk= -github.com/rarimo/zkverifier-kit v0.2.2-rc.2/go.mod h1:3YDg5dTkDRr4IdfaDHGYetopd6gS/2SuwSeseYTWwNw= +github.com/rarimo/zkverifier-kit v0.2.2-rc.3 h1:QarWLZxDpng8FeNZ6LxO+0RBEB88N9fqnCFpC0MgQBE= +github.com/rarimo/zkverifier-kit v0.2.2-rc.3/go.mod h1:3YDg5dTkDRr4IdfaDHGYetopd6gS/2SuwSeseYTWwNw= github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 h1:N/ElC8H3+5XpJzTSTfLsJV/mx9Q9g7kxmchpfZyxgzM= github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/regen-network/cosmos-proto v0.3.1 h1:rV7iM4SSFAagvy8RiyhiACbWEGotmqzywPxOvwMdxcg= diff --git a/internal/service/handlers/create_airdrop.go b/internal/service/handlers/create_airdrop.go index aaddccf..9b9602d 100644 --- a/internal/service/handlers/create_airdrop.go +++ b/internal/service/handlers/create_airdrop.go @@ -4,12 +4,14 @@ import ( "errors" "net/http" + "github.com/cosmos/cosmos-sdk/types" "github.com/rarimo/airdrop-svc/internal/data" "github.com/rarimo/airdrop-svc/internal/service/requests" zk "github.com/rarimo/zkverifier-kit" "github.com/rarimo/zkverifier-kit/identity" "gitlab.com/distributed_lab/ape" "gitlab.com/distributed_lab/ape/problems" + "gitlab.com/distributed_lab/logan/v3" ) // Full list of the OpenSSL signature algorithms and hash-functions is provided here: @@ -38,7 +40,16 @@ func CreateAirdrop(w http.ResponseWriter, r *http.Request) { return } - err = Verifier(r).VerifyProof(req.Data.Attributes.ZkProof, zk.WithRarimoAddress(req.Data.Attributes.Address)) + addr, err := types.AccAddressFromBech32(req.Data.Attributes.Address) + if err != nil { + Log(r).WithError(err).WithFields(logan.F{ + "address": req.Data.Attributes.Address, + }).Error("Failed to decode hex ethereum address") + ape.RenderErr(w, problems.InternalError()) + return + } + + err = Verifier(r).VerifyProof(req.Data.Attributes.ZkProof, zk.WithEventData(addr.Bytes())) if err != nil { if errors.Is(err, identity.ErrContractCall) { Log(r).WithError(err).Error("Failed to verify proof") From 5ef9cf996b4728d39d365698d85c0622a0739e2a Mon Sep 17 00:00:00 2001 From: Maksym Hrynenko Date: Thu, 6 Jun 2024 14:07:48 +0300 Subject: [PATCH 2/2] update: but zkverifier version --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index f79589b..e5c9918 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/go-ozzo/ozzo-validation/v4 v4.3.0 github.com/iden3/go-rapidsnark/types v0.0.3 github.com/rarimo/rarimo-core v0.0.0-20231004143803-6b209428ecbf - github.com/rarimo/zkverifier-kit v0.2.2-rc.3 + github.com/rarimo/zkverifier-kit v0.2.2 github.com/rubenv/sql-migrate v1.6.1 gitlab.com/distributed_lab/ape v1.7.1 gitlab.com/distributed_lab/figure/v3 v3.1.4 diff --git a/go.sum b/go.sum index c4553c4..c849f31 100644 --- a/go.sum +++ b/go.sum @@ -2108,6 +2108,8 @@ github.com/rarimo/rarimo-core v0.0.0-20231004143803-6b209428ecbf h1:NvYhOErW0d7o github.com/rarimo/rarimo-core v0.0.0-20231004143803-6b209428ecbf/go.mod h1:Onkd0EJP94hw4dT/2KH7QXRwDG4eIGeaMffSjA1i6/s= github.com/rarimo/zkverifier-kit v0.2.2-rc.3 h1:QarWLZxDpng8FeNZ6LxO+0RBEB88N9fqnCFpC0MgQBE= github.com/rarimo/zkverifier-kit v0.2.2-rc.3/go.mod h1:3YDg5dTkDRr4IdfaDHGYetopd6gS/2SuwSeseYTWwNw= +github.com/rarimo/zkverifier-kit v0.2.2 h1:U2NrGQicGN/dNxYgEzbKO061ooCu2LTDoVL8cOLJdHw= +github.com/rarimo/zkverifier-kit v0.2.2/go.mod h1:3YDg5dTkDRr4IdfaDHGYetopd6gS/2SuwSeseYTWwNw= github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 h1:N/ElC8H3+5XpJzTSTfLsJV/mx9Q9g7kxmchpfZyxgzM= github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/regen-network/cosmos-proto v0.3.1 h1:rV7iM4SSFAagvy8RiyhiACbWEGotmqzywPxOvwMdxcg=