Skip to content

Commit

Permalink
update: zkverifier kit version, verify proof with decoded rarimo addr
Browse files Browse the repository at this point in the history
  • Loading branch information
mhrynenko committed Jun 5, 2024
1 parent 265fb63 commit 5ec1e14
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 2 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
13 changes: 12 additions & 1 deletion internal/service/handlers/create_airdrop.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit 5ec1e14

Please sign in to comment.