crypto

package
v0.25.14-cadence-v0.23... Latest Latest
Warning

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

Go to latest
Published: May 27, 2022 License: AGPL-3.0 Imports: 8 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AggregatePublicKeys added in v0.25.0

func AggregatePublicKeys(keys []*runtime.PublicKey) (*runtime.PublicKey, error)

AggregatePublicKeys aggregate multiple public keys into one; currently only works for BLS

func AggregateSignatures added in v0.25.0

func AggregateSignatures(sigs [][]byte) (crypto.Signature, error)

AggregateSignatures aggregate multiple signatures into one; currently only works for BLS

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 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) error

ValidatePublicKey returns : - nil if key is valid and no exception occurred. - crypto.invalidInputsError if key is invalid and no exception occurred. - panics if an exception occurred.

func VerifyPOP added in v0.25.0

func VerifyPOP(pk *runtime.PublicKey, s crypto.Signature) (bool, error)

VerifyPOP verifies a proof of possession (PoP) for the receiver public key; currently only works for BLS

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