commit cbd4917ff3e464b14b464a598fcb8385d5fd0f68 Author: arnaucube Date: Sun Dec 10 20:07:38 2023 +0100 init diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4fffb2f --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/target +/Cargo.lock diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..b28f770 --- /dev/null +++ b/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"]} + diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..81f0843 --- /dev/null +++ b/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::::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. + } +}