crypto

package
v0.0.0-...-7277db8 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

nntpchan crypto package wraps all external crypro libs

Index

Constants

This section is empty.

Variables

View Source
var Hash = blake256.New

common hash function is blake2

View Source
var RandBytes = nacl.RandBytes

generate random bytes

Functions

func GenKeypair

func GenKeypair() (pk, sk []byte)

create a standard keypair

func ToPublic

func ToPublic(sk []byte) (pk []byte)

get the public component given the secret key

Types

type SigDecoder

type SigDecoder interface {
	// decode signature from io.Reader
	// reads all data until io.EOF
	// returns singaure or error if an error occured while reading
	Decode(r io.Reader) (Signature, error)
	// decode a signature from string
	// returns signature or error if an error ocurred while decoding
	DecodeString(str string) (Signature, error)
}

a decoder of signatures

type SigEncoder

type SigEncoder interface {
	// encode a signature to an io.Writer
	// return error if one occurrened while writing out signature
	Encode(sig Signature, w io.Writer) error
	// encode a signature to a string
	EncodeString(sig Signature) string
}

type Signature

type Signature []byte

a detached signature

type Signer

type Signer interface {
	io.Writer
	// generate detached Signature from previously fed body via Write()
	Sign() Signature
}

provides generic signing interface for producing detached signatures call Write() to feed data to be signed, call Sign() to generate a detached signature

func CreateSigner

func CreateSigner(sk []byte) Signer

create a standard signer given a secret key

type Verifer

type Verifer interface {
	io.Writer
	// verify detached signature from body previously fed via Write()
	// return true if the detached signature is valid given the body
	Verify(sig Signature) bool
}

provides generic signature call Write() to feed in message body once the entire body has been fed in via Write() call Verify() with detached signature to verify the detached signature against the previously fed body

func CreateVerifier

func CreateVerifier(pk []byte) Verifer

create a standard verifier given a public key

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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