Cryptography: ECDSA

Overview "If you can't explain it simply, you don't understand it well enough" Albert Einstein Elliptic curve cryptography (ECC) and digital signature algorithm (ECDSA) are more complex than RSA or ElGamal but I will try my best to hide the hairy math and the implementation details. Here is the ELI5 version in 18 lines of SageMath / Python code. I use Sage because it provides elliptic curves as first-class citizens (`FiniteField` and `EllipticCurve`) and we can take multiplication operation for granted. [Read More]

Cryptography: ElGamal

Overview "If you can't explain it simply, you don't understand it well enough" Albert Einstein ElGamal is a public key cryptosystem that is used in encryption , digital signature and homomorphic cryptography. Here is my take in 12 lines of Python code: 1 p = 7 2 g = [x for x in range(1, p) if len(set([x**i % p for i in range(1, p)])) == p-1][0] 3 k = 4 4 t = g**k % p 5 m = 6 6 import random 7 r = random. [Read More]

Cryptography: RSA

Overview "If you can't explain it simply, you don't understand it well enough" Albert Einstein RSA (Rivest-Shamir-Adleman) needs no introduction, it is well known and most used public-key cryptosystem that governs our digital lives. Here is my take, a simple implementation in 10 lines of Ruby code that is neither the best implementation nor the most efficient one but is enough for the purpose of this article. 1 p = 7 2 q = 11 3 n = p * q 4 phi = (p-1) * (q-1) 5 gcd = ->(a, b) { while(b ! [Read More]

Introducing Cryptos-ruby project

I just want to announce the very first release [v0.0.3] of Cryptos-ruby project, a simple and very easy to use Ruby API to manipulate multiple crypto coins. For more information please check Github project page. Features Generate private/public keys Generate Bitcoin/Litecoin addresses (more to come) Create Bitcoin/Litecoin transactions Execute atomic swaps between Bitcoin and Litecoin Installation gem install cryptos Usage # Importing library... 2.5.1 :001 > require 'cryptos' # Generating private key. [Read More]

Bitcoin: transaction

The hard way - Bitcoin: Transaction This is Part 2 of ‘The hard way - Bitcoin’ series and I will start with ‘the easy way’ section first because even this gets a bit complex, then will continue with the hard stuff, crafting a Bitcoin transaction from scratch using basic math and cryptography. A. The easy way Create private key, public key and address We are going to generate private key, public key and Bitcoin testnet address to be used in this article. [Read More]

Bitcoin: private key, public key, address

The hard way series - Bitcoin: private key, public key, address This article is all about two ways of generating a Bitcoin address: the hard way using simple math and the easy way using an existing Bitcoin library. A. The hard way In this section I am going to use simple math functions like addition and multiplication to generate a valid Bitcoin address starting from a number, the private key and calculating everything all the way up to public key and final Bitcoin address. [Read More]