GithubHelp home page GithubHelp logo

firoorg / solidity-bignumber Goto Github PK

View Code? Open in Web Editor NEW
86.0 12.0 19.0 268 KB

Full BigNumber library implementation for Solidity.

License: MIT License

Solidity 98.13% Makefile 0.07% Nix 0.02% TypeScript 1.77%

solidity-bignumber's Introduction

Big Number Library for Solidity

Disclaimer!

While extensive testing has occured, this code has not been audited. The developers take no responsiblity should this code be used in a production environment without first auditing sections applicable to you by a reputable auditing firm.

Introduction

With the release of Metropolis, and the precompiled contract allowing modular exponentiations for arbitrary-sized inputs, we can now process big integer functions on the EVM, ie. values greater than a single EVM word (256 bits). These functions can be used as the building blocks for various cryptographic operations, for example in RSA signature verification, and ring-signature schemes.

Overview

Values in memory on the EVM are in 256 bit (32 byte) words - BigNumbers in this library are considered to be consecutive words in big-endian order (top to bottom: word 0 - word n).

The struct BigNumber defined in (src/BigNumber.sol) consists of the bytes value, the bit-length, and the sign of the value.

The value is in the Solidity bytes data structure. by default, this data structure is 'tightly packed', ie. it has no leading zeroes, and it has a 'length' word indicating the number of bytes in the structure.

We consider each BigNumber value to NOT be tightly packed in the bytes data structure, ie. it has a number of leading zeros such that the value aligns at exactly the size of a number of words. for explanation's sake, imagine that instead the EVM had a 32 bit word width, and the following value (in bytes):

 ae1b6b9f1be57476a6948f77effc

this is 14 bytes. by default, solidity's bytes would prepend this structure with the value 0x0e (14 in hex), and it's representation in memory would be like so:

 0000000e - length
 ae1b6b9f - word 0
 1be57476 - word 1
 a6948f77 - word 2
 effc0000 - word 3

In our scheme, the values are literally shifted to the right by the amount of zero bytes in the final word, and the length is changed to include these bytes. our scheme:

 00000010 - length (16 - num words * 4, 4 bytes per word)
 0000ae1b - word 0
 6b9f1be5 - word 1
 7476a694 - word 2
 8f77effc - word 3

this is a kind of 'normalisation'. values will 'line up' with their number representation in memory and so it saves us the hassle of trying to manage the offset when performing operations like add and subtract.

our scheme is the same as above with 32 byte words. This is actually how uint[] represents values (bar the length being the number of words as opposed to number of bytes); however, using raw bytes has a number of advantages.

Rationale

As we are using assembly to manipulate values directly in memory, uint[] is cumbersome and adds too much unnecessary overhead. Additionally, the modular exponentiation pre-compiled contract, used and derived from in the library for various operations, expects as parameters, AND returns, the bytes datatype, so it saves the conversion either side.

The sign of the value is controlled artificially, as is the case with other big integer libraries.

The most significant bit (bitlen) is tracked throughout the lifespan of the BigNumber instance. when the caller creates a BigNumber they can also indicate this value (which the contract verifies), or allow the contract to compute it itself.

Verification

In performing computations that consume an impossibly large amount of gas, it is necessary to compute them off-chain and have them verified on-chain. In this library, this is possible with two functions: divVerify and modinvVerify. in both cases, the user must pass the result of each computation along with the computation's inputs, and the contracts verifies that they were computed correctly, before returning the result.

To make this as frictionless as possible: - Import your function into a Foundry test case - use the ffi cheatcode to call the real function in an external library - write the resulting calldata to be used for the function call.

see tests/differential for examples of this.

Usage

If you're functions directly take BigNumbers as arguments, it is required to first call verify() on these values to ensure that they are in the right format. See src/utils/Crypto.sol for an example of this.

Crypto

The library src/utils/Crypto.sol contains some common algorithms that can be used with this BigNumber library. Is also shows some example usage.

Development

This is a Foundry project. Ensure you have that installed.

Build

$ forge build

Run Unit Tests

$ forge test --mc BigNumbersTest

Differential Testing

Similar to Murky, this project makes use of Foundry's differential and fuzz testing capibilities. More info and setup is in test/differential.

Any proposed extensions, improvements, issue discoveries etc. are welcomed!

solidity-bignumber's People

Contributors

pr0methean avatar riordant avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

solidity-bignumber's Issues

Build failed

I was trying to build and got error:

