delphi

package module
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2024 License: MIT Imports: 15 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 ErrBadKey = errors.New("bad key")
View Source
var ErrDecryptionFailed = errors.New("decryption failed")
View Source
var ErrDelphi = errors.New("delphi")
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 NewSubKey added in v0.0.4

func NewSubKey(randy io.Reader) subKey

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
	Decrypter
}

a Cipherer can encrypt and decrypt a [message]

type CryptOpts

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

type Decrypter added in v0.0.4

type Decrypter interface {
	Decrypt(*Message, crypto.DecrypterOpts) error
}

type Encrypter

type Encrypter interface {
	Encrypt(io.Reader, *Message, EncrypterOpts) error
}

type EncrypterOpts added in v0.0.4

type EncrypterOpts = any

type IPrincipal added in v0.0.5

type IPrincipal interface {
	Cipherer
	Certifier
	encoding.BinaryMarshaler
	encoding.BinaryUnmarshaler
	PublicKey() Key
	PrivateKey() Key
}

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

type Key added in v0.0.5

type Key [2]subKey

a Key is two (specifically one encryption and one signing) subKeys

func KeyFromBytes added in v0.0.3

func KeyFromBytes(b []byte) Key

func KeyFromHex added in v0.0.5

func KeyFromHex(str string) Key

func NewKey added in v0.0.4

func NewKey(randy io.Reader) Key

func (Key) Bytes added in v0.0.5

func (k Key) Bytes() []byte

func (Key) Encryption added in v0.0.5

func (k Key) Encryption() subKey

func (Key) Equal added in v0.0.5

func (k Key) Equal(j Key) bool

func (Key) From added in v0.0.5

func (k Key) From(b []byte) Key

func (Key) IsZero added in v0.0.5

func (k Key) IsZero() bool

func (Key) Signing added in v0.0.5

func (k Key) Signing() subKey

type KeyPair added in v0.0.5

type KeyPair [2]Key

a KeyPair is two keys. One public, one private

func NewKeyPair added in v0.0.4

func NewKeyPair(randy io.Reader) KeyPair

func (KeyPair) Bytes added in v0.0.5

func (k KeyPair) Bytes() []byte

func (KeyPair) IsZero added in v0.0.5

func (kp KeyPair) IsZero() bool

type Message

type Message struct {
	Recipient Key                                  `msgpack:"to"`
	Sender    Key                                  `msgpack:"from"`
	Headers   *stablemap.StableMap[string, []byte] `msgpack:"hdrs"` // additional authenticated data (AAD)

	PlainText []byte `msgpack:"ptxt"`
	// contains filtered or unexported fields
}

func NewMessage

func NewMessage(randy io.Reader, plainTxt []byte) *Message

func (*Message) Digest added in v0.0.3

func (msg *Message) Digest() ([]byte, error)

func (*Message) Encrypt

func (msg *Message) Encrypt(randy io.Reader, encrypter Encrypter, opts EncrypterOpts) error

msg.Encrypt(Encrypter) is another way of doing encrypter.Encrypt(*Message)

func (*Message) Encrypted added in v0.0.4

func (msg *Message) Encrypted() bool

func (*Message) Ephemeral added in v0.0.4

func (m *Message) Ephemeral() crypto.PublicKey

func (*Message) From

func (m *Message) From() crypto.PublicKey

func (*Message) MarshalBinary added in v0.0.4

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

func (*Message) Plain added in v0.0.4

func (msg *Message) Plain() bool

func (*Message) Sign added in v0.0.3

func (msg *Message) Sign(randy io.Reader, signer crypto.Signer) error

msg.Sign(Signer) is another way of doing signer.Sign(*Message)

func (*Message) Signatory added in v0.0.4

func (m *Message) Signatory() crypto.PublicKey

func (*Message) Signature

func (m *Message) Signature() []byte

func (*Message) To

func (m *Message) To() crypto.PublicKey

func (*Message) UnmarshalBinary

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

func (*Message) Valid added in v0.0.4

func (msg *Message) Valid() bool

type Nonce added in v0.0.3

type Nonce [NonceSize]byte

func NewNonce added in v0.0.4

func NewNonce(randy io.Reader) Nonce

func (Nonce) Bytes added in v0.0.4

func (nonce Nonce) Bytes() []byte

func (Nonce) IsZero added in v0.0.3

func (nonce Nonce) IsZero() bool

type Principal

type Principal = KeyPair

*

  • Layout:
  • 1st 32 bytes: public encrpytion key
  • 2nd 32 bytes: public signing key
  • 3rd 32 bytes: private encryption key
  • 4th 32 bytes: private signing key *

func NewPrincipal

func NewPrincipal(randy io.Reader) *Principal

func (*Principal) Decrypt added in v0.0.5

func (p *Principal) Decrypt(msg *Message, opts crypto.DecrypterOpts) error

func (*Principal) Encrypt added in v0.0.5

func (p *Principal) Encrypt(randy io.Reader, msg *Message, opts any) error

func (*Principal) Equal added in v0.0.5

func (p *Principal) Equal(p2 crypto.PublicKey) bool

func (Principal) From added in v0.0.5

func (Principal) From(b []byte) Principal

func (*Principal) MarshalBinary added in v0.0.5

func (p *Principal) MarshalBinary() ([]byte, error)

func (*Principal) PrivateKey added in v0.0.5

func (p *Principal) PrivateKey() Key

func (*Principal) Public added in v0.0.5

func (p *Principal) Public() crypto.PublicKey

func (*Principal) PublicKey added in v0.0.5

func (p *Principal) PublicKey() Key

func (*Principal) Sign added in v0.0.5

func (p *Principal) Sign(_ io.Reader, digest []byte, opts crypto.SignerOpts) ([]byte, error)

func (*Principal) UnmarshalBinary added in v0.0.5

func (p *Principal) UnmarshalBinary(b []byte) error

func (*Principal) Verify added in v0.0.5

func (p *Principal) Verify(delphiPubKey crypto.PublicKey, digest []byte, sig []byte) bool

type Verifier

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

a Verifier can verify that a signature is valid

Jump to

Keyboard shortcuts

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