Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
libdap-chain-net-srv
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
cellframe
libdap-chain-net-srv
Commits
53ca750d
Commit
53ca750d
authored
5 years ago
by
Dmitriy A. Gerasimov
Browse files
Options
Downloads
Patches
Plain Diff
[-] Removed useless stuff
parent
17a058bf
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
CMakeLists.txt
+0
-2
0 additions, 2 deletions
CMakeLists.txt
dap_chain_net_srv_common.c
+0
-1
0 additions, 1 deletion
dap_chain_net_srv_common.c
dap_chain_net_srv_key.c
+0
-164
0 additions, 164 deletions
dap_chain_net_srv_key.c
dap_chain_net_srv_key.h
+0
-40
0 additions, 40 deletions
dap_chain_net_srv_key.h
with
0 additions
and
207 deletions
CMakeLists.txt
+
0
−
2
View file @
53ca750d
...
...
@@ -4,7 +4,6 @@ project (dap_chain_net_srv)
set
(
DAP_CHAIN_NET_SRV_SRCS
dap_chain_net_srv.c
dap_chain_net_srv_order.c
dap_chain_net_srv_key.c
dap_chain_net_srv_client.c
dap_chain_net_srv_common.c
dap_chain_net_srv_stream_session.c
...
...
@@ -14,7 +13,6 @@ set(DAP_CHAIN_NET_SRV_HEADERS
dap_chain_net_srv.h
dap_chain_net_srv_client.h
dap_chain_net_srv_order.h
dap_chain_net_srv_key.h
dap_chain_net_srv_common.h
dap_chain_net_srv_stream_session.h
)
...
...
This diff is collapsed.
Click to expand it.
dap_chain_net_srv_common.c
+
0
−
1
View file @
53ca750d
...
...
@@ -44,6 +44,5 @@
#include
"rand/dap_rand.h"
#include
"dap_chain_datum_tx_items.h"
#include
"dap_stream.h"
#include
"dap_chain_net_srv_key.h"
#include
"dap_chain_net_srv_common.h"
This diff is collapsed.
Click to expand it.
dap_chain_net_srv_key.c
deleted
100644 → 0
+
0
−
164
View file @
17a058bf
/*
* Authors:
* Dmitriy A. Gearasimov <gerasimov.dmitriy@demlabs.net>
* Aleksandr Lysikov <alexander.lysikov@demlabs.net>
* CellFrame https://cellframe.net
* DeM Labs Inc. https://demlabs.net
* Copyright (c) 2017-2019
* All rights reserved.
This file is part of DAP (Deus Applications Prototypes) the open source project
DAP (Deus Applicaions Prototypes) is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
DAP is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with any DAP based project. If not, see <http://www.gnu.org/licenses/>.
*/
#include
<string.h>
#include
<stddef.h>
#include
<dap_common.h>
#include
"dap_config.h"
#include
"dap_enc_key.h"
#include
"dap_strfuncs.h"
#include
"dap_hash.h"
#include
"dap_chain_common.h"
#include
"dap_sign.h"
#include
"dap_chain_wallet.h"
#include
"dap_chain_net_srv_key.h"
#define LOG_TAG "dap_chain_net_srv_key"
/**
* Parse a_service_key from service client
* a_addr_base58[out] - address
* a_sign_hash[out] - hash of sign
*/
bool
dap_chain_net_srv_key_parse
(
const
char
*
a_service_key
,
char
**
a_addr_base58
,
char
**
a_sign_hash
)
{
bool
l_ret
=
false
;
// format a_service_key = "a_addr_base58;a_sign_hash"
if
(
!
a_service_key
)
return
false
;
char
**
l_str
=
dap_strsplit
(
a_service_key
,
";"
,
-
1
);
if
(
dap_str_countv
(
l_str
)
==
2
)
{
if
(
a_addr_base58
)
*
a_addr_base58
=
strdup
(
l_str
[
0
]);
if
(
a_sign_hash
)
*
a_sign_hash
=
strdup
(
l_str
[
1
]);
l_ret
=
true
;
}
dap_strfreev
(
l_str
);
return
l_ret
;
}
/**
* Create new service_key
*/
char
*
dap_chain_net_srv_key_create
(
const
char
*
a_wallet_name
)
{
char
*
l_addr_base58
=
NULL
;
char
*
l_sign_hash_str
=
dap_chain_net_srv_key_create_hash
(
a_wallet_name
,
&
l_addr_base58
);
char
*
l_ret_str
=
NULL
;
if
(
l_sign_hash_str
&&
l_addr_base58
)
{
l_ret_str
=
dap_strdup_printf
(
"%s;%s"
,
l_addr_base58
,
l_sign_hash_str
);
}
DAP_DELETE
(
l_addr_base58
);
DAP_DELETE
(
l_sign_hash_str
);
return
l_ret_str
;
}
/**
* Create new key hash
*/
char
*
dap_chain_net_srv_key_create_hash
(
const
char
*
a_wallet_name
,
char
**
a_addr_base58
)
{
const
char
*
c_wallets_path
=
dap_config_get_item_str
(
g_config
,
"general"
,
"wallets_path"
);
dap_chain_wallet_t
*
l_wallet
=
dap_chain_wallet_open
(
a_wallet_name
,
c_wallets_path
);
if
(
!
l_wallet
)
return
NULL
;
dap_enc_key_t
*
l_key
=
dap_chain_wallet_get_key
(
l_wallet
,
0
);
const
dap_chain_addr_t
*
l_addr
=
NULL
;
// TODO: make work with chain network // dap_chain_wallet_get_addr(l_wallet);
char
*
l_addr_base58
=
dap_chain_addr_to_str
(
l_addr
);
if
(
!
l_addr_base58
)
return
NULL
;
// make signature
const
void
*
l_data
=
l_addr_base58
;
const
size_t
l_data_size
=
strlen
(
l_data
);
dap_sign_t
*
l_chain_sign
=
dap_sign_create
(
l_key
,
l_data
,
l_data_size
,
0
);
size_t
l_chain_sign_size
=
dap_sign_get_size
(
l_chain_sign
);
dap_chain_wallet_close
(
l_wallet
);
if
(
a_addr_base58
)
*
a_addr_base58
=
l_addr_base58
;
else
DAP_DELETE
(
l_addr_base58
);
// make dap_sign_t hash
dap_chain_hash_fast_t
l_sign_hash
;
if
(
!
dap_hash_fast
(
l_chain_sign
,
l_chain_sign_size
,
&
l_sign_hash
)
)
{
return
NULL
;
}
// hash to str
const
size_t
cl_str_ret_size
=
sizeof
(
dap_chain_hash_fast_t
)
*
2
+
1
;
char
*
l_str_ret
=
DAP_NEW_Z_SIZE
(
char
,
sizeof
(
dap_chain_hash_fast_t
)
*
2
+
1
);
dap_chain_hash_fast_to_str
(
&
l_sign_hash
,
l_str_ret
,
cl_str_ret_size
);
return
l_str_ret
;
}
/**
* Checking service_key from service client
*/
bool
dap_chain_net_srv_key_check
(
char
*
a_addr_base58
,
const
char
*
a_sign_hash_str
)
{
//exist_user_in_db("da");
if
(
!
a_addr_base58
||
!
a_sign_hash_str
)
return
false
;
/* // create l_chain_sign for check a_sign
dap_sign_t *l_chain_sign = DAP_NEW_Z_SIZE(dap_sign_t,
sizeof(dap_sign_t) + a_sign_size + l_pkey_size);
l_chain_sign->header.type = l_sig_type;
l_chain_sign->header.sign_size = l_pkey_size;
l_chain_sign->header.sign_pkey_size = l_pkey_size;
// write serialized public key to dap_sign_t
memcpy(l_chain_sign->pkey_n_sign, l_pkey, l_pkey_size);
// write serialized signature to dap_sign_t
memcpy(l_chain_sign->pkey_n_sign + l_pkey_size, a_sign, a_sign_size);
// check signature
if(dap_sign_verify(l_chain_sign, a_sign, a_sign_size) != 1) {
// invalid signature
return 0;
}*/
// TODO add find l_wallet_name by a_addr_base58
const
char
*
l_wallet_name
=
"w_picnic"
;
// Create new hash
char
*
l_sign_hash_str
=
dap_chain_net_srv_key_create_hash
(
l_wallet_name
,
NULL
);
size_t
l_sign_hash_str_len
=
(
l_sign_hash_str
)
?
strlen
(
l_sign_hash_str
)
:
0
;
// compare l_sign_hash_str and a_sign_hash_str
if
(
!
l_sign_hash_str_len
||
l_sign_hash_str_len
!=
strlen
(
a_sign_hash_str
))
{
return
false
;
}
if
(
memcmp
(
l_sign_hash_str
,
a_sign_hash_str
,
l_sign_hash_str_len
))
{
return
false
;
}
return
true
;
}
This diff is collapsed.
Click to expand it.
dap_chain_net_srv_key.h
deleted
100644 → 0
+
0
−
40
View file @
17a058bf
/*
* Authors:
* Dmitriy A. Gearasimov <gerasimov.dmitriy@demlabs.net>
* Aleksandr Lysikov <alexander.lysikov@demlabs.net>
* CellFrame https://cellframe.net
* DeM Labs Inc. https://demlabs.net
* Copyright (c) 2017-2019
* All rights reserved.
This file is part of DAP (Deus Applications Prototypes) the open source project
DAP (Deus Applicaions Prototypes) is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
DAP is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with any DAP based project. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include
<stdint.h>
#include
<stdbool.h>
// Parse a_service_key from service client
bool
dap_chain_net_srv_key_parse
(
const
char
*
a_service_key
,
char
**
a_addr_base58
,
char
**
a_sign_hash
);
// Create new service_key
char
*
dap_chain_net_srv_key_create
(
const
char
*
a_wallet_name
);
// Create new key hash
char
*
dap_chain_net_srv_key_create_hash
(
const
char
*
a_wallet_name
,
char
**
a_addr_base58
);
// Checking service_key from service client
bool
dap_chain_net_srv_key_check
(
char
*
a_addr_base58
,
const
char
*
a_sign_hash_str
);
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