Răsfoiți Sursa

zkas: Add EcMulBase opcode.

parazyd 4 ani în urmă
părinte
comite
e71c8bebb1
4 a modificat fișierele cu 18 adăugiri și 7 ștergeri
  1. 1 1
      zkas/proofs/burn.zk
  2. 1 3
      zkas/src/main.rs
  3. 6 3
      zkas/src/opcode.rs
  4. 10 0
      zkas/src/parser.rs

+ 1 - 1
zkas/proofs/burn.zk

@@ -49,7 +49,7 @@ circuit "Burn" {
 
 	# Finally, we derive a public key for the signature and
 	# constrain its coordinates:
-	signature_public = ec_mul(signature_secret, NULLIFIER_K);
+	signature_public = ec_mul_base(signature_secret, NULLIFIER_K);
 	signature_x = ec_get_x(signature_public);
 	signature_y = ec_get_y(signature_public);
 	constrain_instance(signature_x);

+ 1 - 3
zkas/src/main.rs

@@ -56,9 +56,7 @@ fn main() -> Result<()> {
         !cli.strip,
     );
 
-    let bincode = compiler.compile();
-
-    println!("{:#?}", bincode);
+    let _bincode = compiler.compile();
 
     Ok(())
 }

+ 6 - 3
zkas/src/opcode.rs

@@ -6,9 +6,11 @@ use crate::types::Type;
 pub enum Opcode {
     EcAdd = 0x00,
     EcMul = 0x01,
-    EcMulShort = 0x02,
-    EcGetX = 0x03,
-    EcGetY = 0x04,
+    EcMulBase = 0x02,
+    EcMulShort = 0x03,
+
+    EcGetX = 0x08,
+    EcGetY = 0x09,
 
     PoseidonHash = 0x10,
 
@@ -25,6 +27,7 @@ impl Opcode {
             // (return_type, opcode_arg_types)
             Opcode::EcAdd => (vec![Type::EcPoint], vec![Type::EcPoint, Type::EcPoint]),
             Opcode::EcMul => (vec![Type::EcPoint], vec![Type::Scalar, Type::EcFixedPoint]),
+            Opcode::EcMulBase => (vec![Type::EcPoint], vec![Type::Base, Type::EcFixedPoint]),
             Opcode::EcMulShort => (vec![Type::EcPoint], vec![Type::Base, Type::EcFixedPoint]),
             Opcode::EcGetX => (vec![Type::Base], vec![Type::EcPoint]),
             Opcode::EcGetY => (vec![Type::Base], vec![Type::EcPoint]),

+ 10 - 0
zkas/src/parser.rs

@@ -545,6 +545,16 @@ impl Parser {
                         continue
                     }
 
+                    "ec_mul_base" => {
+                        stmt.args = self.parse_function_call(token, &mut iter);
+                        stmt.opcode = Opcode::EcMulBase;
+                        stmt.line = token.line;
+                        stmts.push(stmt.clone());
+
+                        parsing = false;
+                        continue
+                    }
+
                     "ec_mul" => {
                         stmt.args = self.parse_function_call(token, &mut iter);
                         stmt.opcode = Opcode::EcMul;