rln

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2022 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const AssetDebug = false

AssetDebug is true if the assets were built with the debug flag enabled.

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 Asset

func Asset(name string) ([]byte, error)

Asset loads and returns the asset for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetDigest

func AssetDigest(name string) ([sha256.Size]byte, error)

AssetDigest returns the digest of the file with the given name. It returns an error if the asset could not be found or the digest could not be loaded.

func AssetDir

func AssetDir(name string) ([]string, error)

AssetDir returns the file names below a certain directory embedded in the file by go-bindata. For example if you run go-bindata on data/... and data contains the following hierarchy:

data/
  foo.txt
  img/
    a.png
    b.png

then AssetDir("data") would return []string{"foo.txt", "img"}, AssetDir("data/img") would return []string{"a.png", "b.png"}, AssetDir("foo.txt") and AssetDir("notexist") would return an error, and AssetDir("") will return []string{"data"}.

func AssetInfo

func AssetInfo(name string) (os.FileInfo, error)

AssetInfo loads and returns the asset info for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetNames

func AssetNames() []string

AssetNames returns the names of the assets.

func AssetString

func AssetString(name string) (string, error)

AssetString returns the asset contents as a string (instead of a []byte).

func Bytes256

func Bytes256(b []byte) [256]byte

func Bytes32

func Bytes32(b []byte) [32]byte

func Digests

func Digests() (map[string][sha256.Size]byte, error)

Digests returns a map of all known files and their checksums.

func MustAsset

func MustAsset(name string) []byte

MustAsset is like Asset but panics when Asset would return an error. It simplifies safe initialization of global variables.

func MustAssetString

func MustAssetString(name string) string

MustAssetString is like AssetString but panics when Asset would return an error. It simplifies safe initialization of global variables.

func RestoreAsset

func RestoreAsset(dir, name string) error

RestoreAsset restores an asset under the given directory.

func RestoreAssets

func RestoreAssets(dir, name string) error

RestoreAssets restores an asset under the given directory recursively.

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 added in v0.2.2

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) 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