Open jgeewax opened 8 years ago
@jgeewax I wonder if you would be interested in taking a look at my fork of this project and seeing if you have similar issues still there. I don't think any changes have been accepted on this project for a couple of years. I did a pretty major revamp on the fork and perhaps it resolved your issues. I would certainly take a look at pull requests if there is an issue you are still seeing.
https://github.com/grempe/secrets.js
Glenn
So, I know I haven't worked on this project in years, but just glancing through your comments, I wanted to point a few things out. Most of this is obvious from the readme btw:
Why are we using base 36? For a larger number than 8, (ie, 200), there's no way that this will generate a valid hexadecimal value... ((200).toString(36) == '5k')
secrets.js only uses Galois fields between 2^3 and 2^20, so the bits
accepted must be between 3 and 20. In the interest of using ONE character for the bit-field in the final share, base-36 was selected, to encode all possible values using the characters [3-9, a-k].
The issue looks to be with the prefixing, which always appends an "8" (https://github.com/amper5and/secrets.js/blob/master/secrets.js#L246)
The 8 is appended because an 8-bit field is used by default. You can change config.bits to something other than 8, and you'll have that value appended
The issue looks to be with the prefixing, which always appends an "8" (https://github.com/amper5and/secrets.js/blob/master/secrets.js#L246)
From what I can see, the following lines aren't quite right:
(200).toString(36) == '5k'
)Assuming we meant this to be
16
instead of36
(which makes much more sense), it still can result in an odd-length string, which is :-1: ((8).toString(16) == '8'
)I think we should do what you did a bit later in the line with
padLeft
:The question then becomes, what corresponding changes do we need for the combining portion of code...?
I think we would need to update the
processShare
method to make this work (https://github.com/amper5and/secrets.js/blob/master/secrets.js#L301)(the lines affected are
var bits = ...
andvar id = ...
)