crypt

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2025 License: MIT Imports: 14 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decrypt

func Decrypt(buf []byte, key []byte) ([]byte, error)

Decrypt decrypts buf using key with AES-GCM AEAD mode.

func Encrypt

func Encrypt(buf []byte, key []byte) ([]byte, error)

Encrypt encrypts buf using key with AES-GCM AEAD mode, nonce is prepended to encrypted text and result is hex encoded.

func HandleWithEncryption

func HandleWithEncryption(provider secretProvider, handler http.Handler) http.HandlerFunc

HandleWithEncryption returns a http handler function that encrypts content returned by handler using key provided by secretProvider.

func Sign

func Sign(privateKey *ecdsa.PrivateKey, message string) (string, error)

Sign signs a message with an ECDSA private key. Returns signature in 0x string format.

func SignWithTimestamp

func SignWithTimestamp(privateKey *ecdsa.PrivateKey, message string) (string, string, error)

SignWithTimestamp signs a message with an ECDSA private key. Returns signature in 0x string format.

func ValidateSignedMessage deprecated

func ValidateSignedMessage(message string, signature string) (common.Address, error)

ValidateSignedMessage validates a signed message and returns wallet address from signature. Expects signature in 0x string format (hex).

Deprecated: ValidateSignedMessage is half-broken, as it does not check that the signature matches the message. You instead have to rely on checking the returned address matches the expected one. Use VerifySignedMessage instead.

func VerifySignedMessage added in v0.1.15

func VerifySignedMessage(publicKey *ecdsa.PublicKey, message, signature string) (common.Address, error)

VerifySignedMessage verifies a signed message against a public key and returns matching wallet address. Expects signature in 0x string format (hex).

Types

type HagallSecretProvider

type HagallSecretProvider struct {
	// contains filtered or unexported fields
}

A secret provider using Hagall token from HDS client.

func NewHagallSecretProvider

func NewHagallSecretProvider(client hdsClient) HagallSecretProvider

Returns a new HagallSecretProvider.

func (HagallSecretProvider) GetKey

func (h HagallSecretProvider) GetKey() ([]byte, error)

GetKey generates a 256-bit key using sha256 hash of Hagall secret with cache.

Jump to

Keyboard shortcuts

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