Skip to content

Instantly share code, notes, and snippets.

View SaifRehman's full-sized avatar
🎯
Focusing

SaifRehman SaifRehman

🎯
Focusing
  • IBM
  • Dubai
View GitHub Profile
@SaifRehman
SaifRehman / service-deployment.yml
Created April 3, 2018 12:51
service-deployment.yml
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: tendermintnodeone # give any name
spec:
replicas: 1
template:
metadata:
name: tendermintnodeone
labels:
@SaifRehman
SaifRehman / config.ts
Created April 3, 2018 13:06
config.ts
export class config {
public static baseUrl = "http://<appname>.mybluemix.net";
public constructor() {
}
}
@SaifRehman
SaifRehman / frontendNode.ts
Created April 3, 2018 13:21
frontendNode.ts
let app = require('lotion')({
genesis: './genesis.json',
initialState: { messages: [] },
tendermintPort: 46657,
logTendermint: true,
peers: ['ws://159.122.175.154:30092','ws://184.173.1.108:30092']
})
app.use((state, tx) => {
if (typeof tx.sender === 'string' && typeof tx.message === 'string') {
state.messages.push({ sender: tx.sender, message: tx.message })
pragma solidity ^0.4.18;
contract Contract {
function set(string _value) public {
value = _value;
}
function get() public constant returns (string) {
return value;
}
@SaifRehman
SaifRehman / app.js
Created July 14, 2018 00:27
app.js
var Web3 = require('web3')
var web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:5000'))
web3.eth.defaultAccount = web3.eth.accounts[0]
console.log(web3.eth.accounts[0])
var ABI = [
{
"constant": false,
"inputs": [
{
"name": "_value",
@SaifRehman
SaifRehman / params.rb
Created September 22, 2018 19:58
domain paramts
$provePrimeNumber = 2**256 - 2**32 - 2**9 - 2**8 - 2**7 - 2**6 - 2**4 -1
$numberOfPointsInFeild = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141
$xcoordinate = 55066263022277343669578718895168534326250603453777594175500187360389116729240
$ycoordinate = 32670510020758816978083085130507043184471273380659243275938904335757337482424
$privKey = "A665A45920422F9D417E4867EFDC4FB8A04A1F3FFF1FA07E998E86F7F7A27AE3"
$point = Array.new([$xcoordinate,$ycoordinate])
@SaifRehman
SaifRehman / helper.rb
Last active September 22, 2018 20:01
require 'digest'
$m = 2**32
$a = 1103515245
$c = 12345
def dectobin(var)
return var.to_s(2)
end
def modInverse (var,n)
lm = 1
hm = 0
low = var % n
high = n
while low > 1 do
ratio = high/low
nm, enew = hm-lm*ratio, high-low*ratio
lm, low, hm, high = nm, enew, lm, low
end
def SignatureGeneration(genPoint,randomNumber,hashOfThingToSign)
q = EccMultiply(genPoint,randomNumber)
xRandSignPoint = q[0][0]
yRandSignPoint = q[0][1]
r = xRandSignPoint % $numberOfPointsInFeild;
s = ((hashOfThingToSign + (r*hextodec($privKey)))*(modInverse(randomNumber,$numberOfPointsInFeild))) % $numberOfPointsInFeild
return [r,s]
end
def SignatureVerification(s,r,hashOfThingToSign,publicKey)
require 'digest'
$provePrimeNumber = 2**256 - 2**32 - 2**9 - 2**8 - 2**7 - 2**6 - 2**4 -1
$numberOfPointsInFeild = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141
$Acurve = 0
$xcoordinate = 55066263022277343669578718895168534326250603453777594175500187360389116729240
$ycoordinate = 32670510020758816978083085130507043184471273380659243275938904335757337482424
$privKey = "A665A45920422F9D417E4867EFDC4FB8A04A1F3FFF1FA07E998E86F7F7A27AE3"
$point = Array.new([$xcoordinate,$ycoordinate])
def dectobin(var)