sphinx

package
v0.0.0-...-f65740e Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2018 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	K = 16
	R = 5
)

Variables

This section is empty.

Functions

func AES_CTR

func AES_CTR(key, plaintext []byte) ([]byte, error)

func BytesToString

func BytesToString(b []byte) string

func GenerateKeyPair

func GenerateKeyPair() ([]byte, []byte, error)

func Hmac

func Hmac(key, message []byte) []byte

func KDF

func KDF(key []byte) []byte

func ProcessSphinxHeader

func ProcessSphinxHeader(packet Header, privKey []byte) (Hop, Commands, Header, error)

ProcessSphinxHeader unwraps one layer of encryption from the header of a sphinx packet. ProcessSphinxHeader recomputes the shared key and checks whether the message authentication code is valid. If not, the packet is dropped and error is returned. If MAC checking was passed successfully ProcessSphinxHeader performs the AES_CTR decryption, recomputes the blinding factor and updates the init public element from the header. Next, ProcessSphinxHeader extracts the routing information from the decrypted packet and returns it, together with the updated init public element. If any crypto or parsing operation failed ProcessSphinxHeader returns an error.

func ProcessSphinxPacket

func ProcessSphinxPacket(packetBytes []byte, privKey []byte) (Hop, Commands, []byte, error)

ProcessSphinxPacket processes the sphinx packet using the given private key. ProcessSphinxPacket unwraps one layer of both the header and the payload encryption. ProcessSphinxPacket returns a new packet and the routing information which should be used by the processing node. If any cryptographic or parsing operation failed ProcessSphinxPacket returns an error.

func ProcessSphinxPayload

func ProcessSphinxPayload(alpha []byte, payload []byte, privKey []byte) ([]byte, error)

ProcessSphinxPayload unwraps a single layer of the encryption from the sphinx packet payload. ProcessSphinxPayload first recomputes the shared secret which is used to perform the AES_CTR decryption. ProcessSphinxPayload returns the new packet payload or an error if the decryption failed.

func XorBytes

func XorBytes(b1, b2 []byte) []byte

Types

This section is empty.

Jump to

Keyboard shortcuts

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