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

[JS] Method BigInteger.fromByteArray fails in JS (NodeJS & Browser) #265

Open
hamada147 opened this issue Aug 14, 2023 · 3 comments
Open
Assignees

Comments

@hamada147
Copy link

hamada147 commented Aug 14, 2023

Describe the bug
BigInteger.fromByteArray fails in JS but works with no issues in all other platforms.

To Reproduce
Steps to reproduce the behaviour:

val byteArrayInBase64Padded = "P6XiWtDoaj6g3le12ljqjl3J/ZXa/kRswC9GNUYmkTU="
val byteArray = byteArrayInBase64Padded.base64PadDecodedBytes // value is [63, -91, -30, 90, -48, -24, 106, 62, -96, -34, 87, -75, -38, 88, -22, -114, 93, -55, -3, -107, -38, -2, 68, 108, -64, 47, 70, 53, 70, 38, -111, 53] // correct value
val bigInteger = BigInteger.fromByteArray(byteArray, Sign.POSITIVE) // fails here with `ClassCastException`
println(bigInteger.toString()) // 28788801469504357252816216561604952156895770089726804292579259475621317087541

Expected behaviour
Should create a BigInteger value without issue.

Platform
[JS]

If JS (please complete the following information):

  • OS: macOS Ventura 13.5 (22G74)
  • Browser: Google Chrome
  • Version: 115.0.5790.170 (Official Build) (arm64)

Additional context
The following method in unit test testToAndFromByteArray on https://github.com/ionspin/kotlin-multiplatform-bignum/blob/main/bignum/src/commonTest/kotlin/com/ionspin/kotlin/bignum/integer/ByteArrayConversionTest.kt also fails with the same exception ClassCastException.

@ionspin
Copy link
Owner

ionspin commented Aug 15, 2023

Thanks for reporting.

@ionspin ionspin self-assigned this Aug 15, 2023
@ionspin
Copy link
Owner

ionspin commented Feb 6, 2024

Sorry for taking so long to look into this, is it still reproducible?

@hamada147
Copy link
Author

Unfortunately yes, it is still reproducible

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