Coherence
Search…
DSA
In order to understand hex and type parameters read Hash

DSA

spec
Description: Public-key cryptosystem
Problem: Discrete logarithm problem
Uses: Digital signatures
    It only supports "type":"string"

How to ???

1
import requests
2
import json
3
import os,binascii
4
5
def sending(message):
6
url = 'http://127.0.0.1:6613/'
7
response = requests.post(url, data=message)
8
print response.content
9
return response.content
10
11
def dsa(data_js, bits):
12
req=json.loads(data_js)
13
req["length"]=bits
14
print "Send gen parameters : \n " + json.dumps(req) +"\n"
15
data_js_n=sending(json.dumps(req))
16
answ=json.loads(data_js_n)
17
print "Recived dsa gen: \n"+(json.dumps(answ)) +"\n\n\n"
18
json_s=json_v='{ "version": 1 , "algorithm":"DSA", "type":"string","plaintext": "Hello world!", "hex":0,"privkey": "" ,"operation":"sign"}'
19
req=json.loads(json_s)
20
req["privkey"]=answ["privkey"]
21
print "Send sign : \n " + json.dumps(req) +"\n"
22
data_js_n=sending(json.dumps(req))
23
answ_1=json.loads(data_js_n)
24
print "Recived sign done: \n"+(json.dumps(answ_1)) +"\n\n\n"
25
json_v='{ "version": 1 , "algorithm":"DSA", "type":"string","plaintext": "Hello world!", "hex":0,"pubkey": "" ,"sign":"","operation":"verify"}'
26
req=json.loads(json_v)
27
req["pubkey"]=answ["pubkey"]
28
req["sign"]=answ_1["sign"]
29
print "Send verify : \n " + json.dumps(req) +"\n"
30
data_js_n=sending(json.dumps(req))
31
answ_2=json.loads(data_js_n)
32
print "Recived verify done: \n"+(json.dumps(answ_2)) +"\n\n\n"
33
34
35
dsa_gen='{ "version": 1 , "algorithm":"DSA", "operation":"gen", "length": 0 }'
36
dsa(dsa_gen,1024)
Copied!
In this example we generate a DSA key (1024 bits), we sign "Hello world!" and validate it.
Json to generate
1
{"operation": "gen", "version": 1, "length": INT, "algorithm": "DSA"}
Copied!
    Length can be 1024, 2048 and 3072
Json to sign string
1
{"algorithm": "DSA", "plaintext": "your string", "hex": BOOL, "version": 1, "operation": "sign", "type": "string", "privkey": "your private key"}
Copied!
Json to validate string
1
{"algorithm": "DSA", "plaintext": "Hello world", "pubkey": "your hex pubkey", "hex": 0, "sign": "your hex signature", "version": 1, "operation": "verify", "type": "string"}
Copied!
Copy link