Open dragan2234 opened 6 months ago
With this code:
use ark_std::str::FromStr;
use std::env;
use ark_ec::{CurveGroup, VariableBaseMSM};
use ark_ed_on_bls12_381_bandersnatch::SWAffine;
use ark_ed_on_bls12_381_bandersnatch::SWProjective;
use ark_ed_on_bls12_381_bandersnatch::{Fq, Fr as ScalarField};
fn main() {
let args: Vec<String> = env::args().collect();
if args.len() == 1 {
return;
}
if args[1] == "addFr" {
let lhs = ScalarField::from_str(&args[2]).unwrap();
let rhs = ScalarField::from_str(&args[3]).unwrap();
println!("{}", lhs + rhs);
} else if args[1] == "mulFr" {
let lhs = ScalarField::from_str(&args[2]).unwrap();
let rhs = ScalarField::from_str(&args[3]).unwrap();
println!("{}", lhs * rhs);
} else if args[1] == "addSW" {
/*
let x_a = Fq::from_str(&args[2]).unwrap();
let y_a = Fq::from_str(&args[2]).unwrap();
let x_b = Fq::from_str(&args[2]).unwrap();
let y_b = Fq::from_str(&args[2]).unwrap();
let point_a = SWAffine::new(x_a, y_a, false);
let point_b = SWAffine::new(x_b, y_b, false);
*/
let generator_x = Fq::from_str(
"30900340493481298850216505686589334086208278925799850409469406976849338430199",
)
.unwrap();
let generator_y = Fq::from_str(
"12663882780877899054958035777720958383845500985908634476792678820121468453298",
)
.unwrap();
let generator = SWAffine::new(generator_x, generator_y);
// i want to do 5G here print it so we can get the values
//
// also i need to get the args in a good way (two dif points)
let scalar = ScalarField::from_str("5").unwrap();
let res = SWProjective::msm(&[generator], &[scalar]);
let r = res.unwrap().into_affine();
println!("{}", r);
} else if args[1] == "mulSw" {
}
}
I'm having different results for 5*G
(8768738582522594538485122038190459677397928262526825851355323624315152110043, 8208364587749463077245963347730518467382014917786377188869948942465072180633)
It's in decimal. but still different after conversion
Using this tutorial for MSM https://github.com/arkworks-rs/algebra/tree/3a6156785e12eeb9083a7a402ac037de01f6c069/ec#scalar-multiplication
So idk where the results are coming :D
Thanks @MatteoMer ! just added affine results too in the description. I'll double-check halo2 implementation maybe it's wrong
explanation for parameters confusion: https://github.com/arkworks-rs/curves/pull/158#discussion_r1323172895
make few tests against either https://github.com/lambdaclass/lambdaworks/ or https://github.com/arkworks-rs/algebra/tree/master/curves/ed_on_bls12_381_bandersnatch or https://github.com/asanso/Bandersnatch
Examples from halo2curves, short weistrass form:
Projective:
Affine: