ecies

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Provides ECIES implementation using: sha256 hashing , secp256k1 curves, and aes 128 ctr (16 byte key) encryption.

Code in this package was built from the following 2 docs: 1. https://csrc.nist.gov/CSRC/media/Publications/sp/800-56a/archive/2006-05-03/documents/sp800-56-draft-jul2005.pdf 2. https://github.com/ethereum/devp2p/blob/master/rlpx.md#ecies-encryption

Index

Constants

View Source
const Overhead = 113

Overhead is the length in bytes of the ECIES message *excluding* the ciphertext length. It is 65 (uncompressed public key) + 16 (IV) + 32 (MAC).

Variables

This section is empty.

Functions

func Decrypt

func Decrypt(prvKey *secp256k1.PrivateKey, ciphertext, shared []byte) ([]byte, error)

Decrypts ciphertext using prvKey using the following construction:

ciphertext = R || iv || c || d S = Px where (Px, Py) = kB * R kE || kM = KDF(S, 32) d == MAC(sha256(kM), iv || c || shared) msg = AES(kE, iv || c)

func Encrypt

func Encrypt(destPubKey *secp256k1.PublicKey, msg, shared []byte) ([]byte, error)

Encrypts msg to destPubKey using the following construction:

r = random number (private key) R = r * G (public key) S = Px where (Px, Py) = r * KB kE || kM = KDF(S, 32) iv = random initialization vector c = AES(kE, iv , m) d = MAC(sha256(kM), iv || c || shared) msg = R || iv || c || d For more details, see the ECIES Encryption docs defined by Eth's DevP2P: https://github.com/ethereum/devp2p/blob/master/rlpx.md#ecies-encryption

Types

This section is empty.

Jump to

Keyboard shortcuts

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