[swift-evolution] Is there a need for a BigNumber library in Objective-C/Swift?

Etan Kissling kissling at oberon.ch
Mon Dec 14 05:25:51 CST 2015

Depends on what you want to achieve.

If it's really used for math, then yes, it's great to have such a library available.
Not many "real" use cases, though, imo, to warrant putting it into the core library atm.

For finance, I guess that's what's `NSDecimalNumber` is for.
This class is not that nice to use from Swift, though.

For crypto, you don't want to use a common BigInt library.
- The library doesn't provide any security guarantees. e.g. when buffers are cleared etc.
- Crypto typically involves fixed sizes (e.g. 256-bit). With common BigInts, you lose performance.
- Crypto is not possible to be implemented securely in pure Swift 2.
  The language lacks annotations to prevent compiler optimisations on a fine-grained level.
  i.e. timing invariance of comparisons etc is not guaranteed / no control about caching behaviour.
  Need to do that in Assembly to be safe against side channel attacks.
  Even with Assembly, you may lose to CPU microcode optimisations. Out of scope, though.

> On 12 Dec 2015, at 12:37, Otto van Verseveld via swift-evolution <swift-evolution at swift.org> wrote:
> About I year ago I started, while Swift was still in beta development, a github project containing a wrapper for the GNU Multiple Precision Arithmetic library (see: https://github.com/githotto/osxgmp <https://github.com/githotto/osxgmp>).
> I haven't done much on it lately, also because some questions were not answered in the GMP-community yet. I want to make it also suitable for iOS development, since currently it compiles / runs only on OSX.
> Do you think there is a need for this 'swift-extension' API/library and it is worthwhile developing further such that the Swift language will have a BigDecimal/BigInt library as being present in Java/C#?
> Any thoughts or even help or suggestions on how to get it compiled for iOS are very welcome!
> Thanks in advance, kind regards,
> Otto van Verseveld
>  _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151214/07dde9ff/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151214/07dde9ff/attachment.sig>

More information about the swift-evolution mailing list