SceneGate / Ekona

.NET implementation of DS and DSi file formats
https://scenegate.github.io/Ekona/
MIT License
27 stars 1 forks source link

:sparkles: Verify and generate Twilight digest hashes #24

Closed pleonex closed 2 years ago

pleonex commented 2 years ago

Description

Example

The digest is verified by Binary2NitroRom when the keys are provided. It's also regenerated by NitroRom2Binary when the keys are provided. To use it manually, use the class TwilightHmacGenerator.

Performance

Regenerating or verifying the full content of the ROM impacts the performance. It's optional and only happens if the keys are provided. The results are acceptable under the second.


BenchmarkDotNet=v0.13.1, OS=fedora 34
Intel Core i7-4720HQ CPU 2.60GHz (Haswell), 1 CPU, 8 logical and 4 physical cores
.NET SDK=6.0.103
  [Host]     : .NET 6.0.3 (6.0.322.16001), X64 RyuJIT
  DefaultJob : .NET 6.0.3 (6.0.322.16001), X64 RyuJIT
Method RomPath UseKeys Mean Error StdDev Gen 0 Gen 1 Gen 2 Allocated
ReadRom METALMAX3_BM9JQC_00.nds False 646.5 μs 8.65 μs 7.67 μs 65.4297 32.2266 - 364 KB
WriteRom METALMAX3_BM9JQC_00.nds False 13,830.4 μs 66.63 μs 62.33 μs 453.1250 - - 1,412 KB
ReadRom METALMAX3_BM9JQC_00.nds True 3,822.7 μs 68.78 μs 129.19 μs 265.6250 257.8125 164.0625 1,680 KB
WriteRom METALMAX3_BM9JQC_00.nds True 17,498.3 μs 157.89 μs 139.96 μs 468.7500 - - 2,591 KB
ReadRom NINOKUNI_B2KJHF_00.nds False 51,638.4 μs 928.01 μs 911.43 μs 2100.0000 1000.0000 300.0000 11,477 KB
WriteRom NINOKUNI_B2KJHF_00.nds False 205,883.5 μs 2,838.06 μs 2,369.91 μs 24000.0000 - - 75,966 KB
ReadRom NINOKUNI_B2KJHF_00.nds True 54,195.4 μs 774.02 μs 724.02 μs 2200.0000 1000.0000 300.0000 12,691 KB
WriteRom NINOKUNI_B2KJHF_00.nds True 205,055.0 μs 2,815.72 μs 2,633.82 μs 24333.3333 - - 77,032 KB
ReadRom PSL_VPYJ2P_00.nds False 2,916.6 μs 32.17 μs 28.52 μs 191.4063 93.7500 - 1,209 KB
WriteRom PSL_VPYJ2P_00.nds False 79,985.2 μs 1,597.41 μs 2,239.34 μs 1000.0000 - - 6,050 KB
ReadRom PSL_VPYJ2P_00.nds True 600,838.2 μs 10,032.94 μs 8,893.94 μs 4000.0000 1000.0000 - 16,396 KB
WriteRom PSL_VPYJ2P_00.nds True 369,532.8 μs 5,659.06 μs 4,725.57 μs 6000.0000 - - 21,104 KB

This closes #12