$ forge build 
[⠊] Compiling...
[⠰] Compiling 12 files with 0.8.17
[⠔] Solc 0.8.17 finished in 276.27ms
Error: 
Compiler run failed
error[6553]: SyntaxError: The msize instruction cannot be used when the Yul optimizer is activated because it can change its semantics. Either disable the Yul optimizer or do not use the instruction.
   --> src/BigNumbers.sol:876:9:
    |
876 |         assembly {
    |         ^ (Relevant source part starts here and spans across multiple lines).



error[6553]: SyntaxError: The msize instruction cannot be used when the Yul optimizer is activated because it can change its semantics. Either disable the Yul optimizer or do not use the instruction.
   --> src/BigNumbers.sol:937:9:
    |
937 |         assembly {
    |         ^ (Relevant source part starts here and spans across multiple lines).



error[6553]: SyntaxError: The msize instruction cannot be used when the Yul optimizer is activated because it can change its semantics. Either disable the Yul optimizer or do not use the instruction.
    --> src/BigNumbers.sol:1032:9:
     |
1032 |         assembly {
     |         ^ (Relevant source part starts here and spans across multiple lines).

Do I need to disable optimizer? How to do that?

bn_div

Any chance for an actual bn_div computation function?

I'm using the library for non cryptographic purposes and need this function.

Getting weird results for some big values

I am using this library and noticed some weird results for some large values. I want to multiply 2 values of max 6144 bits each. Here are my two big number instances I want to multiply together:

{
  bigNumberInstanceA: {
    val: '0x00000000000000000000000000000000000000000000000000000000000000003a1eb8ecccb55eb177961acd4c55f91ef6c4170e945167941c74977784dd6b9e2487c70e96fac3618a421b447ad1ab9374a860c6abba75a084894be7d4effb1921608b187b7cfc65e5daa562e66b3567668c5411cf8646c44e3794834d81e259fb0ab419e7f3b8604a0cfbe2e4e7a7e54b0cf98fb04741796f8be7a63f56f827fa8f321e0cb7a81ae02c3c9093ba34db4c65b8f41bfca39ccf0d421c281688ff18463d09bff3aec8ea60bd8e98773afe513d5aec79a11ab4b668315ec11cbf36a8cc2ef9c06b2e7aaa52c009b1f75e2bbf3e695bb5d026fbdca56622bb7d8427ce9158666fec53a5409de3f1c774c1c6a47a64c715b85038169e49970e224cbf98e1ef4d6c0577b887820a1ed7226739efdfc8f21520e1561e23f6596d4bbfc3b558c1d8bf06ada55b649a33a1f9e034cb9885c93dc1d0d8c58d98214087da1ada5a83ef4e59fe5bc718347af72d0f7438fffe17f45177876e51df89e7cb9bd93e928002920dc45366b4b68dab6ef6665b6bbae5aa81a49559434ebe16ddc1249ded47867fb779fe464c2234cb4c89275a2c6bc735e623e678de4ae5d3e87b3aff5b5c85bc7139addefff6f39af790f75be6a14d85cd34976429b81b9428272976bf55a590dc7c25b4576846fbd1b8121820a7284e580de9012f6d8aee2a0700d26664cb92c0cf00d0509bf5406d122d69a01746031ef3a34f36ecbf1d9e3acd24c01b0b9273cf8d5b8561b4d2b03b66de8d630a02422cbb4449d4bb14c6a03777a3c9333c9e190da63372dc586c12add8cf77924a8e76143e6d1be24165d05f05e0796f24dbfaa48bcbadf424db7d8b37b73aec5d9cbda41a7f202ed16508fad952219514419dca7067fda497d2c6d274fb60c5578eb3a493ae3ca0e4e5e3d8e4e6e6b7ad1c70e4897e2631f223f45bfc154a1c9c9c4e5d803473ee26b56fa45bd58358a6e86bc9e138d1a608a398939977899db7a4f17e9a176626e7f33e6a5420b1b4bf056d9f7422b020d75833a728b8496256b599a5634e4f29b52660795a778dace7cb3aeec09e6dbf972f2803a008314e3cf18230579200e390bb04e7',
    neg: false,
    bitlen: 6142
  },
  bigNumberInstanceB: {
    val: '0x00000000000000000000000000000000000000000000000000000000000000004cff437bbe7c242e9254ce4fb0191d1b64586f79c7504f2447713f2408a797740f535e74854c4e64bdbf7040e5831c776892698e30ab990060e541e00462a58d6c42e4b066006939975f17251b7779460c00306c68af3530458d04df217a659055dfe61bcfee8d5da8b6d20832bbd87f7a35c4ed709f65609562eff75cfe1cd4944fd6a12c7224852123cce3775e13ea9baeb72d0fb2b742af5ea6de5cad0b40f5f62dd4d6a26eaf135e9c96a3f812856117d61379e0a6f468e76af8707cbc67a2e35a75c0cf750d823aac4a45bdd9831c9d62978727f009b96d0c14ba7b66c43a8d1419df0f9a7218495f0fca6ab02a2517c4f3e56aa840c20b56e90007a46b4f80ba2ebf11b01bf4a1b43c4a0d7b6418ff29f025802ef84642232fbb78a6ff53bb2f5b237a26a2d26ff4eb2c8511674b029101c0a3972c8e71fb67008a004b0005a045b4c2ff1641682cded289719b955c46ec39710c103a477565f70ea2663402320a04c0eebf84069bc7b166df8618635fdb9ece51760eb05c5888cdf34c46f7bfde13d9a32887e1a814d79c835e758ffd7b0d657f1d52f049ccb0b0827bb407b59d918028c50c8f882611f68107423e232dfb6534ad54861cc35e42d22ed4e204364642cc4984735e58e4ed31b10056a28be2a033bec4c6137cd8b99a865bfdb804efeabd3ca5ee8aa0dda14722c2dc5b8081b32b135a62980170c1ae5c5efc5126987632d7b6e089c7d9bf9f625324e8996ac4ec53316d263406d58f6c9830d6a47fb2ee8fb548a224d776e7dc4e3099fbfdc296e4924d48aa18813910d6e6d3d953aee65c9fe906ae2c544bb6354a57c3f4851daebedafad128942956c4073cb781b0e9d9d97e195b71ed310b8e71e4d56e4df8aa3eafda6cec80e4c29556aee87de93a55ee47b6994181072699c9498247d1b93c69b6d87b00b5de1b08167122f7f2c9b2057b8a4e3f8dd41d7961a25456d14117b9776dd1eaf65aaa2b2243014e413f5931fd470f0953b956e37a8f3561b10b207c09f7d77bfa7eb46e5b5ebe2527003b7828f72337ffbf84f02c45c35fd640b79ed6d8dacbe44531',
    neg: false,
    bitlen: 6143
  }
}

I have implemented the following function in my smart contract:

    function multiply(BigNumber.instance[2] memory data)
        public
        view
        returns (BigNumber.instance memory)
    {
        return data[0].bn_mul(data[1]);
    }

When calling this function with the mentioned inputs, the result is:

{
    val: '0x017b12d2a30d90780c94b1e4cca184946ce13f68a1efe8c5fc57e5d253cf1ddde4e13c8a17830c20caa12395de287187f19da2cbf9579cbcbad81cbcd390f3e0711894551edd48a855b134e007e09c48f9e53f9a97b84c11079c41b3408554f9c5b870420bf82deb10f841e3d9c7966962b7c8889a99484438ea7f294736da2bd9cf952fbf737a160b1fcee9d6c13ee28eba7cc8358fca401ab095a4317d9f2f7c3ae17979cd96995efae9f0f9b2b2f9e766233d983faca337b2c7e0942ffb456c1506edf3fed40d8ee9d41f0b7c6560c3c0ef017466ade93e8ea5d11492b6064d0aeb704041d0c051b804dadababb8a890055171423c5a1a7e61d7bece23ba9e8f9cbbff2685c1db5fe12471bc73ab8d5268935fd6d05990244c652cc7f9777777884fa0a5943fac2225ee9666a4b892553f8fe25d94bf36a3f8d119cbc93a5e016c9a76822473e2cf0ca32644730bc72164532731b3e3cd2b8aa425430d9c91aa9b2017158f1fbef0b7e7a27dc6107bdbdb3c46b4e10f21a79c06fa15df20568eaeaaba4ecb61e93fd5bddbe46cc4ad41fe6348efd1ce4c896ac1fff3bd8f8277e5640737719ff1358ee6b3bb2e0617a986d9155f0ec7c059ef29f04eeb3d81396d95ce97f96d6545884ae3e09df97118602726ba3bf58291fc840555f98cb1c72175277201201f0f3f98a8d46a75995aef560ce9c707364fc89e58a2a65c37ff4cc317506281593c25874fd35b7336f2166d4e94e888bad7e94ae1c9e0f26b9fcfb4c4eebbfa3462e0acf71ef43382a0233560411b5add36accbfb1662fe0226eeca0650f291cfd39228f14c6ac33d32b2ffdb7267b83423c224f52ea998bcdec0e52b4356797be39042f867f862ce5447dbbec7db58d765be145c6cc8e1f29d3cca962e05bcf5e56be33c99e4cfcca3a1710f607ae908f0d5c173b7f3958c50f5ec914d19402296a60ad55603e1c981c6b00d70e0c89ad3c73c826b7d7ab2e45c4af7bc19a51e1cf0fcb2081f9f03fb3bc2e9cdd59ff99914073b75d416b5102e0b4228101febed8b61c756c8dd2eb20642cd0fb3cf107d5d5b6e04abb7b8531f25db68cffa90d406cda5aa9a9f70ed54cb835d59c1bbd99a23e1535cfeaa42dd89bec3f76b909548fce40d2f8bf903551d4f1d0248c122bb33e199c21c7e9364a86347e49a1d5305399be8e75218c1ce40477dfac74414218c7042dea15a48ebb8ef6d03368c0d66c32b2ffc121c3b6067a82b62c3c34ecf20ae5e919452eac400e3c4cafc7e322d6ae5e22dc618eae5b1efb69f9292eb32c61a213f826aefb1b2d50a3eaa95bf0074caa96df0dccbf0cfc15a09f6aa7cf086338a8099881d690a213442121a522ce1badd08445883af37f020efbbe24a532b3e4d096e9b431cd7290223f9bb45b3c5946ccf3b1bf017d27ae36b82e3426107f67b44bd0ae4aac8ae4dcdfa3617e899b21c4210e388c4b095255f3ba7fa1e44ea0ca647c1896858a94a552e09ea2bf1dacb5a336f32ab6d2e8fceda3cbe85255907c7a06ecfdda11a8db2d6d4733a19779ea87035aa3009d3b25c4ed31ec9ce57668f6ec15a4ec7c6718c0703410d9c7fad5a75bdfe9f8bd5890a04965a5d2393ea80b9508490dbb18b0c5c1fe90a252c6c6c4d75a010f02531e8dd40cc7f375fce800b3d83cff2baaf433eefd6baf8cc78e6eae8302d94dad8e9cc527e19cbc6b0445626a2641485280e9e2bc5f9b25ba4f22ac06518b99262baff360ac34bc705e9be26b7d79024c6e0f0ef5a3b73f249a0320aa617728d9143950dca21bd5b8e2f34e7e98cd77bb2ba0856e4442a6e455de6543ae079466e65bc8f79df2962e0f75fad039180062142c493354576a21405623126c41f41bbbc2c0824a4a5998035d79fe846a5627d29a25631de5a1730c9aa13736448e40699370606d349d84022eb2fb1cc09f7304a08434c771201f0bbcf847872868e97e8465a5a1d4e57b92f47f86351f7d11b00341b3208ec5ca02e5dd1c5e95041c1e60f2f5b989fad8febe8ff99b409347a45f64651694fc94640c494e366fb69f486f96511e7dd06771203b02b9b85904863ab8576eddd1dccfbc7d8c2e5c27ec5081b0d0025d6296b369a4cba650a10d86284c81e94a80ca114a8879d7305a087725fd121fc9baa6da3337',
    neg: false,
    bitlen: BigNumber { value: "12281" }
}

Casting the val hex value to BigInt using BigInt(val) gives the value:

6589162891845885612575019946133854740063520802811043717853803045574592257464139801370155694864819502311025730585587379714450022444509839701451537010832711459290336663873265442455715275889705687320688061388706787028315829226828121747550932617639887891374359521545137098704729480301109582594897087889213249373771992712152801239724830920108559084728036514580680135836635540930729794548243871067576085421725929419222689737823277385204297754272577489900410275941196141039053090318785436199834546565283167176460191167585902402842463351141910789344789865373449534827186157483126720684136953055139546207738685742500122468605904098312757083294440300133598952138543470855732112854448933021368213112537322531330308711716817308043265178267760730322294394125708960935661798431453050391561493315381696279277037782869143964815673972357207575929294885505490440945456748848854553649692270942838976680040849007445257006092140293849523452329599727727911423563439421634527849645655262486318035328790625579991044344468228060988309653289487197948209081420590421451127806713815534039046654342981402767740509040005784244413494286324397734927968627046386811957085078739930766419132611342089688042640421198604981876705200687970695218142758141056659101631066836237365724792768198788301369476208452818718201546300306226376415170804056796624360935174024932691864908336957861921239160503307613287584824283125299081010216233173087008546973534571097790340064353801041510058652942709319150781034009394297233187595010576753332598702071875184614399341566500989920179141114217019360097016289783241648167770623255971999307935890912399537141543687057599412973710652307666941311830617778828453373372307132275034065165646668443509439177062478469031416404058792697284640516298149781007253213163788691422010673553639756538294428442733085176240017316789613761134632874628372977601252938811774269668943523134670709403497537148131536354320146668323257372125884342263633754769932698364813032650081122157262885708257406297244123627943618470297965874796707626594924586702471598210006799307394022456759574797023800051132824307253494919165243740307010472916012073567003219104361569287055013636834279166315468071720868796601687600579039415437193460313860979356415124480477904269909060087646994267328198093495757612522018978915121328589206171402112994150727939694945897554493272739447630150089574497875730719701840738527512143492571605457729285332021645702189625043219396409124822943132308075122437398884609157168574298728158614433985819994109031243645245862612647410929969300010696170529989439176381225672310986867871248699861348208208948838850415792567819478216600568572668205428264591941326666122170964836985735404588105644781213923997669053941243245145941575950923731069190229471759600835193014825228946745628342077018300781369545204272228616159945503893549885836723376001910752255593095927269980734971822608893576395447891421104167393584581866365530423149797069124812246520881113579322440750239842367553092412708375316864367356561647167843705039092600594503145487142964057646856244928055767191199971388144949713194562058778663343383233972296598119078065721484939673281051412258473059463594920919061996853584894109102373284991540176131877557912410091180412478245897146384860641865987201962383058658173096501421314333489270196411869385357312155861690975292731595783122596526405203312029193334798400913882778188707428531771699689384186756127461041633106960091592767588592996348198256554954973345778120688985167299811683369317526255178027800602836901478275391058923867815578386036215012489573129145358805444327886490824953277747999569652387724511795949337906027057362708651015537940132999905369575457650422628973935965752982991217340374365591188279

However, the expected result is:

77786989470786096290446181153379605278894675054599450037466273884739744705743495524326810551842132927807523721747568281643253259544666990498353637756387515957723432076069310085718357143217398224018647785718370845026837908145099693498070276840995251638614101791619806030208959033590521185955013440674915897634478613882173411390695524056855621546883291529778063900269996081825588049102140525983639510932190600579603818916929774162435420297441211478664103893686221578729095993851488255464430126637141096065378533514979487725962416739465463907920033131270227034519256767567924540053513233023601632499083416819956517729977110890696128395689985672337756200232470261807324674160392233616016325478672393146364984617748766459626827548648686325801208477507484384632247704634433803416285931787477220387479925504476927190578399439818332424483830458598227194259855391322409390274944181629510859936303649117640988947246865709272109919274946738306324085859404737775164104839340989387106290813589093103269376065120151821994919270068361587544552296980636668942505305677906405275886598385247098791888815543235796258776287122574512324185238226987838332252902332033647507334560394111576769548510727975055101314634248667276548304698643523162061780492280754691734329535357191903585469970887880062201516203126004389455317099724708904875529732431565625458779032135602334234802564369869706563123493389014772688921473203924420268151068964704907645222059137559159890055453240502606110806895556890458499181709940328553496206882251824444175499265717716717877109124196161017155856856717985145990388494735505024196095485930629855499494039866942377160823099663958905683954145172220138590534753716262929918110240069284084657513670826503175706096208664569509482068506324711727872870286708299154170288395970514776494834180784733270115340220561550427964200399837062518292912358530557937931585030398101798331213550354519845151096920880441480260899837568297130085489330655247884380207327915645059034612845923815997721084694341341500784967692100941366347647966598337790828009107876917200612535949893877357657487888652639588256220586048389987840188689025466207689177665698319239951592054044727318086634675902940233838286017845660493005509285555220649160423304462732325477589290900666933131159767012207438294344013748149422132898335200076103063486840661651916981510266739328979816658717261565123981456222991083618934668417253180251266964038408282884782903668324686539176995453886301383715983199921523559578708627952429716805546454914023230565984733367209254010502276171744059026988767763706467614296149087912240223437819709109907296828704175659040717043597144448806147040937049844014598838756672482956370155157266304756666351279499915606815912111069300278485644669100709441168987530830898669388935777355369205804989832228357798320419490910471225685970924581216621922009968381432426752573869059230276226100566078669138270318333514115815419743008225496908712239384387129732146230367638100915785211202638884575239766990129537219120094210864520931571158650564485810916806509881041385577931029723235368086552143324558060599300423350918520075895908343308987756682354256758491946462787700438832919559636547280884879822432512761143914433888977700856823496732083373582837669503954262940927036456599553024805975778682506350985129598370903892645740067116955747765469617045968963754344416958029873867425351263223407149108681723975896481628061415628362304256061081681852485742575710923963022512612569253674605646803104592147821717177074532209316958546345274733429307875315119242545395947848530799484137797920946458126359087011412454331375825543096731255089903981462506607712779479545640538484741423805741577706103023069254720188071908779211555287479095

For most 614x bit integers, the multiplication does give the correct result. Am I overseeing some limitation or configuration? Does anyone have experienced this?

modular multiplication runs out of gas

Trying this code to calculate modular exponentiation, however in the below code prepare_modexp modular exponentiation works with the values x and p, but modmul modular multiplication runs out of gas.

pragma solidity >=0.4.20 <0.6;

import "./BigNumber.sol";

/* 

 */

contract testmod {
  using BigNumber for *; 
  
  function test() public returns(bytes memory,bool,uint){
    BigNumber.instance memory g;
    BigNumber.instance memory p;
    BigNumber.instance memory x;

    g.val = hex"04";
    g.neg = false;
    g.bitlen = BigNumber.get_bit_length(g.val);

    p.val = hex"0800";
    p.neg = false;
    p.bitlen = BigNumber.get_bit_length(p.val);

    x.val = hex"03";
    x.neg = false;
    x.bitlen = BigNumber.get_bit_length(x.val);

    //BigNumber.instance memory res = g.modmul(x,p);
    BigNumber.instance memory res = g.prepare_modexp(x,p);

    return (res.val, res.neg, res.bitlen);
  }

I think the issue is with the for loop on line 140 in bn_add(), but not sure how to fix it:
https://github.com/zcoinofficial/solidity-BigNumber/blob/db0d6d298cee2d8974cb6ffa76659d96f3454150/contracts/BigNumber.sol#L140-L168

Help needed

I would like to know which algorithm have you used.
Have you got any survey or paper where you explain this.

Converting BigNumber into int256

Hi there,

Assuming, the code can inspect big number, and if ensured it fits into int256 - how to covert it?

I didn't find any example.

LICENSE??

Hi, thank you for great OSS.

Maybe my question seems weird but I would like to know.

This repository says this is MIT license, but your solidity code says SPDX unlicense.

Could I use your code and upload my repository??

thank you.

update contracts to work with solidity ^0.8.0

hi @riordant, as noted in a few of the other issues, this library doesn't work with solidity ^0.8.0 due to the addition of built-in safemath operations

are there any plans to update this repo to support latest solidity? this way a few of us wouldn't need to fork it. thanks!

[FAIL. Reason: Arithmetic over/underflow] testRSA() (gas: 6003)

Hello, There was a error after I execute the command.
forge test --mc BigNumbersTest

In total I executed the following commands

git clone https://github.com/firoorg/solidity-BigNumber.git
cd solidity-BigNumber
forge build
forge test --mc BigNumbersTest

And this is all of the message

[⠑] Compiling...
No files changed, compilation skipped

Running 11 tests for test/BigNumbers.t.sol:BigNumbersTest
[PASS] testDiv() (gas: 27532)
[PASS] testFailVerifyBitlen() (gas: 668)
[PASS] testFailVerifyLength() (gas: 499)
[PASS] testInit() (gas: 31180)
[PASS] testLengths() (gas: 11256)
[PASS] testModMul() (gas: 24026)
[PASS] testMul() (gas: 83697)
[FAIL. Reason: Arithmetic over/underflow] testRSA() (gas: 6003)
[PASS] testShiftLeft() (gas: 153374)
[PASS] testShiftRight() (gas: 59236)
[PASS] testVerify() (gas: 733)
Test result: FAILED. 10 passed; 1 failed; 0 skipped; finished in 1.98ms
Ran 1 test suites: 10 tests passed, 1 failed, 0 skipped (11 total tests)

Failing tests:
Encountered 1 failing test in test/BigNumbers.t.sol:BigNumbersTest
[FAIL. Reason: Arithmetic over/underflow] testRSA() (gas: 6003)

Encountered a total of 1 failing tests, 10 tests succeeded

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.