From 1a6f587a02fdf5c0082a97b4dde735c893b0606f Mon Sep 17 00:00:00 2001 From: Jake Taylor <jake@elixxir.io> Date: Thu, 23 Jun 2022 14:20:17 -0500 Subject: [PATCH] update bindings docs --- bindings/connect.go | 11 ----------- bindings/e2eHandler.go | 41 ++++++++++++++++++++++++++++++----------- 2 files changed, 30 insertions(+), 22 deletions(-) diff --git a/bindings/connect.go b/bindings/connect.go index 42add7b30..81a482a32 100644 --- a/bindings/connect.go +++ b/bindings/connect.go @@ -52,17 +52,6 @@ func (c *Cmix) Connect(e2eId int, recipientContact []byte) ( return connectionTrackerSingleton.make(connection), nil } -// E2ESendReport is the bindings representation of the return values of SendE2E -// Example E2ESendReport: -// {"Rounds":[1,5,9], -// "MessageID":"51Yy47uZbP0o2Y9B/kkreDLTB6opUol3M3mYiY2dcdQ=", -// "Timestamp":1653582683183384000} -type E2ESendReport struct { - RoundsList - MessageID []byte - Timestamp int64 -} - // SendE2E is a wrapper for sending specifically to the Connection's partner.Manager // Returns marshalled E2ESendReport func (c *Connection) SendE2E(mt int, payload []byte) ([]byte, error) { diff --git a/bindings/e2eHandler.go b/bindings/e2eHandler.go index e0d8e9d19..89879d654 100644 --- a/bindings/e2eHandler.go +++ b/bindings/e2eHandler.go @@ -18,13 +18,28 @@ type IdList struct { Ids [][]byte } +// E2ESendReport is the bindings representation of the return values of SendE2E +// Example E2ESendReport: +// {"Rounds":[1,5,9], +// "MessageID":"51Yy47uZbP0o2Y9B/kkreDLTB6opUol3M3mYiY2dcdQ=", +// "Timestamp":1653582683183384000} +type E2ESendReport struct { + RoundsList + MessageID []byte + Timestamp int64 +} + // GetReceptionID returns the marshalled default IDs +// Returns: +// - []byte - the marshalled bytes of the id.ID object. func (e *E2e) GetReceptionID() []byte { return e.api.GetE2E().GetReceptionID().Marshal() } // GetAllPartnerIDs returns a marshalled list of all partner IDs that the user has // an E2E relationship with. +// Returns: +// - []byte - the marshalled bytes of the IdList object. func (e *E2e) GetAllPartnerIDs() ([]byte, error) { partnerIds := e.api.GetE2E().GetAllPartnerIDs() convertedIds := make([][]byte, len(partnerIds)) @@ -59,18 +74,24 @@ func (e *E2e) FirstPartitionSize() int { } // GetHistoricalDHPrivkey returns the user's marshalled Historical DH Private Key +// Returns: +// - []byte - the marshalled bytes of the cyclic.Int object. func (e *E2e) GetHistoricalDHPrivkey() ([]byte, error) { return e.api.GetE2E().GetHistoricalDHPrivkey().MarshalJSON() } // GetHistoricalDHPubkey returns the user's marshalled Historical DH // Public Key +// Returns: +// - []byte - the marshalled bytes of the cyclic.Int object. func (e *E2e) GetHistoricalDHPubkey() ([]byte, error) { return e.api.GetE2E().GetHistoricalDHPubkey().MarshalJSON() } // HasAuthenticatedChannel returns true if an authenticated channel with the // partner exists, otherwise returns false +// Parameters: +// - partnerId - the marshalled bytes of the id.ID object. func (e *E2e) HasAuthenticatedChannel(partnerId []byte) (bool, error) { partner, err := id.Unmarshal(partnerId) if err != nil { @@ -88,6 +109,11 @@ func (e *E2e) RemoveService(tag string) error { // recipient of the passed message type, per the given // parameters - encrypted with end-to-end encryption. // Default parameters can be retrieved through +// Parameters: +// - recipientId - the marshalled bytes of the id.ID object. +// - e2eParams - the marshalled bytes of the e2e.Params object. +// Returns: +// - []byte - the marshalled bytes of the E2ESendReport object. func (e *E2e) SendE2E(messageType int, recipientId, payload, e2eParams []byte) ([]byte, error) { @@ -106,17 +132,10 @@ func (e *E2e) SendE2E(messageType int, recipientId, payload, return nil, err } - result := SendE2eResults{ - roundIds: roundIds, - messageId: messageId.Marshal(), - ts: ts.UnixNano(), + result := E2ESendReport{ + RoundsList: makeRoundsList(roundIds), + MessageID: messageId.Marshal(), + Timestamp: ts.UnixNano(), } return json.Marshal(result) } - -// SendE2eResults is the return type for SendE2e -type SendE2eResults struct { - roundIds []id.Round - messageId []byte - ts int64 -} -- GitLab