{"id":16550345,"url":"https://github.com/marcogarlet/cuda_cubeattack","last_synced_at":"2025-10-28T18:30:51.051Z","repository":{"id":43253755,"uuid":"468790973","full_name":"MarcoGarlet/CUDA_CubeAttack","owner":"MarcoGarlet","description":"CUDA implementation of Cube Attack","archived":false,"fork":false,"pushed_at":"2022-03-11T23:20:31.000Z","size":9814,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-02-01T17:05:38.794Z","etag":null,"topics":["cryptography","cubeattack","cuda"],"latest_commit_sha":null,"homepage":"","language":"Cuda","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MarcoGarlet.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-03-11T14:53:24.000Z","updated_at":"2024-09-28T15:16:39.000Z","dependencies_parsed_at":"2022-09-03T01:50:14.934Z","dependency_job_id":null,"html_url":"https://github.com/MarcoGarlet/CUDA_CubeAttack","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarcoGarlet%2FCUDA_CubeAttack","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarcoGarlet%2FCUDA_CubeAttack/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarcoGarlet%2FCUDA_CubeAttack/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarcoGarlet%2FCUDA_CubeAttack/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MarcoGarlet","download_url":"https://codeload.github.com/MarcoGarlet/CUDA_CubeAttack/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238689790,"owners_count":19514093,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cryptography","cubeattack","cuda"],"created_at":"2024-10-11T19:33:57.443Z","updated_at":"2025-10-28T18:30:48.793Z","avatar_url":"https://github.com/MarcoGarlet.png","language":"Cuda","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CUDA_CubeAttack\n\n[![DOI](https://zenodo.org/badge/468790973.svg)](https://zenodo.org/badge/latestdoi/468790973)\n\n## Overview\n\n**CUDA_CubeAttack** aims to offer a flexible implementation of cube attack exploiting CUDA framework (sm_50).\n\n## Break one of the ciphers in ./final_attack/ciphers_lib\n\nChoose the proper bit/byte ordering in *cipher.cu* and *validator.py* file, \nsetting the proper public and private key size.\n\nCopy cipher's code in **cipher.cu** until the bottom delimiter.\n\nThen just uncomment one of following lines in *IV_gen* and *IV_gen_host* functions:\n\n```C\n...\niv[(cube_index[i]/8)] += to_MSB(c_i * (1\u003c\u003c(cube_index[i]%8))); //Trivium\n//iv[(IV_dim-1)-(cube_index[i]/8)] += to_MSB(c_i * (1\u003c\u003c(cube_index[i]%8))); // Grain\n//iv[(cube_index[i]/8)] += (c_i * (1\u003c\u003c((cube_index[i]%8)))); // Morus\n...\n```\n\nchoose the same order in *key_gen_superpoly_reconstruction*:\n\n```C\n...\n//k_start[(tid/8)] = (1\u003c\u003c(pos%8)); // Morus\nk_start[(tid/8)] = to_MSB(1\u003c\u003c(pos%8)); // Trivium\n//k_start[(K_dim-1) - (tid/8)] = to_MSB(1\u003c\u003c7-(pos%8)); //Grain \n...\n```\n\nand finally edit **validator.py**:\n\n\n```Python3\n...\nbin_assignment = reduce(lambda x,y:x+y,[('0'*(8-len(bin(c).split('b')[1]))+bin(c).split('b')[1]) for c in ks]) # this depends on the cipher, OK for Trivium\n#bin_assignment = reduce(lambda x,y:x+y,[('0'*(8-len(bin(c).split('b')[1]))+bin(c).split('b')[1])[::-1] for c in ks]) # this depends on the cipher, OK for MORUS\n#bin_assignment = reduce(lambda x,y:x+y,[('0'*(8-len(bin(c).split('b')[1]))+bin(c).split('b')[1])[::-1] for c in ks][::-1]) # this depends on the cipher, OK for Grain\n...\n```\n\nRemember to set the proper *K_dim*.\n\n\n## Usage \n\nOnce set the proper *N_ROUND* in **cipehr.cu**, after choosing the proper output bit position through *BIT_POSITION_APP* and *BIT_POSITION*, you can call **launch_attack.sh** as follow:\n\n\n\n\u003cp align='left'\u003e\n\u003cimg src='pics/launch_att.gif'\u003e\n\u003c/p\u003e\n\n\nThen two files are produced:\n* **cubes_test.txt**\n* **superpolies.txt**\n\nWhere the line position links each *maxterm* with the corresponding *superpoly*.\n\n\nCheck results using *validator.py*:\n\n\u003cp align='left'\u003e\n\u003cimg src='pics/validate.gif'\u003e\n\u003c/p\u003e\n\n## Attack a different cipher\n\nTo integrate new cipher's code in **cipher.cu**, the following functions has to be implemented:\n* *encrypt*: receive two byte arrays (public/private information), return a bit according to *BIT_POSITION_APP* and *BIT_POSITION*\n* *encrypt_exploit*: receive only public key as parameter (the private key is in constant memory *d_key_2_guess*)\n\nThen implement the corresponding host functions(*encrypt_host*, *encrypt_exploit_host*).\n\nThe following parameters must be defined according to cipher's specification:\n* *K_dim*\n* *IV_dim*\n\n## Cubes and superpolies verification\n\nChecking literature results for cubes and superpolies. Write the candidate *maxterm* in *cubes_test_window.txt* in *offline* subdirectory (indexing start from 0).\n\nSelect one of the ordering in **cipher.cu**, call **./final_attack/offline/superpoly_rec/att1** and check in *superpolies_window.txt* the superpolies obtained.\n\nThe right ordering will generate the same published superpolies.\n\n## Use different maxterm version\n\nFrom **launch_attack.sh** you can select one of the following *maxterm mining* versions:\n\n* version 5: trivial parallelized version without huge cube support \n* version 6: proposed parallelized version without huge cube support\n* version 7: trivial parallelized version with arbitrary huge cube support \n\n## Results \n\nResults against Trivium, Morus-640-128 and Grain-128AEAD are reported [here](/docs/MasterThesis.pdf).\n\n\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcogarlet%2Fcuda_cubeattack","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarcogarlet%2Fcuda_cubeattack","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcogarlet%2Fcuda_cubeattack/lists"}