Encrypt once the message has been broken into chunks
(
rng: &mut R,
message_chunks: Vec<CHUNK_TYPE>,
ek: &EncryptionKey<E>,
g_i: &[E::G1Affine],
)
| 625 | |
| 626 | /// Encrypt once the message has been broken into chunks |
| 627 | pub fn encrypt_decomposed_message<R: RngCore>( |
| 628 | rng: &mut R, |
| 629 | message_chunks: Vec<CHUNK_TYPE>, |
| 630 | ek: &EncryptionKey<E>, |
| 631 | g_i: &[E::G1Affine], |
| 632 | ) -> crate::Result<(Vec<E::G1Affine>, E::ScalarField)> { |
| 633 | let expected_count = ek.supported_chunks_count()? as usize; |
| 634 | if message_chunks.len() != expected_count { |
| 635 | return Err(SaverError::IncompatibleEncryptionKey( |
| 636 | message_chunks.len(), |
| 637 | expected_count, |
| 638 | )); |
| 639 | } |
| 640 | if message_chunks.len() > g_i.len() { |
| 641 | return Err(SaverError::VectorShorterThanExpected( |
| 642 | message_chunks.len(), |
| 643 | g_i.len(), |
| 644 | )); |
| 645 | } |
| 646 | let r = E::ScalarField::rand(rng); |
| 647 | let r_repr = r.into_bigint(); |
| 648 | let mut ct = vec![]; |
| 649 | ct.push(ek.X_0.mul_bigint(r_repr)); |
| 650 | let mut m = cfg_into_iter!(message_chunks) |
| 651 | .map(|m_i| <E::ScalarField as PrimeField>::BigInt::from(m_i as u64)) |
| 652 | .collect::<Vec<_>>(); |
| 653 | for i in 0..ek.X.len() { |
| 654 | ct.push(ek.X[i].mul_bigint(r_repr).add(g_i[i].mul_bigint(m[i]))); |
| 655 | } |
| 656 | |
| 657 | // Commit to the message chunks with randomness `r` |
| 658 | m.push(r.into_bigint()); |
| 659 | let psi = E::G1::msm_bigint(&ek.commitment_key(), &m); |
| 660 | |
| 661 | ct.push(psi); |
| 662 | Ok((E::G1::normalize_batch(&ct), r)) |
| 663 | } |
| 664 | |
| 665 | /// Does not use precomputation |
| 666 | fn solve_discrete_log( |
nothing calls this directly
no test coverage detected