diff --git a/shared_model/cryptography/blob.hpp b/shared_model/cryptography/blob.hpp index c5496ef866..c510ebd8d2 100644 --- a/shared_model/cryptography/blob.hpp +++ b/shared_model/cryptography/blob.hpp @@ -82,7 +82,7 @@ namespace shared_model { * migration to shared model in whole project */ template - [[deprecated]] BlobType makeOldModel() const { + BlobType makeOldModel() const { return BlobType::from_string(blob()); } diff --git a/shared_model/cryptography/ed25519_sha3_impl/CMakeLists.txt b/shared_model/cryptography/ed25519_sha3_impl/CMakeLists.txt index 348ad9cf34..25f0705917 100644 --- a/shared_model/cryptography/ed25519_sha3_impl/CMakeLists.txt +++ b/shared_model/cryptography/ed25519_sha3_impl/CMakeLists.txt @@ -13,6 +13,7 @@ # limitations under the License. add_subdirectory(internal) +add_subdirectory(bindings) add_library(shared_ed25519_sha3 signer.cpp diff --git a/shared_model/cryptography/ed25519_sha3_impl/bindings/CMakeLists.txt b/shared_model/cryptography/ed25519_sha3_impl/bindings/CMakeLists.txt new file mode 100644 index 0000000000..12923294e3 --- /dev/null +++ b/shared_model/cryptography/ed25519_sha3_impl/bindings/CMakeLists.txt @@ -0,0 +1,26 @@ +# Copyright 2017 Soramitsu Co., Ltd. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +find_package(SWIG REQUIRED) +INCLUDE(${SWIG_USE_FILE}) + +FIND_PACKAGE(PythonLibs REQUIRED) +INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH}) +SET(CMAKE_SWIG_FLAGS "") +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) + +SET_SOURCE_FILES_PROPERTIES(crypto.i PROPERTIES CPLUSPLUS ON) +SWIG_ADD_LIBRARY(crypto LANGUAGE python SOURCES crypto.i) + +SWIG_LINK_LIBRARIES(crypto ${PYTHON_LIBRARIES} shared_ed25519_sha3 hash cryptography ed25519_sha3) diff --git a/shared_model/cryptography/ed25519_sha3_impl/bindings/crypto.i b/shared_model/cryptography/ed25519_sha3_impl/bindings/crypto.i new file mode 100644 index 0000000000..e87835b3e1 --- /dev/null +++ b/shared_model/cryptography/ed25519_sha3_impl/bindings/crypto.i @@ -0,0 +1,51 @@ +/** + * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. + * http://soramitsu.co.jp + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +%module crypto +%include "std_string.i" + +%{ +#include "cryptography/ed25519_sha3_impl/crypto_provider.hpp" +%} + +%include "interfaces/model_primitive.hpp" +%include "interfaces/primitive.hpp" +%include "cryptography/blob.hpp" +%include "cryptography/seed.hpp" +%include "cryptography/signed.hpp" +%include "cryptography/public_key.hpp" +%include "cryptography/private_key.hpp" +%include "cryptography/keypair.hpp" +%include "cryptography/ed25519_sha3_impl/crypto_provider.hpp" + +namespace shared_model { + namespace interface { + %template(imodelprim) shared_model::interface::ModelPrimitive; + %template(ikeypair) ModelPrimitive; + %template(iprim) shared_model::interface::Primitive; + } + + namespace crypto { + class Blob; + class Keypair; + class Seed; + class Signed; + class PublicKey; + class PrivateKey; + class CryptoProvider; + } +} diff --git a/shared_model/cryptography/ed25519_sha3_impl/crypto_provider.cpp b/shared_model/cryptography/ed25519_sha3_impl/crypto_provider.cpp index 4be555d17d..24386b9593 100644 --- a/shared_model/cryptography/ed25519_sha3_impl/crypto_provider.cpp +++ b/shared_model/cryptography/ed25519_sha3_impl/crypto_provider.cpp @@ -41,9 +41,7 @@ namespace shared_model { } Keypair CryptoProvider::generateKeypair() const { - auto keypair = iroha::create_keypair(); - return Keypair(PublicKey(keypair.pubkey.to_string()), - PrivateKey(keypair.privkey.to_string())); + return generateKeypair(generateSeed()); } Keypair CryptoProvider::generateKeypair(const Seed &seed) const { diff --git a/shared_model/cryptography/ed25519_sha3_impl/crypto_provider.hpp b/shared_model/cryptography/ed25519_sha3_impl/crypto_provider.hpp index 632766756e..fc08d05fa5 100644 --- a/shared_model/cryptography/ed25519_sha3_impl/crypto_provider.hpp +++ b/shared_model/cryptography/ed25519_sha3_impl/crypto_provider.hpp @@ -47,8 +47,9 @@ namespace shared_model { bool verify(const Signed &signedData, const Blob &orig, const PublicKey &publicKey) const; + /** - * Generates nes seed + * Generates new seed * @return Seed generated */ Seed generateSeed() const; diff --git a/shared_model/cryptography/ed25519_sha3_impl/internal/CMakeLists.txt b/shared_model/cryptography/ed25519_sha3_impl/internal/CMakeLists.txt index d7313ea42b..a06c3167e8 100644 --- a/shared_model/cryptography/ed25519_sha3_impl/internal/CMakeLists.txt +++ b/shared_model/cryptography/ed25519_sha3_impl/internal/CMakeLists.txt @@ -22,7 +22,6 @@ add_library(hash ) target_link_libraries(hash - ed25519_sha3 common pb_model_converters ) diff --git a/shared_model/cryptography/ed25519_sha3_impl/internal/impl/CMakeLists.txt b/shared_model/cryptography/ed25519_sha3_impl/internal/impl/CMakeLists.txt index 06b2bf6e12..728d917d55 100644 --- a/shared_model/cryptography/ed25519_sha3_impl/internal/impl/CMakeLists.txt +++ b/shared_model/cryptography/ed25519_sha3_impl/internal/impl/CMakeLists.txt @@ -11,4 +11,3 @@ add_library(ed25519_sha3 sign.c verify.c ) -#target_include_directories(ed25519_sha3 INTERFACE ed25519) diff --git a/shared_model/cryptography/keypair.hpp b/shared_model/cryptography/keypair.hpp index 8ddca4acff..9ff0899db4 100644 --- a/shared_model/cryptography/keypair.hpp +++ b/shared_model/cryptography/keypair.hpp @@ -64,7 +64,8 @@ namespace shared_model { .finalize(); } - OldModelType *makeOldModel() const override { + interface::Primitive::OldModelType * + makeOldModel() const override { return new iroha::keypair_t{ .pubkey = publicKey().makeOldModel(), .privkey = diff --git a/shared_model/interfaces/primitive.hpp b/shared_model/interfaces/primitive.hpp index f1472c92ef..a23bb8ca57 100644 --- a/shared_model/interfaces/primitive.hpp +++ b/shared_model/interfaces/primitive.hpp @@ -45,7 +45,7 @@ namespace shared_model { * model * @return pointer for old-style object */ - [[deprecated]] virtual OldModelType *makeOldModel() const = 0; + virtual OldModelType *makeOldModel() const = 0; }; } // namespace interface