| ---
|
| title: ascad-v2-15k
|
| tags:
|
| - side-channel-analysis
|
| - cryptography
|
| - DLSCA
|
| parameters:
|
| HF_ORG: DLSCA
|
| CHUNK_SIZE_Y: 100000
|
| TOTAL_CHUNKS_ON_Y: 6
|
| CHUNK_SIZE_X: 10
|
| TOTAL_CHUNKS_ON_X: 1500
|
| NUM_JOBS: 10
|
| CAN_RUN_LOCALLY: True
|
| CAN_RUN_ON_CLOUD: False
|
| COMPRESSED: True
|
| ---
|
|
|
| # ascad-v2-15k
|
|
|
| This script downloads, extracts, and uploads the ASCAD v2 extracted dataset to Hugging Face Hub.
|
| Profiling (500k) and attack (10k) traces are merged into a single flat dataset of 510k traces with 15k samples per trace.
|
| Chunks: CHUNK_SIZE_Y=100000, TOTAL_CHUNKS_ON_Y=6 (last chunk has 10000 traces).
|
|
|
| ## Dataset Structure
|
|
|
| This dataset is stored in Zarr format, optimized for chunked and compressed cloud storage.
|
|
|
| ### Traces (`/traces`)
|
| - **Shape**: `[510000, 15000]` (Traces x Time Samples)
|
| - **Data Type**: `int8`
|
| - **Chunk Shape**: `[100000, 10]`
|
|
|
| ### Metadata (`/metadata`)
|
| - **key**: shape `[510000, 16]`, dtype `uint8`
|
| - **mask**: shape `[510000, 16]`, dtype `uint8`
|
| - **mask_**: shape `[510000, 16]`, dtype `uint8`
|
| - **perm_index**: shape `[510000, 16]`, dtype `uint8`
|
| - **plaintext**: shape `[510000, 16]`, dtype `uint8`
|
| - **rin**: shape `[510000, 1]`, dtype `uint8`
|
| - **rin_**: shape `[510000, 1]`, dtype `uint8`
|
| - **rm**: shape `[510000, 1]`, dtype `uint8`
|
| - **rm_**: shape `[510000, 1]`, dtype `uint8`
|
| - **rout**: shape `[510000, 1]`, dtype `uint8`
|
| - **rout_**: shape `[510000, 1]`, dtype `uint8`
|
| - **sbox_masked**: shape `[510000, 16]`, dtype `uint8`
|
| - **sbox_masked_with_perm**: shape `[510000, 16]`, dtype `uint8`
|
|
|
| ## Leakage Analysis Targets
|
|
|
| The following targets are available for side-channel leakage analysis on this dataset:
|
|
|
| | Target Name | Description |
|
| | :--- | :--- |
|
| | `ciphertext` | Returns `metadata['ciphertext'][:, byte_index]` |
|
| | `key` | Returns `metadata['key'][:, byte_index]` |
|
| | `mask` | Returns `metadata['mask'][:, byte_index]` |
|
| | `mask_` | Returns `metadata['mask_'][:, byte_index]` |
|
| | `perm_index` | Returns `metadata['perm_index'][:, byte_index]` |
|
| | `plaintext` | Returns `metadata['plaintext'][:, byte_index]` |
|
| | `rin` | Returns `metadata['rin'][:, 0]` |
|
| | `rin_` | Returns `metadata['rin_'][:, 0]` |
|
| | `rm` | Returns `metadata['rm'][:, 0]` |
|
| | `rm_` | Returns `metadata['rm_'][:, 0]` |
|
| | `rout` | Returns `metadata['rout'][:, 0]` |
|
| | `rout_` | Returns `metadata['rout_'][:, 0]` |
|
| | `sbi` | Returns `np.bitwise_xor(metadata['plaintext'][:, byte_index], metadata['key'][:, byte_index])` |
|
| | `sbo` | Returns `SBOX[Targets.sbi(metadata=metadata, byte_index=byte_index, dataset_name=dataset_name)]` |
|
| | `sbox_masked` | Returns `metadata['sbox_masked'][:, byte_index]` |
|
| | `sbox_masked_with_perm` | Returns `metadata['sbox_masked_with_perm'][:, byte_index]` |
|
| | `v2_affine_ptx` | State after Map_in_G + Xor_states at slot ``byte_index``.<br><br>``rm * ptx[j] ^ mask[j]`` where ``j = perm[byte_index]``.<br><br>The affine-masked plaintext before any round key has been mixed in. |
|
| | `v2_key` | Plain key byte at the AES position consumed by shuffling slot ``byte_index``.<br><br>``key[j]`` where ``j = perm[byte_index]``.<br><br>The key byte is loaded unprotected from flash/ROM during AddRoundKey r=0 before being scaled into the GF(256) domain via ``gtab``. Classic first-order DPA target; ``v2_rm_key`` is the masked (GF-scaled) version. |
|
| | `v2_lut_idx` | sboxMasked LUT index computed during SubBytes at round 1, slot ``byte_index``.<br><br>``rm * (ptx[j] ^ key[j]) ^ rin`` where ``j = perm[byte_index]``.<br><br>Computed as ``state[j] ^ state2[j]`` inside the SubBytes loop: the additive masks (masksState) cancel, leaving only the multiplicatively-masked SBI XORed with rin. This is the value whose hamming weight leaks during the LUT address computation. |
|
| | `v2_mask_at_perm` | Per-byte additive mask at the AES position consumed by shuffling slot ``byte_index``.<br><br>``mask[j]`` where ``j = perm[byte_index]``.<br><br>Distinct from ``mask[byte_index]`` whenever the permutation is non-identity. This is the mask that enters and leaves every intermediate in the affine invariant for slot ``byte_index``. |
|
| | `v2_masked_sbi` | State entering round 1 at slot ``byte_index``: after AddRoundKey r=0.<br><br>``rm * (ptx[j] ^ key[j]) ^ mask[j]`` where ``j = perm[byte_index]``.<br><br>This is the affine-masked plaintext XOR key value that the round-1 SubBytes call will process. |
|
| | `v2_perm` | Shuffling permutation index at slot ``byte_index`` for ASCAD v2.<br><br>Returns ``j = perm[:, byte_index]`` — for each trace the AES byte position (0–15) processed in shuffling slot ``byte_index``. All other slot-indexed ``v2_*`` targets derive ``j`` via this method.<br><br>**Original-paper label:** ``perm_index[byte_index]`` in the ASCAD v2 HDF5 file. Derived as:<br><br> perm[n, i] = G[G[G[G[(15 - i) XOR x0[n]] XOR x1[n]] XOR x2[n]] XOR x3[n]]<br><br>where G = ``_V2_PERM_G`` and x0..x3 are the lower nibbles of mask[:, 0..3]. |
|
| | `v2_ptx` | Plaintext byte at the AES position consumed by shuffling slot ``byte_index``.<br><br>``ptx[j]`` where ``j = perm[byte_index]``.<br><br>The byte value loaded from the plaintext register before ``Map_in_G`` scales it into the GF(256) multiplicative domain. Classic first-order DPA target; ``v2_rm_ptx`` is the masked version after Map_in_G. |
|
| | `v2_raw_out` | SubBytes ``raw_out`` at round 1, slot ``byte_index``: the sboxMasked LUT output.<br><br>``rm * SBOX(ptx[j] ^ key[j]) ^ rout`` where ``j = perm[byte_index]``.<br><br>This is ``sboxMasked[lut_idx]`` — the value read from the firmware's masked S-Box LUT before it is XORed with ``state2[j]`` (masksState). It sits between :meth:`v2_lut_idx` (the LUT address) and :meth:`v2_sbo_mid` (the value written back into ``state[j]``).<br><br>**Original-paper label:** ``sbox_masked[byte_index]`` in the ASCAD v2 HDF5 file and the NCC Group ML-104 blog 34-task model. |
|
| | `v2_raw_out_direct` | SubBytes ``raw_out`` at round 1 indexed directly by AES byte position.<br><br>``rm * SBOX(ptx[i] ^ key[i]) ^ rout`` where ``i = byte_index`` (no perm).<br><br>Unlike :meth:`v2_raw_out`, the shuffle permutation is **not** applied — ``byte_index`` maps directly to the AES state byte position. This is the same formula as :meth:`v2_raw_out` but over the identity byte ordering, making it practical as an un-permuted SNR or model target.<br><br>**Original-paper label:** ``sbox_masked_with_perm[byte_index]`` in the ASCAD v2 HDF5 file and the NCC Group ML-104 blog 18-task model (``RMmSBOxROUT`` in scandal/crypto.py). |
|
| | `v2_rm_key` | Masked round-key contribution added during AddRoundKey r=0 at slot ``byte_index``.<br><br>``rm * key[j]`` where ``j = perm[byte_index]``.<br><br>This is ``gtab[key[j]]`` — the value XORed into state during the masked AddRoundKey call, scaled into the same multiplicative domain as the plaintext. |
|
| | `v2_rm_ptx` | Map_in_G output at slot ``byte_index``: ``rm * ptx[j]``, ``j = perm[byte_index]``.<br><br>The plaintext byte scaled into the GF(256) multiplicative domain. Additive mask (masksState) has not yet been applied at this point. |
|
| | `v2_sbi_perm` | Unmasked SBI at the AES byte position consumed by shuffling slot ``byte_index``.<br><br>``ptx[j] ^ key[j]`` where ``j = perm[byte_index]``.<br><br>Unlike :meth:`sbi`, which uses ``byte_index`` as a direct AES byte position, this target follows the actual byte consumed by the firmware SubBytes shuffle at slot ``byte_index``. |
|
| | `v2_sbo_affine` | Affine-masked SBO at slot ``byte_index`` after full SubBytes (post-loop rout strip).<br><br>``rm * SBOX(ptx[j] ^ key[j]) ^ mask[j]`` where ``j = perm[byte_index]``.<br><br>This is the state value after the post-loop ``state[j] ^= rout`` pass restores the affine invariant. The rout mask is gone; only the multiplicative mask rm and the per-byte additive mask remain. |
|
| | `v2_sbo_mid` | Mid-SubBytes state at slot ``byte_index`` before post-loop rout strip.<br><br>``rm * SBOX(ptx[j] ^ key[j]) ^ rout ^ mask[j]`` where ``j = perm[byte_index]``.<br><br>This is ``raw_out ^ state2[j]``, i.e. the value written back into ``state[j]`` inside the SubBytes inner loop, before the post-loop ``state[j] ^= rout`` pass. The rout mask has not yet been removed. |
|
| | `v2_sbo_perm` | Unmasked SBO at the AES byte position consumed by shuffling slot ``byte_index``.<br><br>``SBOX(ptx[j] ^ key[j])`` where ``j = perm[byte_index]``. |
|
| | `v2_xw_state` | State after Xor_Word at round 1 (before SubBytes) at slot ``byte_index``.<br><br>``rm * (ptx[j] ^ key[j]) ^ mask[j] ^ rin`` where ``j = perm[byte_index]``.<br><br>This is the state byte written to the register immediately before the firmware issues the sboxMasked lookup. |
|
|
|
| ## Auto-Generated Leakage Plots
|
|
|
| | Dataset | Target | Byte Index | Plot |
|
| | :--- | :--- | :---: | :---: |
|
| | ascad-v2-15k | key | 0 | <img src="plots/ascad_v2_15k_key_0.png" alt="ascad-v2-15k key" width="400"/> |
|
| | ascad-v2-15k | mask | 0 | <img src="plots/ascad_v2_15k_mask_0.png" alt="ascad-v2-15k mask" width="400"/> |
|
| | ascad-v2-15k | mask_ | 0 | <img src="plots/ascad_v2_15k_mask__0.png" alt="ascad-v2-15k mask_" width="400"/> |
|
| | ascad-v2-15k | perm_index | 0 | <img src="plots/ascad_v2_15k_perm_index_0.png" alt="ascad-v2-15k perm_index" width="400"/> |
|
| | ascad-v2-15k | plaintext | 0 | <img src="plots/ascad_v2_15k_plaintext_0.png" alt="ascad-v2-15k plaintext" width="400"/> |
|
| | ascad-v2-15k | sbi | 0 | <img src="plots/ascad_v2_15k_sbi_0.png" alt="ascad-v2-15k sbi" width="400"/> |
|
| | ascad-v2-15k | sbo | 0 | <img src="plots/ascad_v2_15k_sbo_0.png" alt="ascad-v2-15k sbo" width="400"/> |
|
| | ascad-v2-15k | sbox_masked | 0 | <img src="plots/ascad_v2_15k_sbox_masked_0.png" alt="ascad-v2-15k sbox_masked" width="400"/> |
|
| | ascad-v2-15k | sbox_masked_with_perm | 0 | <img src="plots/ascad_v2_15k_sbox_masked_with_perm_0.png" alt="ascad-v2-15k sbox_masked_with_perm" width="400"/> |
|
| | ascad-v2-15k | v2_affine_ptx | 0 | <img src="plots/ascad_v2_15k_v2_affine_ptx_0.png" alt="ascad-v2-15k v2_affine_ptx" width="400"/> |
|
| | ascad-v2-15k | v2_key | 0 | <img src="plots/ascad_v2_15k_v2_key_0.png" alt="ascad-v2-15k v2_key" width="400"/> |
|
| | ascad-v2-15k | v2_lut_idx | 0 | <img src="plots/ascad_v2_15k_v2_lut_idx_0.png" alt="ascad-v2-15k v2_lut_idx" width="400"/> |
|
| | ascad-v2-15k | v2_mask_at_perm | 0 | <img src="plots/ascad_v2_15k_v2_mask_at_perm_0.png" alt="ascad-v2-15k v2_mask_at_perm" width="400"/> |
|
| | ascad-v2-15k | v2_masked_sbi | 0 | <img src="plots/ascad_v2_15k_v2_masked_sbi_0.png" alt="ascad-v2-15k v2_masked_sbi" width="400"/> |
|
| | ascad-v2-15k | v2_perm | 0 | <img src="plots/ascad_v2_15k_v2_perm_0.png" alt="ascad-v2-15k v2_perm" width="400"/> |
|
| | ascad-v2-15k | v2_ptx | 0 | <img src="plots/ascad_v2_15k_v2_ptx_0.png" alt="ascad-v2-15k v2_ptx" width="400"/> |
|
| | ascad-v2-15k | v2_raw_out | 0 | <img src="plots/ascad_v2_15k_v2_raw_out_0.png" alt="ascad-v2-15k v2_raw_out" width="400"/> |
|
| | ascad-v2-15k | v2_raw_out_direct | 0 | <img src="plots/ascad_v2_15k_v2_raw_out_direct_0.png" alt="ascad-v2-15k v2_raw_out_direct" width="400"/> |
|
| | ascad-v2-15k | v2_rm_key | 0 | <img src="plots/ascad_v2_15k_v2_rm_key_0.png" alt="ascad-v2-15k v2_rm_key" width="400"/> |
|
| | ascad-v2-15k | v2_rm_ptx | 0 | <img src="plots/ascad_v2_15k_v2_rm_ptx_0.png" alt="ascad-v2-15k v2_rm_ptx" width="400"/> |
|
| | ascad-v2-15k | v2_sbi_perm | 0 | <img src="plots/ascad_v2_15k_v2_sbi_perm_0.png" alt="ascad-v2-15k v2_sbi_perm" width="400"/> |
|
| | ascad-v2-15k | v2_sbo_affine | 0 | <img src="plots/ascad_v2_15k_v2_sbo_affine_0.png" alt="ascad-v2-15k v2_sbo_affine" width="400"/> |
|
| | ascad-v2-15k | v2_sbo_mid | 0 | <img src="plots/ascad_v2_15k_v2_sbo_mid_0.png" alt="ascad-v2-15k v2_sbo_mid" width="400"/> |
|
| | ascad-v2-15k | v2_sbo_perm | 0 | <img src="plots/ascad_v2_15k_v2_sbo_perm_0.png" alt="ascad-v2-15k v2_sbo_perm" width="400"/> |
|
| | ascad-v2-15k | v2_xw_state | 0 | <img src="plots/ascad_v2_15k_v2_xw_state_0.png" alt="ascad-v2-15k v2_xw_state" width="400"/> |
|
| | ascad-v2-15k | rin | none | <img src="plots/ascad_v2_15k_rin.png" alt="ascad-v2-15k rin" width="400"/> |
|
| | ascad-v2-15k | rin_ | none | <img src="plots/ascad_v2_15k_rin_.png" alt="ascad-v2-15k rin_" width="400"/> |
|
| | ascad-v2-15k | rm | none | <img src="plots/ascad_v2_15k_rm.png" alt="ascad-v2-15k rm" width="400"/> |
|
| | ascad-v2-15k | rm_ | none | <img src="plots/ascad_v2_15k_rm_.png" alt="ascad-v2-15k rm_" width="400"/> |
|
| | ascad-v2-15k | rout | none | <img src="plots/ascad_v2_15k_rout.png" alt="ascad-v2-15k rout" width="400"/> |
|
| | ascad-v2-15k | rout_ | none | <img src="plots/ascad_v2_15k_rout_.png" alt="ascad-v2-15k rout_" width="400"/> |
|
|
|
| ## Parameters Used for Generation
|
|
|
| - **HF_ORG**: `DLSCA`
|
| - **CHUNK_SIZE_Y**: `100000`
|
| - **TOTAL_CHUNKS_ON_Y**: `6`
|
| - **CHUNK_SIZE_X**: `10`
|
| - **TOTAL_CHUNKS_ON_X**: `1500`
|
| - **NUM_JOBS**: `10`
|
| - **CAN_RUN_LOCALLY**: `True`
|
| - **CAN_RUN_ON_CLOUD**: `False`
|
| - **COMPRESSED**: `True`
|
|
|
| ## Usage
|
|
|
| You can load this dataset directly using Zarr and Hugging Face File System:
|
|
|
| ```python
|
| import zarr
|
| from huggingface_hub import HfFileSystem
|
|
|
| fs = HfFileSystem()
|
|
|
| # Map only once to the dataset root
|
| root = zarr.open_group(fs.get_mapper("datasets/DLSCA/ascad-v2-15k"), mode="r")
|
|
|
| # Access traces directly
|
| traces = root["traces"]
|
| print("Traces shape:", traces.shape)
|
|
|
| # Access plaintext metadata directly
|
| plaintext = root["metadata"]["plaintext"]
|
| print("Plaintext shape:", plaintext.shape)
|
| ```
|
| |