Home Manual Reference Source
public class | source

Contact

A contact that can be used to send or receive secure messages. Essentially an abstraction of a public/private key.

Static Method Summary

Static Public Methods
public static

create(key: String | Buffer | Uint8Array | Array=, salt: String | Buffer | Uint8Array | Array=, scryptConfig: Object=, params: Object=): ContactPromise

Creates a contact from the given key / salt.

public static

fromJSON(json: String | Object | Promise, sync: Boolean=): ContactPromise

Processes a JSON string or object, and converts it into a Contact class.

public static

Alias for fromJSON

Static Private Methods
private static

Imports the asynchronous version of a DiscreteCrypt Contact

private static

Imports the synchronous version of a DiscreteCrypt Contact

private static

_modifyPromise(prom: *): *

Member Summary

Public Members
public

params: {"prime": *, "gen": *}

public

private: *

public

Method Summary

Public Methods
public

Converts the object to the fully asynchronous Contact

public

clean(extra: *): Contact

public

compute(key: String | Buffer | Array): ContactPromise

Computes the private key for a contact from an input key.

public

export(extra: Object): Object

Used to export the (safe) JSON for the Contact for sharing.

public

open(data: *): Promise<Object>

Opens an encrypted payload for the contact.

public

privateKey(): bigInt

Returns the private key

public

publicKey(): bigInt

Returns the public key

public

send(recipient: Contact | ContactPromise, data: *): Promise<Object>

Sends the data to the recipient, encrypted.

public

sign(data: Object | Promise<Object>, bundle: Boolean): Promise<Object>

Signs data using the Contact, using the Schnorr Signature algorithm.

public

verify(data: Object | Promise<Object>, source: Object | Promise.<Object>=): Promise<Boolean>

Verifies the signed data.

Protected Methods
protected

setParams(params: *): Contact

protected

setScrypt(scryptConfig: *): Contact

Static Public Methods

public static create(key: String | Buffer | Uint8Array | Array=, salt: String | Buffer | Uint8Array | Array=, scryptConfig: Object=, params: Object=): ContactPromise source

Creates a contact from the given key / salt.

Params:

NameTypeAttributeDescription
key String | Buffer | Uint8Array | Array=

Key, can be passed in as a string or Buffer-like object.

salt String | Buffer | Uint8Array | Array=

Salt, can be passed in as a hex string or Buffer-like object.

scryptConfig Object=

Configuration for Scrypt

params Object=

Discrete Log Parameters

Return:

ContactPromise

public static fromJSON(json: String | Object | Promise, sync: Boolean=): ContactPromise source

Processes a JSON string or object, and converts it into a Contact class.

Params:

NameTypeAttributeDescription
json String | Object | Promise
sync Boolean=

Determines whether this returns a synchronous contact or asynchronous. If true, the input must be synchronous.

Return:

ContactPromise

public static import(json: String | Object, sync: Boolean): ContactPromise | Contact source

Alias for fromJSON

Params:

NameTypeAttributeDescription
json String | Object
sync Boolean

Specifies whether this should be synchronous or not

See:

Static Private Methods

private static _fromJSONAsync(json: String | Object | Promise): * source

Imports the asynchronous version of a DiscreteCrypt Contact

Params:

NameTypeAttributeDescription
json String | Object | Promise

Return:

*

private static _fromJSONSync(json: String | Object): * source

Imports the synchronous version of a DiscreteCrypt Contact

Params:

NameTypeAttributeDescription
json String | Object

Return:

*

private static _modifyPromise(prom: *): * source

Params:

NameTypeAttributeDescription
prom *

Return:

*

Public Members

public params: {"prime": *, "gen": *} source

public private: * source

public scryptConfig: * source

Public Methods

public async(): ContactPromise source

Converts the object to the fully asynchronous Contact

Return:

ContactPromise

public clean(extra: *): Contact source

Params:

NameTypeAttributeDescription
extra *

Return:

Contact

public compute(key: String | Buffer | Array): ContactPromise source

Computes the private key for a contact from an input key.

Params:

NameTypeAttributeDescription
key String | Buffer | Array

Return:

ContactPromise

public export(extra: Object): Object source

Used to export the (safe) JSON for the Contact for sharing.

Params:

NameTypeAttributeDescription
extra Object

Return:

Object

An object that is safe to share with others

public open(data: *): Promise<Object> source

Opens an encrypted payload for the contact.

Params:

NameTypeAttributeDescription
data *

Return:

Promise<Object>

Decrypted data

public privateKey(): bigInt source

Returns the private key

Return:

bigInt

private key

public publicKey(): bigInt source

Returns the public key

Return:

bigInt

public key

public send(recipient: Contact | ContactPromise, data: *): Promise<Object> source

Sends the data to the recipient, encrypted.

Params:

NameTypeAttributeDescription
recipient Contact | ContactPromise
data *

Return:

Promise<Object>

Encrypted data

public sign(data: Object | Promise<Object>, bundle: Boolean): Promise<Object> source

Signs data using the Contact, using the Schnorr Signature algorithm.

This is not how DiscreteCrypt (C++) currently handles signatures, but that will be changed.

Params:

NameTypeAttributeDescription
data Object | Promise<Object>
bundle Boolean

allows you to specify whether the source data should be bundled in or not.

Return:

Promise<Object>

Signature

public verify(data: Object | Promise<Object>, source: Object | Promise.<Object>=): Promise<Boolean> source

Verifies the signed data.

Params:

NameTypeAttributeDescription
data Object | Promise<Object>
source Object | Promise.<Object>=

Return:

Promise<Boolean>

Protected Methods

protected setParams(params: *): Contact source

Params:

NameTypeAttributeDescription
params *

Return:

Contact

Contact

protected setScrypt(scryptConfig: *): Contact source

Params:

NameTypeAttributeDescription
scryptConfig *

Return:

Contact

Contact