x3dh

package module
v0.0.0-...-e3df1ab Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2019 License: MIT Imports: 4 Imported by: 4

README

Build Status Coverage Status Go Report Card Documentation license

X3DH (Extended triple Diffie-Hellman protocol)

Golang implementation of Signal's X3DH protocol

Installation

go get -u github.com/farazdagi/x3dh

Usage

Todo

  • Linters
  • Dockerize

Documentation

Overview

Package x3dh implements the X3DH key agreement protocol. See https://signal.org/docs/specifications/x3dh/.

Index

Constants

View Source
const (
	// PublicKeySize is the size of public keys used in this package, in bytes.
	PublicKeySize = 32

	// PrivateKeySize is the size of private keys used in this package, in bytes.
	PrivateKeySize = 32
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Curve

type Curve interface {
	// GenerateKey generates private key using entropy from rand reader
	GenerateKey(reader io.Reader) (privateKey PrivateKey, err error)

	// PublicKey given user's private key, computes (on curve) corresponding public key.
	PublicKey(privateKey PrivateKey) (publicKey PublicKey)

	// ComputeSecret computes the shared secret using otherPublicKey as the other party's public key.
	ComputeSecret(privateKey PrivateKey, otherPublicKey PublicKey) []byte
}

Curve represents either X25519 or X488 elliptic curve

type Curve25519

type Curve25519 struct{}

Curve25519 is representation of X25519 curve.

func NewCurve25519

func NewCurve25519() Curve25519

NewCurve25519 creates instance of X25519 curve.

func (Curve25519) ComputeSecret

func (curve Curve25519) ComputeSecret(privateKey PrivateKey, otherPublicKey PublicKey) []byte

ComputeSecret computes the shared secret using otherPublicKey as the other party's public key.

func (Curve25519) GenerateKey

func (curve Curve25519) GenerateKey(reader io.Reader) (privateKey PrivateKey, err error)

GenerateKey is used to generate private key on a given curve.

func (Curve25519) PublicKey

func (curve Curve25519) PublicKey(privateKey PrivateKey) (publicKey PublicKey)

PublicKey given user's private key, computes (on curve) corresponding public key.

type KeyExchange

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

KeyExchange is a facade for DH key exchange functionality.

func New

func New() *KeyExchange

New creates default key exchange implementation

func NewKeyExchange

func NewKeyExchange(info string, curve Curve, hash crypto.Hash) *KeyExchange

NewKeyExchange creates parametrized version of key exchange object.

func (KeyExchange) Curve

func (kex KeyExchange) Curve() Curve

Curve returns associated elliptic curve (either X25519 or X488)

func (KeyExchange) GenerateKeyPair

func (kex KeyExchange) GenerateKeyPair(reader io.Reader) (publicKey PublicKey, privateKey PrivateKey, err error)

GenerateKeyPair generates a public/private key pair using entropy from rand reader. If reader is nil, crypto/rand.Reader will be used.

type PrivateKey

type PrivateKey [PrivateKeySize]byte

type PublicKey

type PublicKey [PublicKeySize]byte

Jump to

Keyboard shortcuts

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