crypto

package
v0.0.0-...-020e20f Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package crypto implements Asymmetric, Symmetric Encryption and Hash function.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddPKCSPadding

func AddPKCSPadding(src []byte) []byte

AddPKCSPadding adds padding to a block of data.

func DecryptAndCheck

func DecryptAndCheck(inputPrivateKey *asymmetric.PrivateKey, inData []byte) ([]byte, error)

DecryptAndCheck (inputPrivateKey, inData) MAIN PROCEDURE:

  1. Decrypt the inData
  2. Verify the HMAC.

func EncryptAndSign

func EncryptAndSign(inputPublicKey *asymmetric.PublicKey, inData []byte) ([]byte, error)

EncryptAndSign (inputPublicKey, inData) MAIN PROCEDURE:

  1. newPrivateKey, newPubKey := genSecp256k1Keypair()
  2. encKey, HMACKey := SHA512(ECDH(newPrivateKey, inputPublicKey))
  3. PaddedIn := PKCSPadding(in)
  4. OutBytes := IV + newPubKey + AES-256-CBC(encKey, PaddedIn) + HMAC-SHA-256(HMACKey)

func PubKeyHash

func PubKeyHash(pubKey *asymmetric.PublicKey) (addr proto.AccountAddress, err error)

PubKeyHash generates the account hash address for specified public key.

func RemovePKCSPadding

func RemovePKCSPadding(src []byte) ([]byte, error)

RemovePKCSPadding removes padding from data that was added with addPKCSPadding.

Types

This section is empty.

Directories

Path Synopsis
Package asymmetric implements Asymmetric Encryption methods ported from btcd, Ethereum-go etc.
Package asymmetric implements Asymmetric Encryption methods ported from btcd, Ethereum-go etc.
Package etls implements "Enhanced Transport Layer Security", but more efficient than TLS used in https.
Package etls implements "Enhanced Transport Layer Security", but more efficient than TLS used in https.
Package hash provides abstracted hash functionality.
Package hash provides abstracted hash functionality.
Package kms implements Key Management System According the best practices from "sections 3.5 and 3.6 of the PCI DSS standard" and "ANSI X9.17 - Financial Institution Key Management".
Package kms implements Key Management System According the best practices from "sections 3.5 and 3.6 of the PCI DSS standard" and "ANSI X9.17 - Financial Institution Key Management".
Package secp256k1 wraps the bitcoin secp256k1 C library.
Package secp256k1 wraps the bitcoin secp256k1 C library.
Package symmetric implements Symmetric Encryption methods.
Package symmetric implements Symmetric Encryption methods.

Jump to

Keyboard shortcuts

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