trisa

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: May 30, 2024 License: MIT Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMissingIdentity = &api.Error{
		Code:    api.Error_MISSING_FIELDS,
		Message: "identity payload is required",
		Retry:   true,
	}

	ErrMissingTransaction = &api.Error{
		Code:    api.Error_MISSING_FIELDS,
		Message: "transaction payload is required",
		Retry:   true,
	}

	ErrMissingSentAt = &api.Error{
		Code:    api.Error_MISSING_FIELDS,
		Message: "sent at payload field is required for non-repudiation",
		Retry:   true,
	}

	ErrInvalidTimestamp = &api.Error{
		Code:    api.Error_VALIDATION_ERROR,
		Message: "could not parse payload timestamp as RFC3339 timestamp",
		Retry:   true,
	}
)

Functions

func Validate

func Validate(payload *api.Payload) *api.Error

Validates an incoming TRISA payload, ensuring that it has all required fields and handled types for the specified node. If not, a TRISA error is returned.

Types

type Incoming

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

Incoming stores the full context of an incoming transfer message for handling.

func NewIncoming

func NewIncoming(ctx context.Context, peer peers.Peer, env *api.SecureEnvelope, log zerolog.Logger) *Incoming

func (*Incoming) Error

func (i *Incoming) Error(reject *api.Error) (out *Outgoing, err error)

Create a rejection envelope from the api error

func (*Incoming) ID

func (i *Incoming) ID() string

Helper for retrieving the envelope ID directly from the envelope.

func (*Incoming) Model

func (i *Incoming) Model() *models.SecureEnvelope

Converts the incoming message into a database model for storage. This method assumes that the envelopeID has already been parsed as a uuid and panics if the envelopeID is not a uuid. Since this is an incoming message, the encryption key and hmac secret are assumed to be sealed using a public key of the local TRISA node, identified by the public key signature.

func (*Incoming) Outgoing

func (i *Incoming) Outgoing(msg *api.SecureEnvelope) (out *Outgoing, err error)

Create an outgoing envelope associated with the incoming envelope

func (*Incoming) PublicKeySignature

func (i *Incoming) PublicKeySignature() string

Helper for retrieving the envelope public key signature if available

func (*Incoming) Reject

func (i *Incoming) Reject(code api.Error_Code, message string, retry bool) (*Outgoing, error)

Create a rejection envelope from the incoming envelope

func (*Incoming) SetHMACValid

func (i *Incoming) SetHMACValid(valid bool)

Mark the incoming HMAC as validated (or not).

func (*Incoming) UpdateRecord

func (i *Incoming) UpdateRecord() (err error)

Helper method to update the transaction with the incoming record details

type Outgoing

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

func (*Outgoing) Model

func (o *Outgoing) Model() (model *models.SecureEnvelope, err error)

Creates an model to save an outgoing secure envelope to disk. The complicated thing about outgoing secure envelopes is that they're encrypted with the recipient's public keys, so instead, original envelope is kept intact and the encryption key and hmac secret are saved with the keys used to decrypt the associated incoming envelope.

func (*Outgoing) SetStorageCrypto

func (o *Outgoing) SetStorageCrypto(k keys.PublicKey, c crypto.Crypto) (err error)

type Server

type Server struct {
	api.UnimplementedTRISAHealthServer
	api.UnimplementedTRISANetworkServer
	// contains filtered or unexported fields
}

The TRISA server implements the TRISANetwork and TRISAHealth services defined by the TRISA protocol buffers in the github.com/trisacrypto/trisa repository. It can be run as a standalone service or can be embedded as a component in a larger service.

func New

func New(conf config.TRISAConfig, network network.Network, store store.Store, echan chan<- error) (s *Server, err error)

Create a new TRISA server ready to handle gRPC requests.

func (*Server) ConfirmAddress

func (s *Server) ConfirmAddress(ctx context.Context, in *api.Address) (*api.AddressConfirmation, error)

Address confirmation allows an originator VASP to establish that a beneficiary VASP has control of a crypto wallet address, prior to sending transaction information with sensitive PII data.

NOTE: this RPC is currently undefined by the v9 whitepaper

func (*Server) HandleIncoming

func (s *Server) HandleIncoming(in *Incoming) (out *Outgoing, err error)

func (*Server) HandleIncomingError

func (s *Server) HandleIncomingError(in *Incoming) (out *Outgoing, err error)

Handles envelopes that only contain errors and require no decryption. The error is stored locally and to complete the transfer, the error is echoed back to the sender.

func (*Server) HandleSealed

func (s *Server) HandleSealed(in *Incoming) (out *Outgoing, err error)

func (*Server) KeyExchange

func (s *Server) KeyExchange(ctx context.Context, in *api.SigningKey) (out *api.SigningKey, err error)

KeyExchange is a preperatory RPC that is required before Transfer RPCs to ensure each counterparty has the public keys needed to encrypt secure envelopes for the recipient.

func (*Server) Run

func (s *Server) Run(sock net.Listener)

func (*Server) Serve

func (s *Server) Serve() (err error)

func (*Server) Shutdown

func (s *Server) Shutdown() error

func (*Server) Status

func (s *Server) Status(ctx context.Context, in *api.HealthCheck) (out *api.ServiceState, err error)

Status implements the TRISAHealth gRPC interface and is used for GDS health checks. TODO: allow user to configure not before/after time window

func (*Server) Transfer

func (s *Server) Transfer(ctx context.Context, in *api.SecureEnvelope) (_ *api.SecureEnvelope, err error)

func (*Server) TransferStream

func (s *Server) TransferStream(stream api.TRISANetwork_TransferStreamServer) (err error)

Directories

Path Synopsis
gds

Jump to

Keyboard shortcuts

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