-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: improve identities implementation (#120)
- Loading branch information
1 parent
2c0fe64
commit de42ef9
Showing
68 changed files
with
1,823 additions
and
974 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
_extends: .github |
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
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,46 @@ | ||
|
||
/** | ||
* This file is part of Ark Cpp Crypto. | ||
* | ||
* (c) Ark Ecosystem <info@ark.io> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
**/ | ||
#include "crypto/curve.hpp" | ||
|
||
#include "interfaces/identities.hpp" | ||
|
||
#include "uECC.h" | ||
|
||
namespace Ark { | ||
namespace Crypto { | ||
|
||
PublicKeyBytes Curve::PublicKey::compute(const uint8_t* privateKeyBytes) { | ||
const struct uECC_Curve_t* curve = uECC_secp256k1(); | ||
|
||
PublicKeyPoint uncompressed {}; | ||
if (uECC_compute_public_key(privateKeyBytes, | ||
uncompressed.data(), | ||
curve) == 0) { return {}; }; | ||
|
||
PublicKeyBytes compressed {}; | ||
uECC_compress(uncompressed.data(), compressed.data(), curve); | ||
|
||
return compressed; | ||
} | ||
|
||
/**/ | ||
|
||
bool Curve::PublicKey::validate(const uint8_t* publicKeyBytes) { | ||
const struct uECC_Curve_t* curve = uECC_secp256k1(); | ||
|
||
PublicKeyPoint uncompressed {}; | ||
uECC_decompress(publicKeyBytes, uncompressed.data(), curve); | ||
|
||
return (uECC_valid_public_key(uncompressed.data(), curve) != 0); | ||
} | ||
|
||
|
||
} // namespace Crypto | ||
} // namespace Ark |
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,29 @@ | ||
|
||
/** | ||
* This file is part of Ark Cpp Crypto. | ||
* | ||
* (c) Ark Ecosystem <info@ark.io> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
**/ | ||
|
||
#ifndef CRYPTO_CURVE_HPP | ||
#define CRYPTO_CURVE_HPP | ||
|
||
#include "interfaces/identities.hpp" | ||
|
||
namespace Ark { | ||
namespace Crypto { | ||
|
||
struct Curve { | ||
struct PublicKey { | ||
static PublicKeyBytes compute(const uint8_t* privateKeyBytes); | ||
static bool validate(const uint8_t* publicKeyBytes); | ||
}; | ||
}; | ||
|
||
} // namespace Crypto | ||
} // namespace Ark | ||
|
||
#endif |
Oops, something went wrong.