Skip to content
Snippets Groups Projects
Select Git revision
  • 96dfef9c9e87c841897b6c8347e780eb59e99bdd
  • 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

contact.go

Blame
  • contact.go 2.14 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 bindings
    
    import (
    	"gitlab.com/elixxir/crypto/contact"
    	"gitlab.com/elixxir/primitives/fact"
    )
    
    /* fact object*/
    //creates a new fact. The factType must be either:
    //  0 - Username
    //  1 - Email
    //  2 - Phone Number
    // The fact must be well formed for the type and must not include commas or
    // semicolons. If it is not well formed, it will be rejected.  Phone numbers
    // must have the two letter country codes appended.  For the complete set of
    // validation, see /elixxir/primitives/fact/fact.go
    func NewFact(factType int, factStr string) (*Fact, error) {
    	f, err := fact.NewFact(fact.FactType(factType), factStr)
    	if err != nil {
    		return nil, err
    	}
    	return &Fact{f: &f}, nil
    }
    
    type Fact struct {
    	f *fact.Fact
    }
    
    func (f *Fact) Get() string {
    	return f.f.Fact
    }
    
    func (f *Fact) Type() int {
    	return int(f.f.T)
    }
    
    func (f *Fact) Stringify() string {
    	return f.f.Stringify()
    }
    
    /* contact object*/
    type Contact struct {
    	c *contact.Contact
    }
    
    // GetID returns the user ID for this user.
    func (c *Contact) GetID() []byte {
    	return c.c.ID.Bytes()
    }
    
    // GetDHPublicKey returns the public key associated with the Contact.
    func (c *Contact) GetDHPublicKey() []byte {
    	return c.c.DhPubKey.Bytes()
    }
    
    // GetDHPublicKey returns hash of a DH proof of key ownership.
    func (c *Contact) GetOwnershipProof() []byte {
    	return c.c.OwnershipProof
    }
    
    // Returns a fact list for adding and getting facts to and from the contact
    func (c *Contact) GetFactList() *FactList {
    	return &FactList{c: c.c}
    }
    
    func (c *Contact) Marshal() ([]byte, error) {
    	return c.c.Marshal(), nil
    }
    
    // GetAPIContact returns the api contact object. Not exported to bindings.
    func (c *Contact) GetAPIContact() *contact.Contact {
    	return c.c
    }