Documentation ¶
Index ¶
- Constants
- Variables
- func NewSubKey(randy io.Reader) subKey
- type Certifier
- type Cipherer
- type CryptOpts
- type Decrypter
- type Encrypter
- type EncrypterOpts
- type Key
- type KeyPair
- type Message
- func (msg *Message) Digest() ([]byte, error)
- func (msg *Message) Encrypt(randy io.Reader, encrypter Encrypter, opts EncrypterOpts) error
- func (msg *Message) Encrypted() bool
- func (m *Message) Ephemeral() crypto.PublicKey
- func (m *Message) From() crypto.PublicKey
- func (m *Message) MarshalBinary() ([]byte, error)
- func (msg *Message) Plain() bool
- func (msg *Message) Sign(randy io.Reader, signer crypto.Signer) error
- func (m *Message) Signatory() crypto.PublicKey
- func (m *Message) Signature() []byte
- func (m *Message) To() crypto.PublicKey
- func (m *Message) UnmarshalBinary(p []byte) error
- func (msg *Message) Valid() bool
- type Nonce
- type Principal
- func (p *Principal) Decrypt(msg *Message, opts crypto.DecrypterOpts) error
- func (p *Principal) Encrypt(randy io.Reader, msg *Message, opts any) error
- func (p *Principal) Equal(p2 crypto.PublicKey) bool
- func (Principal) From(b []byte) Principal
- func (p *Principal) MarshalBinary() ([]byte, error)
- func (p *Principal) PrivateKey() Key
- func (p *Principal) Public() crypto.PublicKey
- func (p *Principal) PublicKey() Key
- func (p *Principal) Sign(_ io.Reader, digest []byte, opts crypto.SignerOpts) ([]byte, error)
- func (p *Principal) UnmarshalBinary(b []byte) error
- func (p *Principal) Verify(delphiPubKey crypto.PublicKey, digest []byte, sig []byte) bool
- type Verifier
Constants ¶
const ByteSize = 128
const GLOBAL_SALT = "oracle/v1"
const NonceSize = chacha20poly1305.NonceSize
Variables ¶
var ErrBadKey = errors.New("bad key")
var ErrDecryptionFailed = errors.New("decryption failed")
var ErrDelphi = errors.New("delphi")
var ErrEncryptionFailed = errors.New("encryption failed")
var ErrNoEphemeralKey = errors.New("no ephemeral key")
var ErrNotImplemented = errors.New("not implemented")
var UniversalNonce []byte = make([]byte, chacha20poly1305.NonceSize)
Functions ¶
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 Decrypter ¶ added in v0.0.4
type Decrypter interface {
Decrypt(*Message, crypto.DecrypterOpts) error
}
type EncrypterOpts ¶ added in v0.0.4
type EncrypterOpts = any
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 KeyFromHex ¶ added in v0.0.5
func (Key) Encryption ¶ added in v0.0.5
func (k Key) Encryption() subKey
type KeyPair ¶ added in v0.0.5
type KeyPair [2]Key
a KeyPair is two [Key]s. One public, one private
func NewKeyPair ¶ added in v0.0.4
NewKeyPair generates valid ed25519 and X25519 keys
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 }
a Message is a message that represents either plain text or cipher text, encapsulating all data and metadata necessary to perform cryptographic operations.
func NewMessage ¶
NewMessage() creates a new Message
func (*Message) Digest ¶ added in v0.0.3
Digest() returns that portion of a Message which should be hashed and signed
func (*Message) Encrypt ¶
msg.Encrypt(Encrypter) is another way of doing encrypter.Encrypt(*Message)
func (*Message) Ephemeral ¶ added in v0.0.4
Ephemeral() returns the value of the ephemeral X25519 key attached to an encrypted Message
func (*Message) MarshalBinary ¶ added in v0.0.4
func (*Message) Sign ¶ added in v0.0.3
msg.Sign(Signer) is another way of doing signer.Sign(*Message)
func (*Message) Signatory ¶ added in v0.0.4
Signatory() returns the public signing key of the sender
func (*Message) UnmarshalBinary ¶
type Nonce ¶ added in v0.0.3
A Nonce is a random value with a reasonably high chance of being globally unqiue.
type Principal ¶
type Principal = KeyPair
a Principal contains cryptographic key material and can sign, verify, encrypt, and decrypt [Message]s.
func NewPrincipal ¶
NewPrincipal() creates a new Principal
func (*Principal) Decrypt ¶ added in v0.0.5
func (p *Principal) Decrypt(msg *Message, opts crypto.DecrypterOpts) error
Decrypt() decrypts a Message