Skip to content
Snippets Groups Projects
Select Git revision
  • fc58a387f8c8e97706ee4eb3039e48a5901507b6
  • release default
  • 11-22-implement-kv-interface-defined-in-collectiveversionedkvgo
  • master protected
  • XX-4688/DbEncoding
  • hotfix/update
  • @XX-4682/Files
  • hotfix/XX-4655
  • dev protected
  • project/HavenNotifications
  • XX-4602/SilentMessageType
  • jono/npmTest
  • wasmTest2
  • XX-4461/FileUpload
  • XX-4505/blockuser
  • XX-4441
  • Jakub/Emoji-CI-Test
  • testing/websockets
  • fastReg
  • fast-registration
  • NewHostPool
  • v0.3.22
  • v0.3.21
  • v0.3.20
  • v0.3.18
  • v0.3.17
  • v0.3.16
  • v0.3.15
  • v0.3.14
  • v0.3.13
  • v0.3.12
  • v0.3.11
  • v0.3.10
  • v0.3.9
  • v0.3.8
  • v0.3.7
  • v0.3.6
  • v0.3.5
  • v0.3.4
  • 812b395df518ce096d01d5292596ca26f8fe92d9c4487ddfa515e190a51aa1a1
  • 76ba08e2dfa1798412a265404fa271840b52c035869111fce8e8cdb23a036a5a
41 results

index2.html

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
    }