crypto

package
v0.22.8-patch-4-ledger... Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2021 License: AGPL-3.0 Imports: 8 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CryptoToRuntimeHashingAlgorithm

func CryptoToRuntimeHashingAlgorithm(h hash.HashingAlgorithm) runtime.HashAlgorithm

CryptoToRuntimeHashingAlgorithm converts a crypto hashing algorithm to a runtime hash algorithm.

func CryptoToRuntimeSigningAlgorithm

func CryptoToRuntimeSigningAlgorithm(s crypto.SigningAlgorithm) runtime.SignatureAlgorithm

CryptoToRuntimeSigningAlgorithm converts a crypto signature algorithm to a runtime signature algorithm.

func HashWithTag added in v0.18.0

func HashWithTag(hashAlgo hash.HashingAlgorithm, tag string, data []byte) ([]byte, error)

func NewBLSKMAC added in v0.18.0

func NewBLSKMAC(_ string) hash.Hasher

func NewPrefixedHashing added in v0.18.0

func NewPrefixedHashing(shaAlgo hash.HashingAlgorithm, tag string) (hash.Hasher, error)

NewPrefixedHashing returns a new hasher that prefixes the tag for all hash computations (only when tag is not empty). Only SHA2 and SHA3 algorithms are supported.

func RuntimeToCryptoHashingAlgorithm

func RuntimeToCryptoHashingAlgorithm(s runtime.HashAlgorithm) hash.HashingAlgorithm

RuntimeToCryptoHashingAlgorithm converts a runtime hash algorithm to a crypto hashing algorithm.

func RuntimeToCryptoSigningAlgorithm

func RuntimeToCryptoSigningAlgorithm(s runtime.SignatureAlgorithm) crypto.SigningAlgorithm

RuntimeToCryptoSigningAlgorithm converts a runtime signature algorithm to a crypto signature algorithm.

func ValidatePublicKey added in v0.18.0

func ValidatePublicKey(signAlgo runtime.SignatureAlgorithm, pk []byte) (valid bool, err error)

ValidatePublicKey returns true if public key is valid

func VerifySignatureFromRuntime

func VerifySignatureFromRuntime(
	verifier SignatureVerifier,
	signature []byte,
	tag string,
	message []byte,
	rawPublicKey []byte,
	signatureAlgorithm runtime.SignatureAlgorithm,
	hashAlgorithm runtime.HashAlgorithm,
) (bool, error)

VerifySignatureFromRuntime is an adapter that performs signature verification using raw values provided by the Cadence runtime.

Types

type DefaultSignatureVerifier

type DefaultSignatureVerifier struct{}

func NewDefaultSignatureVerifier

func NewDefaultSignatureVerifier() DefaultSignatureVerifier

func (DefaultSignatureVerifier) Verify

func (DefaultSignatureVerifier) Verify(
	signature []byte,
	tag string,
	message []byte,
	publicKey crypto.PublicKey,
	hashAlgo hash.HashingAlgorithm,
) (bool, error)

type SignatureVerifier

type SignatureVerifier interface {
	Verify(
		signature []byte,
		tag string,
		message []byte,
		publicKey crypto.PublicKey,
		hashAlgo hash.HashingAlgorithm,
	) (bool, error)
}

Jump to

Keyboard shortcuts

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