# README
eciesgo
Elliptic Curve Integrated Encryption Scheme for secp256k1, written in Go with minimal dependencies.
This is the Go version of ecies/py with a built-in class-like secp256k1 API, you may go there for detailed documentation of the mechanism under the hood.
Install
go get github.com/ecies/go
Quick Start
package main
import (
"github.com/ecies/go"
"log"
)
func main() {
k, err := eciesgo.GenerateKey()
if err != nil {
panic(err)
}
log.Println("key pair has been generated")
ciphertext, err := eciesgo.Encrypt(k.PublicKey, []byte("THIS IS THE TEST"))
if err != nil {
panic(err)
}
log.Printf("plaintext encrypted: %v\n", ciphertext)
plaintext, err := eciesgo.Decrypt(k, ciphertext)
if err != nil {
panic(err)
}
log.Printf("ciphertext decrypted: %s\n", string(plaintext))
}
# Functions
Decrypt decrypts a passed message with a receiver private key, returns plaintext or decryption error.
Encrypt encrypts a passed message with a receiver public key, returns ciphertext or encryption error.
GenerateKey generates secp256k1 key pair.
NewPrivateKeyFromBytes decodes private key raw bytes, computes public key and returns PrivateKey instance.
NewPrivateKeyFromHex decodes hex form of private key raw bytes, computes public key and returns PrivateKey instance.
NewPublicKeyFromBytes decodes public key raw bytes and returns PublicKey instance; Supports both compressed and uncompressed public keys.
NewPublicKeyFromHex decodes hex form of public key raw bytes and returns PublicKey instance.
# Structs
PrivateKey is an instance of secp256k1 private key with nested public key.
PublicKey instance with nested elliptic.Curve interface (secp256k1 instance in our case).