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

Review necessity of serialization utility functions #279

Open
seemenkina opened this issue Feb 11, 2025 · 0 comments · May be fixed by #287
Open

Review necessity of serialization utility functions #279

seemenkina opened this issue Feb 11, 2025 · 0 comments · May be fixed by #287
Assignees

Comments

@seemenkina
Copy link
Collaborator

seemenkina commented Feb 11, 2025

The utility functions in rln/src/utils.rs are used across various serialization functions, and tests for them exist in rln/tests/protocol.rs. However, it’s unclear whether all of these functions are actually necessary.

Tasks:

  • Analyze the usage of each function in utils.rs to determine if they are all needed.
  • Check if any functionality is redundant or can be optimized.
  • Consider simplifying or removing unused functions if possible.

Possible but maybe doesn't make sense

  • Benchmark different serialization approaches to compare performance.
  • Check with other team members to see what serialization methods they are using and whether these functions align with them.

Suggested changes

  1. Update this function regarding current version of RLN.
    pub fn prepare_prove_input(

Example:

let mut serialized: Vec<u8> = Vec::new();
serialized.append(&mut fr_to_bytes_le(&identity_secret_hash));
serialized.append(&mut normalize_usize(identity_index));
serialized.append(&mut fr_to_bytes_le(&user_message_limit));
serialized.append(&mut fr_to_bytes_le(&Fr::from(1)));
serialized.append(&mut fr_to_bytes_le(&utils_poseidon_hash(&[
epoch,
rln_identifier,
])));
serialized.append(&mut normalize_usize(signal.len()));
serialized.append(&mut signal.to_vec());

  1. Use this function inside test to avoid problem with serialisation
    pub fn prepare_verify_input(proof_data: Vec<u8>, signal: &[u8]) -> Vec<u8> {

One of place where need to replace:

let mut proof_data = output_buffer.into_inner();
// We prepare input for verify_rln_proof API
// input_data is [ proof<128> | root<32> | external_nullifier<32> | x<32> | y<32> | nullifier<32> | signal_len<8> | signal<var> ]
// that is [ proof_data || signal_len<8> | signal<var> ]
proof_data.append(&mut normalize_usize(signal.len()));
proof_data.append(&mut signal.to_vec());


Related issue: #21

@vinhtc27 vinhtc27 self-assigned this Feb 27, 2025
@vinhtc27 vinhtc27 linked a pull request Feb 28, 2025 that will close this issue
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 a pull request may close this issue.

2 participants