Documentation ¶
Index ¶
- Constants
- func AesCtr(key, plaintext []byte) ([]byte, error)
- func BytesToString(b []byte) string
- func CompareElements(e1, e2 CryptoElement) bool
- func GenerateKeyPair() (*PrivateKey, *PublicKey, error)
- func Hmac(key, message []byte) ([]byte, error)
- func KDF(key []byte) ([]byte, error)
- func ProcessSphinxHeader(packet Header, privKey *PrivateKey) (Hop, Commands, Header, error)
- func ProcessSphinxPacket(packetBytes []byte, privKey *PrivateKey) (Hop, Commands, []byte, error)
- func ProcessSphinxPayload(alpha []byte, payload []byte, privKey *PrivateKey) ([]byte, error)
- func XorBytes(b1, b2 []byte) []byte
- type Commands
- func (*Commands) Descriptor() ([]byte, []int)
- func (m *Commands) GetDelay() float64
- func (m *Commands) GetFlag() []byte
- func (*Commands) ProtoMessage()
- func (m *Commands) Reset()
- func (m *Commands) String() string
- func (m *Commands) XXX_DiscardUnknown()
- func (m *Commands) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *Commands) XXX_Merge(src proto.Message)
- func (m *Commands) XXX_Size() int
- func (m *Commands) XXX_Unmarshal(b []byte) error
- type CryptoElement
- type FieldElement
- type Header
- func (*Header) Descriptor() ([]byte, []int)
- func (m *Header) GetAlpha() []byte
- func (m *Header) GetBeta() []byte
- func (m *Header) GetMac() []byte
- func (*Header) ProtoMessage()
- func (m *Header) Reset()
- func (m *Header) String() string
- func (m *Header) XXX_DiscardUnknown()
- func (m *Header) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *Header) XXX_Merge(src proto.Message)
- func (m *Header) XXX_Size() int
- func (m *Header) XXX_Unmarshal(b []byte) error
- type HeaderInitials
- func (*HeaderInitials) Descriptor() ([]byte, []int)
- func (m *HeaderInitials) GetAlpha() []byte
- func (m *HeaderInitials) GetBlinder() []byte
- func (m *HeaderInitials) GetSecret() []byte
- func (m *HeaderInitials) GetSecretHash() []byte
- func (*HeaderInitials) ProtoMessage()
- func (m *HeaderInitials) Reset()
- func (m *HeaderInitials) String() string
- func (m *HeaderInitials) XXX_DiscardUnknown()
- func (m *HeaderInitials) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *HeaderInitials) XXX_Merge(src proto.Message)
- func (m *HeaderInitials) XXX_Size() int
- func (m *HeaderInitials) XXX_Unmarshal(b []byte) error
- type Hop
- func (*Hop) Descriptor() ([]byte, []int)
- func (m *Hop) GetAddress() string
- func (m *Hop) GetId() string
- func (m *Hop) GetPubKey() []byte
- func (*Hop) ProtoMessage()
- func (m *Hop) Reset()
- func (m *Hop) String() string
- func (m *Hop) XXX_DiscardUnknown()
- func (m *Hop) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *Hop) XXX_Merge(src proto.Message)
- func (m *Hop) XXX_Size() int
- func (m *Hop) XXX_Unmarshal(b []byte) error
- type PrivateKey
- type PublicKey
- type RoutingInfo
- func (*RoutingInfo) Descriptor() ([]byte, []int)
- func (m *RoutingInfo) GetMac() []byte
- func (m *RoutingInfo) GetNextHop() *Hop
- func (m *RoutingInfo) GetNextHopMetaData() []byte
- func (m *RoutingInfo) GetRoutingCommands() *Commands
- func (*RoutingInfo) ProtoMessage()
- func (m *RoutingInfo) Reset()
- func (m *RoutingInfo) String() string
- func (m *RoutingInfo) XXX_DiscardUnknown()
- func (m *RoutingInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *RoutingInfo) XXX_Merge(src proto.Message)
- func (m *RoutingInfo) XXX_Size() int
- func (m *RoutingInfo) XXX_Unmarshal(b []byte) error
- type SphinxPacket
- func (*SphinxPacket) Descriptor() ([]byte, []int)
- func (m *SphinxPacket) GetHdr() *Header
- func (m *SphinxPacket) GetPld() []byte
- func (*SphinxPacket) ProtoMessage()
- func (m *SphinxPacket) Reset()
- func (m *SphinxPacket) String() string
- func (m *SphinxPacket) XXX_DiscardUnknown()
- func (m *SphinxPacket) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *SphinxPacket) XXX_Merge(src proto.Message)
- func (m *SphinxPacket) XXX_Size() int
- func (m *SphinxPacket) XXX_Unmarshal(b []byte) error
Constants ¶
const ( FieldElementSize = 32 PrivateKeySize = FieldElementSize PublicKeySize = FieldElementSize )
const (
// K TODO: document padding-related Sphinx parameter
K = 16
)
Variables ¶
This section is empty.
Functions ¶
func BytesToString ¶
BytesToString converts the given bytes to a string.
func CompareElements ¶
func CompareElements(e1, e2 CryptoElement) bool
func GenerateKeyPair ¶
func GenerateKeyPair() (*PrivateKey, *PublicKey, error)
GenerateKeyPair returns public and private keypair bytes for Curve25519 elliptic curve, or an error.
func Hmac ¶
Hmac computes a hash-based message authentication code for a given key and message. Returns a byte array containing the MAC checksum.
func ProcessSphinxHeader ¶
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 ¶
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 *PrivateKey) ([]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.
Types ¶
type Commands ¶
type Commands struct { Delay float64 `protobuf:"fixed64,1,opt,name=Delay,json=delay,proto3" json:"Delay,omitempty"` Flag []byte `protobuf:"bytes,2,opt,name=Flag,json=flag,proto3" json:"Flag,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
func (*Commands) Descriptor ¶
func (*Commands) ProtoMessage ¶
func (*Commands) ProtoMessage()
func (*Commands) XXX_DiscardUnknown ¶
func (m *Commands) XXX_DiscardUnknown()
func (*Commands) XXX_Marshal ¶
func (*Commands) XXX_Unmarshal ¶
type FieldElement ¶
type FieldElement struct {
// contains filtered or unexported fields
}
func BytesToFieldElement ¶
func BytesToFieldElement(b []byte) *FieldElement
func RandomElement ¶
func RandomElement() (*FieldElement, error)
func (*FieldElement) Bytes ¶
func (fe *FieldElement) Bytes() []byte
type Header ¶
type Header struct { Alpha []byte `protobuf:"bytes,1,opt,name=Alpha,json=alpha,proto3" json:"Alpha,omitempty"` Beta []byte `protobuf:"bytes,2,opt,name=Beta,json=beta,proto3" json:"Beta,omitempty"` Mac []byte `protobuf:"bytes,3,opt,name=Mac,json=mac,proto3" json:"Mac,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
func (*Header) Descriptor ¶
func (*Header) ProtoMessage ¶
func (*Header) ProtoMessage()
func (*Header) XXX_DiscardUnknown ¶
func (m *Header) XXX_DiscardUnknown()
func (*Header) XXX_Marshal ¶
func (*Header) XXX_Unmarshal ¶
type HeaderInitials ¶
type HeaderInitials struct { Alpha []byte `protobuf:"bytes,1,opt,name=Alpha,json=alpha,proto3" json:"Alpha,omitempty"` Secret []byte `protobuf:"bytes,2,opt,name=Secret,json=secret,proto3" json:"Secret,omitempty"` Blinder []byte `protobuf:"bytes,3,opt,name=Blinder,json=blinder,proto3" json:"Blinder,omitempty"` SecretHash []byte `protobuf:"bytes,4,opt,name=SecretHash,json=secretHash,proto3" json:"SecretHash,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
func (*HeaderInitials) Descriptor ¶
func (*HeaderInitials) Descriptor() ([]byte, []int)
func (*HeaderInitials) GetAlpha ¶
func (m *HeaderInitials) GetAlpha() []byte
func (*HeaderInitials) GetBlinder ¶
func (m *HeaderInitials) GetBlinder() []byte
func (*HeaderInitials) GetSecret ¶
func (m *HeaderInitials) GetSecret() []byte
func (*HeaderInitials) GetSecretHash ¶
func (m *HeaderInitials) GetSecretHash() []byte
func (*HeaderInitials) ProtoMessage ¶
func (*HeaderInitials) ProtoMessage()
func (*HeaderInitials) Reset ¶
func (m *HeaderInitials) Reset()
func (*HeaderInitials) String ¶
func (m *HeaderInitials) String() string
func (*HeaderInitials) XXX_DiscardUnknown ¶
func (m *HeaderInitials) XXX_DiscardUnknown()
func (*HeaderInitials) XXX_Marshal ¶
func (m *HeaderInitials) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*HeaderInitials) XXX_Merge ¶
func (m *HeaderInitials) XXX_Merge(src proto.Message)
func (*HeaderInitials) XXX_Size ¶
func (m *HeaderInitials) XXX_Size() int
func (*HeaderInitials) XXX_Unmarshal ¶
func (m *HeaderInitials) XXX_Unmarshal(b []byte) error
type Hop ¶
type Hop struct { Id string `protobuf:"bytes,1,opt,name=Id,json=id,proto3" json:"Id,omitempty"` Address string `protobuf:"bytes,2,opt,name=Address,json=address,proto3" json:"Address,omitempty"` PubKey []byte `protobuf:"bytes,3,opt,name=PubKey,json=pubKey,proto3" json:"PubKey,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
func (*Hop) Descriptor ¶
func (*Hop) GetAddress ¶
func (*Hop) ProtoMessage ¶
func (*Hop) ProtoMessage()
func (*Hop) XXX_DiscardUnknown ¶
func (m *Hop) XXX_DiscardUnknown()
func (*Hop) XXX_Unmarshal ¶
type PrivateKey ¶
type PrivateKey struct {
// contains filtered or unexported fields
}
TODO: redefine private and public keys to be interfaces instead?
func BytesToPrivateKey ¶
func BytesToPrivateKey(b []byte) *PrivateKey
func (*PrivateKey) Bytes ¶
func (pk *PrivateKey) Bytes() []byte
func (*PrivateKey) MarshalBinary ¶
func (pk *PrivateKey) MarshalBinary() ([]byte, error)
MarshalBinary is an implementation of a method on the BinaryMarshaler interface defined in https://golang.org/pkg/encoding/
func (*PrivateKey) ToFieldElement ¶
func (pk *PrivateKey) ToFieldElement() *FieldElement
func (*PrivateKey) UnmarshalBinary ¶
func (pk *PrivateKey) UnmarshalBinary(data []byte) error
UnmarshalBinary is an implementation of a method on the BinaryUnmarshaler interface defined in https://golang.org/pkg/encoding/
type PublicKey ¶
type PublicKey struct {
// contains filtered or unexported fields
}
func BytesToPublicKey ¶
func (*PublicKey) MarshalBinary ¶
MarshalBinary is an implementation of a method on the BinaryMarshaler interface defined in https://golang.org/pkg/encoding/
func (*PublicKey) ToFieldElement ¶
func (pub *PublicKey) ToFieldElement() *FieldElement
func (*PublicKey) UnmarshalBinary ¶
UnmarshalBinary is an implementation of a method on the BinaryUnmarshaler interface defined in https://golang.org/pkg/encoding/
type RoutingInfo ¶
type RoutingInfo struct { NextHop *Hop `protobuf:"bytes,1,opt,name=NextHop,json=nextHop,proto3" json:"NextHop,omitempty"` RoutingCommands *Commands `protobuf:"bytes,2,opt,name=RoutingCommands,json=routingCommands,proto3" json:"RoutingCommands,omitempty"` NextHopMetaData []byte `protobuf:"bytes,3,opt,name=NextHopMetaData,json=nextHopMetaData,proto3" json:"NextHopMetaData,omitempty"` Mac []byte `protobuf:"bytes,4,opt,name=Mac,json=mac,proto3" json:"Mac,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
func (*RoutingInfo) Descriptor ¶
func (*RoutingInfo) Descriptor() ([]byte, []int)
func (*RoutingInfo) GetMac ¶
func (m *RoutingInfo) GetMac() []byte
func (*RoutingInfo) GetNextHop ¶
func (m *RoutingInfo) GetNextHop() *Hop
func (*RoutingInfo) GetNextHopMetaData ¶
func (m *RoutingInfo) GetNextHopMetaData() []byte
func (*RoutingInfo) GetRoutingCommands ¶
func (m *RoutingInfo) GetRoutingCommands() *Commands
func (*RoutingInfo) ProtoMessage ¶
func (*RoutingInfo) ProtoMessage()
func (*RoutingInfo) Reset ¶
func (m *RoutingInfo) Reset()
func (*RoutingInfo) String ¶
func (m *RoutingInfo) String() string
func (*RoutingInfo) XXX_DiscardUnknown ¶
func (m *RoutingInfo) XXX_DiscardUnknown()
func (*RoutingInfo) XXX_Marshal ¶
func (m *RoutingInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*RoutingInfo) XXX_Merge ¶
func (m *RoutingInfo) XXX_Merge(src proto.Message)
func (*RoutingInfo) XXX_Size ¶
func (m *RoutingInfo) XXX_Size() int
func (*RoutingInfo) XXX_Unmarshal ¶
func (m *RoutingInfo) XXX_Unmarshal(b []byte) error
type SphinxPacket ¶
type SphinxPacket struct { Hdr *Header `protobuf:"bytes,1,opt,name=Hdr,json=hdr,proto3" json:"Hdr,omitempty"` Pld []byte `protobuf:"bytes,2,opt,name=Pld,json=pld,proto3" json:"Pld,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
func PackForwardMessage ¶
func PackForwardMessage(path config.E2EPath, delays []float64, message []byte) (SphinxPacket, error)
PackForwardMessage encapsulates the given message into the cryptographic Sphinx packet format. As arguments the function takes the path, consisting of the sequence of nodes the packet should traverse and the destination of the message, a set of delays and the information about the curve used to perform cryptographic operations. In order to encapsulate the message PackForwardMessage computes two parts of the packet - the header and the encrypted payload. If creating of any of the packet block failed, an error is returned. Otherwise, a Sphinx packet format is returned.
func (*SphinxPacket) Descriptor ¶
func (*SphinxPacket) Descriptor() ([]byte, []int)
func (*SphinxPacket) GetHdr ¶
func (m *SphinxPacket) GetHdr() *Header
func (*SphinxPacket) GetPld ¶
func (m *SphinxPacket) GetPld() []byte
func (*SphinxPacket) ProtoMessage ¶
func (*SphinxPacket) ProtoMessage()
func (*SphinxPacket) Reset ¶
func (m *SphinxPacket) Reset()
func (*SphinxPacket) String ¶
func (m *SphinxPacket) String() string
func (*SphinxPacket) XXX_DiscardUnknown ¶
func (m *SphinxPacket) XXX_DiscardUnknown()
func (*SphinxPacket) XXX_Marshal ¶
func (m *SphinxPacket) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*SphinxPacket) XXX_Merge ¶
func (m *SphinxPacket) XXX_Merge(src proto.Message)
func (*SphinxPacket) XXX_Size ¶
func (m *SphinxPacket) XXX_Size() int
func (*SphinxPacket) XXX_Unmarshal ¶
func (m *SphinxPacket) XXX_Unmarshal(b []byte) error