Line data Source code
1 : /**
2 : * Copyright Soramitsu Co., Ltd. All Rights Reserved.
3 : * SPDX-License-Identifier: Apache-2.0
4 : */
5 :
6 : #include "cryptography/ed25519_sha3_impl/crypto_provider.hpp"
7 : #include "cryptography/ed25519_sha3_impl/internal/ed25519_impl.hpp"
8 : #include "cryptography/ed25519_sha3_impl/signer.hpp"
9 : #include "cryptography/ed25519_sha3_impl/verifier.hpp"
10 :
11 : namespace shared_model {
12 : namespace crypto {
13 :
14 : Signed CryptoProviderEd25519Sha3::sign(const Blob &blob,
15 : const Keypair &keypair) {
16 6459 : return Signer::sign(blob, keypair);
17 : }
18 :
19 : bool CryptoProviderEd25519Sha3::verify(const Signed &signedData,
20 : const Blob &orig,
21 : const PublicKey &publicKey) {
22 16041 : return Verifier::verify(signedData, orig, publicKey);
23 : }
24 :
25 : Seed CryptoProviderEd25519Sha3::generateSeed() {
26 714 : return Seed(iroha::create_seed().to_string());
27 0 : }
28 :
29 : Seed CryptoProviderEd25519Sha3::generateSeed(
30 : const std::string &passphrase) {
31 0 : return Seed(iroha::create_seed(passphrase).to_string());
32 0 : }
33 :
34 : Keypair CryptoProviderEd25519Sha3::generateKeypair() {
35 714 : return generateKeypair(generateSeed());
36 0 : }
37 :
38 : Keypair CryptoProviderEd25519Sha3::generateKeypair(const Seed &seed) {
39 714 : auto keypair = iroha::create_keypair(
40 714 : iroha::blob_t<32>::from_string(toBinaryString(seed)));
41 714 : return Keypair(PublicKey(keypair.pubkey.to_string()),
42 714 : PrivateKey(keypair.privkey.to_string()));
43 0 : }
44 :
45 : const size_t CryptoProviderEd25519Sha3::kHashLength = 256 / 8;
46 : const size_t CryptoProviderEd25519Sha3::kPublicKeyLength = 256 / 8;
47 : const size_t CryptoProviderEd25519Sha3::kPrivateKeyLength = 512 / 8;
48 : const size_t CryptoProviderEd25519Sha3::kSignatureLength = 512 / 8;
49 : const size_t CryptoProviderEd25519Sha3::kSeedLength = 256 / 8;
50 : } // namespace crypto
51 : } // namespace shared_model
|