delphi

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2024 License: MIT Imports: 14 Imported by: 6

README

Go Delphi

Delphi provides primitives needed for Oracles to handle cryptic messages.

Documentation

Index

Constants

View Source
const ByteSize = 128
View Source
const GLOBAL_SALT = "oracle/v1"

Variables

View Source
var ErrDecryptionFailed = errors.New("decryption failed")
View Source
var ErrEncryptionFailed = errors.New("encryption failed")
View Source
var ErrNoEphemeralKey = errors.New("no ephemeral key")
View Source
var ErrNotImplemented = errors.New("not implemented")
View Source
var UniversalNonce []byte = make([]byte, chacha20poly1305.NonceSize)

Functions

func NewPrincipal

func NewPrincipal(randy io.Reader) principal

Types

type Certifier

type Certifier interface {
	crypto.PrivateKey
	crypto.Signer
	Verifier
}

a Certifier can produce and verify signatures

type Cipherer

type Cipherer interface {
	crypto.PrivateKey
	Encrypter
	crypto.Decrypter
}

a Cipherer can encrypt and decrypt an [Envelope]

type CryptOpts

type CryptOpts struct {
	Nonce []byte
	AAED  []byte
}

type Encrypter

type Encrypter interface {
	Encrypt(msg []byte, recipient crypto.PublicKey, opts any) ([]byte, error)
}

type Message

type Message struct {
	To                 *ecdh.PublicKey
	From               *ecdh.PublicKey
	Metadata           *stablemap.StableMap[string, any] // additional authenticated data (AAD)
	EphemeralPublicKey []byte
	Nonce              []byte
	CipherText         []byte
	PlainText          []byte
	Signature          []byte
}

func NewMessage

func NewMessage(plainTxt []byte) *Message

func (*Message) Decrypt

func (msg *Message) Decrypt(recipientPrivKey *ecdh.PrivateKey) error

func (*Message) Encrypt

func (msg *Message) Encrypt(randomness io.Reader) error

func (*Message) MarhsalBinary

func (m *Message) MarhsalBinary() ([]byte, error)

func (*Message) UnmarshalBinary

func (m *Message) UnmarshalBinary(p []byte) error

type Principal

a Principal is a holder of a public/private key-pair that can perform encryption, decryption, signing, and verifying operations.

type Verifier

type Verifier interface {
	Verify(pub crypto.PublicKey, msg []byte, sig []byte) bool
}

Jump to

Keyboard shortcuts

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