auth

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2024 License: Apache-2.0 Imports: 8 Imported by: 1

Documentation

Overview

Package auth contains any known Authenticator extensions that may be selected at build-time for use in kwild. Authenticator extensions are used to expand the type of signatures that may be verified, and define address derivation for the public keys of the corresponding type.

Build constraints a.k.a. build tags are used to enable extensions in a kwild binary. See README.md in the extensions package for more information.

Index

Constants

View Source
const (
	// Ed25519Sha256Auth is the authenticator name
	// the "nr" suffix is for NEAR, and provides backwards compatibility
	Ed25519Sha256Auth = "ed25519_nr"
)

Variables

View Source
var (
	// ErrAuthenticatorExists is returned when an authenticator is already registered
	ErrAuthenticatorExists = errors.New("authenticator already exists")
	// ErrAuthenticatorNotFound is returned when an authenticator is not found
	ErrAuthenticatorNotFound = errors.New("authenticator not found")
)

Functions

func GetAuthenticator

func GetAuthenticator(name string) (auth.Authenticator, error)

getAuthenticator returns an authenticator by the name it was registered with

func RegisterAuthenticator

func RegisterAuthenticator(mod ModOperation, name string, auth auth.Authenticator) error

RegisterAuthenticator registers, removes, or updates an authenticator with the Kwil network.

Types

type Ed22519Sha256Authenticator added in v0.8.1

type Ed22519Sha256Authenticator struct{}

Ed22519Sha256Authenticator is an authenticator that applies the sha256 hash to the message before verifying the signature. This is a common standard in ecosystems like NEAR.

func (Ed22519Sha256Authenticator) Identifier added in v0.8.1

func (e Ed22519Sha256Authenticator) Identifier(publicKey []byte) (string, error)

Identifier returns the hex-encoded public key as the identifier. The input must be a 32-byte ed25519 public key.

func (Ed22519Sha256Authenticator) Verify added in v0.8.1

func (e Ed22519Sha256Authenticator) Verify(publicKey []byte, msg []byte, signature []byte) error

Verify verifies the signature against the given public key and data.

type ModOperation added in v0.8.1

type ModOperation int8

ModOperation is the type used to enumerate authenticator modifications.

const (
	ModRemove ModOperation = iota - 1
	ModUpdate
	ModAdd
)

Resolutions may be removed, updated, or added.

Jump to

Keyboard shortcuts

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