diff --git a/go.mod b/go.mod index 797d42c..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.2 + 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 fd36ecb..c849f31 100644 --- a/go.sum +++ b/go.sum @@ -2106,14 +2106,10 @@ 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/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= 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")