make sure vectors are sized to number of elements

This commit is contained in:
Dmitriy Ryajov 2024-02-14 12:31:40 -06:00
parent 190adb8c23
commit 23ff59715d
No known key found for this signature in database
GPG Key ID: DA8C680CE7C657A4
6 changed files with 15 additions and 2 deletions

10
fixtures/mycircuit.circom Normal file
View File

@ -0,0 +1,10 @@
template Multiplier() {
signal private input a;
signal private input b;
signal output c;
c <== a*b;
}
component main = Multiplier();

BIN
fixtures/mycircuit.r1cs Normal file

Binary file not shown.

BIN
fixtures/mycircuit.wasm Normal file

Binary file not shown.

Binary file not shown.

BIN
fixtures/test.zkey Normal file

Binary file not shown.

View File

@ -147,7 +147,9 @@ impl From<VerifyingKey> for ark_groth16::VerifyingKey<Bn254> {
impl From<&ark_groth16::VerifyingKey<Bn254>> for VerifyingKey {
fn from(vk: &ark_groth16::VerifyingKey<Bn254>) -> Self {
let ic: Vec<G1> = vk.gamma_abc_g1.iter().map(|p| p.into()).collect();
let mut ic: Vec<G1> = vk.gamma_abc_g1.iter().map(|p| p.into()).collect();
ic.shrink_to_fit();
let len = ic.len();
Self {
alpha1: G1::from(&vk.alpha_g1),
@ -162,11 +164,12 @@ impl From<&ark_groth16::VerifyingKey<Bn254>> for VerifyingKey {
impl From<&[Fr]> for Inputs {
fn from(src: &[Fr]) -> Self {
let els: Vec<[u8; 32]> = src
let mut els: Vec<[u8; 32]> = src
.iter()
.map(|point| point_to_slice(*point))
.collect();
els.shrink_to_fit();
let len = els.len();
Self {
elms: Box::leak(els.into_boxed_slice()).as_ptr(),