在 Google Colab 中安裝 SageMath


在本文中,我們將SageMathGoogle Colab. 我們之前發表過一篇文章:“在 Fedora 64 位(10GB)雲虛擬服務器上安裝 SageMath 進行密碼分析”,但為了繼續對比特幣區塊鏈進行密碼分析,我們的許多讀者更喜歡Debian使用. 據我們所知,它已更新為.UbuntuFedoraGoogle Colab"Ubuntu 20.04.5 LTS"

我們可以通過運行命令來檢查這一點:

!cat /etc/lsb-release

在 Google Colab 中安裝 SageMath

因此"Ubuntu 20.04.5 LTS",該版本只允許我們安裝SageMath version 9.0, Release Date: 2020-01-01

使用標準安裝命令:

!sudo apt-get install -y sagemath-common
在 Google Colab 中安裝 SageMath

不幸的是這個版本不能正常工作。

為了進行完整的密碼分析,我們將安裝Google Colab一個全新的版本SageMath version 9.3

文件:Install_SageMath_in_Google_Colab.ipynb 我們發佈在GitHub

我們去官網看看: https: //colab.research.google.com

選擇選項“下載記事本”


在 Google Colab 中安裝 SageMath

下載文件:Install_SageMath_in_Google_Colab.ipynb


在 Google Colab 中安裝 SageMath

現在,通過該實用程序,wget 下載tar-filesage-9.3-Ubuntu_20.04-x86_64.tar.bz2

!wget https://cryptodeeptech.ru/sage-9.3-Ubuntu_20.04-x86_64.tar.bz2
!tar -xf sage-9.3-Ubuntu_20.04-x86_64.tar.bz2
在 Google Colab 中安裝 SageMath

讓我們瀏覽一下目錄:

cd SageMath/

在 Google Colab 中安裝 SageMath

打開面板並轉到文件夾:SageMath


在 Google Colab 中安裝 SageMath

檢查Python-script:relocate-once.py是否存在


在 Google Colab 中安裝 SageMath

使用以下命令運行Python-script:relocate-once.py :

!python3 relocate-once.py
在 Google Colab 中安裝 SageMath

一切準備就緒!

現在讓我們運行SageMath命令:

!./sage -sh
在 Google Colab 中安裝 SageMath

讓我們運行版本檢查命令:

sage -v
在 Google Colab 中安裝 SageMath

好的!

我們有一個新版本: SageMath version 9.3, Release Date: 2021-05-09


實現Twist Attack算法,下載  Python-script:discrete.py

wget https://raw.githubusercontent.com/demining/CryptoDeepTools/bbd83042e7405508cd2e646ad1b0819da0f9c58d/18TwistAttack/discrete.py

在 Google Colab 中安裝 SageMath

要求解離散對數, (Pollard's rho algorithm for logarithms) 請運行 Python-script:discrete.py

現在,要獲取私鑰,我們只需要運行命令:

python3 discrete.py
在 Google Colab 中安裝 SageMath

Sage Math 9.3 求解離散對數問題 (Pollard's rho algorithm for logarithms)


現在一切正常!

我們收到了十進制格式的比特幣錢包私鑰,然後我們需要按照專門針對 Twist 攻擊的文章的說明進行密碼分析


來源

電報:https://t.me/cryptodeeptech

視頻素材:https://youtu.be/DBu0UnVe0ig

來源:https://cryptodeep.ru/install-sagemath-in-google-colab


在 Google Colab 中安裝 SageMath

 密碼分析

Crypto Deep Tech