cryptoutil

package
v1.14.0 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2023 License: Apache-2.0, MIT Imports: 14 Imported by: 8

Documentation

Overview

Package cryptoutil contains generic & stateless crypto helpers.

Index

Constants

View Source
const (
	KeySize          = 32 // Key size required by box
	NonceSize        = 24 // Nonce size required by box
	ScryptIterations = 1 << 15
	ScryptR          = 8
	ScryptP          = 1
	ScryptKeyLen     = 32
)

Variables

This section is empty.

Functions

func AESCTRStream

func AESCTRStream(key, iv []byte) (cipher.Stream, error)

AESCTRStream returns a CTR stream that can be used to produce ciphertext without padding.

func AESGCMDecrypt

func AESGCMDecrypt(key, data []byte) ([]byte, error)

AESGCMDecrypt uses AES+GCM to decrypt plaintext data.

func AESGCMEncrypt

func AESGCMEncrypt(key, data []byte) ([]byte, error)

AESGCMEncrypt use AES+GCM to encrypt plaintext data.

The generated output will be longer than the original plaintext input.

func ConcatAndHashSha256

func ConcatAndHashSha256(slices ...[]byte) *[sha256.Size]byte

func DeriveKey

func DeriveKey(passphrase, salt []byte) ([]byte, []byte, error)

DeriveKey takes a passphrase of any length and returns a key of fixed size.

If no salt is provided, a new one will be created and returned.

func EdwardsToMontgomery

func EdwardsToMontgomery(privKey crypto.PrivKey, pubKey crypto.PubKey) (*[32]byte, *[32]byte, error)

EdwardsToMontgomery converts ed25519 priv/pub keys to X25519 keys.

func EdwardsToMontgomeryPriv

func EdwardsToMontgomeryPriv(privKey crypto.PrivKey) (*[KeySize]byte, error)

EdwardsToMontgomeryPriv converts ed25519 priv key to X25519 priv key.

func EdwardsToMontgomeryPub

func EdwardsToMontgomeryPub(pubKey crypto.PubKey) (*[KeySize]byte, error)

EdwardsToMontgomeryPub converts ed25519 pub key to X25519 pub key.

func GenerateNonce

func GenerateNonce() (*[NonceSize]byte, error)

func GenerateNonceSize

func GenerateNonceSize(size int) ([]byte, error)

func KeySliceToArray

func KeySliceToArray(keySlice []byte) (*[KeySize]byte, error)

func NewFuncSigner added in v1.3.2

func NewFuncSigner(key libp2p_ci.PubKey, signer func([]byte) ([]byte, error)) stdcrypto.Signer

func NonceSliceToArray

func NonceSliceToArray(nonceSlice []byte) (*[NonceSize]byte, error)

func PrivateKeyToCurve25519 added in v1.2.4

func PrivateKeyToCurve25519(ret *[32]byte, privateKey ed25519.PrivateKey)

from: https://github.com/agl/ed25519/blob/5312a61534124124185d41f09206b9fef1d88403/extra25519/extra25519.go#LL16C11-L16C11 PrivateKeyToCurve25519 converts an ed25519 private key into a corresponding curve25519 private key such that the resulting curve25519 public key will equal the result from PublicKeyToCurve25519.

func PublicKeyToCurve25519 added in v1.2.4

func PublicKeyToCurve25519(ret *[32]byte, publicKey ed25519.PublicKey) error

PublicKeyToCurve25519 converts an Ed25519 public key into the curve25519 public key that would be generated from the same private key.

func SeedFromEd25519PrivateKey

func SeedFromEd25519PrivateKey(key crypto.PrivKey) ([]byte, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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