rln

package
v0.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 14, 2023 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BytesToRateLimitProof added in v0.9.0

func BytesToRateLimitProof(data []byte) (*rln.RateLimitProof, error)

Bytres2RateLimitProof converts a slice of bytes into a RateLimitProof instance

func GetRLNInstanceAndRootTracker added in v0.8.0

func GetRLNInstanceAndRootTracker(treePath string) (*rln.RLN, *group_manager.MerkleRootTracker, error)

Types

type Metrics added in v0.8.0

type Metrics interface {
	RecordMessage()
	RecordSpam(contentTopic string)
	RecordInvalidMessage(cause invalidCategory)
	RecordError(err errCategory)
	RecordProofVerification(duration time.Duration)
	RecordProofGeneration(duration time.Duration)
	RecordValidMessages(rootIndex int)
	RecordInstanceCreation(duration time.Duration)
}

Metrics exposes the functions required to update prometheus metrics for lightpush protocol

type NullifierLog added in v0.8.0

type NullifierLog struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

NullifierLog is the log of nullifiers and Shamir shares of the past messages grouped per epoch

func NewNullifierLog added in v0.8.0

func NewNullifierLog(ctx context.Context, log *zap.Logger) *NullifierLog

NewNullifierLog creates an instance of NullifierLog

func (*NullifierLog) HasDuplicate added in v0.8.0

func (n *NullifierLog) HasDuplicate(proofMD rln.ProofMetadata) (bool, error)

HasDuplicate returns true if there is another message in the `nullifierLog` with the same epoch and nullifier as `msg`'s epoch and nullifier but different Shamir secret shares otherwise, returns false

func (*NullifierLog) Insert added in v0.8.0

func (n *NullifierLog) Insert(proofMD rln.ProofMetadata) error

Insert stores a proof in the nullifier log only if it doesnt exist already

type RegistrationHandler

type RegistrationHandler = func(tx *types.Transaction)

type SpamHandler

type SpamHandler = func(msg *pb.WakuMessage, topic string) error

type WakuRLNRelay

type WakuRLNRelay struct {
	group_manager.Details
	// contains filtered or unexported fields
}

func New added in v0.6.0

func (*WakuRLNRelay) AppendRLNProof

func (rlnRelay *WakuRLNRelay) AppendRLNProof(msg *pb.WakuMessage, senderEpochTime time.Time) error

func (*WakuRLNRelay) IdentityCredential added in v0.6.0

func (rlnRelay *WakuRLNRelay) IdentityCredential() (rln.IdentityCredential, error)

func (*WakuRLNRelay) IsReady added in v0.8.0

func (rlnRelay *WakuRLNRelay) IsReady(ctx context.Context) (bool, error)

IsReady returns true if the RLN Relay protocol is ready to relay messages

func (*WakuRLNRelay) MembershipIndex

func (rlnRelay *WakuRLNRelay) MembershipIndex() uint

func (*WakuRLNRelay) Start added in v0.6.0

func (rlnRelay *WakuRLNRelay) Start(ctx context.Context) error

func (*WakuRLNRelay) Stop

func (rlnRelay *WakuRLNRelay) Stop() error

Stop will stop any operation or goroutine started while using WakuRLNRelay

func (*WakuRLNRelay) ValidateMessage

func (rlnRelay *WakuRLNRelay) ValidateMessage(msg *pb.WakuMessage, optionalTime *time.Time) (messageValidationResult, error)

ValidateMessage validates the supplied message based on the waku-rln-relay routing protocol i.e., the message's epoch is within `maxEpochGap` of the current epoch the message's has valid rate limit proof the message's does not violate the rate limit if `optionalTime` is supplied, then the current epoch is calculated based on that, otherwise the current time will be used

func (*WakuRLNRelay) Validator added in v0.8.0

func (rlnRelay *WakuRLNRelay) Validator(
	spamHandler SpamHandler) func(ctx context.Context, msg *pb.WakuMessage, topic string) bool

Validator returns a validator for the waku messages. The message validation logic is according to https://rfc.vac.dev/spec/17/

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL