Development
...
Basics
Accounts
7 min
signum is an account oriented blockchain (in contrast to https //en wikipedia org/wiki/unspent transaction output like it used in bitcoin) this concept is a bit more intuitive, as this is similar to common bank accounts other than in ethereum, accounts in signum can be identified by three different types public key, numerical id, and the so called reed solomon address the public key is the origin and is being generated using a specific key generation algorithm the numeric id and reed solomonis are derived from the public key and are more commonly used for accounts identification due to their better readability the numeric id and reed solomon address can always be derived from a public key, but you can't derive a public key from the numeric id or reed solomon address! type example public key 41074bdc6430fc0eafffab07682c092922c39475ddfaaf09451dc9950c1bc45f numeric id 8952122635653861124 reed solomon address s 5ms6 5fby 74h4 9n4hs create account object creating an account object with signumjs is pretty easy the account will not be visible (created) on the chain unless you send or receive something to that address const {generatemasterkeys} = require('@signumjs/crypto') const {address} = require('@signumjs/core') ((seed)=> { const keys = generatemasterkeys(seed) const accountaddress = address frompublickey(keys publickey) console log('public key', accountaddress getpublickey()) console log('numeric id', accountaddress getnumericid()) console log('reed solomon', accountaddress getreedsolomonaddress()) })('somerandomseed') as one can see here, to generate the cryptographic keys the method generatemasterkeys is being used to work with the representations of an account the value object class address should be used ideally, one creates the address object from the public key, but for common use cases, where a public key is not really necessary, i e to identify a recipient, you can also create the address object from the numeric id or reed solomon address generate secure passphrases/seeds as depicted in the upper example, the generatemasterkeys function needs a seed to generate the keys it is crucial that the seed is sufficiently random, such it cannot be guessed you can use whatever (secure) random input string to create the keys math random() is not a secure random number generator never use it to generate a random seed ideally, you use the platforms crypto methods ( https //nodejs org/api/crypto html#cryptorandombytessize callback or https //developer mozilla org/en us/docs/web/api/crypto/getrandomvalues ), but to facilitate the generation of a strong seed, signumjs provides a cross platform (isomorphic) method to generate a 12 word seed based on a 2048 english words dictionary (which is used by https //github com/bitcoin/bips/blob/master/bip 0039 mediawiki#wordlists ) const {randombytes} = require("crypto"); // works only with nodejs const {passphrasegenerator} = require("@signumjs/crypto"); const generator = new passphrasegenerator() function generatedefault() { // this works throughout all platforms, but we recommend to add additional entropy return generator generatepassphrase() } function generatewithadditionalentropy() { // now, we use the platform specific random function const random = randombytes(128) // and add more entropy to the generator if possible, this is the preferred way return generator generatepassphrase(array from(random)) } // our entry point has to be async, as our subsequent calls are // this pattern keeps your app running until all async calls are executed (async () => { for (let i = 1; i < 10; ++i) { console log(i, (await generatedefault()) join(' ')) } console log('====================with additional entropy==============================') for (let i = 1; i < 10; ++i) { console log(i, (await generatewithadditionalentropy()) join(' ')) } })(); are 2048 known words as dictionary for a 12 word passphrase secure?! see https //trustwallet com/blog/could someone guess your mnemonic https //ethereum stackexchange com/questions/99691/how secure is the seed phrase 12 words 24 words convert account identifiers to convert the account identifiers just use the address value object class const {address} = require("@signumjs/core"); // now, we don't know if the account is an numeric id or an reed solomon address // the most convenient way is to use the address value object class try { // we use the create method, that tries to guess and convert the input // if it cannot convert the input an exception will be thrown const address = address create(account) console log('numeric id ', address getnumericid()) // the prefix is not an identifying part of the address, and though interchangeable // by default, 's' is being used, but we can use whatever we want // convention is s for main net, and ts for test net const addressprefix = 'foo' console log('reed solomon address ', address getreedsolomonaddress(addressprefix)) // attention as it is not possible to derive a public key from numeric id or reed solomon address, // the following instruction won't work, i e the output stays empty console log('public key', address getpublickey()) } catch (e) { // invalid input console error(e) } active accounts in signum we different states of registered accounts in the chain \[inexistent] not registered at all no transaction from or to that account was done yet \[inactive] registered, but without public key assigned somebody sent something to that account \[active] registered and with public key assigned usually, the account did an outgoing transaction an active account is considered as fully secured account, and is the only way to receive p2p encrypted messages see more about activation https //github com/signum network/signum account activator