init
arnaucube root@arnaucube.com
Sun, 10 Dec 2023 20:07:38 +0100
3 files changed,
42 insertions(+),
0 deletions(-)
A
Cargo.toml
@@ -0,0 +1,13 @@
+[package] +name = "rust" +version = "0.1.0" +edition = "2021" + +[dependencies] +ark-ff = { version = "^0.4.0", default-features = false } +ark-std = { version = "^0.4.0", default-features = false } +ark-relations = { version = "^0.4.0", default-features = false } +ark-r1cs-std = { version="^0.4.0", default-features = false } +ark-serialize = "^0.4.0" +ark-pallas = {version="0.4.0", features=["r1cs"]} +
A
src/lib.rs
@@ -0,0 +1,27 @@
+#![allow(non_snake_case)] + +#[cfg(test)] +mod tests { + use ark_pallas::{constraints::GVar, Fq, Projective}; + use ark_r1cs_std::{alloc::AllocVar, R1CSVar, ToBytesGadget}; + use ark_relations::r1cs::ConstraintSystem; + use ark_serialize::CanonicalSerialize; + use ark_std::UniformRand; + + #[test] + fn test_point_to_bytes() { + let mut rng = ark_std::test_rng(); + let cs = ConstraintSystem::<Fq>::new_ref(); + + let point = Projective::rand(&mut rng); + let pointVar = GVar::new_witness(cs.clone(), || Ok(point)).unwrap(); + + let mut point_bytes = Vec::new(); + point.serialize_uncompressed(&mut point_bytes).unwrap(); + + let pointVar_bytes = pointVar.to_bytes().unwrap(); + + assert_eq!(pointVar_bytes.value().unwrap(), point_bytes); + // They differ in the last byte, the one used to indicate if is point at infinity. + } +}