Skip to content
Snippets Groups Projects
Select Git revision
  • f974b6f3e6ef60661ceda767a3b44802f7a378f2
  • release default protected
  • 11-22-implement-kv-interface-defined-in-collectiveversionedkvgo
  • hotfix/TestHostPool_UpdateNdf_AddFilter
  • XX-4719/announcementChannels
  • xx-4717/logLevel
  • jonah/noob-channel
  • master protected
  • XX-4707/tagDiskJson
  • xx-4698/notification-retry
  • hotfix/notifylockup
  • syncNodes
  • hotfix/localCB
  • XX-4677/NewChanManagerMobile
  • XX-4689/DmSync
  • duplicatePrefix
  • XX-4601/HavenInvites
  • finalizedUICallbacks
  • XX-4673/AdminKeySync
  • debugNotifID
  • anne/test
  • v4.7.5
  • v4.7.4
  • v4.7.3
  • v4.7.2
  • v4.7.1
  • v4.6.3
  • v4.6.1
  • v4.5.0
  • v4.4.4
  • v4.3.11
  • v4.3.8
  • v4.3.7
  • v4.3.6
  • v4.3.5
  • v4.2.0
  • v4.3.0
  • v4.3.4
  • v4.3.3
  • v4.3.2
  • v4.3.1
41 results

cmix.go

Blame
  • params.go 3.23 KiB
    ///////////////////////////////////////////////////////////////////////////////
    // Copyright © 2020 xx network SEZC                                          //
    //                                                                           //
    // Use of this source code is governed by a license that can be found in the //
    // LICENSE file                                                              //
    ///////////////////////////////////////////////////////////////////////////////
    
    package xxdk
    
    // params.go define the high level parameters structures (which embed E2E and
    // CMIX params respectively) that are passed down into the core xxdk modules.
    
    import (
    	"encoding/json"
    
    	"gitlab.com/elixxir/client/auth"
    	"gitlab.com/elixxir/client/cmix"
    	"gitlab.com/elixxir/client/e2e"
    	"gitlab.com/elixxir/client/e2e/ratchet/partner/session"
    	"gitlab.com/elixxir/client/e2e/rekey"
    )
    
    // CMIXParams contains the parameters for Network tracking and for specific CMIX
    // messaging settings.
    //
    // FIXME: this breakdown could be cleaner and is an unfortunate side effect of
    //        several refactors of the codebase.
    type CMIXParams struct {
    	Network cmix.Params
    	CMIX    cmix.CMIXParams
    }
    
    // E2EParams holds all the settings for e2e and it's various submodules.
    //
    // Note that Base wraps cmix.CMIXParams to control message send params, so that
    // xxdk library users should copy the desired settings to both.
    // FIXME: this should not wrap a copy of cmix.CMIXParams.
    type E2EParams struct {
    	Session        session.Params
    	Base           e2e.Params
    	Rekey          rekey.Params
    	EphemeralRekey rekey.Params
    	Auth           auth.Params
    }
    
    ////////////////////////////////////////////////////////////////////////////////
    // CMix Params Helper Functions                                               //
    ////////////////////////////////////////////////////////////////////////////////
    
    // GetDefaultCMixParams returns a new CMIXParams with the default parameters.
    func GetDefaultCMixParams() CMIXParams {
    	return CMIXParams{
    		Network: cmix.GetDefaultParams(),
    		CMIX:    cmix.GetDefaultCMIXParams(),
    	}
    }
    
    // Unmarshal fills an empty object with the deserialized contents of the JSON
    // data.
    func (p *CMIXParams) Unmarshal(jsonData []byte) error {
    	return json.Unmarshal(jsonData, p)
    }
    
    // Marshal creates JSON data of the object.
    func (p *CMIXParams) Marshal() ([]byte, error) {
    	return json.Marshal(p)
    }
    
    ////////////////////////////////////////////////////////////////////////////////
    // E2E Params Helper Functions                                                //
    ////////////////////////////////////////////////////////////////////////////////
    
    // GetDefaultE2EParams returns a new E2EParams with the default parameters.
    func GetDefaultE2EParams() E2EParams {
    	return E2EParams{
    		Session:        session.GetDefaultParams(),
    		Base:           e2e.GetDefaultParams(),
    		Rekey:          rekey.GetDefaultParams(),
    		EphemeralRekey: rekey.GetDefaultEphemeralParams(),
    		Auth:           auth.GetDefaultParams(),
    	}
    }
    
    // Unmarshal fills an empty object with the deserialized contents of the JSON
    // data.
    func (p *E2EParams) Unmarshal(jsonData []byte) error {
    	return json.Unmarshal(jsonData, p)
    }
    
    // Marshal creates JSON data of the object.
    func (p *E2EParams) Marshal() ([]byte, error) {
    	return json.Marshal(p)
    }