-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrequest.py
95 lines (76 loc) · 3.27 KB
/
request.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
"""
Filename: request.py
Author: Ziyu Ye
User will only need his user id, info id, the algorithm used of KEM,
and ciphertext_abs, along with the transaction details (e.g., value)
to make the transaction. The private key will never be transmitted.
"""
import qure
import argparse
# ############################################
# Preparation
# ############################################
# ===========================================
# 0.0. Parameters
# ===========================================
# Initialize the parser
parser = argparse.ArgumentParser()
# Argument for user id
parser.add_argument('-u', '--user_id', type=str,
default='leviathan',
help='Your user id in SeQure.')
# Argument for info id
parser.add_argument('-i', '--key_id', type=str,
default='0',
help='Your info id for this key in SeQure.')
# Argument for ciphertext
parser.add_argument('-ca', '--ciphertext_abs', type=str,
default='7f9da539c7ca9cbab104cb2a76d93be0',
help='The corresponding ciphertext for this info.')
# Argument for url
parser.add_argument('-url', '--url', type=str,
default='https://eth-goerli.g.alchemy.com/v2/fss_yq1JH8COJapGjbQCuaCD77JrjQRp',
help='The url used to connect to web3.')
parser.add_argument('-ci', '--chain_id', type=int,
default=5,
help='See docs.alchemy.com/docs/how-to-add-alchemy-rpc-endpoints-to-metamask#step-4-fill-in-the-network-details')
# Argument for account address
parser.add_argument('-af', '--account_from', type=str,
default='0xA5b372E60a60A70f2c6ACB87710eba30Ecc4D479',
help='The account of the payer.')
parser.add_argument('-at', '--account_to', type=str,
default='0xA059250F4b97bbB3C081f6D9e1fC7249c6Ea2A0c',
help='The account of the receiver.')
# Argument for the value in this transaction
parser.add_argument('-v', '--value', type=float,
default=0.0001,
help='The value used in transaction')
# Below can be omitted
parser.add_argument('-g', '--gas', type=int,
default=21000,
help='The gas used in transaction')
parser.add_argument('-gp', '--gas_price', type=int,
default=200000000,
help='The gas price used in transaction')
# Argument for the root of the database
parser.add_argument('-r', '--root', type=str,
default='./database',
help='The root of the database.')
# Parse the arguments
p = parser.parse_args()
# ######################################################################
# 1. PQC Transaction
# ######################################################################
if __name__ == '__main__':
# Call package to encrypt and save info
qure.safe_transaction(p.user_id,
p.key_id,
p.ciphertext_abs,
p.account_from,
p.account_to,
p.value,
p.url,
p.chain_id,
p.gas,
p.gas_price,
p.root)