This project is dedicated to the world community as an Open-source Post-quantum blockchain layer 1 project, means anyone can join and contribute based on his/ her passion and skills. SPHINX is a blockchain protocol designed to provide secure and scalable solutions in the post-quantum era.
This repository contains code for the SPHINXKey project, which is a Merged Hybrid Key pair
and generating Address
module for the SPHINX blockchain framework.
This code is alternative for SPHINXHKey as further consideration.
-
SPHINXHybridKey: A namespace that contains the definition of the
HybridKeypair
structure, which represents a hybrid cryptographic key pair. -
SPHINXHash: A namespace that contains the definitions of two hash functions:
SPHINX_256
andRIPEMD_160
. These functions take a vector of unsigned characters(std::vector<unsigned char>)
as input and return a string representing the hashed value.
-
The code defines a static constant string
base58_chars
, which contains characters used for Base58 encoding. Base58 is a binary-to-text encoding scheme commonly used for encoding in Bitcoin addresses and other cryptographic data, we needed this only to produce shorter address and for human readability. -
The function
EncodeBase58
takes a vector of unsigned characters(std::vector<unsigned char>)
as input and returns the Base58 encoded string.
-
The code provides several functions for generating and handling hybrid key pairs, which are composed of both
Curve448
andKyber1024
key pairs. -
The SPHINXKey namespace contains functions for generating public and private keys, merging public and private keys, converting keys to strings, and generating smart contract addresses based on public keys and contract names.
-
generate_hybrid_keypair
: This function generates a hybrid key pair by creatingCurve448
andKyber1024
key pairs and then merging them into a single key pair. -
generate_and_perform_key_exchange
: This function demonstrates the process of generating a hybrid key pair, performing a key exchange usingX448
andKyber1024
KEM (Key Encapsulation Mechanism), and encrypting and decrypting a message usingKyber1024 PKE
(Public Key Encryption).
The code contains two functions named mergePrivateKeys
and mergePublicKeys
, both of which take Curve448
and Kyber1024
private/public keys as input, merge them together, and then hash the merged keys using the SPHINX_256
hash function.
printKeyPair
: This function takes a name, private key, and public key as input, prints them, and generates a contract address based on the public key and a contract name.
- The code defines several constants related to key sizes and hybrid key structures.
This code provides a set of functions and structures to support hybrid key generation, key exchange, encryption, decryption, and other cryptographic operations.
The interaction and collaboration between Key.cpp and SPHINXHybridKey can be summarized as follows:
-
SPHINXKey Namespace interacts with the SPHINXHybridKey Namespace by calling the function
generate_hybrid_keypair
from theSPHINXHybridKey
namespace. This function generates the hybrid keypair and its corresponding private and public keys. -
The function
SPHINXKey::generateAddress
uses theSPHINXHybridKey::SPHINXHash::SPHINX_256
function to hash the public key and generate an address based on the hash. This address is used for smart contract identification. -
In
SPHINXHybridKey::generate_hybrid_keypair
, Kyber1024 and X448 keypairs are generated. The function also derives a master private key and chain code using HMAC-SHA512 from a seed value and then derives private and public keys from the master key and chain code using HMAC-SHA512. -
The
SPHINXHybridKey
namespace provides functions to encrypt and decrypt messages using Kyber1024 for KEM (Key Encapsulation Mechanism). -
The
SPHINXHybridKey::performX448KeyExchange
function performs the X448 key exchange. -
The
SPHINXHybridKey
namespace also includes functions to encapsulate and decapsulate shared secrets using the hybrid KEM, combining the results of Kyber1024 and X448.
Combined Usage:
The combined usage of SPHINXKey
and SPHINXHybridKey
allows for the generation of secure hybrid keypairs that leverage the strengths of both Kyber1024 and X448 cryptographic algorithms. The hybrid keypairs can be used for various cryptographic purposes, including encryption, decryption, and key exchange, making it a versatile and robust cryptographic solution.
The interaction between Key.cpp and Hybrid_key.hpp involves calling functions defined in Hybrid_key.hpp from Key.cpp to perform various operations related to hybrid key generation, key exchange, address generation, and public key calculation. Hybrid_key.hpp provides the necessary functions and data structures to support these operations, and Key.cpp utilizes them to implement the desired functionality.
Every code in the repository is a part of the SPHINX blockchain algorithm, which is currently in development and not fully integrated or extensively tested for functionality. The purpose of this repository is to provide a framework and algorithm for the digital signature scheme in the SPHINX blockchain project.
As the project progresses, further updates and enhancements will be made to ensure the code's stability and reliability. We encourage contributors to participate in improving and refining the SPHINXBlock algorithm by submitting pull requests and providing valuable insights.
We appreciate your understanding and look forward to collaborative efforts in shaping the future of the SPHINX blockchain project.
To get started with the SPHINX blockchain project, follow the instructions below:
- Clone the repository:
git clone https://github.com/ChyKusuma/SPHINXKey.git
- Install the necessary dependencies (List the dependencies or provide a link to the installation guide).
- Explore the codebase to understand the project structure and components.
- Run the project or make modifications as needed.
We welcome contributions from the developer community to enhance the SPHINX blockchain project. If you are interested in contributing, please follow the guidelines below:
- Fork the repository on GitHub.
- Create a new branch for your feature or bug fix:
git checkout -b feature/your-feature-name
orgit checkout -b bugfix/your-bug-fix
. - Make your modifications and ensure the code remains clean and readable.
- Write tests to cover the changes you've made, if applicable.
- Commit your changes:
git commit -m "Description of your changes"
. - Push the branch to your forked repository:
git push origin your-branch-name
. - Open a pull request against the main repository, describing your changes and the problem it solves.
- Insert your information (i.e name, email) in the authors space.
Specify the license under which the project is distributed (MIT License).
If you have any questions, suggestions, or feedback regarding the SPHINX blockchain project, feel free to reach out to us at [email protected].