Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
cellframe-sdk
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Code
Merge requests
17
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cellframe
cellframe-sdk
Commits
1095933d
Commit
1095933d
authored
3 years ago
by
Dmitrii
Browse files
Options
Downloads
Patches
Plain Diff
[+] add signer functionality
parent
0fb94a4a
No related branches found
No related tags found
2 merge requests
!432
Feature 5220
,
!431
Feature 5220
Pipeline
#10387
passed with stage
in 6 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
modules/net/dap_chain_node_cli.c
+2
-2
2 additions, 2 deletions
modules/net/dap_chain_node_cli.c
modules/net/dap_chain_node_cli_cmd.c
+46
-62
46 additions, 62 deletions
modules/net/dap_chain_node_cli_cmd.c
with
48 additions
and
64 deletions
modules/net/dap_chain_node_cli.c
+
2
−
2
View file @
1095933d
...
@@ -929,8 +929,8 @@ int dap_chain_node_cli_init(dap_config_t * g_config)
...
@@ -929,8 +929,8 @@ int dap_chain_node_cli_init(dap_config_t * g_config)
// "global_db wallet_info set -addr <wallet address> -cell <cell id> \n\n"
// "global_db wallet_info set -addr <wallet address> -cell <cell id> \n\n"
);
);
dap_chain_node_cli_cmd_item_create
(
"mempool"
,
com_signer
,
"Sign operations"
,
dap_chain_node_cli_cmd_item_create
(
"mempool"
,
com_signer
,
"Sign operations"
,
"mempool sign -net <net name> -chain <chain name> -file <filename> [-mime <(SIGNER_FILENAME,SIGNER_FILENAME_SHORT,SIGNER_FILESIZE,SIGNER_DATE,SIGNER_MIME_MAGIC) or (SIGNER_ALL_FLAGS)>]
\n
"
"mempool sign
-cert <cert name>
-net <net name> -chain <chain name> -file <filename> [-mime <(SIGNER_FILENAME,SIGNER_FILENAME_SHORT,SIGNER_FILESIZE,SIGNER_DATE,SIGNER_MIME_MAGIC) or (SIGNER_ALL_FLAGS)>]
\n
"
"mempool check -net <net name> ((-file <filename>) or (-hash <hash>)) [-mime <(SIGNER_FILENAME,SIGNER_FILENAME_SHORT,SIGNER_FILESIZE,SIGNER_DATE,SIGNER_MIME_MAGIC) or (SIGNER_ALL_FLAGS)>]
\n
"
"mempool check
-cert <cert name>
-net <net name> ((-file <filename>) or (-hash <hash>)) [-mime <(SIGNER_FILENAME,SIGNER_FILENAME_SHORT,SIGNER_FILESIZE,SIGNER_DATE,SIGNER_MIME_MAGIC) or (SIGNER_ALL_FLAGS)>]
\n
"
);
);
dap_chain_node_cli_cmd_item_create
(
"node"
,
com_node
,
"Work with node"
,
dap_chain_node_cli_cmd_item_create
(
"node"
,
com_node
,
"Work with node"
,
"node add -net <net name> -addr {<node address> | -alias <node alias>} {-port <port>} -cell <cell id> {-ipv4 <ipv4 external address> | -ipv6 <ipv6 external address>}
\n\n
"
"node add -net <net name> -addr {<node address> | -alias <node alias>} {-port <port>} -cell <cell id> {-ipv4 <ipv4 external address> | -ipv6 <ipv6 external address>}
\n\n
"
...
...
This diff is collapsed.
Click to expand it.
modules/net/dap_chain_node_cli_cmd.c
+
46
−
62
View file @
1095933d
...
@@ -4449,6 +4449,7 @@ static int s_get_key_from_file(const char *a_file, const char *a_mime, const cha
...
@@ -4449,6 +4449,7 @@ static int s_get_key_from_file(const char *a_file, const char *a_mime, const cha
static
int
s_check_cmd
(
int
a_arg_index
,
int
a_argc
,
char
**
a_argv
,
char
**
a_str_reply
)
static
int
s_check_cmd
(
int
a_arg_index
,
int
a_argc
,
char
**
a_argv
,
char
**
a_str_reply
)
{
{
int
l_ret
=
0
;
int
l_ret
=
0
;
enum
{
OPT_FILE
,
OPT_HASH
,
OPT_NET
,
OPT_MIME
,
OPT_CERT
,
enum
{
OPT_FILE
,
OPT_HASH
,
OPT_NET
,
OPT_MIME
,
OPT_CERT
,
OPT_COUNT
};
OPT_COUNT
};
struct
opts
l_opts_check
[]
=
{
struct
opts
l_opts_check
[]
=
{
...
@@ -4487,6 +4488,7 @@ static int s_check_cmd(int a_arg_index, int a_argc, char **a_argv, char **a_str_
...
@@ -4487,6 +4488,7 @@ static int s_check_cmd(int a_arg_index, int a_argc, char **a_argv, char **a_str_
dap_chain_node_cli_set_reply_text
(
a_str_reply
,
"Not found datum signer in network %s"
,
l_str_opts_check
[
OPT_NET
]);
dap_chain_node_cli_set_reply_text
(
a_str_reply
,
"Not found datum signer in network %s"
,
l_str_opts_check
[
OPT_NET
]);
return
-
1
;
return
-
1
;
}
}
int
found
=
0
;
dap_sign_t
*
l_sign
=
NULL
;
dap_sign_t
*
l_sign
=
NULL
;
dap_chain_datum_t
*
l_datum
=
NULL
;
dap_chain_datum_t
*
l_datum
=
NULL
;
...
@@ -4495,73 +4497,64 @@ static int s_check_cmd(int a_arg_index, int a_argc, char **a_argv, char **a_str_
...
@@ -4495,73 +4497,64 @@ static int s_check_cmd(int a_arg_index, int a_argc, char **a_argv, char **a_str_
l_gdb_group
=
dap_chain_net_get_gdb_group_mempool
(
l_chain
);
l_gdb_group
=
dap_chain_net_get_gdb_group_mempool
(
l_chain
);
if
(
!
l_gdb_group
)
{
if
(
!
l_gdb_group
)
{
dap_chain_node_cli_set_reply_text
(
a_str_reply
,
"Not found network group for chain: %s"
,
l_chain
->
name
);
l_ret
=
-
1
;
l_ret
=
-
1
;
goto
end
;
goto
end
;
}
}
printf
(
"....%p
\n
"
,
l_
c
ha
in
->
cells
)
;
dap_chain_hash_fast_t
l_ha
sh_tmp
;
if
(
l_str_opts_check
[
OPT_HASH
])
{
if
(
l_str_opts_check
[
OPT_HASH
])
{
#if 0
dap_chain_hash_fast_from_str
(
l_str_opts_check
[
OPT_HASH
],
&
l_hash_tmp
);
size_t l_size_store_datum = 0;
dap_store_obj_t *l_store_datum = dap_chain_global_db_obj_gr_get(l_str_opts_check[OPT_HASH], &l_size_store_datum, l_gdb_group);
dap_chain_node_cli_set_reply_text(a_str_reply, "%s datum by hash: %s",
l_size_store_datum ? "found" : "not found",
l_str_opts_check[OPT_HASH]);
#endif
}
}
if
(
l_str_opts_check
[
OPT_FILE
])
{
if
(
l_str_opts_check
[
OPT_FILE
])
{
l_ret
=
s_get_key_from_file
(
l_str_opts_check
[
OPT_FILE
],
l_str_opts_check
[
OPT_MIME
],
l_str_opts_check
[
OPT_CERT
],
&
l_sign
);
l_ret
=
s_get_key_from_file
(
l_str_opts_check
[
OPT_FILE
],
l_str_opts_check
[
OPT_MIME
],
l_str_opts_check
[
OPT_CERT
],
&
l_sign
);
if
(
!
l_ret
)
{
if
(
!
l_ret
)
{
l_ret
=
-
1
;
l_ret
=
-
1
;
goto
end
;
goto
end
;
}
}
#if 0
dap_chain_hash_fast_t l_key_hash;
l_datum
=
dap_chain_datum_create
(
DAP_CHAIN_DATUM_SIGNER
,
l_sign
->
pkey_n_sign
,
l_sign
->
header
.
sign_size
);
dap_hash_fast(l_sign->pkey_n_sign, l_sign->header.sign_size, &l_key_hash);
if
(
!
l_datum
)
{
char *l_key_str = dap_chain_hash_fast_to_str_new(&l_key_hash);
dap_chain_node_cli_set_reply_text
(
a_str_reply
,
"not created datum"
);
if (l_key_str) {
l_ret
=
-
1
;
size_t l_size_store_datum = 0;
goto
end
;
dap_store_obj_t *l_store_datum = dap_chain_global_db_obj_gr_get(l_key_str, &l_size_store_datum, l_gdb_group);
dap_chain_node_cli_set_reply_text(a_str_reply, "%s datum by file: %s",
l_size_store_datum ? "found" : "not found",
l_str_opts_check[OPT_FILE]);
DAP_FREE(l_key_str);
}
}
#endif
#if 0
dap_chain_cell_id_t l_cell_id = {0};
dap_chain_atom_iter_t *l_iter = NULL;
for (uint64_t i = 0; i >= 0; i++) {
l_iter = l_chain->callback_atom_iter_create(l_chain, l_cell_id);
if (l_iter) {
size_t l_size = 0;
dap_chain_datum_t *l_datum = l_chain->callback_atom_iter_get_next(l_iter, &l_size);
if (l_datum) {
printf("l_size: %ld\n", l_size);
for (size_t i = 0; i < l_size; i++) {
dap_hash_fast_t l_hash;
dap_chain_hash_fast_from_str(l_datum[i].data, &l_hash);
char *l_key = dap_hash_fast_to_str_new(&l_hash);
printf("key: %s\n", l_key);
}
dap_hash_fast
(
l_datum
->
data
,
l_datum
->
header
.
data_size
,
&
l_hash_tmp
);
}
}
} else break;
dap_chain_cell_id_t
l_cell_id
=
{
0
};
l_cell_id.uint64++;
dap_chain_atom_iter_t
*
l_iter
=
NULL
;
dap_chain_cell_t
*
l_cell_tmp
=
NULL
;
dap_chain_cell_t
*
l_cell
=
NULL
;
dap_chain_datum_t
*
l_datum_tmp
=
NULL
;
size_t
l_size
=
0
;
HASH_ITER
(
hh
,
l_chain
->
cells
,
l_cell
,
l_cell_tmp
)
{
l_iter
=
l_cell
->
chain
->
callback_atom_iter_create
(
l_cell
->
chain
,
l_cell
->
id
);
dap_chain_datum_t
*
l_datum
=
l_cell
->
chain
->
callback_atom_find_by_hash
(
l_iter
,
&
l_hash_tmp
,
&
l_size
);
if
(
l_datum
)
{
dap_hash_fast_t
l_hash
;
dap_hash_fast
(
l_datum
->
data
,
l_datum
->
header
.
data_size
,
&
l_hash
);
if
(
!
memcmp
(
l_hash_tmp
.
raw
,
l_hash
.
raw
,
DAP_CHAIN_HASH_FAST_SIZE
))
{
dap_chain_node_cli_set_reply_text
(
a_str_reply
,
"found!"
);
found
=
1
;
break
;
}
}
}
#endif
}
}
end:
end:
if
(
l_gdb_group
)
DAP_FREE
(
l_gdb_group
);
if
(
l_gdb_group
)
DAP_FREE
(
l_gdb_group
);
if
(
!
found
)
{
dap_chain_node_cli_set_reply_text
(
a_str_reply
,
"not found!"
);
}
return
0
;
return
0
;
}
}
...
@@ -4661,7 +4654,6 @@ static int s_signer_cmd(int a_arg_index, int a_argc, char **a_argv, char **a_str
...
@@ -4661,7 +4654,6 @@ static int s_signer_cmd(int a_arg_index, int a_argc, char **a_argv, char **a_str
dap_chain_datum_t
*
l_datum
=
NULL
;
dap_chain_datum_t
*
l_datum
=
NULL
;
dap_global_db_obj_t
*
l_objs
=
NULL
;
dap_global_db_obj_t
*
l_objs
=
NULL
;
printf
(
"#
\n
"
);
l_ret
=
s_get_key_from_file
(
l_opts_sign
[
OPT_FILE
],
l_opts_sign
[
OPT_MIME
],
l_opts_sign
[
OPT_CERT
],
&
l_sign
);
l_ret
=
s_get_key_from_file
(
l_opts_sign
[
OPT_FILE
],
l_opts_sign
[
OPT_MIME
],
l_opts_sign
[
OPT_CERT
],
&
l_sign
);
if
(
!
l_ret
)
{
if
(
!
l_ret
)
{
dap_chain_node_cli_set_reply_text
(
a_str_reply
,
"%s cert not found"
,
l_opts_sign
[
OPT_CERT
]);
dap_chain_node_cli_set_reply_text
(
a_str_reply
,
"%s cert not found"
,
l_opts_sign
[
OPT_CERT
]);
...
@@ -4670,7 +4662,6 @@ static int s_signer_cmd(int a_arg_index, int a_argc, char **a_argv, char **a_str
...
@@ -4670,7 +4662,6 @@ static int s_signer_cmd(int a_arg_index, int a_argc, char **a_argv, char **a_str
}
}
printf
(
"##
\n
"
);
l_datum
=
dap_chain_datum_create
(
DAP_CHAIN_DATUM_SIGNER
,
l_sign
->
pkey_n_sign
,
l_sign
->
header
.
sign_size
);
l_datum
=
dap_chain_datum_create
(
DAP_CHAIN_DATUM_SIGNER
,
l_sign
->
pkey_n_sign
,
l_sign
->
header
.
sign_size
);
if
(
!
l_datum
)
{
if
(
!
l_datum
)
{
...
@@ -4679,24 +4670,16 @@ static int s_signer_cmd(int a_arg_index, int a_argc, char **a_argv, char **a_str
...
@@ -4679,24 +4670,16 @@ static int s_signer_cmd(int a_arg_index, int a_argc, char **a_argv, char **a_str
goto
end
;
goto
end
;
}
}
printf
(
"###
\n
"
);
#if 0
char *l_hash_str = dap_chain_mempool_datum_add(l_datum, l_chain);
dap_chain_node_cli_set_reply_text(a_str_reply, "%s by certificate is signed %s", l_opts_sign[OPT_FILE],
l_hash_str ? "successfull": "not successfull");
if (l_hash_str) {
l_ret = 0;
DAP_FREE(l_hash_str);
}
printf("####\n");
#endif
dap_chain_cell_id_t
l_cell_id
=
{
0
};
dap_chain_cell_id_t
l_cell_id
=
{
0
};
dap_chain_cell_create_fill
(
l_chain
,
l_cell_id
);
dap_chain_cell_create_fill
(
l_chain
,
l_cell_id
);
l_ret
=
l_chain
->
callback_add_datums
(
l_chain
,
&
l_datum
,
1
);
l_ret
=
l_chain
->
callback_add_datums
(
l_chain
,
&
l_datum
,
1
);
printf
(
"l_ret datum: %d
\n
"
,
l_ret
);
dap_hash_fast_t
l_hash
;
dap_hash_fast
(
l_datum
->
data
,
l_datum
->
header
.
data_size
,
&
l_hash
);
char
*
l_key_str
=
dap_chain_hash_fast_to_str_new
(
&
l_hash
);
dap_chain_node_cli_set_reply_text
(
a_str_reply
,
"hash: %s"
,
l_key_str
);
DAP_FREE
(
l_key_str
);
end:
end:
if
(
l_datum
)
DAP_FREE
(
l_datum
);
if
(
l_datum
)
DAP_FREE
(
l_datum
);
...
@@ -4823,15 +4806,14 @@ static byte_t *s_concat_meta (dap_list_t *a_meta, int a_index_meta, size_t *a_fu
...
@@ -4823,15 +4806,14 @@ static byte_t *s_concat_meta (dap_list_t *a_meta, int a_index_meta, size_t *a_fu
for
(
dap_list_t
*
l_iter
=
dap_list_first
(
a_meta
);
l_iter
;
l_iter
=
l_iter
->
next
){
for
(
dap_list_t
*
l_iter
=
dap_list_first
(
a_meta
);
l_iter
;
l_iter
=
l_iter
->
next
){
if
(
!
l_iter
->
data
)
continue
;
if
(
!
l_iter
->
data
)
continue
;
dap_tsd_t
*
l_tsd
=
(
dap_tsd_t
*
)
l_iter
->
data
;
dap_tsd_t
*
l_tsd
=
(
dap_tsd_t
*
)
l_iter
->
data
;
size_t
l_tsd_size
=
dap_tsd_size
(
l_tsd
);
l_index
=
l_counter
;
l_index
=
l_counter
;
l_counter
+=
l_tsd_size
;
l_counter
+=
strlen
(
l_tsd
->
data
)
;
if
(
l_counter
>=
l_part_power
)
{
if
(
l_counter
>=
l_part_power
)
{
l_part_power
=
l_part
*
l_power
++
;
l_part_power
=
l_part
*
l_power
++
;
l_buf
=
(
byte_t
*
)
DAP_REALLOC
(
l_buf
,
l_part_power
);
l_buf
=
(
byte_t
*
)
DAP_REALLOC
(
l_buf
,
l_part_power
);
}
}
memcpy
(
&
l_buf
[
l_index
],
l_tsd
->
data
,
l_tsd_size
);
memcpy
(
&
l_buf
[
l_index
],
l_tsd
->
data
,
strlen
(
l_tsd
->
data
)
);
}
}
if
(
a_fullsize
)
if
(
a_fullsize
)
...
@@ -4890,7 +4872,9 @@ static dap_tsd_t *s_alloc_metadata (const char *a_file, const int a_meta)
...
@@ -4890,7 +4872,9 @@ static dap_tsd_t *s_alloc_metadata (const char *a_file, const int a_meta)
{
{
struct
stat
l_st
;
struct
stat
l_st
;
stat
(
a_file
,
&
l_st
);
stat
(
a_file
,
&
l_st
);
return
dap_tsd_create_scalar
(
SIGNER_FILESIZE
,
l_st
.
st_size
);
char
l_size
[
513
];
snprintf
(
l_size
,
513
,
"%ld"
,
l_st
.
st_size
);
return
dap_tsd_create_string
(
SIGNER_FILESIZE
,
l_size
);
}
}
break
;
break
;
case
SIGNER_DATE
:
case
SIGNER_DATE
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment