소스 검색

zkas: Add Uin64 type.

parazyd 4 년 전
부모
커밋
65e189fad6
3개의 변경된 파일14개의 추가작업 그리고 0개의 파일을 삭제
  1. 1 0
      contrib/zk.lua
  2. 9 0
      src/zkas/parser.rs
  3. 4 0
      src/zkas/types.rs

+ 1 - 0
contrib/zk.lua

@@ -24,6 +24,7 @@ local keyword = token(l.KEYWORD, word_match{
 local type = token(l.TYPE, word_match{
   'EcPoint', 'EcFixedPoint', 'Base', 'BaseArray',
   'Scalar', 'ScalarArray', 'MerklePath', 'Uint32',
+  'Uint64',
 })
 
 -- Instructions.

+ 9 - 0
src/zkas/parser.rs

@@ -430,6 +430,15 @@ impl Parser {
                     });
                 }
 
+                "Uint64" => {
+                    ret.push(Witness {
+                        name: k.to_string(),
+                        typ: Type::Uint64,
+                        line: v.0.line,
+                        column: v.0.column,
+                    });
+                }
+
                 x => {
                     self.error(format!("`{}` is an illegal witness type", x), v.1.line, v.1.column);
                 }

+ 4 - 0
src/zkas/types.rs

@@ -24,6 +24,9 @@ pub enum Type {
     /// Unsigned 32-bit integer
     Uint32 = 0x30,
 
+    /// Unsigned 64-bit integer
+    Uint64 = 0x31,
+
     /// Intermediate type, should never appear in the result
     Dummy = 0xff,
 }
@@ -39,6 +42,7 @@ impl Type {
             0x13 => Self::ScalarArray,
             0x20 => Self::MerklePath,
             0x30 => Self::Uint32,
+            0x31 => Self::Uint64,
             _ => unimplemented!(),
         }
     }