![ZK 콜 미리보기 [C ++]](https://images.downcodes.com/uploads/20250315/img_67d5683eb87ef30.png)
이 저장소는 Schnorr의 프로토콜을 세련된 구현으로 호스팅하여 보안 조치를 향상시키기 위해 주 시드를 혁신적으로 통합합니다. 근본적인 증거는 복잡해 보일 수 있지만, 나는 그들의 기능을 최대한 활용하기 위해 그들의 기능을 설명하는 것을 목표로합니다. 그러나 더 깊은 이해를 위해, 나는 포괄적 인 통찰력을 제공하기 때문에이 구현을 뒷받침하는 중요한 연구 논문을 참조하는 것이 좋습니다.

추가 탐색을 위해 :
타원 곡선 기반 "제로 지식"증명 및 Ioannis Chatzigiannakis, Apostolos Pyrgelis, Paul G. Spirakis 및 Yannis C. Stamatiou의 자원 제약 장치에 대한 적용 가능성

또한이 저장소는 "제로 지식"증명 (ZKP) 및 해시 기반 메시지 인증 코드 (HMAC) 의 개념을 탐구합니다. ZKPS는 한 당사자 (Prover) 가 다른 당사자 (검증 자) 에게 진술 자체의 유효성을 넘어서 추가 정보를 공개하지 않고 주어진 진술이 사실임을 증명할 수있는 암호화 프로토콜입니다. 이 부동산은 특히 신뢰를 확립하면서 프라이버시를 보존하는 데 특히 가치가 있습니다.
반면에 HMAC는 메시지 인증에 사용되는 암호화 해시 함수 유형입니다. 여기에는 암호화 해시 함수 (SHA-256) 와 비밀 암호화 키가 포함됩니다. HMACS는 데이터 무결성과 메시지의 진위를 모두 확인하여 전송 중에 변경되거나 변조되지 않았으며 실제로는 변호 된 발신자에서 유래했는지 확인합니다.
오늘날의 빠르게 진화하고 응용 프로그램 개발 환경에서 "제로 지식"증명 (ZKP)은 인증 보안을위한 중추적 패러다임으로 등장합니다. 비밀번호 또는 해시와 같은 클레임 자체에 대한 민감한 정보를 밝히지 않고 비밀 암호의 소유를 증명하는 것과 같은 청구의 유효성을 확인하는 이들의 능력은 안전한 AAA 운영 ( 인증 , 승인 및 회계 )의 보증에 혁명을 일으킨다.

ZK-Call & Labs는 텍스트 기반 비밀을 검증하기 위해 특별히 맞춤화 된 NIZKP (Nonteractive) "제로 지식"증명 (NIZKP) 프로토콜을 구현하는 것을 나타냅니다. 이 프레임 워크는 비밀번호 및 기타 인증 메커니즘을 보호하는 데 귀중한 것으로 판명되어 개인 정보를 손상시키지 않고 강력한 보안 조치를 보장합니다. 또한 HMAC (HASH 기반 메시지 인증 코드) 의 통합은 인증 프로세스를 더욱 강화하여 데이터 무결성을 향상시키고 잠재적 보안 위반을 방해합니다.
이 시스템에서 사용 된 인증 프로토콜은 "ZERO-KNAGLEDGE"증명 (ZKPS) 및 해시 기반 메시지 인증 코드 (HMAC)의 두 가지 기본 개념을 기반으로 작동합니다. 이러한 각 구성 요소를 조사하고 메시징 응용 프로그램의 안전한 인증을 보장하기 위해 시너지 효과를 이해해 봅시다.
Zkps는 개인 정보 보호 인증 메커니즘의 기반을 형성합니다. 이러한 증거를 통해 한 당사자 (잠재적) 는 청구의 타당성을 넘어서 추가 정보를 공개하지 않고 다른 당사자 (검증 자) 에 대한 클레임의 타당성을 입증 할 수 있습니다. 본질적으로 ZKP는 프로버가 암호 또는 암호화 키와 같은 민감한 데이터를 공개 할 필요없이 인증을 가능하게합니다.




메시징 응용 프로그램의 맥락에서 ZKP는 네트워크를 통해 명시적인 자격 증명을 전송할 필요없이 사용자의 신원을 확인하는 데 중추적 인 역할을합니다. 대신, 사용자는 해당 자격 증명 자체를 노출시키지 않고 특정 자격 증명의 신원 또는 소유를 증명하는 암호화 증명을 생성 할 수 있습니다. 이를 통해 인증 프로세스 중에 민감한 정보가 기밀로 유지되어 보안 및 개인 정보를 강화합니다.
HMAC는 당사자 간 교환 된 메시지의 무결성과 진정성을 확인하기위한 강력한 메커니즘을 제공합니다. 여기에는 비밀 키와 함께 암호화 해시 함수를 사용하여 각 메시지에 대해 고유 한 코드 (HMAC) 를 생성합니다. 이 코드는 디지털 서명 역할을하여 수신자가 전송 중에 메시지가 변조되거나 변경되지 않았는지 확인할 수 있습니다.

메시징 응용 프로그램에서 HMAC를 사용하여 메시지 발신자를 인증하고 통신 채널의 무결성을 보장 할 수 있습니다. 공유 비밀 키를 사용하여 각 메시지에 HMAC를 추가함으로써 발신자와 수신자는 영수증시 메시지의 진위를 검증 할 수 있습니다. 메시지에 대한 무단 수정은 계산 된 HMAC 와 수신 된 HMAC 사이에 불일치가 발생하여 수신자에게 잠재적 변조를 경고합니다.
결합하면 "제로 지식"증명 과 HMAC는 메시징 응용 프로그램에서 안전한 인증을위한 강력한 프레임 워크를 만듭니다. ZKP는 민감한 정보를 공개하지 않고 신원 확인을 용이하게하는 반면, HMAC는 당사자 간 교환 된 메시지의 무결성과 진정성을 보장합니다. 이러한 메커니즘은 함께 커뮤니케이션 채널의 기밀, 무결성 및 진정성을지지하고 디지털 영역에서 사용자의 개인 정보 및 보안을 보호합니다.

"HMAC_Client" с ++ API는 간단하고 직관적입니다.
Core Components 보안 메시지 암호화 및 암호 해독을 간소화하여 데이터 보호 향상을 위해 청크 및 문자 수준 처리를 모두 지원합니다.

메소드 메시지를 청크 로 처리하여 메시지를 암호화합니다 .
std::string encrypt_message_by_chunks(const std::string& message);
message: string # The message to be encrypted, processed in chunks
방법 문자 로 메시지를 암호화하는 방법.
std::string encrypt_message(const std::string& message);
message: string # The message to be encrypted, processed in characters
메소드 메시지를 청크 로 처리하여 메시지를 해독하는 방법.
std::string decrypt_message_by_chunks(const std::string& message);
message: string # The message to be decrypted, processed in chunks
메소드 메시지를 숯 으로 처리하여 메시지를 해독하는 방법.
std::string encrypt_message(const std::string& message);
message: string # The message to be decrypted, processed in characters
TODO : Example Usage 포함하십시오
#include <iostream> // Include the input/output stream standard header
#include <thread> // Include the thread standard header
#include <queue> // Include the queue standard header
#include <string> // Include the string standard header
#include "src/HMAC/core/base.h" // Include the header file for HMAC_Client functionality
#include "src/SeedGeneration/core/base.h" // Include the header file for SeedGenerator functionality
constexpr bool DEBUG = true; // Define a constexpr boolean variable DEBUG with value true
void print_msg(const std::string &who, const std::string &message) { // Define a function to print messages
if (DEBUG) { // Check if debugging is enabled
std::cout << "[" << who << "] " << message << std::endl; // Print the message with source identifier
}
}
bool check_if_queue_empty(std::queue<std::string> &socket) { // Define a function to check if a queue is empty
while (true) { // Infinite loop
if (!socket.empty()) { // Check if the queue is not empty
return true; // Return true if the queue is not empty
}
}
}
std::string get_content_from_socket(std::queue<std::string> &socket) { // Define a function to get content from a socket (queue)
if (check_if_queue_empty(socket)) { // Check if the queue is not empty
std::string val = socket.front(); // Get the front element of the queue
socket.pop(); // Remove the front element from the queue
return val; // Return the retrieved value
}
}
void client(std::queue<std::string> &client_socket, std::queue<std::string> &server_socket) { // Define the client function
// Generating the main seed
SeedGenerator seed_generator("job"); // Create an instance of SeedGenerator
std::vector<unsigned char> main_seed = seed_generator.generate(); // Generate the main seed
// Creating an instance of HMAC_Client for encrypting messages
print_msg("client", "first");
HMAC_Client obj("sha256", main_seed, 1); // Create an instance of HMAC_Client
// Sending the main seed to the server
server_socket.emplace(main_seed.begin(), main_seed.end()); // Convert the main seed vector to a string and send it to the server
print_msg("client", "after obj");
// Checking if the server has successfully received the seed
if (get_content_from_socket(client_socket) == obj.encrypt_message("")) { // Check if the server received the seed
print_msg("client", "after if");
// If successful, send a message to the server
std::string message = "hello"; // Define the message to be sent
server_socket.push(obj.encrypt_message_by_chunks(message)); // Encrypt and send the message to the server
print_msg("client", "client sent message " + message);
// Checking if the server has successfully decrypted the message
if (get_content_from_socket(client_socket) == obj.encrypt_message(message)) { // Check if the server decrypted the message
print_msg("client", "server has decrypted message");
}
}
}
void server(std::queue<std::string> &server_socket, std::queue<std::string> &client_socket) { // Define the server function
// Receiving the main seed from the client
std::string main_seed = get_content_from_socket(server_socket); // Receive the main seed from the client
// Creating an instance of HMAC_Client for encrypting messages
HMAC_Client obj("sha256", std::vector<unsigned char>(main_seed.begin(), main_seed.end()), 1); // Create an instance of HMAC_Client
// Sending an empty message to the client as acknowledgment
client_socket.push(obj.encrypt_message("")); // Encrypt and send an empty message to the client as acknowledgment
// Receiving the encrypted message from the client
std::string msg = get_content_from_socket(server_socket); // Receive the encrypted message from the client
print_msg("server", "message encrypted: " + msg);
// Decrypting the message
print_msg("server", "before decrypt ");
std::string msg_raw = obj.decrypt_message_by_chunks(msg); // Decrypt the received message
print_msg("server", "message raw: " + msg_raw);
// Sending the encrypted message back to the client
client_socket.push(obj.encrypt_message(msg_raw)); // Encrypt and send the decrypted message back to the client
}
int main() { // Main function
std::queue<std::string> client_socket, server_socket; // Create queues for client and server sockets
std::thread client_thread(client, std::ref(client_socket), std::ref(server_socket)); // Create a thread for the client function
std::thread server_thread(server, std::ref(server_socket), std::ref(client_socket)); // Create a thread for the server function
// Joining the threads to wait for their completion
client_thread.join(); // Wait for the client thread to finish
server_thread.join(); // Wait for the server thread to finish
return 0; // Return 0 to indicate successful execution
}
#include "src/ZeroKnowledge/core/base.h" // Include the header file for ZeroKnowledge class
int main() { // Main function
// Creating a ZeroKnowledge object for the client with specified curve and hash algorithm
ZeroKnowledge clientObject = ZeroKnowledge::createNew("secp256k1", "sha3_256");
// Creating a ZeroKnowledge object for the server with specified curve and hash algorithm
ZeroKnowledge serverObject = ZeroKnowledge::createNew("secp384r1", "sha3_512");
// Setting the server password
std::string serverPassword = "SecretServerPassword";
// Creating a signature for the server password
ZeroKnowledgeSignature serverSignature = serverObject.createSignature(serverPassword);
// Creating a signature for the client identity
std::string identity = "John";
ZeroKnowledgeSignature clientSignature = clientObject.createSignature(identity);
std::cout<<"beforen";
// Generating a token signed by the server for the client
std::cout<<clientObject.token()<<"n";
ZeroKnowledgeData token = serverObject.sign(serverPassword, clientObject.token());
std::cout<<"aftern";
// Generating proof using client identity and token
ZeroKnowledgeData proof = clientObject.sign(identity, token.data);
// Verifying the received proof
bool serverVerification = serverObject.verify(token, serverSignature);
if (!serverVerification) { // Check if server verification failed
std::cout << "Server verification failed" << std::endl; // Print error message
} else { // If server verification succeeded
// Otherwise, verify the proof using client signature
bool clientVerification = clientObject.verify(token, clientSignature, proof.proof);
if (!clientVerification) { // Check if client verification failed
std::cout << "Client verification failed" << std::endl; // Print error message
} else { // If client verification succeeded
std::cout << "Authentication successful" << std::endl; // Print success message
}
}
return 0; // Return 0 to indicate successful execution
}
#include "src/ZeroKnowledge/core/base.h" // Include the header file for ZeroKnowledge class
#include "src/HMAC/core/base.h" // Include the header file for HMAC_Client functionality
#include "src/SeedGeneration/core/base.h" // Include the header file for SeedGenerator functionality
#include <iostream> // Include the input/output stream standard header
#include <thread> // Include the thread standard header
#include <queue> // Include the queue standard header
#include <string> // Include the string standard header
constexpr bool DEBUG = true; // Define a constexpr boolean variable DEBUG with value true
void print_msg(const std::string &who, const std::string &message) { // Define a function to print messages
if (DEBUG) { // Check if debugging is enabled
std::cout << "[" << who << "] " << message << std::endl; // Print the message with source identifier
}
}
bool check_if_queue_empty(std::queue<std::string> &socket) { // Define a function to check if a queue is empty
while (true) { // Infinite loop
if (!socket.empty()) { // Check if the queue is not empty
return true; // Return true if the queue is not empty
}
}
}
std::string get_content_from_socket(std::queue<std::string> &socket) { // Define a function to get content from a socket (queue)
if (check_if_queue_empty(socket)) { // Check if the queue is not empty
std::string val = socket.front(); // Get the front element of the queue
socket.pop(); // Remove the front element from the queue
return val; // Return the retrieved value
}
}
void client(std::queue<std::string> &client_socket, std::queue<std::string> &server_socket) { // Define the client function
// Generating the main seed
SeedGenerator seed_generator("job"); // Create an instance of SeedGenerator
std::vector<unsigned char> main_seed = seed_generator.generate(); // Generate the main seed
// Creating an instance of HMAC_Client for encrypting messages
print_msg("client", "first");
HMAC_Client obj("sha256", main_seed, 1); // Create an instance of HMAC_Client
// Sending the main seed to the server
server_socket.emplace(main_seed.begin(), main_seed.end()); // Convert the main seed vector to a string and send it to the server
print_msg("client", "after obj");
// Checking if the server has successfully received the seed
if (get_content_from_socket(client_socket) == obj.encrypt_message("")) { // Check if the server received the seed
print_msg("client", "after if");
// If successful, send a message to the server
std::string message = "hello"; // Define the message to be sent
server_socket.push(obj.encrypt_message_by_chunks(message)); // Encrypt and send the message to the server
print_msg("client", "client sent message " + message);
// Checking if the server has successfully decrypted the message
if (get_content_from_socket(client_socket) == obj.encrypt_message(message)) { // Check if the server decrypted the message
print_msg("client", "server has decrypted message");
}
}
}
void server(std::queue<std::string> &server_socket, std::queue<std::string> &client_socket) { // Define the server function
// Receiving the main seed from the client
std::string main_seed = get_content_from_socket(server_socket); // Receive the main seed from the client
// Creating an instance of HMAC_Client for encrypting messages
HMAC_Client obj("sha256", std::vector<unsigned char>(main_seed.begin(), main_seed.end()), 1); // Create an instance of HMAC_Client
// Sending an empty message to the client as acknowledgment
client_socket.push(obj.encrypt_message("")); // Encrypt and send an empty message to the client as acknowledgment
// Receiving the encrypted message from the client
std::string msg = get_content_from_socket(server_socket); // Receive the encrypted message from the client
print_msg("server", "message encrypted: " + msg);
// Decrypting the message
print_msg("server", "before decrypt ");
std::string msg_raw = obj.decrypt_message_by_chunks(msg); // Decrypt the received message
print_msg("server", "message raw: " + msg_raw);
// Sending the encrypted message back to the client
client_socket.push(obj.encrypt_message(msg_raw)); // Encrypt and send the decrypted message back to the client
}
void init_talking() { // Define a function to initialize client-server communication
std::queue<std::string> client_socket, server_socket; // Create queues for client and server sockets
std::thread client_thread(client, std::ref(client_socket), std::ref(server_socket)); // Create a thread for the client function
std::thread server_thread(server, std::ref(server_socket), std::ref(client_socket)); // Create a thread for the server function
// Joining the threads to wait for their completion
client_thread.join(); // Wait for the client thread to finish
server_thread.join(); // Wait for the server thread to finish
}
int main() { // Main function
// Creating a ZeroKnowledge object for the client with specified curve and hash algorithm
ZeroKnowledge clientObject = ZeroKnowledge::createNew("secp256k1", "sha3_256");
// Creating a ZeroKnowledge object for the server with specified curve and hash algorithm
ZeroKnowledge serverObject = ZeroKnowledge::createNew("secp384r1", "sha3_512");
// Setting the server password
std::string serverPassword = "SecretServerPassword";
// Creating a signature for the server password
ZeroKnowledgeSignature serverSignature = serverObject.createSignature(serverPassword);
// Creating a signature for the client identity
std::string identity = "John";
ZeroKnowledgeSignature clientSignature = clientObject.createSignature(identity);
std::cout << "beforen";
// Generating a token signed by the server for the client
std::cout << clientObject.token() << "n";
ZeroKnowledgeData token = serverObject.sign(serverPassword, clientObject.token());
std::cout << "aftern";
// Generating proof using client identity and token
ZeroKnowledgeData proof = clientObject.sign(identity, token.data);
// Verifying the received proof
bool serverVerification = serverObject.verify(token, serverSignature);
if (!serverVerification) { // Check if server verification failed
std::cout << "Server verification failed" << std::endl; // Print error message
} else { // If server verification succeeded
// Otherwise, verify the proof using client signature
bool clientVerification = clientObject.verify(token, clientSignature, proof.proof);
if (!clientVerification) { // Check if client verification failed
std::cout << "Client verification failed" << std::endl; // Print error message
} else { // If client verification succeeded
std::cout << "Authentication successful" << std::endl; // Print success message
init_talking(); // Initialize client-server communication
}
}
return 0; // Return 0 to indicate successful execution
}