Browse Source

init

main
arnaucube 10 months ago
commit
cbd4917ff3
3 changed files with 42 additions and 0 deletions
  1. +2
    -0
      .gitignore
  2. +13
    -0
      Cargo.toml
  3. +27
    -0
      src/lib.rs

+ 2
- 0
.gitignore

@ -0,0 +1,2 @@
/target
/Cargo.lock

+ 13
- 0
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"]}

+ 27
- 0
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.
}
}

Loading…
Cancel
Save