Skip to content

Review necessity of serialization utility functions #279

Closed
@seemenkina

Description

@seemenkina

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions