Skip to content

Commit 47167e3

Browse files
committed
allowing channels with height 1
1 parent 14683a5 commit 47167e3

File tree

6 files changed

+19
-17
lines changed

6 files changed

+19
-17
lines changed

lib/message.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const MESSAGE_FRAGMENT_TRYTES = 2187
1616

1717
const Errors = {
1818
INVALID_LENGTH: `The message cannot be longer than ${Math.pow(27, MESSAGE_LENGTH_TRYTES)} trytes.`,
19-
INVALID_HEIGHT: "Merkle tree height must be between 2 and 26.",
19+
INVALID_HEIGHT: "Merkle tree height must be between 1 and 26.",
2020
INVALID_SECURITY_LEVEL: "Key security must be between 1 and 4.",
2121
INVALID_INDEX: "Index is either negative or to big for amount of provided authentication hashes.",
2222
WRONG_INDEX: "Message has different index than requested. Please check channel root.",
@@ -54,7 +54,7 @@ function createTransfers(merkleRoot, message, sig, index,
5454
const key = getKey(merkleRoot, channelPassword, indexTrits, messagePassword)
5555

5656
const height = authPathHashes.length
57-
if (height < 2 || height > 26) {
57+
if (height < 1 || height > 26) {
5858
throw new Error(Errors.INVALID_HEIGHT)
5959
}
6060
if (index < 0 || index >= Math.pow(2, height)) {

lib/raam.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ class RAAM extends RAAMReader {
2727
* keys of the messages.
2828
* @param {Array.<Node>} hashes - The nodes of the merkle tree which will be used for the
2929
* authentication path of the messages.
30+
* @param {number} height - A number between 1 and 26 representing the height
31+
* of the merkle tree used for this channel.
3032
* @param {object} [options] - Optional parameters.
3133
* @param {API} [options.iota] - A composed IOTA API for communication with a full node providing POW.
3234
* @param {Trytes} [options.channelPassword] - The optional password for the channel as trytes.
@@ -68,7 +70,7 @@ class RAAM extends RAAMReader {
6870
* An object representing the compiled RAAM message with all neccessary information to create its transfers.
6971
* @typedef {object} Message
7072
* @property {number} index - The index of the message in the channel.
71-
* @property {number} height - A number between 2 and 26 representing the height
73+
* @property {number} height - A number between 1 and 26 representing the height
7274
* of the merkle tree used for this channel.
7375
* @property {number} security - The security of the signing and encryption keys as a number between 1 and 4.
7476
* @property {Trytes} message - The message to attach to the channel as trytes.
@@ -184,7 +186,7 @@ class RAAM extends RAAMReader {
184186
* @param {Trytes} seed - The seed from which the signing keys are created.
185187
* @param {object} [options] - Optional parameters.
186188
* @param {number} [options.amount] - The maximum amount of messages that can be published in this channel.
187-
* @param {number} [options.height = Math.ceil(Math.log2(amount))] - A number between 2 and 26 representing the height
189+
* @param {number} [options.height = Math.ceil(Math.log2(amount))] - A number between 1 and 26 representing the height
188190
* of the merkle tree used for this channel.
189191
* @param {API} [options.iota = this.iota] - A composed IOTA API for communication with a full node providing POW.
190192
* @param {Trytes} [options.channelPassword] - The optional password for the channel as trytes.
@@ -241,7 +243,7 @@ class RAAM extends RAAMReader {
241243
* @param {API} [options.iota = this.iota] - A composed IOTA API for communication with a full node providing POW.
242244
* @param {Trytes} [options.channelPassword] - The optional password for the channel as trytes.
243245
* @param {number} [options.amount] - The maximum amount of messages that can be published in this channel.
244-
* @param {number} [options.height = Math.ceil(Math.log2(amount))] - A number between 2 and 26 representing the height
246+
* @param {number} [options.height = Math.ceil(Math.log2(amount))] - A number between 1 and 26 representing the height
245247
* of the merkle tree used for this channel.
246248
* @param {Trytes} [options.seed] - The seed from which the signing keys are created.
247249
* @param {number} [options.offset = 0] - The starting index used for building the subroots from which the keys are created.

lib/raamReader.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class RAAMReader {
2727
* This is parameter is only used as an extra verification information.
2828
* @param {number} [options.amount] - The maximum amount of messages in this channel.
2929
* From this the height of the channel can be calculated. This is parameter is only used as an extra verification information.
30-
* @param {number} [options.height] - The height as a number between 2 and 26 of the channel yielding the maximum
30+
* @param {number} [options.height] - The height as a number between 1 and 26 of the channel yielding the maximum
3131
* amount of messages of the channel. This is parameter is only used as an extra verification information.
3232
*/
3333
constructor(channelRoot, {iota, channelPassword, security,
@@ -245,7 +245,7 @@ class RAAMReader {
245245
* different messages. The ith element is the password for the ith message in the channel.
246246
* @param {number} [options.security] - The security of the signing and encryption keys as a number between 1 and 4.
247247
* This is parameter is only used as an extra verification information.
248-
* @param {number} [options.height] - The height as a number between 2 and 26 of the channel yielding the maximum
248+
* @param {number} [options.height] - The height as a number between 1 and 26 of the channel yielding the maximum
249249
* amount of messages of the channel. This is parameter is only used as an extra verification information.
250250
*
251251
* @returns {Promise}
@@ -312,7 +312,7 @@ class RAAMReader {
312312
* the found message.
313313
* @param {number} [options.security] - The security of the signing and encryption keys as a number between 1 and 4.
314314
* This is parameter is only used as an extra verification information.
315-
* @param {number} [options.height] - The height as a number between 2 and 26 of the channel yielding the maximum
315+
* @param {number} [options.height] - The height as a number between 1 and 26 of the channel yielding the maximum
316316
* amount of messages of the channel. This is parameter is only used as an extra verification information.
317317
*
318318
* @returns {Promise}
@@ -359,7 +359,7 @@ class RAAMReader {
359359
* the found message.
360360
* @param {number} [options.security] - The security of the signing and encryption keys as a number between 1 and 4.
361361
* This is parameter is only used as an extra verification information.
362-
* @param {number} [options.height] - The height as a number between 2 and 26 of the channel yielding the maximum
362+
* @param {number} [options.height] - The height as a number between 1 and 26 of the channel yielding the maximum
363363
* amount of messages of the channel. This is parameter is only used as an extra verification information.
364364
*
365365
* @returns {SingleSubscription} An object containing information about the created subscription, including the

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "raam.client.js",
3-
"version": "0.7.2",
3+
"version": "0.7.3",
44
"description": "A messaging protocol for the IOTA tangle allowing access of arbitrary messages in O(1)",
55
"keywords": [
66
"iota",

types/raam.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export class MessageTransfers {
4646
* An object representing the compiled RAAM message with all neccessary information to create its transfers.
4747
* @typedef {object} Message
4848
* @property {number} index - The index of the message in the channel.
49-
* @property {number} height - A number between 2 and 26 representing the height
49+
* @property {number} height - A number between 1 and 26 representing the height
5050
* of the merkle tree used for this channel.
5151
* @property {number} security - The security of the signing and encryption keys as a number between 1 and 4.
5252
* @property {Trytes} message - The message to attach to the channel as trytes.
@@ -178,7 +178,7 @@ export class RAAM extends RAAMReader {
178178
* @param {Trytes} seed - The seed from which the signing keys are created.
179179
* @param {object} [options] - Optional parameters.
180180
* @param {number} [options.amount] - The maximum amount of messages that can be published in this channel.
181-
* @param {number} [options.height = Math.ceil(Math.log2(amount))] - A number between 2 and 26 representing the height
181+
* @param {number} [options.height = Math.ceil(Math.log2(amount))] - A number between 1 and 26 representing the height
182182
* of the merkle tree used for this channel.
183183
* @param {API} [options.iota = this.iota] - A composed IOTA API for communication with a full node providing POW.
184184
* @param {Trytes} [options.channelPassword] - The optional password for the channel as trytes.
@@ -207,7 +207,7 @@ export class RAAM extends RAAMReader {
207207
* @param {API} [options.iota = this.iota] - A composed IOTA API for communication with a full node providing POW.
208208
* @param {Trytes} [options.channelPassword] - The optional password for the channel as trytes.
209209
* @param {number} [options.amount] - The maximum amount of messages that can be published in this channel.
210-
* @param {number} [options.height = Math.ceil(Math.log2(amount))] - A number between 2 and 26 representing the height
210+
* @param {number} [options.height = Math.ceil(Math.log2(amount))] - A number between 1 and 26 representing the height
211211
* of the merkle tree used for this channel.
212212
* @param {Trytes} [options.seed] - The seed from which the signing keys are created.
213213
* @param {number} [options.offset = 0] - The starting index used for building the subroots from which the keys are created.

types/raamReader.d.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ export class RAAMReader {
126126
* This is parameter is only used as an extra verification information.
127127
* @param {number} [options.amount] - The maximum amount of messages in this channel.
128128
* From this the height of the channel can be calculated. This is parameter is only used as an extra verification information.
129-
* @param {number} [options.height] - The height as a number between 2 and 26 of the channel yielding the maximum
129+
* @param {number} [options.height] - The height as a number between 1 and 26 of the channel yielding the maximum
130130
* amount of messages of the channel. This is parameter is only used as an extra verification information.
131131
*/
132132
public constructor(channelRoot: Int8Array, {iota, channelPassword, security,
@@ -239,7 +239,7 @@ export class RAAMReader {
239239
* different messages. The ith element is the password for the ith message in the channel.
240240
* @param {number} [options.security] - The security of the signing and encryption keys as a number between 1 and 4.
241241
* This is parameter is only used as an extra verification information.
242-
* @param {number} [options.height] - The height as a number between 2 and 26 of the channel yielding the maximum
242+
* @param {number} [options.height] - The height as a number between 1 and 26 of the channel yielding the maximum
243243
* amount of messages of the channel. This is parameter is only used as an extra verification information.
244244
*
245245
* @returns {Promise}
@@ -264,7 +264,7 @@ export class RAAMReader {
264264
* the found message.
265265
* @param {number} [options.security] - The security of the signing and encryption keys as a number between 1 and 4.
266266
* This is parameter is only used as an extra verification information.
267-
* @param {number} [options.height] - The height as a number between 2 and 26 of the channel yielding the maximum
267+
* @param {number} [options.height] - The height as a number between 1 and 26 of the channel yielding the maximum
268268
* amount of messages of the channel. This is parameter is only used as an extra verification information.
269269
*
270270
* @returns {Promise}
@@ -295,7 +295,7 @@ export class RAAMReader {
295295
* the found message.
296296
* @param {number} [options.security] - The security of the signing and encryption keys as a number between 1 and 4.
297297
* This is parameter is only used as an extra verification information.
298-
* @param {number} [options.height] - The height as a number between 2 and 26 of the channel yielding the maximum
298+
* @param {number} [options.height] - The height as a number between 1 and 26 of the channel yielding the maximum
299299
* amount of messages of the channel. This is parameter is only used as an extra verification information.
300300
*
301301
* @returns {Subscription} An object containing information about the created subscription, including the

0 commit comments

Comments
 (0)