소스 검색

organizing

plato 5 년 전
부모
커밋
06378da693
2개의 변경된 파일15개의 추가작업 그리고 2개의 파일을 삭제
  1. 15 0
      lisp/core.rs
  2. 0 2
      lisp/lisp.rs

+ 15 - 0
lisp/core.rs

@@ -398,6 +398,20 @@ fn scalar_from(a: MalArgs) -> MalRet {
     }
 }
 
+fn scalar_square(a: MalArgs) -> MalRet {
+    match a[0].clone() {
+        ZKScalar(a0) => {
+            let mut z0 = a0.clone();
+            Ok(ZKScalar(z0.square()))
+        }
+        Str(a0) => {
+            let mut s0 = bls12_381::Scalar::from_string(&a0);
+            Ok(ZKScalar(s0.square()))
+        }
+        _ => error(&format!("scalar square expect (zkscalar or string) found \n {:?}", a).to_string()),
+    }
+}
+
 fn add_scalar(a: MalArgs) -> MalRet {
     match (a[0].clone(), a[1].clone()) {
         (Func(_, _), ZKScalar(a1)) => {
@@ -544,6 +558,7 @@ pub fn ns() -> Vec<(&'static str, MalVal)> {
         ("neg", func(negate_from)),
         ("scalar::zero", func(scalar_zero)),
         ("scalar", func(scalar_from)),
+        ("square", func(scalar_square)),
         ("cs::one", func(cs_one)),
     ]
 }

+ 0 - 2
lisp/lisp.rs

@@ -38,8 +38,6 @@ use crate::env::{env_bind, env_find, env_get, env_new, env_set, env_sets, Env};
 #[macro_use]
 mod core;
 
-pub const ZK_CIRCUIT_ENV_KEY: &str = "ZKC";
-
 // read
 fn read(str: &str) -> MalRet {
     reader::read_str(str.to_string())