mirror of
https://github.com/logos-storage/circom-compat-ffi.git
synced 2026-01-03 13:23:09 +00:00
use slice_to_point for proper conversion
This commit is contained in:
parent
5d1f509fce
commit
e00ae0a814
@ -4,7 +4,6 @@ use ark_bn254::{Bn254, Fq, Fq2, Fr, G1Affine, G2Affine};
|
||||
use ark_ff::{BigInteger, PrimeField};
|
||||
use ark_serialize::CanonicalDeserialize;
|
||||
use ark_std::Zero;
|
||||
use num_bigint::BigUint;
|
||||
|
||||
// Helper for converting a PrimeField to little endian byte slice
|
||||
fn slice_to_point<F: PrimeField>(point: &[u8; 32]) -> F {
|
||||
@ -164,9 +163,9 @@ impl From<&ark_groth16::VerifyingKey<Bn254>> for VerifyingKey {
|
||||
impl From<&[Fr]> for Inputs {
|
||||
fn from(src: &[Fr]) -> Self {
|
||||
let els: Vec<[u8; 32]> = src
|
||||
.iter()
|
||||
.map(|point| point_to_slice(*point))
|
||||
.collect();
|
||||
.iter()
|
||||
.map(|point| point_to_slice(*point))
|
||||
.collect();
|
||||
|
||||
let len = els.len();
|
||||
Self {
|
||||
@ -181,10 +180,7 @@ impl From<Inputs> for Vec<Fr> {
|
||||
let els: Vec<Fr> = unsafe {
|
||||
(&*slice_from_raw_parts(src.elms, src.len))
|
||||
.iter()
|
||||
.map(|point| {
|
||||
let uint = BigUint::from_bytes_le(point);
|
||||
Fr::from(uint)
|
||||
})
|
||||
.map(|point| slice_to_point(point))
|
||||
.collect()
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user