Skip to content

Commit

Permalink
update: zkverifier version, verifying proof by decoded eth addr
Browse files Browse the repository at this point in the history
  • Loading branch information
mhrynenko committed Jun 5, 2024
1 parent 2d77f85 commit 100937d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require (
github.com/go-chi/chi v4.1.2+incompatible
github.com/go-ozzo/ozzo-validation/v4 v4.3.0
github.com/iden3/go-rapidsnark/types v0.0.3
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/dig v0.0.0-20230207152643-c44f80a4294c
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2088,6 +2088,8 @@ github.com/rarimo/zkverifier-kit v0.2.2-rc.1 h1:IHf+Ctl/ilHxK37r6oJmhxNUz/tTWB6i
github.com/rarimo/zkverifier-kit v0.2.2-rc.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/protobuf v1.3.3-alpha.regen.1 h1:OHEc+q5iIAXpqiqFKeLpu5NwTIkVXUs48vFMwzqpqY4=
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/ethereum/go-ethereum/common/hexutil"
"github.com/rarimo/evm-airdrop-svc/internal/data"
"github.com/rarimo/evm-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.WithEthereumAddress(req.Data.Attributes.Address))
decodedAddress, err := hexutil.Decode(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(decodedAddress))
if err != nil {
if errors.Is(err, identity.ErrContractCall) {
Log(r).WithError(err).Error("Failed to verify proof")
Expand Down

0 comments on commit 100937d

Please sign in to comment.