forked from hyperledger-iroha/iroha-dco
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Introduce unsigned proto object - Return unsigned object from builder - Move SignatureType to types.hpp - Signing and adding signature perform by one method call now - Improve builder test to be aware about signatures - Adapt Swig interface for changes above Signed-off-by: luckychess <[email protected]>
- Loading branch information
1 parent
b46159a
commit bb6aea6
Showing
14 changed files
with
106 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/** | ||
* 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. | ||
*/ | ||
|
||
#ifndef IROHA_UNSIGNED_PROTO_HPP | ||
#define IROHA_UNSIGNED_PROTO_HPP | ||
|
||
#include "backend/protobuf/common_objects/signature.hpp" | ||
#include "cryptography/crypto_provider/crypto_signer.hpp" | ||
#include "cryptography/keypair.hpp" | ||
|
||
namespace shared_model { | ||
namespace proto { | ||
/** | ||
* Class for holding built but still unsigned objects | ||
* @tparam T - type of object received from builder | ||
*/ | ||
template <typename T> | ||
class UnsignedWrapper { | ||
public: | ||
/** | ||
* Constructs new unsigned object instance | ||
* @param o - object received from builder | ||
*/ | ||
UnsignedWrapper(const T &o) : unsigned_(o) {} | ||
|
||
/** | ||
* Add signature and retrieve signed result | ||
* @param signature - signature to add | ||
* @return signed object | ||
*/ | ||
T signAndAddSignature(const crypto::Keypair &keypair) { | ||
auto signedBlob = shared_model::crypto::CryptoSigner<>::sign( | ||
shared_model::crypto::Blob(unsigned_.blob()), keypair); | ||
iroha::protocol::Signature protosig; | ||
protosig.set_pubkey(keypair.publicKey().blob()); | ||
protosig.set_signature(signedBlob.blob()); | ||
auto *s1 = new Signature(protosig); | ||
unsigned_.addSignature(detail::PolymorphicWrapper<Signature>( | ||
s1)); // TODO: 05.12.2017 luckychess think about false case | ||
return unsigned_; | ||
} | ||
|
||
private: | ||
T unsigned_; | ||
}; | ||
} // namespace proto | ||
} // namespace shared_model | ||
|
||
#endif // IROHA_UNSIGNED_PROTO_HPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters