Explorar el Código

sdk-py: Add random to Point

freerangedev hace 3 años
padre
commit
03e39f263f
Se han modificado 1 ficheros con 6 adiciones y 0 borrados
  1. 6 0
      src/sdk/python/src/point.rs

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

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