1
0
Fork 0
mirror of synced 2025-09-23 12:18:44 +00:00

add FIELD_SIZE_IN_BITS constant embed

This commit is contained in:
dark64 2021-06-08 20:42:32 +02:00
parent 85dca36161
commit c2e1f3d544
7 changed files with 87 additions and 2 deletions

View file

@ -14,6 +14,7 @@ use std::fmt;
use std::io;
use std::path::{Path, PathBuf};
use crate::absy::types::UnresolvedType;
use typed_arena::Arena;
use zokrates_common::Resolver;
use zokrates_field::{Bn128Field, Field};
@ -156,6 +157,17 @@ impl Importer {
id: symbol.get_alias(),
symbol: Symbol::Flat(FlatEmbed::U8FromBits),
},
"FIELD_SIZE_IN_BITS" => SymbolDeclaration {
id: symbol.get_alias(),
symbol: Symbol::Here(SymbolDefinition::Constant(
ConstantDefinition {
ty: UnresolvedType::Uint(32).into(),
expression: Expression::U32Constant(T::get_required_bits() as u32)
.into(),
}
.start_end(pos.0, pos.1),
)),
},
s => {
return Err(CompileErrorInner::ImportError(
Error::new(format!("Embed {} not found", s)).with_pos(Some(pos)),

View file

@ -1,4 +1,5 @@
{
"entry_point": "./tests/tests/cached_condition.zok",
"max_constraint_count": 2015
"entry_point": "./tests/tests/cached_condition.zok",
"max_constraint_count": 2015,
"tests": []
}

View file

@ -0,0 +1,4 @@
from "EMBED" import FIELD_SIZE_IN_BITS
def main() -> u32:
return FIELD_SIZE_IN_BITS

View file

@ -0,0 +1,17 @@
{
"entry_point": "./tests/tests/constants/field_size_in_bits.zok",
"max_constraint_count": 1,
"curves": ["Bls12_377"],
"tests": [
{
"input": {
"values": []
},
"output": {
"Ok": {
"values": ["253"]
}
}
}
]
}

View file

@ -0,0 +1,17 @@
{
"entry_point": "./tests/tests/constants/field_size_in_bits.zok",
"max_constraint_count": 1,
"curves": ["Bls12_381"],
"tests": [
{
"input": {
"values": []
},
"output": {
"Ok": {
"values": ["255"]
}
}
}
]
}

View file

@ -0,0 +1,17 @@
{
"entry_point": "./tests/tests/constants/field_size_in_bits.zok",
"max_constraint_count": 1,
"curves": ["Bn128"],
"tests": [
{
"input": {
"values": []
},
"output": {
"Ok": {
"values": ["254"]
}
}
}
]
}

View file

@ -0,0 +1,17 @@
{
"entry_point": "./tests/tests/constants/field_size_in_bits.zok",
"max_constraint_count": 1,
"curves": ["Bw6_761"],
"tests": [
{
"input": {
"values": []
},
"output": {
"Ok": {
"values": ["377"]
}
}
}
]
}