From 318ab44e488611abb2f81a5db74966b033825fbc Mon Sep 17 00:00:00 2001 From: Dmitriy Gerasimov <dm@cifercom.com> Date: Mon, 22 Jan 2018 03:58:47 +0700 Subject: [PATCH] [+] public key TX item type, "extra" section in CryptoNote transaction [+] signature TX item type , "Tx suffix" in CryptoNote transaction --- CMakeLists.txt | 2 ++ dap_chain_block_txs.c | 1 + dap_chain_common.h | 1 + dap_chain_section_tx.h | 6 ++++-- dap_chain_section_tx_pkey.h | 42 ++++++++++++++++++++++++++++++++++++ dap_chain_section_tx_sig.h | 43 +++++++++++++++++++++++++++++++++++++ 6 files changed, 93 insertions(+), 2 deletions(-) create mode 100644 dap_chain_section_tx_pkey.h create mode 100644 dap_chain_section_tx_sig.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 630925c807..e26e9fc7e3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,6 +38,8 @@ set(DAP_CHAIN_HEADERS dap_chain_section_tx.h dap_chain_section_tx_in.h dap_chain_section_tx_out.h + dap_chain_section_tx_pkey.h + dap_chain_section_tx_sig.h dap_hash.h dap_hash_fusion.h dap_hash_keccak.h diff --git a/dap_chain_block_txs.c b/dap_chain_block_txs.c index a672942990..eb69d9a7d0 100644 --- a/dap_chain_block_txs.c +++ b/dap_chain_block_txs.c @@ -21,3 +21,4 @@ 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 "dap_chain_block_txs.h" diff --git a/dap_chain_common.h b/dap_chain_common.h index 6cc1da25c3..078a0edd9a 100644 --- a/dap_chain_common.h +++ b/dap_chain_common.h @@ -44,6 +44,7 @@ typedef enum dap_chain_hash_kind { typedef union dap_chain_sig_type{ enum { SIG_TYPE_NEWHOPE = 0x0000, + SIG_TYPE_KEY_IMAGE = 0xf000, /// @brief key image for anonymous transaction SIG_TYPE_MULTI = 0xffff /// @brief Has inside subset of different signatures and sign composed with all of them } type: 16; diff --git a/dap_chain_section_tx.h b/dap_chain_section_tx.h index 9d52a97b98..3e4c27c441 100644 --- a/dap_chain_section_tx.h +++ b/dap_chain_section_tx.h @@ -26,8 +26,10 @@ #include "dap_chain_section.h" typedef enum dap_chain_tx_item_type{ - TX_ITEM_TYPE_IN = 0x00, - TX_ITEM_TYPE_OUT = 0x10, + TX_ITEM_TYPE_IN = 0x00, /// @brief Transaction inputs + TX_ITEM_TYPE_OUT = 0x10, /// @brief Transaction outputs + TX_ITEM_TYPE_PKEY = 0x20, + TX_ITEM_TYPE_SIG = 0x30, } dap_chain_tx_item_type_t; /** diff --git a/dap_chain_section_tx_pkey.h b/dap_chain_section_tx_pkey.h new file mode 100644 index 0000000000..abf7ab628d --- /dev/null +++ b/dap_chain_section_tx_pkey.h @@ -0,0 +1,42 @@ +/* + * Authors: + * Dmitriy A. Gearasimov <kahovski@gmail.com> + * DeM Labs Inc. https://demlabs.net + * DeM Labs Open source community https://github.com/demlabsinc + * Copyright (c) 2017-2018 + * 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 "dap_common.h" +#include "dap_chain_common.h" +#include "dap_chain_section_tx.h" +/** + * @struct dap_chain_tx_pkey + * @brief TX item with one of the transaction's public keys + */ +typedef struct dap_chain_tx_pkey{ + struct { + dap_chain_tx_item_type_t type:8; /// @param type @brief Transaction item type + dap_chain_sig_type_t sig_type; /// Signature type + uint32_t sig_size; /// Signature size + } header; /// Only header's hash is used for verification + uint32_t seq_no; /// Sequence number, out of the header so could be changed during reorganization + uint8_t pkey[]; /// @param sig @brief raw pkey dat +} DAP_ALIGN_PACKED dap_chain_tx_pkey_t; diff --git a/dap_chain_section_tx_sig.h b/dap_chain_section_tx_sig.h new file mode 100644 index 0000000000..cfeb8503f9 --- /dev/null +++ b/dap_chain_section_tx_sig.h @@ -0,0 +1,43 @@ +/* + * Authors: + * Dmitriy A. Gearasimov <kahovski@gmail.com> + * DeM Labs Inc. https://demlabs.net + * DeM Labs Open source community https://github.com/demlabsinc + * Copyright (c) 2017-2018 + * 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 "dap_common.h" +#include "dap_chain_common.h" +#include "dap_chain_section_tx.h" + + +/** + * @struct dap_chain_tx_sig + * @brief Section with set of transaction signatures + */ +typedef struct dap_chain_tx_sig{ + struct { + dap_chain_tx_item_type_t type:8; /// @param type @brief Transaction item type + dap_chain_sig_type_t sig_type; /// Signature type + uint32_t sig_size; /// Signature size + } header; /// Only header's hash is used for verification + uint8_t sig[]; /// @param sig @brief raw signature data +} DAP_ALIGN_PACKED dap_chain_tx_sig_t; -- GitLab