Crates.io | reveler |
lib.rs | reveler |
version | 0.1.1 |
source | src |
created_at | 2024-11-17 14:50:56.068627 |
updated_at | 2024-11-17 16:45:37.553642 |
description | A cryptographic commitment scheme based on lattice and parallelized matrix-vector multiplication. |
homepage | |
repository | https://github.com/blueokanna/reveler |
max_upload_size | |
id | 1451307 |
size | 96,133 |
This repository implements a cryptographic commitment scheme based on optimized FFT and hashing functions, designed for efficient commitment generation and verification. The scheme uses Fast Fourier Transform (FFT) for matrix multiplication and BlueHash-based hashing for commitment verification.
This library provides two main functions:
commit
): This function generates a cryptographic commitment based on input parameters.verify
): This function verifies the validity of a commitment using a random challenge.The cryptographic commitment uses a combination of FFT-based matrix multiplication and a multi-round BlueHash hashing algorithm to ensure both randomness and security.
The commit
function computes the commitment using the following steps:
Matrix Generation: Random matrices A
and B
are generated using the generate_params
function. These matrices will be used in the FFT-based matrix multiplication.
The matrices ( A ) and ( B ) are of size ( N \times N ), where ( N = 256 ). Each element is randomly chosen from the range ( [0, Q) ), where ( Q = 65535 ).
FFT Matrix Multiplication: For each row ( a_i ) from matrix ( A ) and ( b_i ) from matrix ( B ), we perform an FFT-based matrix multiplication:
Where represents element-wise multiplication of the FFT-transformed rows and the vectors ( m ) and ( r ), respectively.
Commitment Point Calculation: The sum of the FFT results for each row is calculated as:
This results in a commitment point:
Commitment Hashing: The commitment point ( C ) is then hashed using the BlueHash algorithm. The BlueHash algorithm applies multiple rounds of hashing for added randomness and security:
The final commitment hash is obtained after 3 rounds of BlueHash.
The commitment is returned as a struct containing both the commitment point ( C ) and its hash ( H(C) ).
The verify
function checks the validity of a commitment. It recomputes the commitment hash from the commitment point and compares it to the stored commitment hash:
Where ( C' ) is the commitment point being verified. If the recomputed hash ( H(C') ) matches the original hash, the commitment is valid.
The commitment generation relies heavily on FFT-based matrix multiplication. Given two matrices ( A ) and ( B ), the rows of these matrices are transformed into frequency space using FFT. The transformation is given by:
Where ( \mathcal{F} ) represents the FFT transformation.
The matrix multiplication in frequency space is done by element-wise multiplication of the FFT results, which is computationally more efficient than directly multiplying the matrices in the time domain.
The BlueHash algorithm is used for hashing the commitment point to generate the final commitment hash. It applies multiple rounds of hashing to increase the entropy and randomness of the hash.
Where ( H(C) ) is the final hash after 3 rounds of the BlueHash algorithm.
The project consists of three main modules:
fft_matrix_multiply
get_optimal_thread_count
, hash_to_commitment
, generate_params
commit
and verify
functions.
commit
, verify
, RevelerCommit
fn main() {
let (a, b) = generate_params();
let mut rng = rand::thread_rng();
let m: Vec<u64> = (0..N).map(|_| rng.gen_range(0..Q)).collect();
let r: Vec<u64> = (0..N).map(|_| rng.gen_range(0..Q)).collect();
let commitment = commit(&a, &b, &m, &r);
println!("Commitment: {:?}", commitment);
let is_valid = verify(&commitment);
println!("Is commitment valid? {}", is_valid);
}
USDT : Arbitrum One Network: 0x4051d34Af2025A33aFD5EacCA7A90046f7a64Bed | USDC: Arbitrum One Network: 0x4051d34Af2025A33aFD5EacCA7A90046f7a64Bed | Dash: Dash Network: XuJwtHWdsYzfLawymR3B3nDdS2W8dHnxyR |
---|