rise~ RiseIdentity

new RiseIdentity(entropyopt, solutionopt, saltopt)

Rise private identity bundle. This is the primary interface for using this module. Allows to generate new identities and use them as the context for protected operations.

Parameters:
NameTypeAttributesDefaultDescription
entropyUint8Array | buffer<optional>

Private key (secp256k1). If absent a new one will be created.

solutionRiseSolution<optional>

Equihash solution corresponding to the given private key.

saltUint8Array | buffer<optional>
module:rise~RiseSolution~SALT

Salt used for local pbkdf2 operations locking/unlocking this identity.

Members

fingerprint :buffer

160 bit solution hash.

Type:
  • buffer

mnemonic :string

BIP39 recovery words.

Type:
  • string

salt :Uint8Array|buffer

Used for local PBKDF2.

Type:
  • Uint8Array | buffer

secret :module:rise~RiseSecret

Underlying secret key.

solution :module:rise~RiseSolution

Underlying equihash solution.

(static) K

Equihash K parameter (length).

(static) MAGIC

Rise magic number. Used as message terminator and protocol identitifier.

(static) N

Equihash N parameter (width in bits).

(static) SALT

Rise default salt for pbkdf2 operations.

(static) TEST_K

Lowered length for testing.

(static) TEST_MAGIC

Magic number to segment test network.

(static) TEST_N

Lowered width for testing.

(static) TEST_Z

Lowered difficulty for testing.

(static) Z

Default difficuly setting. Require this many leading zeroes in solution proofs.

Methods

lock(password) → {buffer}

Creates an encrypted blob representation of this identity, suitable for persistance to disk.

Parameters:
NameTypeDescription
passwordstring

User provided passphrase used to encrypt this identity.

Returns:
Type: 
buffer

message(toPublicKey, bodyopt, headopt) → {module:rise~SignedRiseMessage}

Constructs an encrypted and signed module:rise~RiseMessage for the given public key.

Parameters:
NameTypeAttributesDescription
toPublicKeyUint8Array | buffer

Recipient identity for encryption.

bodyObject.<string, string><optional>

Key-value pairs to serialize in the message.

headObject.<string, string><optional>

Custom headers to include. Headers are NOT ENCRYPTED. Only information that is necessary for routing should be included here.

solve(nopt, kopt, epochopt) → {Promise.<module:rise~RiseSolution>}

Creates a new RiseSolution for this identity. This method updates the internal state and will overwrite any previous solution performed in this context.

Parameters:
NameTypeAttributesDefaultDescription
nnumber<optional>
module:rise~RiseIdentity~N

Width in bits.

knumber<optional>
module:rise~RiseIdentity~K

Solution length.

epochbuffer<optional>
module:rise~RiseIdentity~MAGIC

Prepended to public key before hashing. This can be used to segment protocol versions by changing this value which would render solutions generated with a previous or otherwise different value invalid and require a new solution.

Returns:
Type: 
Promise.<module:rise~RiseSolution>

toJSON() → {object}

Returns a plain object representation of this identity, serializable to JSON.

Returns:
Type: 
object

(static) generate(zeroesopt, nopt, kopt, epochopt) → {module:rise~RiseIdentity}

"Mines" a new module:rise~RiseIdentity and iteratively generates module:rise~RiseSolutions until one is found that satisfies the stated difficulty.

Parameters:
NameTypeAttributesDefaultDescription
zeroesnumber<optional>
module:rise~RiseIdentity~Z

Difficulty level expressed in number of leading zero bits.

nnumber<optional>
module:rise~RiseIdentity~N

Width in bits.

knumber<optional>
module:rise~RiseIdentity~K

Solution length.

epochbuffer<optional>
module:rise~RiseIdentity~MAGIC

Network magic number.

(static) unlock(password, data, saltopt) → {modulex:rise~RiseIdentity}

Decrypts the blob given the password and creates a new instance.

Parameters:
NameTypeAttributesDefaultDescription
passwordstring

User supplied passphrase for decryption.

databuffer

Binary blob of encrypted identity.

saltbuffer<optional>
module:rise~RiseIdentity~SALT

Salt for pbkdf2.

Returns:
Type: 
modulex:rise~RiseIdentity