Documentation
¶
Overview ¶
Package x3dh implements the X3DH key agreement protocol. See https://signal.org/docs/specifications/x3dh/.
Index ¶
Constants ¶
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 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