crypto

package
v0.0.0-...-69f1810 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2024 License: Apache-2.0 Imports: 14 Imported by: 22

Documentation

Overview

Package ed25519 implements the Ed25519 signature algorithm. See https://ed25519.cr.yp.to/.

These functions are also compatible with the “Ed25519” function defined in RFC 8032. However, unlike RFC 8032's formulation, this package's private key representation includes a public key suffix to make multiple signing operations with the same key more efficient. This package refers to the RFC 8032 private key as the “seed”.

This is a interface adaptation of the original file.

Index

Constants

View Source
const (
	NonceSize      = 12
	Size           = sha256.Size
	CipherKeySize  = 32
	CipherSize     = NonceSize + CipherKeySize
	PublicKeySize  = 32
	TokenSize      = 32
	PrivateKeySize = 64
	SignatureSize  = 64
)
View Source
const AddressSize = 20

Variables

View Source
var ErrPrivateKeyParse = errors.New("could not parse private key")
View Source
var ErrPublicKeyParse = errors.New("could not parse public key")

Functions

func EncodeHash

func EncodeHash(h Hash) string

func IsValidPrivateKey

func IsValidPrivateKey(data []byte) bool

func NewCipherKey

func NewCipherKey() []byte

func Nonce

func Nonce() []byte

func RandomAsymetricKey

func RandomAsymetricKey() (Token, PrivateKey)

Types

type Address

type Address [AddressSize]byte

func (Address) Hex

func (a Address) Hex() string

func (Address) MarshalText

func (a Address) MarshalText() (text []byte, err error)

func (Address) String

func (a Address) String() string

type Cipher

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

func CipherFromKey

func CipherFromKey(key []byte) Cipher

func (Cipher) Open

func (c Cipher) Open(msg []byte) ([]byte, error)

func (Cipher) Seal

func (c Cipher) Seal(msg []byte) []byte

type CipherNonce

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

func CipherNonceFromKey

func CipherNonceFromKey(key []byte) CipherNonce

func (CipherNonce) Open

func (c CipherNonce) Open(msg []byte) ([]byte, error)

func (CipherNonce) OpenNewNonce

func (c CipherNonce) OpenNewNonce(msg []byte, nonce []byte) ([]byte, error)

func (CipherNonce) Seal

func (c CipherNonce) Seal(msg []byte) []byte

func (CipherNonce) SealWithNewNonce

func (c CipherNonce) SealWithNewNonce(msg []byte) ([]byte, []byte)

func (CipherNonce) SetNonce

func (c CipherNonce) SetNonce(nonce []byte)

type Hash

type Hash [Size]byte
var ZeroHash Hash = Hasher([]byte{})
var ZeroValueHash Hash

func BytesToHash

func BytesToHash(bytes []byte) Hash

func DecodeHash

func DecodeHash(text string) Hash

func HashToken

func HashToken(token Token) Hash

func Hasher

func Hasher(data []byte) Hash

func (Hash) Equal

func (h Hash) Equal(another Hash) bool

func (Hash) Equals

func (h Hash) Equals(another []byte) bool

func (Hash) MarshalText

func (h Hash) MarshalText() (text []byte, err error)

func (Hash) String

func (h Hash) String() string

func (Hash) ToInt64

func (hash Hash) ToInt64() int64

func (Hash) UnmarshalText

func (h Hash) UnmarshalText(text []byte) error

type PrivateKey

type PrivateKey [PrivateKeySize]byte
var ZeroPrivateKey PrivateKey

func ParsePEMPrivateKey

func ParsePEMPrivateKey(data []byte) (PrivateKey, error)

func PrivateKeyFromSeed

func PrivateKeyFromSeed(seed [32]byte) PrivateKey

func (PrivateKey) Hex

func (p PrivateKey) Hex() string

func (PrivateKey) PublicKey

func (p PrivateKey) PublicKey() Token

func (PrivateKey) Sign

func (p PrivateKey) Sign(msg []byte) Signature

type Signature

type Signature [SignatureSize]byte
var ZeroSignature Signature

func (Signature) MarshalText

func (s Signature) MarshalText() (text []byte, err error)

func (Signature) String

func (s Signature) String() string

func (Signature) UnmarshalText

func (s Signature) UnmarshalText(text []byte) error

type Token

type Token [TokenSize]byte
var ZeroToken Token

func ParsePEMPublicKey

func ParsePEMPublicKey(data []byte) (Token, error)

func TokenFromString

func TokenFromString(s string) Token

func (Token) Address

func (t Token) Address() Address

func (Token) Equal

func (t Token) Equal(another Token) bool

func (Token) Equals

func (t Token) Equals(bytes []byte) bool

func (Token) Hex

func (t Token) Hex() string

func (Token) IsLike

func (t Token) IsLike(a Address) bool

func (Token) Larger

func (t Token) Larger(another Token) bool

func (Token) MarshalText

func (t Token) MarshalText() (text []byte, err error)

func (Token) String

func (t Token) String() string

func (Token) UnmarshalText

func (t Token) UnmarshalText(text []byte) error

func (Token) Verify

func (t Token) Verify(msg []byte, signature Signature) bool

type TokenCipher

type TokenCipher struct {
	Token  Token
	Cipher []byte
}

type TokenCiphers

type TokenCiphers []TokenCipher

type TokenValue

type TokenValue struct {
	Token Token
	Value uint64
}

Directories

Path Synopsis
dh
curve25519
Package curve25519 provides an implementation of the X25519 function, which performs scalar multiplication on the elliptic curve known as Curve25519.
Package curve25519 provides an implementation of the X25519 function, which performs scalar multiplication on the elliptic curve known as Curve25519.
curve25519/internal/field
Package field implements fast arithmetic modulo 2^255-19.
Package field implements fast arithmetic modulo 2^255-19.
Package pbkdf2 implements the key derivation function PBKDF2 as defined in RFC 2898 / PKCS #5 v2.0.
Package pbkdf2 implements the key derivation function PBKDF2 as defined in RFC 2898 / PKCS #5 v2.0.
Package scrypt implements the scrypt key derivation function as defined in Colin Percival's paper "Stronger Key Derivation via Sequential Memory-Hard Functions" (https://www.tarsnap.com/scrypt/scrypt.pdf).
Package scrypt implements the scrypt key derivation function as defined in Colin Percival's paper "Stronger Key Derivation via Sequential Memory-Hard Functions" (https://www.tarsnap.com/scrypt/scrypt.pdf).

Jump to

Keyboard shortcuts

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