Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent result between 0.17.2 and 0.18.0 #2

Open
mratsim opened this issue Mar 13, 2018 · 1 comment
Open

Inconsistent result between 0.17.2 and 0.18.0 #2

mratsim opened this issue Mar 13, 2018 · 1 comment

Comments

@mratsim
Copy link

mratsim commented Mar 13, 2018

The library is inconsistent between 0.17.2 and 0.18.0 versions:

Test case:

import nimSHA2

var a: SHA256Digest


a[0] = 'a'
a[1] = 'b'
a[10] = 'c'

echo system.`$`(a)
echo nimsha2.`$`(a)
echo $a
echo a.len

O.17.2

ab
ab
ab
32

0.18.0

['a', 'b', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', 'c', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00']
abc
abc
32

I suspect there are at least 2 reasons for this:

  1. 0.18.0 defines a $ operator on arrays
  2. I don't know why but seems like $in 0.17.2 was not iterating for the full length, stopping at the first 0 and this was fixed.

Recommandation: To avoid the $ issue it might be needed to wrap the digest array in an object like what is done in keccak_tiny

@NotoriousRebel
Copy link

Any updates on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants