Skip to content

Instantly share code, notes, and snippets.

View rimrakhimov's full-sized avatar

Rim Rakhimov rimrakhimov

  • Blockscout Technologies
  • Abu Dhabi, UAE
View GitHub Profile
@rimrakhimov
rimrakhimov / ecdh_lab4.py
Last active November 2, 2020 12:22
ECDH algorithm for lab4. Requires to install tinyec library by: `pip3 install tinyec`
import tinyec.registry as reg
import random
def generates_secret_keys(curve):
priv_key = random.randint(0, curve.field.n)
pub_key = priv_key * curve.g
return (priv_key, pub_key)
def get_shared_key(priv_key_a, pub_key_b):
@rimrakhimov
rimrakhimov / cit-HepTh.txt
Created April 26, 2020 18:14
High-energy physics theory citation network dataset, taken from https://snap.stanford.edu/data/cit-HepTh.html
This file has been truncated, but you can view the full file.
# Directed graph (each unordered pair of nodes is saved once): Cit-HepTh.txt
# Paper citation network of Arxiv High Energy Physics Theory category
# Nodes: 27770 Edges: 352807
# FromNodeId ToNodeId
1001 9304045
1001 9308122
1001 9309097
1001 9311042
1001 9401139
1001 9404151
@rimrakhimov
rimrakhimov / vector-clock.py
Created October 25, 2019 19:35
Vector Clock Algorithm
# The main part was taken from https://towardsdatascience.com/understanding-lamport-timestamps-with-pythons-multiprocessing-library-12a6427881c6
from multiprocessing import Process, Pipe
from datetime import datetime
def local_time(counter):
return ' (LOGICAL_TIME={}, LOCAL_TIME={})'.format(counter, datetime.now())
def calc_recv_timestamp(recv_time_stamp, counter):
for id in range(len(counter)):
@rimrakhimov
rimrakhimov / send_file.py
Last active October 2, 2019 20:58
Client and server scripts for uploading files to the server. Distributed systems course, lab 6
#! /usr/bin/python3
import os, sys, socket
class Sender:
def __init__(self, path, file_name, ip_addr, port):
self.path = path
self.file_name = file_name
self.ip_addr = ip_addr
self.port = port
@rimrakhimov
rimrakhimov / hill-cipher.py
Created September 27, 2019 20:50
The script for encryption and decryption of text using 2x2 Hill cipher
#!/usr/bin/python3
class HillCipher:
def __init__(self, degree=2):
assert (degree == 2), "only 2 degree cipher is supported for now" # for now only 2x2 Hill ciphers are supported
self._modular_base = 26
self._degree = degree
def encrypt(self, plaintext, key):
degree = self.degree()
@rimrakhimov
rimrakhimov / Bridge.sol
Created July 16, 2018 23:05
Contracts of bridge for module 3
pragma solidity ^0.4.24;
contract ERC721 {
function getSerializedData(string _tokenId) public returns (bytes);
function demolishToken(string _tokenVIN) public;
function recoveryToken(address _owner, string _tokenVIN, bytes _serializedData) public;
}
@rimrakhimov
rimrakhimov / Bridge.sol
Created July 15, 2018 23:50
Bridges for ERC721
pragma solidity ^0.4.24;
contract ERC721 {
function getSerializedData(string _tokenId) public returns (bytes);
function demolishToken(string _tokenVIN) public;
function recoveryToken(address _owner, string _tokenVIN, bytes _serializedData) public;
}