From 26f34edc8314e971ffaadff8ccf0f1bf9bae7834 Mon Sep 17 00:00:00 2001 From: sowle Date: Wed, 13 Jul 2022 04:35:15 +0200 Subject: [PATCH] CLSAG prototypes --- src/common/crypto_serialization.h | 23 ++++++++++++++++++--- src/crypto/clsag.cpp | 19 +++++++++++++++++ src/crypto/clsag.h | 34 +++++++++++++++++++++++++++++++ 3 files changed, 73 insertions(+), 3 deletions(-) create mode 100644 src/crypto/clsag.cpp create mode 100644 src/crypto/clsag.h diff --git a/src/common/crypto_serialization.h b/src/common/crypto_serialization.h index ff244deb..c5fb5f4c 100644 --- a/src/common/crypto_serialization.h +++ b/src/common/crypto_serialization.h @@ -18,6 +18,7 @@ #include "crypto/crypto.h" #include "crypto/hash.h" #include "crypto/range_proofs.h" +#include "crypto/clsag.h" #include "boost_serialization_maps.h" // @@ -26,7 +27,7 @@ namespace crypto { - struct bpp_signature_serialized : public crypto::bpp_signature + struct bpp_signature_serialized : public bpp_signature { BEGIN_SERIALIZE_OBJECT() FIELD(L) @@ -51,7 +52,7 @@ namespace crypto END_BOOST_SERIALIZATION() }; - struct bppe_signature_serialized : public crypto::bppe_signature + struct bppe_signature_serialized : public bppe_signature { BEGIN_SERIALIZE_OBJECT() FIELD(L) @@ -77,7 +78,23 @@ namespace crypto BOOST_SERIALIZE(delta_2) END_BOOST_SERIALIZATION() }; -} + + struct CLSAG_GG_signature_serialized : public CLSAG_GG_signature + { + BEGIN_SERIALIZE_OBJECT() + FIELD(c) + FIELD((std::vector&)(r)) + FIELD(K1) + END_SERIALIZE() + + BEGIN_BOOST_SERIALIZATION() + BOOST_SERIALIZE(c) + BOOST_SERIALIZE((std::vector&)(r)) + BOOST_SERIALIZE(K1) + END_BOOST_SERIALIZATION() + }; + +} // namespace crypto BLOB_SERIALIZER(crypto::chacha8_iv); BLOB_SERIALIZER(crypto::hash); diff --git a/src/crypto/clsag.cpp b/src/crypto/clsag.cpp new file mode 100644 index 00000000..c64d401f --- /dev/null +++ b/src/crypto/clsag.cpp @@ -0,0 +1,19 @@ +// Copyright (c) 2022 Zano Project +// Copyright (c) 2022 sowle (val@zano.org, crypto.sowle@gmail.com) +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// +// This file contains implementation of CLSAG (s.a. https://eprint.iacr.org/2019/654.pdf by Goodel at el) +// +#include "clsag.h" + +namespace crypto +{ + + bool generate_CLSAG_GG(const hash& m, const std::vector& ring, const point_t& pseudo_out_amount_commitment, const key_image& ki, + const scalar_t& secret_x, const scalar_t& secret_f, CLSAG_GG_signature& sig) + { + return false; + } + +} // namespace crypto diff --git a/src/crypto/clsag.h b/src/crypto/clsag.h new file mode 100644 index 00000000..b00dd419 --- /dev/null +++ b/src/crypto/clsag.h @@ -0,0 +1,34 @@ +// Copyright (c) 2022 Zano Project +// Copyright (c) 2022 sowle (val@zano.org, crypto.sowle@gmail.com) +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// +// This file contains implementation of CLSAG (s.a. https://eprint.iacr.org/2019/654.pdf by Goodel at el) +// +#pragma once +#include "crypto-sugar.h" + +namespace crypto +{ + // GG stands for double layers (ring dimentions) both with respect to group element G + struct CLSAG_GG_signature + { + scalar_t c; + scalar_vec_t r; // size = size of the ring + public_key K1; // auxiliary key image for layer 1 + }; + + + struct CLSAG_GG_input_ref_t + { + CLSAG_GG_input_ref_t(const public_key& stealth_address, const public_key& amount_commitment) + : stealth_address(stealth_address), amount_commitment(amount_commitment) {} + + const public_key& stealth_address; + const public_key& amount_commitment; + }; + + bool generate_CLSAG_GG(const hash& m, const std::vector& ring, const point_t& pseudo_out_amount_commitment, const key_image& ki, + const scalar_t& secret_x, const scalar_t& secret_f, CLSAG_GG_signature& sig); + +} // namespace crypto