Эх сурвалжийг харах

sdk-py: Add random to Point

freerangedev 3 жил өмнө
parent
commit
03e39f263f

+ 6 - 0
src/sdk/python/src/point.rs

@@ -33,6 +33,7 @@ use darkfi_sdk::{
 };
 };
 use halo2_gadgets::ecc::chip::FixedPoint;
 use halo2_gadgets::ecc::chip::FixedPoint;
 use pyo3::{basic::CompareOp, prelude::*};
 use pyo3::{basic::CompareOp, prelude::*};
+use rand::rngs::OsRng;
 
 
 use super::{affine::Affine, base::Base, scalar::Scalar};
 use super::{affine::Affine, base::Base, scalar::Scalar};
 
 
@@ -75,6 +76,11 @@ impl Point {
         Self(r.0 * blind.0)
         Self(r.0 * blind.0)
     }
     }
 
 
+    #[staticmethod]
+    fn random() -> Self {
+        Self(pallas::Point::random(&mut OsRng))
+    }
+
     fn __str__(&self) -> String {
     fn __str__(&self) -> String {
         format!("{:?}", self.0)
         format!("{:?}", self.0)
     }
     }