From 43540c12e8577017991c0c623837a4cc3c3d202c Mon Sep 17 00:00:00 2001 From: capt-nemo429 Date: Sat, 22 Apr 2023 19:03:54 -0300 Subject: [PATCH] feat(core): add full `BigInt` parser/serializer --- package.json | 3 +- packages/common/src/utils/bigIntUtils.spec.ts | 37 +- packages/common/src/utils/bigIntUtils.ts | 74 ++- .../sigma/constantSerializer.spec.ts | 49 +- .../src/serializer/sigma/dataSerializer.ts | 4 +- .../core/src/serializer/sigma/sigmaReader.ts | 11 +- .../core/src/serializer/sigma/sigmaWriter.ts | 19 +- .../tests/testVectors/constantsTestVectors.ts | 436 +++++------------- vitest.config.ts | 2 +- 9 files changed, 267 insertions(+), 368 deletions(-) diff --git a/package.json b/package.json index d2dae2b5..c36bf5c3 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,8 @@ "test:prettier": "prettier ./**/*.ts --list-different", "test:unit": "vitest run", "cov:check": "vitest run --coverage", - "cov:open": "vitest run --coverage ; open-cli coverage/index.html" + "cov:open": "vitest run --coverage ; open-cli coverage/index.html", + "bench": "vitest bench" }, "devDependencies": { "@noble/hashes": "^1.3.0", diff --git a/packages/common/src/utils/bigIntUtils.spec.ts b/packages/common/src/utils/bigIntUtils.spec.ts index ee6cdf9b..d7152d0a 100644 --- a/packages/common/src/utils/bigIntUtils.spec.ts +++ b/packages/common/src/utils/bigIntUtils.spec.ts @@ -1,5 +1,12 @@ import { describe, expect, it } from "vitest"; -import { decimalize, ensureBigInt, sumBy, undecimalize } from "./bigIntUtils"; +import { + bigIntToHex, + decimalize, + ensureBigInt, + hexToBigInt, + sumBy, + undecimalize +} from "./bigIntUtils"; describe("decimalize()", () => { it("Should decimalize", () => { @@ -168,4 +175,32 @@ describe("BigInt sumBy()", () => { ) ).toBe(13158n); }); + + it("Should convert a bigint value to a hex string", () => { + expect(bigIntToHex(-54417895017443177n)).toBe("ff3eab367a0f9097"); + + expect(bigIntToHex(170892133397465074381480318756786823280n)).toBe( + "008090a0b0c0d0e0f00010203040506070" + ); + expect(bigIntToHex(-169390233523473389081894288674981388176n)).toBe( + "8090a0b0c0d0e0f00010203040506070" + ); + + expect(bigIntToHex(1207883114728849269100423775319436127n)).toBe( + "00e8a13c46cdde58d442c8e45b9f2b5f" + ); + expect(bigIntToHex(-518499127179672366370132270668500813n)).toBe( + "9c2404f2634ef40afccc320eed30b3" + ); + expect(bigIntToHex(4n)).toBe("04"); + }); + + it("Should convert a hex string to a bigint value", () => { + expect(hexToBigInt("0e8a13c46cdde58d442c8e45b9f2b5f")).toBe( + 1207883114728849269100423775319436127n + ); + expect(hexToBigInt("9c2404f2634ef40afccc320eed30b3")).toBe( + -518499127179672366370132270668500813n + ); + }); }); diff --git a/packages/common/src/utils/bigIntUtils.ts b/packages/common/src/utils/bigIntUtils.ts index 23bb7b2d..b378e49a 100644 --- a/packages/common/src/utils/bigIntUtils.ts +++ b/packages/common/src/utils/bigIntUtils.ts @@ -1,5 +1,5 @@ import { Amount } from "../types"; -import { isEmpty } from "./arrayUtils"; +import { first, isEmpty } from "./arrayUtils"; import { _0n, _10n } from "./bigIntLiterals"; import { isUndefined } from "./objectUtils"; @@ -149,3 +149,75 @@ export function sumBy( return acc; } + +/** + * Converts a hex string to bigint. + * @param hex The hex string to be converted. + * @returns The bigint value represented by the hex string. + */ +export function hexToBigInt(hex: string): bigint { + // https://coolaj86.com/articles/convert-hex-to-decimal-with-js-bigints/ + if (hex.length % 2) { + hex = "0" + hex; + } + + const value = BigInt("0x" + hex); + const highByte = parseInt(hex.slice(0, 2), 16); + + if (0x80 & highByte) { + return -_bitNegate(value); // add two's complement and invert the number to negative + } + + return value; +} + +/** + * Serializes a `BigInt` to a hex string + * @param value The bigint value to be serialized + * @returns Hex representation for the provided `number`. + */ +export function bigIntToHex(value: bigint): string { + // implementation inspired on + // https://coolaj86.com/articles/convert-decimal-to-hex-with-js-bigints/ + const positive = value >= _0n; + if (!positive) { + value = _bitNegate(value); + } + + let hex = value.toString(16); + if (hex.length % 2) { + hex = "0" + hex; + } + + if (positive && 0x80 & parseInt(hex.slice(0, 2), 16)) { + hex = "00" + hex; + } + + return hex; +} + +/** + * Returns the two’s complement of a bigint value. + * @param value The bigint value to negate. + * @returns The two’s complement of `number` as a bigint. + */ +export function _bitNegate(value: bigint): bigint { + const negative = value < _0n; + if (negative) { + value = -value; // turn into a positive number + } + + const bits = value.toString(2); + let bitLen = bits.length; // convert to binary + + const mod = bitLen % 8; + if (mod > 0) { + bitLen += 8 - mod; + } else if (negative && first(bits) === "1" && bits.indexOf("1", 1) !== -1) { + bitLen += 8; + } + + const mask = (1n << BigInt(bitLen)) - 1n; // create a mask + + return (~value & mask) + 1n; // invert bits, mask it, and add one +} diff --git a/packages/core/src/serializer/sigma/constantSerializer.spec.ts b/packages/core/src/serializer/sigma/constantSerializer.spec.ts index 45bd8347..7a20e8e7 100644 --- a/packages/core/src/serializer/sigma/constantSerializer.spec.ts +++ b/packages/core/src/serializer/sigma/constantSerializer.spec.ts @@ -7,11 +7,10 @@ import { collIntTestVectors, collLongTestVectors, collShortTestVectors, + sBigIntTestVectors, sGroupElementTestVectors, sIntTestVectors, sLongTestVectors, - sNegativeBigIntTestVectors, - sPositiveBigIntTestVectors, sSigmaPropTestVectors } from "../../tests/testVectors/constantsTestVectors"; import { SConstant, SParse } from "./constantSerializer"; @@ -59,20 +58,12 @@ describe("Primary types serialization", () => { } }); - it("Should serialize positive SBigInt", () => { - for (const tv of sPositiveBigIntTestVectors) { + it("Should serialize SBigInt", () => { + for (const tv of sBigIntTestVectors) { expect(SConstant(SBigInt(tv.value))).toBe(tv.hex); } }); - it("Should fail for negative SBigInt", () => { - for (const tv of sNegativeBigIntTestVectors) { - expect(() => { - SConstant(SBigInt(tv.value)); - }).toThrow(); - } - }); - it("Should serialize SUnit", () => { expect(SConstant(SUnit())).toBe("62"); }); @@ -220,11 +211,38 @@ describe("SColl deserialization", () => { } }); + it("Should deserialize SBigInt", () => { + for (const tv of sBigIntTestVectors) { + expect(SParse(tv.hex).toString()).toBe(tv.value); + } + }); + it("Should deserialize 'Coll[SLong]'", () => { for (const tv of collLongTestVectors) { expect(SParse(tv.hex)).toEqual(tv.coll); } }); + + it("Should deserialize 'Coll[Coll[Byte]]'", () => { + const hex = + "1a0c4065653430323366366564303963313332326234363630376538633163663737653733653030353039613334343838306232663339616332643430623433376463046572676f0763617264616e6f3339666965744263636a48774c774b4c5339573131453641766d565a6e4e6938347042487854317a3946723978314b6b79424a686761646472317179733577356d76796665783572646c75683039393273766d3074747834643439346336767979346a3933336573707a6d776e6c343277633833763837736b6c71773979387266766a6366743973616433376c61747778677170637132747a36347a08000000003b9aca00080000000002faf080080000000000013880036572672c6173736574316a7935713561307670737475747135713664386367646d72643471753579656663646e6a677a40366331346131353637363364613936303962383065386638326363613436663630363330346630613864306363363665356565323234306336333165666166640800000000000ee48c"; + const expected = [ + "65653430323366366564303963313332326234363630376538633163663737653733653030353039613334343838306232663339616332643430623433376463", + "6572676f", + "63617264616e6f", + "39666965744263636a48774c774b4c5339573131453641766d565a6e4e6938347042487854317a3946723978314b6b79424a68", + "61646472317179733577356d76796665783572646c75683039393273766d3074747834643439346336767979346a3933336573707a6d776e6c343277633833763837736b6c71773979387266766a6366743973616433376c61747778677170637132747a36347a", + "000000003b9aca00", + "0000000002faf080", + "0000000000013880", + "657267", + "6173736574316a7935713561307670737475747135713664386367646d72643471753579656663646e6a677a", + "36633134613135363736336461393630396238306538663832636361343666363036333034663061386430636336366535656532323430633633316566616664", + "00000000000ee48c" + ].map((x) => hexToBytes(x)); + + expect(SParse(hex)).toStrictEqual(expected); + }); }); describe("Serialize -> Parse roundtrip", () => { @@ -281,6 +299,13 @@ describe("Serialize -> Parse roundtrip", () => { } }); + it("Should roundtrip SBigInt", () => { + for (let i = 0; i < 1000; i++) { + const value = randomBigInt(-9_223_372_036_854_775_808_000n, 9_223_372_036_854_775_807_000n); + expect(SParse(SConstant(SBigInt(value)))).toBe(value); + } + }); + it("Should roundtrip SGroupElement", () => { for (const tv of sGroupElementTestVectors) { expect(SParse(SConstant(SGroupElement(hexToBytes(tv.value))))).toEqual(hexToBytes(tv.value)); diff --git a/packages/core/src/serializer/sigma/dataSerializer.ts b/packages/core/src/serializer/sigma/dataSerializer.ts index e1ebfe49..1bd33f15 100644 --- a/packages/core/src/serializer/sigma/dataSerializer.ts +++ b/packages/core/src/serializer/sigma/dataSerializer.ts @@ -100,8 +100,8 @@ export class DataSerializer { return reader.readInt(); case SigmaTypeCode.Long: return reader.readLong(); - // case SigmaTypeCode.BigInt: - // break; + case SigmaTypeCode.BigInt: + return reader.readBigInt(); case SigmaTypeCode.GroupElement: return reader.readBytes(GROUP_ELEMENT_LENGTH); case SigmaTypeCode.SigmaProp: { diff --git a/packages/core/src/serializer/sigma/sigmaReader.ts b/packages/core/src/serializer/sigma/sigmaReader.ts index 2f51acc5..4b88d702 100644 --- a/packages/core/src/serializer/sigma/sigmaReader.ts +++ b/packages/core/src/serializer/sigma/sigmaReader.ts @@ -1,5 +1,5 @@ -import { HexString, isEmpty } from "@fleet-sdk/common"; -import { hexToBytes } from "@noble/hashes/utils"; +import { HexString, hexToBigInt, isEmpty } from "@fleet-sdk/common"; +import { bytesToHex, hexToBytes } from "@noble/hashes/utils"; import { readBigVLQ, readVLQ } from "../vlq"; import { zigZagDecode, zigZagDecodeBigInt } from "../zigZag"; import { SigmaTypeCode } from "./sigmaTypeCode"; @@ -76,4 +76,11 @@ export class SigmaReader { public readLong(): bigint { return zigZagDecodeBigInt(readBigVLQ(this)); } + + public readBigInt(): bigint { + const len = readVLQ(this); + const hex = bytesToHex(this.readBytes(len)); + + return hexToBigInt(hex); + } } diff --git a/packages/core/src/serializer/sigma/sigmaWriter.ts b/packages/core/src/serializer/sigma/sigmaWriter.ts index c734f364..a03519cb 100644 --- a/packages/core/src/serializer/sigma/sigmaWriter.ts +++ b/packages/core/src/serializer/sigma/sigmaWriter.ts @@ -1,4 +1,4 @@ -import { _0n } from "@fleet-sdk/common"; +import { bigIntToHex } from "@fleet-sdk/common"; import { bytesToHex } from "@noble/hashes/utils"; import { writeBigVLQ, writeVLQ } from "../vlq"; import { zigZagEncode, zigZagEncodeBigInt } from "../zigZag"; @@ -103,21 +103,8 @@ export class SigmaWriter { return this; } - public writeBigInt(number: bigint): SigmaWriter { - // todo: take a look at https://coolaj86.com/articles/convert-decimal-to-hex-with-js-bigints/ - // and https://coolaj86.com/articles/convert-hex-to-decimal-with-js-bigints/ - if (number < _0n) { - throw new Error("Negative BigInt values are not supported Fleet serializer."); - } - - let hex = number.toString(16); - if (hex.length % 2) { - hex = "0" + hex; - } else if (Number.parseInt(hex.substring(0, 1), 16) >= 8) { - // maximum positive need to prepend 0 otherwise results in negative number - hex = "00" + hex; - } - + public writeBigInt(value: bigint): SigmaWriter { + const hex = bigIntToHex(value); this.writeVLQ(hex.length / 2); this.writeHex(hex); diff --git a/packages/core/src/tests/testVectors/constantsTestVectors.ts b/packages/core/src/tests/testVectors/constantsTestVectors.ts index 0e0c5cb1..7c6bb320 100644 --- a/packages/core/src/tests/testVectors/constantsTestVectors.ts +++ b/packages/core/src/tests/testVectors/constantsTestVectors.ts @@ -6395,336 +6395,108 @@ export const sSigmaPropTestVectors = [ } ]; -export const sPositiveBigIntTestVectors = [ - { - hex: "060104", - value: "4" - }, - { - hex: "06010f", - value: "15" - }, - { - hex: "06011a", - value: "26" - }, - { - hex: "06017a", - value: "122" - }, - { - hex: "0602040f", - value: "1039" - }, - { - hex: "060400c1f4a5", - value: "12711077" - }, - { - hex: "060519debd01c7", - value: "111111111111" - }, - { - hex: "06060102b36211c7", - value: "1111111111111" - }, - { - hex: "06100080c2a6bf0e86c4b39aaf5b72bf25cf", - value: "668561996359741991358095026099791311" - }, - { - hex: "061000844935789da1a1015e411873fd04a3", - value: "686868037649042878185896845279823011" - }, - { - hex: "06100085a44d9646705fedbf146bcd80d8ef", - value: "693907944436551502091064778281769199" - }, - { - hex: "0610008606aef67f7442935a0cda261003c3", - value: "695903335488961311997251225989940163" - }, - { - hex: "0610008d0321174966b3d1a7ba77bbde4bc7", - value: "732177326018476430535707317822704583" - }, - { - hex: "0610008dac13d61cb361d20126285dced5a3", - value: "735604003104815686742214505046922659" - }, - { - hex: "0610008df25316218afd4e460f46e2a4e73f", - value: "737028782964204211163388796098373439" - }, - { - hex: "06100091991ac37bbc6d7660cbb9bdfd6b17", - value: "755988373588298697683376339645459223" - }, - { - hex: "06100097b32bc931826e1d5bf2c3c89b4d37", - value: "787670846035141012432156203931094327" - }, - { - hex: "0610009b0bd13f17166d1271da34ec4c84b3", - value: "805045697789970748726133654582756531" - }, - { - hex: "0610009b72e45b8015e48e6c5fec839ef0e3", - value: "807136300106749609589074222636789987" - }, - { - hex: "0610009c2404f2634ef40afccc320eed30b3", - value: "810728868605243506533674789611843763" - }, - { - hex: "0610009d856e701be57d7e08c487c732cd5f", - value: "817896917061176012892361981317795167" - }, - { - hex: "0610009fac05c69ea6092fc5ab2644d2a977", - value: "829064232569504557995589523934980471" - }, - { - hex: "061000a02e5ea807365ff490a7fef04a162f", - value: "831707987656817646828920747896477231" - }, - { - hex: "061000a1e67af086b4b8245d54944dff3e4b", - value: "840634488708025712379450645356166731" - }, - { - hex: "061000a5193712ff9561e84fdb512544795f", - value: "857240405326987834472602105603717471" - }, - { - hex: "061000a79ceb66ca5c80dd70aa00bf4a1e77", - value: "870296281703787578865521086368980599" - }, - { - hex: "061000a97b1581804cbdafac7cc879d287d3", - value: "879994609343718995045033133080741843" - }, - { - hex: "061000aac3fce78391ce06ba008195c911e7", - value: "886665572970681461950150709537739239" - }, - { - hex: "061000aaf52b8c24f29df5b1d742d198b897", - value: "887663106487371900496846565376833687" - }, - { - hex: "061000acf5458deff49f81a77751748cd8fb", - value: "898049760691573351094652519658084603" - }, - { - hex: "061000b00cf83370012709401b5ac196afe3", - value: "914107300520817655363679458166222819" - }, - { - hex: "061000b2a53a7c036d1c875931b9aeb8fedf", - value: "927580072017510930343940474822786783" - }, - { - hex: "061000b2f51a850dbbcaa999d89e2ac0aadb", - value: "929200132282428510894593925640661723" - }, - { - hex: "061000b3f2691a9aed3a06529e9c5ece4953", - value: "934337807992786950303823367435602259" - }, - { - hex: "061000b440456cd03c8dae1aa92579e38b8b", - value: "935917009170239750992438470667111307" - }, - { - hex: "061000b5646661b582378b60c5610684a4b3", - value: "941842083867221881046509946577134771" - }, - { - hex: "061000b7baf0eeb7b766d751b821df7da357", - value: "953981941936687942780206273343103831" - }, - { - hex: "061000b7c85fa3424d98b35c886edbec30f7", - value: "954254384234254789240388599746932983" - }, - { - hex: "061000b7e1c65b429510cbd1cbedb3d5f133", - value: "954769582692501846482876099080876339" - }, - { - hex: "061000bc0efe5218eacfd681277d4decbf7f", - value: "976455912500171233402157637300961151" - }, - { - hex: "061000bed0e6367630583b61ea7091d28a6f", - value: "990773383651627155917396919274605167" - }, - { - hex: "061000bfd72de15278001dd5a9df86c3eb67", - value: "996093053046076141224460754855652199" - }, - { - hex: "061000c04e5372d5aec10adf40f09f9695ab", - value: "998509636264877990895239100406076843" - }, - { - hex: "061000c1152c6ecd3042dd7af6d46b4c5e9f", - value: "1002542744629457825420725569826086559" - }, - { - hex: "061000c1b747d2569148c40866b1bfdc8bdf", - value: "1005830664950734269162502371879455711" - }, - { - hex: "061000c39c95c63b5bc29fe08e964de11bbb", - value: "1015673809658467567058126782645476283" - }, - { - hex: "061000c42035d8ac1b641e9acc99c6f3c17f", - value: "1018343487529583037814431892766966143" - }, - { - hex: "061000c444f87cdaa62d237ca9c2e1d2a13b", - value: "1019089075350649858356051595425390907" - }, - { - hex: "061000c7a8b92028c2beb7b69d7e1bfea19f", - value: "1036689186824706321895866115192431007" - }, - { - hex: "061000c7f4e36bf52782585b1423e223fcd3", - value: "1038234000995881897091418275633691859" - }, - { - hex: "061000c86a3e5871bf9e9ed1e64814a8b483", - value: "1040614246643222867082760692456535171" - }, - { - hex: "061000cb69a5f38c25212354373dc190a47f", - value: "1056179063312050627782948972588475519" - }, - { - hex: "061000cccb49d93a722caac004472b9a05db", - value: "1063351739175413669122080545762313691" - }, - { - hex: "061000cdcceef13b33fd094b70fa84b85f53", - value: "1068577398518922498215639125480464211" - }, - { - hex: "061000d068a12f96f4abe7d0bb26760db01b", - value: "1082119887636478480081312507004563483" - }, - { - hex: "061000d0c39401de68fd57ae00569bb19f87", - value: "1083964542794370674823226331338219399" - }, - { - hex: "061000d0ca00a98a55853ed776600087f61f", - value: "1084094845785384066170339850090706463" - }, - { - hex: "061000d9d450c35e10b1730de7a23ed11d6b", - value: "1131034687854327664102029681981726059" - }, - { - hex: "061000da227b94b1c8a9b6e86bade5023bdb", - value: "1132620108169814761934671037482548187" - }, - { - hex: "061000dafc77f53fc25d671773311f54a857", - value: "1137041386432959436361328345748908119" - }, - { - hex: "061000dcaadb310ca2442ecfb78bd812db47", - value: "1145770684657912358341935480834284359" - }, - { - hex: "061000dfe190a133ec554aad9b76c06bc247", - value: "1162457200359348090953536001580712519" - }, - { - hex: "061000e17100d894f87940b6042071de0317", - value: "1170558772484405381497471268332372759" - }, - { - hex: "061000e1abe0c34555caa2fb1d26dcee74e7", - value: "1171752892754361783126534737500206311" - }, - { - hex: "061000e50cb1c5e91805ad615323a1950b93", - value: "1189293454154824464064179714009664403" - }, - { - hex: "061000e7f84477352bf7d30f958e131a7307", - value: "1204456036311298636923366960961057543" - }, - { - hex: "061000e8a13c46cdde58d442c8e45b9f2b5f", - value: "1207883114728849269100423775319436127" - }, - { - hex: "061000ea34aa31173bf32fee89a846f4aa9f", - value: "1216065634177020857607765679674796703" - }, - { - hex: "061000efcfd1d44250e0a8673eef32048a43", - value: "1245174032354738299986861850156632643" - }, - { - hex: "061000f086782f88e6cbd0c2cf66af9954df", - value: "1248878611026048943498367800532620511" - }, - { - hex: "061000f23e4bcfabf10b47565c632d14351b", - value: "1257799355544304906045469172971091227" - }, - { - hex: "061000f41b1d557a8bcf349420bfd763056f", - value: "1267470382612884466141824827221280111" - }, - { - hex: "061000f8fd6727abde979f55e7d4c91bcc2f", - value: "1292829243324792954205043065913855023" - }, - { - hex: "061000fb98488ddf56996aeb9434f5803b8f", - value: "1306355186087083611855402901922921359" - }, - { - hex: "061000fec346162748f0e3c268260919f73f", - value: "1322804024768097068934748188867950399" - }, - { - hex: "061000ff0aed27d915df669709f890468527", - value: "1324257312429289019228814893866452263" - }, - { - hex: "06104b3b4ca85a86c47a098a223fffffffff", - value: "99999999999999999999999999999999999999" - }, - { - hex: "061913aaf504e4bc1e62173f87a4378c37b49c8ccff196ce3f0ad2", - value: "123456789012345678901234567890123456789012345678901234567890" - } -]; - -export const sNegativeBigIntTestVectors = [ - { - hex: "060f9c2404f2634ef40afccc320eed30b3", - value: "-18499127179672366370132270668500813" - }, - { - hex: "060fa48aae0a58c333fcb45c22eb77423f", - value: "-74878549557465338514633771922800065" - }, - { - hex: "060fdd1c7569871f783f9e7c9489215a93", - value: "-81153180225522922855494996901930349" - }, - { - hex: "060ff0be3a08b885a5c09b96aee8797fef", - value: "-9218493979484035630659040499367953" - } +export const sBigIntTestVectors = [ + { hex: "060f9c2404f2634ef40afccc320eed30b3", value: "-518499127179672366370132270668500813" }, + { hex: "060fa48aae0a58c333fcb45c22eb77423f", value: "-474878549557465338514633771922800065" }, + { hex: "060fdd1c7569871f783f9e7c9489215a93", value: "-181153180225522922855494996901930349" }, + { hex: "060ff0be3a08b885a5c09b96aee8797fef", value: "-79218493979484035630659040499367953" }, + { hex: "0610efcb7de64abd55fa4a07b00ffcc80e04", value: "-21540286119252381366314201135174906364" }, + { hex: "0610f7ee0f9e6b31e5b8bf79c0103cd98a94", value: "-10726968522364003605754510423632541036" }, + { hex: "0610e568d66fc6ef02311087197a516bfd08", value: "-35344807721356910388894827443251315448" }, + { hex: "0610ea4b448df22c343557e9d34980ecd344", value: "-28852203192905262646985616891927801020" }, + { hex: "0610ed8d2982d73cf954ca90f09eebd46697", value: "-24522376117792124222555029947659557225" }, + { hex: "0610f6a12915ff35fbfdc0de719c2b44239f", value: "-12455486842055948395012500175862881377" }, + { hex: "0610e730b99d5580f36594530fd961844c3d", value: "-32977704934352917049306884343898813379" }, + { hex: "0610fd399ad011430f3cf1173d88e0157d88", value: "-3688583090539181963106320020268548728" }, + { hex: "0610f51c7da6efcc5267e609d013e6464820", value: "-14473575114305738236514890463904905184" }, + { hex: "060fb5c30093fd377e9986d2cb46a6aa80", value: "-385467148716983254797818803869275520" }, + { hex: "0610eb5839c44ec0be3d5b95d4c9522d72ca", value: "-27455694137492064653731458579914984758" }, + { hex: "0610f7ce9e56ef64e15237a2ab2d91aa1f6b", value: "-10890227300777841195633415700652351637" }, + { hex: "060fcbc5a938f002f37a8784120c51000e", value: "-271182691629644891741764079254962162" }, + { hex: "0610d3d187be808cd61d4215be07445d3179", value: "-58727316548455722622554018085215587975" }, + { hex: "0610edad8f7090c4b7782c4d8e563c3e731c", value: "-24354155260455695334173947929779342564" }, + { hex: "0610f34e21b2b957ed470b2baabc227286a0", value: "-16874281310747317873912526684847700320" }, + { hex: "0610da31d4846523942d30bf81311ed324e8", value: "-50251930933504172440026254536365366040" }, + { hex: "0610eee296791bc9b5bc269844845d3d5eec", value: "-22749592877451455117651003320075198740" }, + { hex: "0610f43d7dea14e4619a1e2e43774e908e20", value: "-15631451993992084997026121768636477920" }, + { hex: "0610ec6afd4980220003c03b50fee83e697f", value: "-26029039175752853511346953066928772737" }, + { hex: "060104", value: "4" }, + { hex: "06010f", value: "15" }, + { hex: "06011a", value: "26" }, + { hex: "06017a", value: "122" }, + { hex: "0602040f", value: "1039" }, + { hex: "060400c1f4a5", value: "12711077" }, + { hex: "060519debd01c7", value: "111111111111" }, + { hex: "06060102b36211c7", value: "1111111111111" }, + { hex: "06100080c2a6bf0e86c4b39aaf5b72bf25cf", value: "668561996359741991358095026099791311" }, + { hex: "061000844935789da1a1015e411873fd04a3", value: "686868037649042878185896845279823011" }, + { hex: "06100085a44d9646705fedbf146bcd80d8ef", value: "693907944436551502091064778281769199" }, + { hex: "0610008606aef67f7442935a0cda261003c3", value: "695903335488961311997251225989940163" }, + { hex: "0610008d0321174966b3d1a7ba77bbde4bc7", value: "732177326018476430535707317822704583" }, + { hex: "0610008dac13d61cb361d20126285dced5a3", value: "735604003104815686742214505046922659" }, + { hex: "0610008df25316218afd4e460f46e2a4e73f", value: "737028782964204211163388796098373439" }, + { hex: "06100091991ac37bbc6d7660cbb9bdfd6b17", value: "755988373588298697683376339645459223" }, + { hex: "06100097b32bc931826e1d5bf2c3c89b4d37", value: "787670846035141012432156203931094327" }, + { hex: "0610009b0bd13f17166d1271da34ec4c84b3", value: "805045697789970748726133654582756531" }, + { hex: "0610009b72e45b8015e48e6c5fec839ef0e3", value: "807136300106749609589074222636789987" }, + { hex: "0610009c2404f2634ef40afccc320eed30b3", value: "810728868605243506533674789611843763" }, + { hex: "0610009d856e701be57d7e08c487c732cd5f", value: "817896917061176012892361981317795167" }, + { hex: "0610009fac05c69ea6092fc5ab2644d2a977", value: "829064232569504557995589523934980471" }, + { hex: "061000a02e5ea807365ff490a7fef04a162f", value: "831707987656817646828920747896477231" }, + { hex: "061000a1e67af086b4b8245d54944dff3e4b", value: "840634488708025712379450645356166731" }, + { hex: "061000a5193712ff9561e84fdb512544795f", value: "857240405326987834472602105603717471" }, + { hex: "061000a79ceb66ca5c80dd70aa00bf4a1e77", value: "870296281703787578865521086368980599" }, + { hex: "061000a97b1581804cbdafac7cc879d287d3", value: "879994609343718995045033133080741843" }, + { hex: "061000aac3fce78391ce06ba008195c911e7", value: "886665572970681461950150709537739239" }, + { hex: "061000aaf52b8c24f29df5b1d742d198b897", value: "887663106487371900496846565376833687" }, + { hex: "061000acf5458deff49f81a77751748cd8fb", value: "898049760691573351094652519658084603" }, + { hex: "061000b00cf83370012709401b5ac196afe3", value: "914107300520817655363679458166222819" }, + { hex: "061000b2a53a7c036d1c875931b9aeb8fedf", value: "927580072017510930343940474822786783" }, + { hex: "061000b2f51a850dbbcaa999d89e2ac0aadb", value: "929200132282428510894593925640661723" }, + { hex: "061000b3f2691a9aed3a06529e9c5ece4953", value: "934337807992786950303823367435602259" }, + { hex: "061000b440456cd03c8dae1aa92579e38b8b", value: "935917009170239750992438470667111307" }, + { hex: "061000b5646661b582378b60c5610684a4b3", value: "941842083867221881046509946577134771" }, + { hex: "061000b7baf0eeb7b766d751b821df7da357", value: "953981941936687942780206273343103831" }, + { hex: "061000b7c85fa3424d98b35c886edbec30f7", value: "954254384234254789240388599746932983" }, + { hex: "061000b7e1c65b429510cbd1cbedb3d5f133", value: "954769582692501846482876099080876339" }, + { hex: "061000bc0efe5218eacfd681277d4decbf7f", value: "976455912500171233402157637300961151" }, + { hex: "061000bed0e6367630583b61ea7091d28a6f", value: "990773383651627155917396919274605167" }, + { hex: "061000bfd72de15278001dd5a9df86c3eb67", value: "996093053046076141224460754855652199" }, + { hex: "061000c04e5372d5aec10adf40f09f9695ab", value: "998509636264877990895239100406076843" }, + { hex: "061000c1152c6ecd3042dd7af6d46b4c5e9f", value: "1002542744629457825420725569826086559" }, + { hex: "061000c1b747d2569148c40866b1bfdc8bdf", value: "1005830664950734269162502371879455711" }, + { hex: "061000c39c95c63b5bc29fe08e964de11bbb", value: "1015673809658467567058126782645476283" }, + { hex: "061000c42035d8ac1b641e9acc99c6f3c17f", value: "1018343487529583037814431892766966143" }, + { hex: "061000c444f87cdaa62d237ca9c2e1d2a13b", value: "1019089075350649858356051595425390907" }, + { hex: "061000c7a8b92028c2beb7b69d7e1bfea19f", value: "1036689186824706321895866115192431007" }, + { hex: "061000c7f4e36bf52782585b1423e223fcd3", value: "1038234000995881897091418275633691859" }, + { hex: "061000c86a3e5871bf9e9ed1e64814a8b483", value: "1040614246643222867082760692456535171" }, + { hex: "061000cb69a5f38c25212354373dc190a47f", value: "1056179063312050627782948972588475519" }, + { hex: "061000cccb49d93a722caac004472b9a05db", value: "1063351739175413669122080545762313691" }, + { hex: "061000cdcceef13b33fd094b70fa84b85f53", value: "1068577398518922498215639125480464211" }, + { hex: "061000d068a12f96f4abe7d0bb26760db01b", value: "1082119887636478480081312507004563483" }, + { hex: "061000d0c39401de68fd57ae00569bb19f87", value: "1083964542794370674823226331338219399" }, + { hex: "061000d0ca00a98a55853ed776600087f61f", value: "1084094845785384066170339850090706463" }, + { hex: "061000d9d450c35e10b1730de7a23ed11d6b", value: "1131034687854327664102029681981726059" }, + { hex: "061000da227b94b1c8a9b6e86bade5023bdb", value: "1132620108169814761934671037482548187" }, + { hex: "061000dafc77f53fc25d671773311f54a857", value: "1137041386432959436361328345748908119" }, + { hex: "061000dcaadb310ca2442ecfb78bd812db47", value: "1145770684657912358341935480834284359" }, + { hex: "061000dfe190a133ec554aad9b76c06bc247", value: "1162457200359348090953536001580712519" }, + { hex: "061000e17100d894f87940b6042071de0317", value: "1170558772484405381497471268332372759" }, + { hex: "061000e1abe0c34555caa2fb1d26dcee74e7", value: "1171752892754361783126534737500206311" }, + { hex: "061000e50cb1c5e91805ad615323a1950b93", value: "1189293454154824464064179714009664403" }, + { hex: "061000e7f84477352bf7d30f958e131a7307", value: "1204456036311298636923366960961057543" }, + { hex: "061000e8a13c46cdde58d442c8e45b9f2b5f", value: "1207883114728849269100423775319436127" }, + { hex: "061000ea34aa31173bf32fee89a846f4aa9f", value: "1216065634177020857607765679674796703" }, + { hex: "061000efcfd1d44250e0a8673eef32048a43", value: "1245174032354738299986861850156632643" }, + { hex: "061000f086782f88e6cbd0c2cf66af9954df", value: "1248878611026048943498367800532620511" }, + { hex: "061000f23e4bcfabf10b47565c632d14351b", value: "1257799355544304906045469172971091227" }, + { hex: "061000f41b1d557a8bcf349420bfd763056f", value: "1267470382612884466141824827221280111" }, + { hex: "061000f8fd6727abde979f55e7d4c91bcc2f", value: "1292829243324792954205043065913855023" }, + { hex: "061000fb98488ddf56996aeb9434f5803b8f", value: "1306355186087083611855402901922921359" }, + { hex: "061000fec346162748f0e3c268260919f73f", value: "1322804024768097068934748188867950399" }, + { hex: "061000ff0aed27d915df669709f890468527", value: "1324257312429289019228814893866452263" }, + { hex: "06104b3b4ca85a86c47a098a223fffffffff", value: "99999999999999999999999999999999999999" }, + // prettier-ignore + { hex: "061913aaf504e4bc1e62173f87a4378c37b49c8ccff196ce3f0ad2", value: "123456789012345678901234567890123456789012345678901234567890" } ]; diff --git a/vitest.config.ts b/vitest.config.ts index cc28fe82..12e617d7 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -8,7 +8,7 @@ export default defineConfig({ reporter: ["text", "json", "html"], lines: 100, statements: 100, - branches: 98.34, + branches: 98.38, functions: 100, thresholdAutoUpdate: true, exclude: ["**/tests/**", "**/*.spec.ts"]