An open API service indexing awesome lists of open source software.

https://github.com/maximilianfeldthusen/verifysignature

verifySignature
https://github.com/maximilianfeldthusen/verifysignature

Last synced: 6 months ago
JSON representation

verifySignature

Awesome Lists containing this project

README

          

## Documentation

### File Signature Verification in C++

The C++ code below shows how to read a file, its associated signature, and a public key, and then verify the signature using the Monocypher library. The program ensures that the data remains unaltered, providing a reliable method for file verification.

### Concepts:

### File I/O:
The program makes use of file input/output operations to read binary data from files.
### Signature Verification:
It uses cryptographic methods to confirm that a file's signature corresponds with the expected signature generated using a related private key.
### Monocypher Library:
This library offers cryptographic functions, including signature verification, which is essential for maintaining data integrity.

### Code:

The code is organized into several main components:

### Function Definitions:
#### readFile:
Reads the contents of a specified file into a buffer.
#### verifySignature:
Checks the signature against the data and public key.

#### Main Function:
Manages command-line arguments, reads the required files, and initiates the verification process.

#### readFile:
This function accepts a filename and a reference to a vector of uint8_t. It attempts to open the file in binary mode and reads its contents into the vector. If the file cannot be opened, it displays an error message and returns false.

#### verifySignature:
This function verifies the signature's validity. It first checks that the signature and public key are of the correct sizes (64 bytes for the signature and 32 bytes for the public key). It then calls the crypto_sign_verify function from the Monocypher library to carry out the actual verification.

#### main:
The program's entry point. It verifies the correct number of command-line arguments, reads the specified files, and calls the verification function. Depending on the outcome, it indicates whether the file is valid.

![C++](https://img.shields.io/badge/c++-%2300599C.svg?style=for-the-badge&logo=c%2B%2B&logoColor=white)