Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standardizing Rate Limiter #23

Open
ChihChengLiang opened this issue Apr 19, 2020 · 0 comments
Open

Standardizing Rate Limiter #23

ChihChengLiang opened this issue Apr 19, 2020 · 0 comments

Comments

@ChihChengLiang
Copy link
Owner

ChihChengLiang commented Apr 19, 2020

In a web service where a user interacts with the service with their registered account, the service can rate limit behaviors of the user by banning or suspending their account. In the setting of Semaphore, where users are anonymous, External Nullifiers are used to rate-limit the user.

An external nullifier can be treated as a topic and a user is only allowed to act to that topic at most once. Standardizing how we format external nullifier string can help developers quickly define an effective one for their use case and prevent shooting themselves in their feet.

The external nullifier "string" should be kept public so that each component in the string can be validated. Then the circuit will take the external nullifier "hash" as input, which is the hash generated by feeding the string to genExternalNullifier from libsemaphore.

Proposed format

version:service:subject_uri:verb_uri:epoch:nonce

Example format:

v1:hojicha:group/123:post:1586328000000:1
  • version: this ensures backward compatibility for future change in the standard.
  • service: prevents a signal to be replayed on other services.
  • subject_uri and verb_uri (high uncertainty here)

Frequency parameters:

  • epoch: define how frequent a user can perform actions. Use _ for pure nonce based rate limit strategy. Put the timestamp value of the epoch start here.
d = new Date()
d.valueOf() - (d.valueOf() % (30*1000))
  • nonce: define how many times an action can be performed in an epoch. Use _ for pure epoch based rate limit strategy.

Should we specify epoch length on the string?

Use case example

Posting article

Rate limit article posting to every 30 secs.

v1:hojicha:group/123:post:1587281460000:_

Commenting on an article

Rate limit article commenting to 5 times every 30 secs.

v1:hojicha:post/1:comment:1587281460000:1

Subscribe to a service

VPN service plan that allows 3000 logins a year

v1:hojicha_vpn:basic_plan:login:1576800000000:1055

Remove a group

Defining both frequency parameters as _ is a YOLO external nullifier.

Example:

User can signal their support to remove a group.

v1:hojicha:group123:self_destruct:_:_
@ChihChengLiang ChihChengLiang changed the title Standardizing Rate limiter Standardizing Rate Limiter Apr 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant