NsZip Switch

From GameBrew
nsZip
Nszipnx.png
General
Authornicoboss
TypePC Utilities
Version2.0.0p2
LicenseMixed
Last Updated2019/04/30
Links
Download
Website
Source

nsZip is an open source PC tool to lossless compress/decompress NSP files in order to save a lot of storage while all NCA files keep their exact same hash.

But it’s more than just a compression. A lot of data like NDV0 partitions or fragment NCA3 files will be removed while compressing and exactly recreated when decompressed which saves even more space especially on updates higher than v65536.

In addition, the NSZ format was designed with emulators in mind so adding NSZ support to Yuzu will be possible in the future and because NSZ contains decrypted NCAs no keys would be needed to only extract game files. As compression algorithm Zstandard is used to multithreaded compress 256 KB chunks while uncompressible chunks are stored uncompressed. That way NSPZ/XCIZ allows random read access. Zstandard has a 43MB/s compression and 7032MB/s decompression speed on an 8 threaded CPU at level 18 while having one of the best compression ratios compared to other compression algorithms.

  • How compressing works: extract NSP > decrypt NCAs > trim fragments > compress to NSZ > verify correctness > repack NSPZ file.
  • How decompressing works: extract NSPZ > decompress NSZ > untrim fragments > encrypt NCAs > verify correctness > repack as NSP.

Note: nsZip only supports the depreciated NSZP format, for the new homebrew compatible NSZ format, please use NSZ instead.

User guide

FAQ

Q. It prod.keys not found!

Dump them using Lockpick and copy them to %userprofile%/.switch/prod.keys

Q. How much storage does this save?

It depends on the game. The compressed size is usually around 40-80% of the original size.

Q. What about XCI?

Compression to XCIZ is supported, but XCIZ to XCI recreation is still in development.

Q. The program throws an error or seems to behaves not as intended!

Open an issue on my GitHub page where you give me exact steps how to reproduce.

Q. Does this compress installed games?

Not now but it's planned for the far future.

Differences between NSZ and NSPZ

Block compressed NSZ is very similar to NSPZ format just without all the unnecessarily complexity which made NSPZ unfeasible for other software to implement.

NSPZ/XCIZ:

  • GitHub Project: https://github.com/nicoboss/nsZip
  • Always uses Block compression allowing random read access to play compressed games in the future.
  • Decrypts the whole NCA.
  • Trims NDV0 fragments to their header and reconstructs them.
  • Only supported by nsZip and unfortunately doesn't really have a future.

NSZ/XCZ:

  • GitHub Project: https://github.com/nicoboss/nsz
  • Uses solid compression by default. Block compression can be enabled using the -B option. Block compression will be the default for XCZ.
  • Decrypts all sections while keeping the first 0x4000 bytes encrypted. Puts informations needed to encrypt inside the header.
  • Deleted NDV0 fragments as they have no use for end users as they only exist to save CDN bandwidth.
  • Already widely used. Supported by Tinfoil, SX Installer v3.0.0 and probably a lot of other software in the future.

Screenshots

nszipnx.png

Changelog

v2.0.0 preview 2 2019/04/30

  • Fixed XCI to XCIZ compression.

v2.0.0 preview 1 2019/04/10

  • New UI made using WPF instead of WinForms.
  • Huge performance improvements.
    • Directly decrypt the NSP without extracting it first.
    • Directly decompressing NSPZ files without extracting them first.
    • Huge encrypting speed increase.
    • Huge SHA-256 verification speed increase.
    • Enhanced compressing multithreading.
    • Support for up to 400 CPU Cores.
  • Improved game compatibility.
  • Command Line support.
  • More settings.

Version 1.1.0 2019/02/15

  • Added support for over multiple NCAs splitted NDV0 fragment trimming.

Version 1.0.1 2019/02/02

  • Let the user continue when detecting a yet unimplemented multifile NDV0 fragment. I'll add proper support for that unimplemented multifile NDV0 fragment format in the following days.
  • The compression level can now be changed (tradeoff between speed and compression ratio).
  • The block size can now be changed (tradeoff between random access time and compression ratio).

Version 1.0.0 2019/02/02

  • First stable version.

External links

Advertising: