Skip to content

Commit

Permalink
chnage some proof-parameters to default value
Browse files Browse the repository at this point in the history
  • Loading branch information
chabanyknikita committed Aug 28, 2024
1 parent 1fc1b26 commit cbb4028
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
8 changes: 2 additions & 6 deletions internal/config/proof_parameters.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 0 additions & 1 deletion internal/config/verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
Expand Down
15 changes: 10 additions & 5 deletions internal/service/handlers/get_proof_parameters.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ const (
citizenshipBit = 5
timestampUpperBoundBit = 9
identityCounterUpperBoundBit = 11
birthDateLowerboundBit = 19
birthDateUpperboundBit = 20
expirationDateLowerboundBit = 21
expirationDateUpperbound = 22
)
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion internal/service/handlers/get_verification_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions internal/service/handlers/verification_callback.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit cbb4028

Please sign in to comment.