From cbb402837cacf2e3990ff6cd40259d87acecd69b Mon Sep 17 00:00:00 2001 From: chabanyknikita Date: Wed, 28 Aug 2024 14:28:54 +0300 Subject: [PATCH] chnage some proof-parameters to default value --- internal/config/proof_parameters.go | 8 ++------ internal/config/verifier.go | 1 - internal/service/handlers/get_proof_parameters.go | 15 ++++++++++----- .../service/handlers/get_verification_status.go | 2 +- .../service/handlers/verification_callback.go | 6 +++--- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/internal/config/proof_parameters.go b/internal/config/proof_parameters.go index 6b875e1..6c3e635 100644 --- a/internal/config/proof_parameters.go +++ b/internal/config/proof_parameters.go @@ -12,12 +12,8 @@ type ProofParametersConfiger interface { } type ProofParametersConfig struct { - EventID string `fig:"event_id,required"` - TimestampLowerBound string `fig:"timestamp_lower_bound,required"` - TimestampUpperBound string `fig:"timestamp_upper_bound,required"` - ExpirationDateLowerBound string `fig:"expiration_date_lower_bound"` - ExpirationDateUpperBound string `fig:"expiration_date_upper_bound"` - BirthDateUpperBound string `fig:"birth_date_upper_bound,required"` + EventID string `fig:"event_id,required"` + TimestampUpperBound string `fig:"timestamp_upper_bound,required"` } type ProofParameters struct { diff --git a/internal/config/verifier.go b/internal/config/verifier.go index 9d6da26..96610c4 100644 --- a/internal/config/verifier.go +++ b/internal/config/verifier.go @@ -15,7 +15,6 @@ type Verifiers struct { func (c *config) Verifiers() Verifiers { return c.verifier.Do(func() interface{} { var cfg struct { - AllowedAge int `fig:"allowed_age,required"` VerificationKeyPath string `fig:"verification_key_path,required"` AllowedIdentityTimestamp int64 `fig:"allowed_identity_timestamp,required"` } diff --git a/internal/service/handlers/get_proof_parameters.go b/internal/service/handlers/get_proof_parameters.go index f43ba84..3adb914 100644 --- a/internal/service/handlers/get_proof_parameters.go +++ b/internal/service/handlers/get_proof_parameters.go @@ -20,6 +20,8 @@ const ( citizenshipBit = 5 timestampUpperBoundBit = 9 identityCounterUpperBoundBit = 11 + birthDateLowerboundBit = 19 + birthDateUpperboundBit = 20 expirationDateLowerboundBit = 21 expirationDateUpperbound = 22 ) @@ -79,9 +81,11 @@ func GetProofParameters(w http.ResponseWriter, r *http.Request) { identityCounterUpperBound: IdentityCounterUpperBound, timestampUpperBound: TimestampUpperBound, citizenshipMask: Utf8ToHex(userInputs.Nationality), - timestampLowerBound: ProofParameters(r).TimestampLowerBound, - birthDateLowerBound: CalculateBirthDateHex(userInputs.AgeLowerBound), - birthDateUpperBound: ProofParameters(r).BirthDateUpperBound, + timestampLowerBound: "0", + birthDateLowerBound: "0x303030303030", + birthDateUpperBound: CalculateBirthDateHex(userInputs.AgeLowerBound), + expirationDateUpperBound: "52983525027888", + expirationDateLowerBound: "52983525027888", } existingUser, err := VerifyUsersQ(r).WhereHashID(user.UserIDHash).Get() @@ -118,8 +122,8 @@ func NewProofParametersResponse(user data.VerifyUsers, params ProofParams) resou CitizenshipMask: params.citizenshipMask, EventData: user.UserIDHash, EventId: params.eventID, - ExpirationDateLowerBound: "52983525027888", - ExpirationDateUpperBound: "52983525027888", + ExpirationDateLowerBound: params.expirationDateLowerBound, + ExpirationDateUpperBound: params.expirationDateUpperBound, IdentityCounter: 0, IdentityCounterLowerBound: 0, IdentityCounterUpperBound: params.identityCounterUpperBound, @@ -160,6 +164,7 @@ func CalculateProofSelector(uniqueness bool) int { var bitLine uint32 bitLine |= 1 << nullifierBit bitLine |= 1 << citizenshipBit + bitLine |= 1 << birthDateLowerboundBit if uniqueness { bitLine |= 1 << timestampUpperBoundBit bitLine |= 1 << identityCounterUpperBoundBit diff --git a/internal/service/handlers/get_verification_status.go b/internal/service/handlers/get_verification_status.go index ca7f529..17c4e7b 100644 --- a/internal/service/handlers/get_verification_status.go +++ b/internal/service/handlers/get_verification_status.go @@ -19,7 +19,7 @@ func GetVerificationStatusById(w http.ResponseWriter, r *http.Request) { verifiedUser, err := VerifyUsersQ(r).WhereID(userID).Get() if err != nil { Log(r).WithError(err).Error("failed to get user by userID") - ape.RenderErr(w, problems.NotFound()) + ape.RenderErr(w, problems.InternalError()) return } if verifiedUser == nil { diff --git a/internal/service/handlers/verification_callback.go b/internal/service/handlers/verification_callback.go index e588f8d..815e746 100644 --- a/internal/service/handlers/verification_callback.go +++ b/internal/service/handlers/verification_callback.go @@ -50,14 +50,14 @@ func VerificationCallback(w http.ResponseWriter, r *http.Request) { selectorInt, err := strconv.Atoi(getter.Get(zk.Selector)) if err != nil { - Log(r).Error("cannot extract selector from public signals") + Log(r).WithError(err).Errorf("cannot extract selector from public signals") ape.RenderErr(w, problems.InternalError()) return } identityCounterUpperBound, err := strconv.ParseInt(getter.Get(zk.IdentityCounterUpperBound), 10, 64) if err != nil { - Log(r).Error("cannot extract identityUpperBound from public signals") + Log(r).WithError(err).Errorf("cannot extract identityUpperBound from public signals") ape.RenderErr(w, problems.InternalError()) return } @@ -86,7 +86,7 @@ func VerificationCallback(w http.ResponseWriter, r *http.Request) { zk.WithCitizenships(verifiedUser.Nationality), zk.WithProofSelectorValue(getter.Get(zk.Selector)), zk.WithIdentitiesCounter(identityCounterUpperBound), - //zk.WithAgeAbove(verifiedUser.AgeLowerBound), + zk.WithAgeAbove(verifiedUser.AgeLowerBound), } err = Verifiers(r).Passport.VerifyProof(*proof, verifyOpts...) if err != nil {