ECC

ECC

ECC intro video

ECC video

In order to understand hex and type parameters read HASH

ECIES

spec

Description: Public-key cryptosystem

Problem: Discrete logarithm problem

Uses: Encrypt

  • It only supports "type":"string"

ECDSA

spec

Description: Public-key cryptosystem

Problem: Discrete logarithm problem

Uses: Digital signatures

  • It only supports "type":"string"

How to ???

import requests
import json
import os,binascii

def sending(message):
    url = 'http://127.0.0.1:6613/'
    response = requests.post(url, data=message)
    print response.content
    return response.content

def ecc_pb(data_js):
    req=json.loads(data_js)
    curve=req["curve"]
    print "Send gen parameters : \n" + data_js +"\n"
    data_js_n=sending(json.dumps(req))
    answ=json.loads(data_js_n)
    print 'Recived  ecc gen: \n'+ json.dumps(answ) +"\n\n\n"
    json_enc='{ "version": 1 , "algorithm":"ECIES", "type":"string","pubkey": "" ,"operation":"enc", "plaintext":"Hello world!" ,"curve":""}'
    req=json.loads(json_enc)
    req["pubkey"]=answ["pubkey"]
    req["curve"]=curve
    print "Send  enc: \n"+(json.dumps(req))+"\n"
    data_js_n=sending(json.dumps(req))
    answ_1=json.loads(data_js_n)
    print "Recived  enc : \n"+(json.dumps(answ_1)) +"\n"
    req["privkey"]=answ["privkey"]
    req["plaintext"]=answ_1["result"]
    req["pubkey"]=""
    req["operation"]="dec"
    data_js_n=sending(json.dumps(req))
    answ_2=json.loads(data_js_n)
    print "Recived  dec done: \n"+(json.dumps(answ_2)) +"\n\n\n"
    json_sign='{ "version": 1 , "algorithm":"ECDSA", "type":"string","plaintext": "Hello world", "hex":0,"privkey": "" ,"operation":"sign"}'
    req=json.loads(json_sign)
    req["privkey"]=answ["privkey"]
    req["curve"]=curve
    data_js_n=sending(json.dumps(req))
    answ_3=json.loads(data_js_n)
    print "Recived  sign done: \n"+(json.dumps(answ_3)) +"\n"
    json_verify='{ "version": 1 , "algorithm":"ECDSA", "type":"string","plaintext": "Hello world", "hex":0,"pubkey": "", "operation":"verify","sign":""}'
    req=json.loads(json_verify)
    req["pubkey"]=answ["pubkey"]
    req["sign"]=answ_3["sign"]
    req["curve"]=curve
    data_js_n=sending(json.dumps(req))
    answ_4=json.loads(data_js_n)
    print "Recived  verify done: \n"+(json.dumps(answ_4)) +"\n\n\n"


ecc_gen='{ "version": 1 , "algorithm":"ECC_GEN", "curve":"secp256k1"}'
ecc_pb(ecc_gen)

In this example we generate a ECC key (secp256k1), sign and validate "Hello world!" string, we enc and dec "Hello world!" string.

On "curve" can be one of {"brainpoolP512r1","secp521r1","brainpoolP384r1","secp384r1","brainpoolP320r1","brainpoolP256r1", "secp256k1","sect571r1","sect571k1","sect409r1","sect409k1","sect283r1","sect283k1"}

The default hash function to sign is sha3256, you can change by adding "hashsign" and can be one of {"sha3_512","sha3_384","sha3_256","sha3_224","sha_512","sha_384","sha_256","sha_224","sha_1","whirlpool"}

Json to gen

{ "version": 1 , "algorithm":"ECC_GEN", "curve":"curve flavor"}

Json to enc

{ "version": 1 , "algorithm":"ECIES", "type":"string", "hex":BOOL,"pubkey": "your hex pubkey",
"operation":"enc", "plaintext":"your string" ,"curve":"curve flavor"}

Json to dec

{ "version": 1 , "algorithm":"ECIES", "type":"string","privkey": "your hex privkey" ,
"operation":"dec", "plaintext":"your hex enc string" ,"curve":"curve flavor"}

Json to sign

{ "version": 1 , "algorithm":"ECDSA", "type":"string","plaintext": "your string", "hex":BOOL,
"privkey": " your hex pirvkey" ,"operation":"sign","curve":"curve flavor"}

Json to verify

{ "version": 1 , "algorithm":"ECDSA", "type":"string","plaintext": "your string", "hex":BOOL,
"pubkey": "your hex pubkey" ,"sign":"your hex signature","operation":"verify","curve":"curve flavor"}

Last updated