Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: jl projection #2

Closed
wants to merge 6 commits into from
Closed

feat: jl projection #2

wants to merge 6 commits into from

Conversation

Junochiu
Copy link
Collaborator

@Junochiu Junochiu commented Nov 8, 2024

Summary

This pr implemented the JL projection method that projects the given polynomial ring matrix to a polynomial ring matrix with smaller dimension.

Example

Given a data matrix D_{2, 256} by setting the target dimension of 128, the expected result would be a data matrix of D_{2, 128}

Comment on lines 44 to 52
let mut projected_data = Vec::with_capacity(data.len());
for data_vec in data.clone() {
let mut projected_vector: Vec<RingGoldilock256> = Vec::with_capacity(target_dim);
for projection_row in projection_matrix.clone() {
let projection_value = RingGoldilock256::dot_product(&data_vec, &projection_row);
projected_vector.push(projection_value);
}
projected_data.push(projected_vector);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably using reference instead of cloning is better here. I am not very sure but we can discuss here

Suggested change
let mut projected_data = Vec::with_capacity(data.len());
for data_vec in data.clone() {
let mut projected_vector: Vec<RingGoldilock256> = Vec::with_capacity(target_dim);
for projection_row in projection_matrix.clone() {
let projection_value = RingGoldilock256::dot_product(&data_vec, &projection_row);
projected_vector.push(projection_value);
}
projected_data.push(projected_vector);
}
let mut projected_data = Vec::with_capacity(data.len());
for data_vec in &data {
let mut projected_vector: Vec<RingGoldilock256> = Vec::with_capacity(target_dim);
for projection_row in &projection_matrix {
let projection_value = RingGoldilock256::dot_product(&data_vec, &projection_row);
projected_vector.push(projection_value);
}
projected_data.push(projected_vector);
}

Copy link
Collaborator

@FoodChain1028 FoodChain1028 Nov 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And I reckon the result of project should be a vector of pure numbers

for example,

we have $r$ = 2 (the number of $\vec{s}$ ($\vec{s}=[s_1, s_2, ...]$ ))
$\vec{S_1} = [1,2, 3,4]$
$\vec{S_2} = [3,4, 5,6]$

lets the randomly sampled projection vector be

$\vec{\pi_1}^{(1)} = [1, 0, 1, -1]$
$\vec{\pi_2}^{(1)} = [0, 1, 1, 0]$

$p_1$ is calculated as below:

$$ \begin{aligned} p_1 &= <\vec{\pi_1}^{(1)}, \vec{s_1}> + <\vec{\pi_2}^{(1)}, \vec{s_2}> &= 1 \times 1 + 0\times2 + 1\times3 + (-1)\times4 + 0\times3 + 1\times4 + 1\times5 + 0\times6 &= 9 \end{aligned} $$

I think in the end we will get a 256-length vector $\vec{p}$, which each element is a pure number, i.e., [9, 2, 13, ...]

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have different understanding here, since the given data would be a polynomial ring matrix, the result should be a polynomial ring matrix with lower dimension.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think @FoodChain1028 is correct, refer to page 35 of https://eprint.iacr.org/2024/311.pdf#page=34.19 , you will find the result of JL projection is in $Z_q^{2\lambda}$, which $\lambda = 128$
image

@pinhaocrypto
Copy link
Collaborator

In the Greyhound paper (https://eprint.iacr.org/2024/1293.pdf#page=28.41), they made some changes to the details of the JL project. I think we should follow these changes. But I'm not sure what the probability distribution of {1, -1}, maybe 1/2?
Screenshot 2024-11-27 at 16 01 16

@Junochiu
Copy link
Collaborator Author

Junochiu commented Dec 4, 2024

Closing the pr for now as we will be focusing on the poc prover implementation and will likely use the implementation from math library

@Junochiu Junochiu closed this Dec 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants