ecc

package
v0.0.0-...-b65cb46 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2019 License: MIT Imports: 11 Imported by: 11

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// NAME - human-readable name of this Crypto implementation
	NAME = "Curve25519,AES-CBC-256,HMAC-SHA-256"
)

Functions

This section is empty.

Types

type KeyPair

type KeyPair struct {
	// contains filtered or unexported fields
}

KeyPair for ECC : Bencrypt Implementation of a Curve25519,AES-CBC-256,HMAC-SHA-256 system

func (*KeyPair) Clone

func (e *KeyPair) Clone() bc.KeyPair

Clone : Returns a new node of the same type as this one

func (*KeyPair) DecryptMessage

func (e *KeyPair) DecryptMessage(data []byte) (bool, []byte, error)

DecryptMessage : Decrypts a message 1) derives the shared secret: S = P_x, where P = (P_x, P_y) = k_B R (it is the same as the one Alice derived because P = k_B R = k_B r G = r k_B G = r K_B), or outputs failed if P=O; 2) checks the luggage tag 3) derives keys the same way as Alice did: k_E \| k_M = \textrm{KDF}(S\|S_1); 4) uses MAC to check the tag and outputs failed if d \ne \textrm{MAC}(k_M; c \| S_2); 5) uses symmetric encryption scheme to decrypt the message m = E^{-1}(k_E; c).

Returns: bool - Luggage Tag check passed []byte - decrypted data, if tag check passed error - what you would expect

func (*KeyPair) EncryptMessage

func (e *KeyPair) EncryptMessage(clear []byte, pubkey bc.PubKey) ([]byte, error)

EncryptMessage : Encrypts a message 1) generates a random number r in [1, n-1] and calculates R = r G; 2) derives a shared secret: S = P_x, where P = (P_x, P_y) = r K_B (and P ne O); 3) uses KDF to derive a symmetric encryption and a MAC key: k_E | k_M = textrm{KDF}(S|S_1); 4) encrypts the message: c = E(k_E; m); 5) computes luggage tag so recipient can quickly see if this is for them 6) computes the tag of encrypted message and S_2: d = textrm{MAC}(k_M; c | S_2); 7) outputs R | luggageTag | c | d.

func (*KeyPair) FromB64

func (e *KeyPair) FromB64(s string) error

FromB64 : Sets the private portion of this keypair from a Base64-encoded string

func (*KeyPair) GenerateKey

func (e *KeyPair) GenerateKey()

GenerateKey : Generates a new keypair inside this KeyPair object

func (*KeyPair) GetName

func (e *KeyPair) GetName() string

GetName : Returns the common language name for this cryptosystem

func (*KeyPair) GetPubKey

func (e *KeyPair) GetPubKey() bc.PubKey

GetPubKey : Returns the Public portion of this KeyPair

func (*KeyPair) Precompute

func (e *KeyPair) Precompute()

Precompute : This does nothing in ECC

func (*KeyPair) ToB64

func (e *KeyPair) ToB64() string

ToB64 : Returns the private portion of this keypair as a Base64-encoded string

func (*KeyPair) ValidatePubKey

func (e *KeyPair) ValidatePubKey(s string) bool

ValidatePubKey : Returns true if and only if the argument is a valid PubKey to this KeyPair

type PubKey

type PubKey struct {
	Pubkey []byte //len=32
}

PubKey : Implements bc.PubKey interface

func (*PubKey) Clone

func (e *PubKey) Clone() bc.PubKey

Clone : Returns a new PubKey of the same type as this one

func (*PubKey) FromB64

func (e *PubKey) FromB64(s string) error

FromB64 : Sets Public Key from a Base64 encoded string

func (*PubKey) FromBytes

func (e *PubKey) FromBytes(b []byte) error

FromBytes : Sets Public Key from bytes

func (*PubKey) Nil

func (e *PubKey) Nil() interface{}

Nil : Returns the interface-to-nil-pointer type for this PubKey

func (*PubKey) ToB64

func (e *PubKey) ToB64() string

ToB64 : Returns Public Key as a Base64 encoded string

func (*PubKey) ToBytes

func (e *PubKey) ToBytes() []byte

ToBytes : Returns Public Key as bytes

Jump to

Keyboard shortcuts

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