crypto

package
v0.33.12 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2024 License: AGPL-3.0 Imports: 9 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(algo 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).

Supported algorithms are SHA2-256, SHA2-384, SHA3-256, SHA3-384 and Keccak256.

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(
	signature []byte,
	tag string,
	message []byte,
	rawPublicKey []byte,
	signatureAlgorithm runtime.SignatureAlgorithm,
	hashAlgorithm runtime.HashAlgorithm,
) (bool, error)

VerifySignatureFromRuntime performs signature verification using raw values provided by the Cadence runtime.

The signature/hash function combinations accepted are:

  • ECDSA (on both curves P-256 and secp256k1) with any of SHA2-256/SHA3-256/Keccak256.
  • BLS (on BLS12-381 curve) with the specific KMAC128 for BLS.

The tag is applied to the message depending on the hash function used.

The function errors:

  • NewValueErrorf for any user error
  • panic for any other unexpected error

func VerifySignatureFromTransaction added in v0.26.0

func VerifySignatureFromTransaction(
	signature []byte,
	message []byte,
	pk crypto.PublicKey,
	hashAlgo hash.HashingAlgorithm,
) (bool, error)

VerifySignatureFromRuntime performs signature verification using raw values provided by the Cadence runtime.

The signature/hash function combinations accepted are:

  • ECDSA (on both curves P-256 and secp256k1) with any of SHA2-256/SHA3-256.

The tag is applied to the message as a constant length prefix.

The function errors:

  • NewValueErrorf for any user error
  • panic for any other unexpected error

Types

This section is empty.

Jump to

Keyboard shortcuts

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