You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
biginToBytes() converts a bigInt to a hex string, which sometimes misses left padding, which causes a conversion error
Expected Behavior
biginToBytes() converts a bigInt to a hex string
Failure Information
Solution:
exportfunctionbigintToBytes(n: bigint): Uint8Array{letb64=n.toString(16);// Pad an extra '0' if the hex string is an odd lengthif(b64.length%2!==0){b64=`0${b64}`;}returnu8a.fromString(b64,'base16');}
constbi=1881146970754576322752261068397796891246589699629597037555588131642783231506nconstbiBytes=bigintToBytes(bi);constbase64=bytesToBase64(biBytes);expect(base64).toBe('BCixAySH6XqSNMR6MVnd4SCluKq3Ey5RQIy0/0Eu7hI=');// fails with error "Unexpected end of data"constbi=100968908336250941489582664670319762383316987426946165788206218268821633081179nconstbiBytes=bigintToBytes(bi);constbase64=bytesToBase64(biBytes);expect(base64).toBe('3zpgfkpIN/0k/xkychS26ElYP4Bnb24RcYACzsbzn1s=');// succeeds
Environment Details
node version: v18.12.1
OS Version: ubuntu 20.04
The text was updated successfully, but these errors were encountered:
Current Behavior
biginToBytes() converts a bigInt to a hex string, which sometimes misses left padding, which causes a conversion error
Expected Behavior
biginToBytes() converts a bigInt to a hex string
Failure Information
Solution:
Issue we found: Tonomy-Foundation/Tonomy-App-Websites#76
Solution we made: https://github.com/Tonomy-Foundation/Tonomy-ID-SDK/pull/228/files#diff-4335ca2354d2963bc461d6d160ca76c2ac0bd3524a6a8eaba6c627407ca1cf41R26
Steps to Reproduce
Environment Details
The text was updated successfully, but these errors were encountered: