pwcrypto

package module
v0.0.0-...-3c0af49 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2022 License: MIT Imports: 8 Imported by: 0

README

PWCrypto

🔐 Share secret password between room channels.

this library is used for tran app.

Installation

go get github.com/abdfnx/pwcrypto

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AvailableCurves

func AvailableCurves() []string

AvailableCurves returns available curves

Types

type EllipticCurve

type EllipticCurve interface {
	Add(x1, y1, x2, y2 *big.Int) (*big.Int, *big.Int)
	ScalarBaseMult(k []byte) (*big.Int, *big.Int)
	ScalarMult(Bx, By *big.Int, k []byte) (*big.Int, *big.Int)
	IsOnCurve(x, y *big.Int) bool
}

type PWCrypto

type PWCrypto struct {
	// Public variables
	Role   int
	Uᵤ, Uᵥ *big.Int
	Vᵤ, Vᵥ *big.Int
	Xᵤ, Xᵥ *big.Int
	Yᵤ, Yᵥ *big.Int

	Pw         []byte
	Vpwᵤ, Vpwᵥ *big.Int
	Upwᵤ, Upwᵥ *big.Int
	Aα         []byte
	Aαᵤ, Aαᵥ   *big.Int
	Zᵤ, Zᵥ     *big.Int
	K          []byte
	// contains filtered or unexported fields
}

func InitCurve

func InitCurve(pw []byte, role int, curve string) (p *PWCrypto, err error)

Init will take the secret weak passphrase (pw) to initialize the points on the elliptic curve. The role is set to either 0 for the sender or 1 for the recipient. The curve can be any elliptic curve.

func (*PWCrypto) Bytes

func (p *PWCrypto) Bytes() (b []byte)

Bytes just marshalls the PAKE structure so that private variables are hidden.

func (*PWCrypto) HaveSessionKey

func (p *PWCrypto) HaveSessionKey() bool

HaveSessionKey returns whether a session key has been generated

func (*PWCrypto) Public

func (p *PWCrypto) Public() *PWCrypto

Public returns the public variables of PWCrypto

func (*PWCrypto) SessionKey

func (p *PWCrypto) SessionKey() ([]byte, error)

SessionKey is returned, unless it is not generated in which is returns an error. This function does not check if it is verifies.

func (*PWCrypto) Update

func (p *PWCrypto) Update(qBytes []byte) (err error)

Update will update itself with the other parties PAKE and automatically determine what stage and what to generate.

Jump to

Keyboard shortcuts

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