rln

package
v0.2.3-test Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2022 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const AcceptableRootWindowSize = 5
View Source
const MAX_CLOCK_GAP_SECONDS = 20

the maximum clock difference between peers in seconds

maximum allowed gap between the epochs of messages' RateLimitProofs

Variables

View Source
var MEMBERSHIP_FEE = big.NewInt(1000000000000000) // wei - 0.001 eth

Functions

func StaticSetup

func StaticSetup(rlnRelayMemIndex r.MembershipIndex) ([]r.IDCommitment, r.MembershipKeyPair, r.MembershipIndex, error)

func ToRateLimitProof

func ToRateLimitProof(msg *pb.WakuMessage) *r.RateLimitProof

Types

type MessageValidationResult

type MessageValidationResult int
const (
	MessageValidationResult_Unknown MessageValidationResult = iota
	MessageValidationResult_Valid
	MessageValidationResult_Invalid
	MessageValidationResult_Spam
)

type RegistrationEventHandler

type RegistrationEventHandler = func(pubkey r.IDCommitment, index r.MembershipIndex) error

the types of inputs to this handler matches the MemberRegistered event/proc defined in the MembershipContract interface

type RegistrationHandler

type RegistrationHandler = func(tx *types.Transaction)

type SpamHandler

type SpamHandler = func(message *pb.WakuMessage) error

type WakuRLNRelay

type WakuRLNRelay struct {
	RLN *r.RLN
	// contains filtered or unexported fields
}

func RlnRelayDynamic

func RlnRelayDynamic(
	ctx context.Context,
	relay *relay.WakuRelay,
	ethClientAddr string,
	ethAccountPrivateKey *ecdsa.PrivateKey,
	memContractAddr common.Address,
	memKeyPair *r.MembershipKeyPair,
	memIndex r.MembershipIndex,
	pubsubTopic string,
	contentTopic string,
	spamHandler SpamHandler,
	registrationHandler RegistrationHandler,
	log *zap.Logger,
) (*WakuRLNRelay, error)

func RlnRelayStatic

func RlnRelayStatic(
	ctx context.Context,
	relay *relay.WakuRelay,
	group []r.IDCommitment,
	memKeyPair r.MembershipKeyPair,
	memIndex r.MembershipIndex,
	pubsubTopic string,
	contentTopic string,
	spamHandler SpamHandler,
	log *zap.Logger,
) (*WakuRLNRelay, error)

func (*WakuRLNRelay) AppendRLNProof

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

func (*WakuRLNRelay) HandleGroupUpdates

func (rln *WakuRLNRelay) HandleGroupUpdates(handler RegistrationEventHandler, errChan chan<- error)

HandleGroupUpdates mounts the supplied handler for the registration events emitting from the membership contract It connects to the eth client, subscribes to the `MemberRegistered` event emitted from the `MembershipContract` and collects all the events, for every received event, it calls the `handler`

func (*WakuRLNRelay) HasDuplicate

func (rln *WakuRLNRelay) HasDuplicate(msg *pb.WakuMessage) (bool, error)

func (*WakuRLNRelay) MembershipContractAddress

func (r *WakuRLNRelay) MembershipContractAddress() common.Address

func (*WakuRLNRelay) MembershipIndex

func (r *WakuRLNRelay) MembershipIndex() r.MembershipIndex

func (*WakuRLNRelay) MembershipKeyPair

func (r *WakuRLNRelay) MembershipKeyPair() *r.MembershipKeyPair

func (*WakuRLNRelay) Register

func (rln *WakuRLNRelay) Register(ctx context.Context) (*r.MembershipIndex, error)

Register registers the public key of the rlnPeer which is rlnPeer.membershipKeyPair.publicKey into the membership contract whose address is in rlnPeer.membershipContractAddress

func (*WakuRLNRelay) Stop

func (rln *WakuRLNRelay) Stop()

func (*WakuRLNRelay) ValidateMessage

func (rln *WakuRLNRelay) ValidateMessage(msg *pb.WakuMessage, optionalTime *time.Time) (MessageValidationResult, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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