How can we convert a u8 element into an element in the elliptic curve bls12_381.
I have written these lines,
let a_prior: [u8;1] = [10;1];
println!("{}",a_prior[1]);
let b_prior: [u8;1] = [20;1];
println!("{}",b_prior[1]);
let a_bits = multipack::bytes_to_bits_le(&a_prior);
let a = multipack::compute_multipacking::<bls12_381::Scalar>(&a_bits);
println!("{:?}",a);
let b_bits = multipack::bytes_to_bits_le(&b_prior);
let b = multipack::compute_multipacking::<bls12_381::Scalar>(&b_bits);
println!("{:?}",b);
let w = redact(a,b);
Unfortunately it converts the elements to the vector in the curve but I want to use it for
let w = redact(a,b);
My code for the function is
fn redact<S: PrimeField>(mut a: S, mut b: S) -> S{
let c = a*b;
c
}
And this gives me error
error[E0277]: the trait bound `Vec<bls12_381::Scalar>: PrimeField` is not satisfied
--> src/main.rs:43:10
|
43 | let w = redact(a,b);
| ^^^^^^ the trait `PrimeField` is not implemented for `Vec<bls12_381::Scalar>`
Is there a way to fix it directly to an element in such that it passes through the function?