beacon

package
v0.87.0 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package beacon provides moneysocket Beacon's for communicating various locations and a SharedSeed encoder for end-to-end encryption

Index

Constants

View Source
const MoneysocketHrp = "moneysocket"

MoneysocketHrp is the human readable part (https://en.bitcoin.it/wiki/BIP_0173#Bech32 ) of the TLV (type-length-value, defined in BOLT #1: https://git.io/JLCRq ).

View Source
const SharedSeedLength = 16

SharedSeedLength defines the length of the shared seed.

Variables

This section is empty.

Functions

This section is empty.

Types

type Beacon

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

Beacon contains a SharedSeed for end-to-end encryption and a list of location.Location's.

func DecodeFromBech32Str

func DecodeFromBech32Str(bech32 string) (Beacon, error)

DecodeFromBech32Str decodes a Beacon from a bech32 string (https://en.bitcoin.it/wiki/BIP_0173#Bech32 ).

func DecodeTLV added in v0.40.0

func DecodeTLV(b []byte) (beacon Beacon, err error)

DecodeTLV decodes a TLV (type-length-value, defined in BOLT #1: https://git.io/JLCRq) into a Beacon. Returns an error if Beacon cannot be decoded.

func NewBeacon

func NewBeacon() Beacon

NewBeacon creates a Beacon with no locations and an auto-generated SharedSeed.

func NewBeaconFromSharedSeed added in v0.40.0

func NewBeaconFromSharedSeed(seed SharedSeed) Beacon

NewBeaconFromSharedSeed creates a Beacon with no locations and the given SharedSeed.

func (*Beacon) AddLocation

func (b *Beacon) AddLocation(loc location.Location)

AddLocation appends a location to the beacon.

func (Beacon) EncodeLocationListTlvs

func (b Beacon) EncodeLocationListTlvs() []byte

EncodeLocationListTlvs encodes a list of locations as tlvs.

func (Beacon) EncodeTLV added in v0.40.0

func (b Beacon) EncodeTLV() []byte

EncodeTLV encodes the tlv.

func (Beacon) GetSharedSeed

func (b Beacon) GetSharedSeed() SharedSeed

GetSharedSeed fetches the shared seed from the beacon.

func (Beacon) Locations

func (b Beacon) Locations() []location.Location

Locations returns the list of locations in the Beacon.

func (Beacon) ToBech32Str

func (b Beacon) ToBech32Str() string

ToBech32Str encodes the tlv to a bech32 string (https://en.bitcoin.it/wiki/BIP_0173#Bech32 ).

func (Beacon) ToObject

func (b Beacon) ToObject() map[string]interface{}

ToObject generates a json-encodable map of the Beacon's data.

type SharedSeed

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

SharedSeed is a seed used for end-to-end encryption.

func BytesToSharedSeed

func BytesToSharedSeed(rawBytes []byte) (seed SharedSeed, err error)

BytesToSharedSeed creates a SharedSeed from a []byte slice returns an error when seed cannot be decoded.

func HexToSharedSeed

func HexToSharedSeed(rawHex string) (seed SharedSeed, err error)

HexToSharedSeed creates a shared seed from an input hex returns an error when this is not possible.

func NewSharedSeed

func NewSharedSeed() SharedSeed

NewSharedSeed generates a new random shared seed.

func (SharedSeed) DeriveAES256Key added in v0.40.0

func (s SharedSeed) DeriveAES256Key() []byte

DeriveAES256Key will generate a DoubleSHA256 of the shared seed see https://en.wikipedia.org/wiki/Advanced_Encryption_Standard for details.

func (SharedSeed) DeriveRendezvousID added in v0.54.0

func (s SharedSeed) DeriveRendezvousID() []byte

DeriveRendezvousID will generate a DoubleSHA256 of the DeriveAES256Key.

func (SharedSeed) DoubleSHA256 added in v0.40.0

func (s SharedSeed) DoubleSHA256(inputBytes []byte) []byte

DoubleSHA256 will generate SHA256(SHA256(inputBytes)).

func (SharedSeed) EncodedTLV

func (s SharedSeed) EncodedTLV() []byte

EncodedTLV will encode the TLV into a byte-slice (See BOLT #1: https://git.io/JLCRq ).

func (SharedSeed) Equal

func (s SharedSeed) Equal(seed SharedSeed) bool

Equal check if two seeds are equal.

func (SharedSeed) GetBytes

func (s SharedSeed) GetBytes() []byte

GetBytes gets the seedBytes from the shared seed.

func (SharedSeed) Hash

func (s SharedSeed) Hash() uint64

Hash converts the seed bytes to a big endian int.

func (SharedSeed) Hex

func (s SharedSeed) Hex() string

Hex converts the shared seed to string via hex encoding.

func (SharedSeed) SHA256 added in v0.40.0

func (s SharedSeed) SHA256(inputBytes []byte) string

SHA256 the seed bytes, format as string.

func (SharedSeed) TLV

func (s SharedSeed) TLV() tlv.Record

TLV will encode the SharedSeed into a tlv.Record.

func (SharedSeed) ToString

func (s SharedSeed) ToString() string

ToString is a wrapper around Hex() for usability.

Directories

Path Synopsis
Package location contains a common interface for interacting with various Location types and every Location TLV type in the moneysocket protocol
Package location contains a common interface for interacting with various Location types and every Location TLV type in the moneysocket protocol
Package util contains helpers for encoding/decoding tlvs to maintain parity with other moneysocket implementations
Package util contains helpers for encoding/decoding tlvs to maintain parity with other moneysocket implementations
bigsize
Package bigsize emulates the bigsize module of py-moneysocket to achieve parity on various kinds of tlv encodings
Package bigsize emulates the bigsize module of py-moneysocket to achieve parity on various kinds of tlv encodings

Jump to

Keyboard shortcuts

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