crypto

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package crypto provides the cryptographic primitives used by the Pocket Network. This includes the RingCache used to build and cache rings used for signing relays, and may expand to include other cryptographic primitives in the future.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PubKeyClient

type PubKeyClient interface {
	// GetPubKeyFromAddress returns the public key of the given account address
	// if it exists.
	GetPubKeyFromAddress(ctx context.Context, address string) (cryptotypes.PubKey, error)
}

PubKeyClient is used to get the public key given an address. On-chain and off-chain implementations should take care of retrieving the address' account and returning its public key.

type RingCache

type RingCache interface {
	RingClient

	// GetCachedAddresses returns the addresses of the applications that are
	// currently cached in the ring cache.
	GetCachedAddresses() []string
	// Start starts the ring cache, it takes a cancellable context and, in a
	// separate goroutine, listens for on-chain delegation events and invalidates
	// the cache if the redelegation event's AppAddress is stored in the cache.
	Start(ctx context.Context)
	// Stop stops the ring cache by unsubscribing from on-chain delegation events.
	// And clears the cache, so that it no longer contains any rings,
	Stop()
}

RingCache is used to store rings used for signing and verifying relay requests. It will cache rings for future use after querying the application module for the addresses of the gateways the application is delegated to, and converting them into their corresponding public key points on the secp256k1 curve.

type RingClient

type RingClient interface {
	// GetRingForAddressAtHeight returns the ring for the given application address
	// and blockHeight if it exists.
	GetRingForAddressAtHeight(
		ctx context.Context,
		appAddress string,
		blockHeight int64,
	) (*ring.Ring, error)

	// VerifyRelayRequestSignature verifies the relay request signature against
	// the ring for the application address in the relay request.
	VerifyRelayRequestSignature(ctx context.Context, relayRequest *types.RelayRequest) error
}

RingClient is used to construct rings by querying the application module for the addresses of the gateways the application delegated to, and converting them into their corresponding public key points on the secp256k1 curve.

Directories

Path Synopsis
Package rings provides the RingCache interface that is used to build rings for applications by either the application itself or a gateway.
Package rings provides the RingCache interface that is used to build rings for applications by either the application itself or a gateway.

Jump to

Keyboard shortcuts

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