bump nightly, fix clippy errors
This commit is contained in:
parent
9e1cb8a07e
commit
8b35413169
26 changed files with 120 additions and 113 deletions
|
@ -1,2 +1,2 @@
|
|||
[toolchain]
|
||||
channel = "nightly-2022-03-10"
|
||||
channel = "nightly-2022-07-01"
|
||||
|
|
|
@ -19,7 +19,7 @@ use zokrates_ast::typed::types::{ConcreteType, UBitwidth};
|
|||
|
||||
use zokrates_field::Field;
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub enum Error {
|
||||
Json(String),
|
||||
Conversion(String),
|
||||
|
|
|
@ -13,7 +13,7 @@ impl fmt::Display for FormatString {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> FormatString {
|
||||
impl FormatString {
|
||||
pub fn len(&self) -> usize {
|
||||
self.parts.len() - 1
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ impl<'a> FormatString {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> From<&str> for FormatString {
|
||||
impl From<&str> for FormatString {
|
||||
fn from(s: &str) -> Self {
|
||||
let parts = s.split("{}").map(|p| p.to_string());
|
||||
FormatString {
|
||||
|
|
|
@ -30,7 +30,7 @@ pub type FlatFunction<T> = FlatFunctionIterator<T, Vec<FlatStatement<T>>>;
|
|||
|
||||
pub type FlatProgIterator<T, I> = FlatFunctionIterator<T, I>;
|
||||
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
#[derive(Clone, PartialEq, Eq, Debug)]
|
||||
pub struct FlatFunctionIterator<T, I: IntoIterator<Item = FlatStatement<T>>> {
|
||||
/// Arguments of the function
|
||||
pub arguments: Vec<Parameter>,
|
||||
|
@ -80,7 +80,7 @@ impl<T: Field> fmt::Display for FlatFunction<T> {
|
|||
///
|
||||
/// * r1cs - R1CS in standard JSON data format
|
||||
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
#[derive(Clone, PartialEq, Eq, Debug)]
|
||||
pub enum FlatStatement<T> {
|
||||
Condition(FlatExpression<T>, FlatExpression<T>, RuntimeError),
|
||||
Definition(Variable, FlatExpression<T>),
|
||||
|
@ -290,7 +290,7 @@ impl<T: Field> From<Variable> for FlatExpression<T> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Debug)]
|
||||
#[derive(PartialEq, Eq, Debug)]
|
||||
pub struct Error {
|
||||
message: String,
|
||||
}
|
||||
|
|
|
@ -98,7 +98,7 @@ impl<T: Field> fmt::Display for Statement<T> {
|
|||
|
||||
pub type Prog<T> = ProgIterator<T, Vec<Statement<T>>>;
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Default)]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Default)]
|
||||
pub struct ProgIterator<T, I: IntoIterator<Item = Statement<T>>> {
|
||||
pub arguments: Vec<Parameter>,
|
||||
pub return_count: usize,
|
||||
|
|
|
@ -10,7 +10,7 @@ type DynamicError = Box<dyn std::error::Error>;
|
|||
const ZOKRATES_MAGIC: &[u8; 4] = &[0x5a, 0x4f, 0x4b, 0];
|
||||
const ZOKRATES_VERSION_2: &[u8; 4] = &[0, 0, 0, 2];
|
||||
|
||||
#[derive(PartialEq, Debug)]
|
||||
#[derive(PartialEq, Eq, Debug)]
|
||||
pub enum ProgEnum<
|
||||
Bls12_381I: IntoIterator<Item = Statement<Bls12_381Field>>,
|
||||
Bn128I: IntoIterator<Item = Statement<Bn128Field>>,
|
||||
|
|
|
@ -5,7 +5,7 @@ use std::io;
|
|||
use std::io::{Read, Write};
|
||||
use zokrates_field::Field;
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Default)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Default)]
|
||||
pub struct Witness<T>(pub BTreeMap<Variable, T>);
|
||||
|
||||
impl<T: Field> Witness<T> {
|
||||
|
|
|
@ -749,7 +749,7 @@ impl<'ast, T: Field> TupleExpression<'ast, T> {
|
|||
TupleExpressionInner::Value(inline_tuple) => inline_tuple
|
||||
.into_iter()
|
||||
.zip(target_tuple_ty.elements.iter())
|
||||
.map(|(value, target_ty)| TypedExpression::align_to_type(value, &*target_ty))
|
||||
.map(|(value, target_ty)| TypedExpression::align_to_type(value, target_ty))
|
||||
.collect::<Result<Vec<_>, _>>()
|
||||
.map(|v| {
|
||||
let ty = TupleType::new(v.iter().map(|e| e.get_type()).collect());
|
||||
|
|
|
@ -66,7 +66,7 @@ pub type TypedModules<'ast, T> = BTreeMap<OwnedTypedModuleId, TypedModule<'ast,
|
|||
pub type TypedFunctionSymbols<'ast, T> =
|
||||
BTreeMap<DeclarationFunctionKey<'ast, T>, TypedFunctionSymbol<'ast, T>>;
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub enum TypedConstantSymbol<'ast, T> {
|
||||
Here(TypedConstant<'ast, T>),
|
||||
There(CanonicalConstantIdentifier<'ast>),
|
||||
|
@ -80,7 +80,7 @@ pub type TypedConstantSymbols<'ast, T> = Vec<(
|
|||
)>;
|
||||
|
||||
/// A typed program as a collection of modules, one of them being the main
|
||||
#[derive(PartialEq, Debug, Clone)]
|
||||
#[derive(PartialEq, Eq, Debug, Clone)]
|
||||
pub struct TypedProgram<'ast, T> {
|
||||
pub modules: TypedModules<'ast, T>,
|
||||
pub main: OwnedTypedModuleId,
|
||||
|
@ -151,7 +151,7 @@ impl<'ast, T: fmt::Display> fmt::Display for TypedProgram<'ast, T> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Debug, Clone)]
|
||||
#[derive(PartialEq, Eq, Debug, Clone)]
|
||||
pub struct TypedFunctionSymbolDeclaration<'ast, T> {
|
||||
pub key: DeclarationFunctionKey<'ast, T>,
|
||||
pub symbol: TypedFunctionSymbol<'ast, T>,
|
||||
|
@ -163,7 +163,7 @@ impl<'ast, T> TypedFunctionSymbolDeclaration<'ast, T> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Debug, Clone)]
|
||||
#[derive(PartialEq, Eq, Debug, Clone)]
|
||||
pub struct TypedConstantSymbolDeclaration<'ast, T> {
|
||||
pub id: CanonicalConstantIdentifier<'ast>,
|
||||
pub symbol: TypedConstantSymbol<'ast, T>,
|
||||
|
@ -179,7 +179,7 @@ impl<'ast, T> TypedConstantSymbolDeclaration<'ast, T> {
|
|||
}
|
||||
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
#[derive(PartialEq, Debug, Clone)]
|
||||
#[derive(PartialEq, Eq, Debug, Clone)]
|
||||
pub enum TypedSymbolDeclaration<'ast, T> {
|
||||
Function(TypedFunctionSymbolDeclaration<'ast, T>),
|
||||
Constant(TypedConstantSymbolDeclaration<'ast, T>),
|
||||
|
@ -209,7 +209,7 @@ impl<'ast, T: fmt::Display> fmt::Display for TypedSymbolDeclaration<'ast, T> {
|
|||
pub type TypedSymbolDeclarations<'ast, T> = Vec<TypedSymbolDeclaration<'ast, T>>;
|
||||
|
||||
/// A typed module as a collection of functions. Types have been resolved during semantic checking.
|
||||
#[derive(PartialEq, Debug, Clone)]
|
||||
#[derive(PartialEq, Eq, Debug, Clone)]
|
||||
pub struct TypedModule<'ast, T> {
|
||||
pub symbols: TypedSymbolDeclarations<'ast, T>,
|
||||
}
|
||||
|
@ -232,7 +232,7 @@ impl<'ast, T> TypedModule<'ast, T> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
#[derive(Clone, PartialEq, Eq, Debug)]
|
||||
pub enum TypedFunctionSymbol<'ast, T> {
|
||||
Here(TypedFunction<'ast, T>),
|
||||
There(DeclarationFunctionKey<'ast, T>),
|
||||
|
@ -315,7 +315,7 @@ impl<'ast, T: fmt::Display> fmt::Display for TypedModule<'ast, T> {
|
|||
}
|
||||
|
||||
/// A typed function
|
||||
#[derive(Clone, PartialEq, Debug, Hash)]
|
||||
#[derive(Clone, PartialEq, Eq, Debug, Hash)]
|
||||
pub struct TypedFunction<'ast, T> {
|
||||
/// Arguments of the function
|
||||
pub arguments: Vec<DeclarationParameter<'ast, T>>,
|
||||
|
@ -374,7 +374,7 @@ impl<'ast, T: fmt::Display> fmt::Display for TypedFunction<'ast, T> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
#[derive(Clone, PartialEq, Eq, Debug)]
|
||||
pub struct TypedConstant<'ast, T> {
|
||||
pub expression: TypedExpression<'ast, T>,
|
||||
pub ty: DeclarationType<'ast, T>,
|
||||
|
|
|
@ -269,6 +269,7 @@ impl<'ast, T> TryInto<usize> for DeclarationConstant<'ast, T> {
|
|||
|
||||
pub type MemberId = String;
|
||||
|
||||
#[allow(clippy::derive_hash_xor_eq)]
|
||||
#[derive(Debug, Clone, Eq, Hash, Serialize, Deserialize, PartialOrd, Ord)]
|
||||
pub struct GStructMember<S> {
|
||||
#[serde(rename = "name")]
|
||||
|
@ -281,7 +282,7 @@ pub type DeclarationStructMember<'ast, T> = GStructMember<DeclarationConstant<'a
|
|||
pub type ConcreteStructMember = GStructMember<u32>;
|
||||
pub type StructMember<'ast, T> = GStructMember<UExpression<'ast, T>>;
|
||||
|
||||
impl<'ast, S, R: PartialEq<S>> PartialEq<GStructMember<S>> for GStructMember<R> {
|
||||
impl<S, R: PartialEq<S>> PartialEq<GStructMember<S>> for GStructMember<R> {
|
||||
fn eq(&self, other: &GStructMember<S>) -> bool {
|
||||
self.id == other.id && *self.ty == *other.ty
|
||||
}
|
||||
|
@ -310,6 +311,7 @@ impl<'ast, T> From<ConcreteStructMember> for StructMember<'ast, T> {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::derive_hash_xor_eq)]
|
||||
#[derive(Clone, Eq, Hash, Serialize, Deserialize, PartialOrd, Ord, Debug)]
|
||||
pub struct GArrayType<S> {
|
||||
pub size: Box<S>,
|
||||
|
@ -321,7 +323,7 @@ pub type DeclarationArrayType<'ast, T> = GArrayType<DeclarationConstant<'ast, T>
|
|||
pub type ConcreteArrayType = GArrayType<u32>;
|
||||
pub type ArrayType<'ast, T> = GArrayType<UExpression<'ast, T>>;
|
||||
|
||||
impl<'ast, S, R: PartialEq<S>> PartialEq<GArrayType<S>> for GArrayType<R> {
|
||||
impl<S, R: PartialEq<S>> PartialEq<GArrayType<S>> for GArrayType<R> {
|
||||
fn eq(&self, other: &GArrayType<S>) -> bool {
|
||||
*self.ty == *other.ty && *self.size == *other.size
|
||||
}
|
||||
|
@ -376,6 +378,7 @@ impl<'ast, T> From<ConcreteArrayType> for ArrayType<'ast, T> {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::derive_hash_xor_eq)]
|
||||
#[derive(Clone, Eq, Hash, Serialize, Deserialize, PartialOrd, Ord, Debug)]
|
||||
pub struct GTupleType<S> {
|
||||
pub elements: Vec<GType<S>>,
|
||||
|
@ -391,7 +394,7 @@ pub type DeclarationTupleType<'ast, T> = GTupleType<DeclarationConstant<'ast, T>
|
|||
pub type ConcreteTupleType = GTupleType<u32>;
|
||||
pub type TupleType<'ast, T> = GTupleType<UExpression<'ast, T>>;
|
||||
|
||||
impl<'ast, S, R: PartialEq<S>> PartialEq<GTupleType<S>> for GTupleType<R> {
|
||||
impl<S, R: PartialEq<S>> PartialEq<GTupleType<S>> for GTupleType<R> {
|
||||
fn eq(&self, other: >upleType<S>) -> bool {
|
||||
*self.elements == *other.elements
|
||||
}
|
||||
|
@ -481,7 +484,7 @@ pub type DeclarationStructType<'ast, T> = GStructType<DeclarationConstant<'ast,
|
|||
pub type ConcreteStructType = GStructType<u32>;
|
||||
pub type StructType<'ast, T> = GStructType<UExpression<'ast, T>>;
|
||||
|
||||
impl<'ast, S, R: PartialEq<S>> PartialEq<GStructType<S>> for GStructType<R> {
|
||||
impl<S, R: PartialEq<S>> PartialEq<GStructType<S>> for GStructType<R> {
|
||||
fn eq(&self, other: &GStructType<S>) -> bool {
|
||||
self.canonical_location == other.canonical_location
|
||||
&& self
|
||||
|
@ -627,6 +630,7 @@ impl fmt::Display for UBitwidth {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::derive_hash_xor_eq)]
|
||||
#[derive(Clone, Eq, Hash, PartialOrd, Ord, Debug)]
|
||||
pub enum GType<S> {
|
||||
FieldElement,
|
||||
|
@ -754,7 +758,7 @@ pub type DeclarationType<'ast, T> = GType<DeclarationConstant<'ast, T>>;
|
|||
pub type ConcreteType = GType<u32>;
|
||||
pub type Type<'ast, T> = GType<UExpression<'ast, T>>;
|
||||
|
||||
impl<'ast, S, R: PartialEq<S>> PartialEq<GType<S>> for GType<R> {
|
||||
impl<S, R: PartialEq<S>> PartialEq<GType<S>> for GType<R> {
|
||||
fn eq(&self, other: >ype<S>) -> bool {
|
||||
use self::GType::*;
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ pub struct Program<'ast> {
|
|||
pub main: OwnedModuleId,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Clone)]
|
||||
#[derive(Debug, PartialEq, Eq, Clone)]
|
||||
pub struct SymbolIdentifier<'ast> {
|
||||
pub id: Identifier<'ast>,
|
||||
pub alias: Option<Identifier<'ast>>,
|
||||
|
@ -77,7 +77,7 @@ impl<'ast> fmt::Display for SymbolIdentifier<'ast> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct CanonicalImport<'ast> {
|
||||
pub source: &'ast Path,
|
||||
pub id: SymbolIdentifier<'ast>,
|
||||
|
@ -91,7 +91,7 @@ impl<'ast> fmt::Display for CanonicalImport<'ast> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct SymbolImport<'ast> {
|
||||
pub module_id: OwnedModuleId,
|
||||
pub symbol_id: Identifier<'ast>,
|
||||
|
@ -521,7 +521,7 @@ impl<'ast> fmt::Display for Range<'ast> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub enum ConditionalKind {
|
||||
IfElse,
|
||||
Ternary,
|
||||
|
|
|
@ -23,7 +23,7 @@ pub use self::folder::Folder;
|
|||
pub use self::identifier::{Identifier, SourceIdentifier};
|
||||
|
||||
/// A typed program as a collection of modules, one of them being the main
|
||||
#[derive(PartialEq, Debug)]
|
||||
#[derive(PartialEq, Eq, Debug)]
|
||||
pub struct ZirProgram<'ast, T> {
|
||||
pub main: ZirFunction<'ast, T>,
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ impl<'ast, T: fmt::Display> fmt::Display for ZirProgram<'ast, T> {
|
|||
}
|
||||
}
|
||||
/// A typed function
|
||||
#[derive(Clone, PartialEq)]
|
||||
#[derive(Clone, PartialEq, Eq)]
|
||||
pub struct ZirFunction<'ast, T> {
|
||||
/// Arguments of the function
|
||||
pub arguments: Vec<Parameter<'ast>>,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use crate::zir::Variable;
|
||||
use std::fmt;
|
||||
|
||||
#[derive(Clone, PartialEq)]
|
||||
#[derive(Clone, PartialEq, Eq)]
|
||||
pub struct Parameter<'ast> {
|
||||
pub id: Variable<'ast>,
|
||||
pub private: bool,
|
||||
|
|
|
@ -85,6 +85,6 @@ mod tests {
|
|||
wire_mapping: Some(mapping),
|
||||
};
|
||||
let rng = create_rng();
|
||||
assert!(prove(circuit.clone(), ¶ms, rng).is_ok());
|
||||
assert!(prove(circuit, ¶ms, rng).is_ok());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -94,7 +94,7 @@ fn cli_check<T: Field>(sub_matches: &ArgMatches) -> Result<(), String> {
|
|||
CompileConfig::default().isolate_branches(sub_matches.is_present("isolate-branches"));
|
||||
|
||||
let resolver = FileSystemResolver::with_stdlib_root(stdlib_path);
|
||||
let _ = check::<T, _>(source, path, Some(&resolver), &config).map_err(|e| {
|
||||
check::<T, _>(source, path, Some(&resolver), &config).map_err(|e| {
|
||||
format!(
|
||||
"Check failed:\n\n{}",
|
||||
e.0.iter()
|
||||
|
|
|
@ -375,14 +375,14 @@ mod integration {
|
|||
|
||||
// Compile lib
|
||||
let g2_lib =
|
||||
Contract::compile_from_src_string(&SOLIDITY_G2_ADDITION_LIB, "BN256G2", true, &[])
|
||||
Contract::compile_from_src_string(SOLIDITY_G2_ADDITION_LIB, "BN256G2", true, &[])
|
||||
.unwrap();
|
||||
|
||||
// Deploy lib
|
||||
let create_result = evm
|
||||
.deploy(g2_lib.encode_create_contract_bytes(&[]).unwrap(), &deployer)
|
||||
.unwrap();
|
||||
let lib_addr = create_result.addr.clone();
|
||||
let lib_addr = create_result.addr;
|
||||
|
||||
// Compile contract
|
||||
let contract = Contract::compile_from_src_string(
|
||||
|
@ -400,7 +400,7 @@ mod integration {
|
|||
&deployer,
|
||||
)
|
||||
.unwrap();
|
||||
let contract_addr = create_result.addr.clone();
|
||||
let contract_addr = create_result.addr;
|
||||
|
||||
// convert to the solidity proof format
|
||||
let solidity_proof = S::Proof::from(proof.proof);
|
||||
|
@ -436,11 +436,11 @@ mod integration {
|
|||
assert_eq!(&result.out, &to_be_bytes(&U256::from(1)));
|
||||
|
||||
// modify the proof
|
||||
let modified_solidity_proof = S::modify(solidity_proof.clone());
|
||||
let modified_solidity_proof = S::modify(solidity_proof);
|
||||
|
||||
let modified_proof_token = S::to_token(modified_solidity_proof.clone());
|
||||
let modified_proof_token = S::to_token(modified_solidity_proof);
|
||||
|
||||
let inputs = [modified_proof_token, input_token.clone()];
|
||||
let inputs = [modified_proof_token, input_token];
|
||||
|
||||
// Call verify function on contract
|
||||
let result = evm
|
||||
|
|
|
@ -18,7 +18,7 @@ use zokrates_ast::untyped::types::UnresolvedType;
|
|||
use zokrates_common::Resolver;
|
||||
use zokrates_field::Field;
|
||||
|
||||
#[derive(PartialEq, Debug)]
|
||||
#[derive(PartialEq, Eq, Debug)]
|
||||
pub struct Error {
|
||||
pos: Option<(Position, Position)>,
|
||||
message: String,
|
||||
|
|
|
@ -26,13 +26,13 @@ use zokrates_ast::typed::types::{
|
|||
TupleType,
|
||||
};
|
||||
|
||||
#[derive(PartialEq, Debug)]
|
||||
#[derive(PartialEq, Eq, Debug)]
|
||||
pub struct ErrorInner {
|
||||
pos: Option<(Position, Position)>,
|
||||
message: String,
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Debug)]
|
||||
#[derive(PartialEq, Eq, Debug)]
|
||||
pub struct Error {
|
||||
pub inner: ErrorInner,
|
||||
pub module_id: PathBuf,
|
||||
|
@ -4715,9 +4715,7 @@ mod tests {
|
|||
// should fail
|
||||
let bar_statements: Vec<StatementNode> = vec![
|
||||
Statement::Definition(
|
||||
untyped::Variable::immutable("a", UnresolvedType::FieldElement.mock())
|
||||
.mock()
|
||||
.into(),
|
||||
untyped::Variable::immutable("a", UnresolvedType::FieldElement.mock()).mock(),
|
||||
Expression::FunctionCall(box Expression::Identifier("foo").mock(), None, vec![])
|
||||
.mock(),
|
||||
)
|
||||
|
@ -4766,9 +4764,7 @@ mod tests {
|
|||
// should fail
|
||||
let bar_statements: Vec<StatementNode> = vec![
|
||||
Statement::Definition(
|
||||
untyped::Variable::immutable("a", UnresolvedType::FieldElement.mock())
|
||||
.mock()
|
||||
.into(),
|
||||
untyped::Variable::immutable("a", UnresolvedType::FieldElement.mock()).mock(),
|
||||
Expression::FunctionCall(box Expression::Identifier("foo").mock(), None, vec![])
|
||||
.mock(),
|
||||
)
|
||||
|
@ -4920,8 +4916,7 @@ mod tests {
|
|||
untyped::Expression::IntConstant(0usize.into()).mock(),
|
||||
),
|
||||
)
|
||||
.mock()
|
||||
.into(),
|
||||
.mock(),
|
||||
Expression::FunctionCall(box Expression::Identifier("foo").mock(), None, vec![])
|
||||
.mock(),
|
||||
)
|
||||
|
|
|
@ -17,7 +17,7 @@ pub struct ConstantResolver<'ast, T> {
|
|||
constants: ProgramConstants<'ast, T>,
|
||||
}
|
||||
|
||||
impl<'ast, 'a, T: Field> ConstantResolver<'ast, T> {
|
||||
impl<'ast, T: Field> ConstantResolver<'ast, T> {
|
||||
pub fn new(
|
||||
modules: TypedModules<'ast, T>,
|
||||
location: OwnedTypedModuleId,
|
||||
|
|
|
@ -18,7 +18,7 @@ use zokrates_field::Field;
|
|||
|
||||
pub type Constants<'ast, T> = HashMap<Identifier<'ast>, TypedExpression<'ast, T>>;
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub enum Error {
|
||||
Type(String),
|
||||
AssertionFailed(String),
|
||||
|
|
|
@ -50,13 +50,13 @@ pub type ConstantDefinitions<'ast, T> =
|
|||
pub type Versions<'ast> = HashMap<CoreIdentifier<'ast>, usize>;
|
||||
|
||||
// A container to represent whether more treatment must be applied to the function
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub enum Output<U, V> {
|
||||
Complete(U),
|
||||
Incomplete(U, V),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub enum Error {
|
||||
Incompatible(String),
|
||||
GenericsInMain,
|
||||
|
|
|
@ -11,7 +11,7 @@ use zokrates_field::Field;
|
|||
|
||||
type Constants<'ast, T> = HashMap<Identifier<'ast>, ZirExpression<'ast, T>>;
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub enum Error {
|
||||
OutOfBounds(usize, usize),
|
||||
DivisionByZero,
|
||||
|
|
|
@ -24,7 +24,7 @@ pub struct Witness<T> {
|
|||
pub values: Vec<T>,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, PartialEq, Clone)]
|
||||
#[derive(Default, Debug, PartialEq, Eq, Clone)]
|
||||
pub struct Constraint<T> {
|
||||
pub a: Vec<(T, usize)>,
|
||||
pub b: Vec<(T, usize)>,
|
||||
|
|
|
@ -271,7 +271,7 @@ impl Interpreter {
|
|||
#[derive(Debug)]
|
||||
pub struct EvaluationError;
|
||||
|
||||
#[derive(PartialEq, Clone, Serialize, Deserialize)]
|
||||
#[derive(PartialEq, Eq, Clone, Serialize, Deserialize)]
|
||||
pub enum Error {
|
||||
UnsatisfiedConstraint { error: Option<RuntimeError> },
|
||||
Solver,
|
||||
|
|
|
@ -124,7 +124,7 @@ mod ast {
|
|||
pub span: Span<'ast>,
|
||||
}
|
||||
|
||||
#[derive(Debug, FromPest, PartialEq, Clone)]
|
||||
#[derive(Debug, FromPest, PartialEq, Eq, Clone)]
|
||||
#[pest_ast(rule(Rule::pragma))]
|
||||
pub struct Pragma<'ast> {
|
||||
pub curve: Curve<'ast>,
|
||||
|
@ -132,7 +132,7 @@ mod ast {
|
|||
pub span: Span<'ast>,
|
||||
}
|
||||
|
||||
#[derive(Debug, FromPest, PartialEq, Clone)]
|
||||
#[derive(Debug, FromPest, PartialEq, Eq, Clone)]
|
||||
#[pest_ast(rule(Rule::curve))]
|
||||
pub struct Curve<'ast> {
|
||||
#[pest_ast(outer(with(span_into_str)))]
|
||||
|
@ -201,14 +201,14 @@ mod ast {
|
|||
pub span: Span<'ast>,
|
||||
}
|
||||
|
||||
#[derive(Debug, FromPest, PartialEq, Clone)]
|
||||
#[derive(Debug, FromPest, PartialEq, Eq, Clone)]
|
||||
#[pest_ast(rule(Rule::import_directive))]
|
||||
pub enum ImportDirective<'ast> {
|
||||
Main(MainImportDirective<'ast>),
|
||||
From(FromImportDirective<'ast>),
|
||||
}
|
||||
|
||||
#[derive(Debug, FromPest, PartialEq, Clone)]
|
||||
#[derive(Debug, FromPest, PartialEq, Eq, Clone)]
|
||||
#[pest_ast(rule(Rule::main_import_directive))]
|
||||
pub struct MainImportDirective<'ast> {
|
||||
pub source: AnyString<'ast>,
|
||||
|
@ -217,7 +217,7 @@ mod ast {
|
|||
pub span: Span<'ast>,
|
||||
}
|
||||
|
||||
#[derive(Debug, FromPest, PartialEq, Clone)]
|
||||
#[derive(Debug, FromPest, PartialEq, Eq, Clone)]
|
||||
#[pest_ast(rule(Rule::import_symbol))]
|
||||
pub struct ImportSymbol<'ast> {
|
||||
pub id: IdentifierExpression<'ast>,
|
||||
|
@ -226,7 +226,7 @@ mod ast {
|
|||
pub span: Span<'ast>,
|
||||
}
|
||||
|
||||
#[derive(Debug, FromPest, PartialEq, Clone)]
|
||||
#[derive(Debug, FromPest, PartialEq, Eq, Clone)]
|
||||
#[pest_ast(rule(Rule::from_import_directive))]
|
||||
pub struct FromImportDirective<'ast> {
|
||||
pub source: AnyString<'ast>,
|
||||
|
@ -244,7 +244,7 @@ mod ast {
|
|||
Tuple(TupleType<'ast>),
|
||||
}
|
||||
|
||||
#[derive(Debug, FromPest, PartialEq, Clone)]
|
||||
#[derive(Debug, FromPest, PartialEq, Eq, Clone)]
|
||||
#[pest_ast(rule(Rule::ty_basic))]
|
||||
pub enum BasicType<'ast> {
|
||||
Field(FieldType<'ast>),
|
||||
|
@ -255,7 +255,7 @@ mod ast {
|
|||
U64(U64Type<'ast>),
|
||||
}
|
||||
|
||||
#[derive(Debug, FromPest, PartialEq, Clone)]
|
||||
#[derive(Debug, FromPest, PartialEq, Eq, Clone)]
|
||||
#[pest_ast(rule(Rule::ty_field))]
|
||||
pub struct FieldType<'ast> {
|
||||
#[pest_ast(outer())]
|
||||
|
@ -279,42 +279,42 @@ mod ast {
|
|||
Tuple(TupleType<'ast>),
|
||||
}
|
||||
|
||||
#[derive(Debug, FromPest, PartialEq, Clone)]
|
||||
#[derive(Debug, FromPest, PartialEq, Eq, Clone)]
|
||||
#[pest_ast(rule(Rule::ty_bool))]
|
||||
pub struct BooleanType<'ast> {
|
||||
#[pest_ast(outer())]
|
||||
pub span: Span<'ast>,
|
||||
}
|
||||
|
||||
#[derive(Debug, FromPest, PartialEq, Clone)]
|
||||
#[derive(Debug, FromPest, PartialEq, Eq, Clone)]
|
||||
#[pest_ast(rule(Rule::ty_u8))]
|
||||
pub struct U8Type<'ast> {
|
||||
#[pest_ast(outer())]
|
||||
pub span: Span<'ast>,
|
||||
}
|
||||
|
||||
#[derive(Debug, FromPest, PartialEq, Clone)]
|
||||
#[derive(Debug, FromPest, PartialEq, Eq, Clone)]
|
||||
#[pest_ast(rule(Rule::ty_u16))]
|
||||
pub struct U16Type<'ast> {
|
||||
#[pest_ast(outer())]
|
||||
pub span: Span<'ast>,
|
||||
}
|
||||
|
||||
#[derive(Debug, FromPest, PartialEq, Clone)]
|
||||
#[derive(Debug, FromPest, PartialEq, Eq, Clone)]
|
||||
#[pest_ast(rule(Rule::ty_u32))]
|
||||
pub struct U32Type<'ast> {
|
||||
#[pest_ast(outer())]
|
||||
pub span: Span<'ast>,
|
||||
}
|
||||
|
||||
#[derive(Debug, FromPest, PartialEq, Clone)]
|
||||
#[derive(Debug, FromPest, PartialEq, Eq, Clone)]
|
||||
#[pest_ast(rule(Rule::ty_u64))]
|
||||
pub struct U64Type<'ast> {
|
||||
#[pest_ast(outer())]
|
||||
pub span: Span<'ast>,
|
||||
}
|
||||
|
||||
#[derive(Debug, FromPest, PartialEq, Clone)]
|
||||
#[derive(Debug, FromPest, PartialEq, Eq, Clone)]
|
||||
#[pest_ast(rule(Rule::ty_struct))]
|
||||
pub struct StructType<'ast> {
|
||||
pub id: IdentifierExpression<'ast>,
|
||||
|
@ -342,18 +342,18 @@ mod ast {
|
|||
pub span: Span<'ast>,
|
||||
}
|
||||
|
||||
#[derive(Debug, FromPest, PartialEq, Clone)]
|
||||
#[derive(Debug, FromPest, PartialEq, Eq, Clone)]
|
||||
#[pest_ast(rule(Rule::vis))]
|
||||
pub enum Visibility {
|
||||
Public(PublicVisibility),
|
||||
Private(PrivateVisibility),
|
||||
}
|
||||
|
||||
#[derive(Debug, FromPest, PartialEq, Clone)]
|
||||
#[derive(Debug, FromPest, PartialEq, Eq, Clone)]
|
||||
#[pest_ast(rule(Rule::vis_public))]
|
||||
pub struct PublicVisibility {}
|
||||
|
||||
#[derive(Debug, FromPest, PartialEq, Clone)]
|
||||
#[derive(Debug, FromPest, PartialEq, Eq, Clone)]
|
||||
#[pest_ast(rule(Rule::vis_private))]
|
||||
pub struct PrivateVisibility {}
|
||||
|
||||
|
@ -386,7 +386,7 @@ mod ast {
|
|||
pub span: Span<'ast>,
|
||||
}
|
||||
|
||||
#[derive(Debug, FromPest, PartialEq, Clone)]
|
||||
#[derive(Debug, FromPest, PartialEq, Eq, Clone)]
|
||||
#[pest_ast(rule(Rule::string))]
|
||||
pub struct AnyString<'ast> {
|
||||
#[pest_ast(outer(with(span_into_str)))]
|
||||
|
@ -423,7 +423,7 @@ mod ast {
|
|||
pub span: Span<'ast>,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Clone)]
|
||||
#[derive(Debug, PartialEq, Eq, Clone)]
|
||||
pub enum BinaryOperator {
|
||||
BitXor,
|
||||
BitAnd,
|
||||
|
@ -559,7 +559,7 @@ mod ast {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, FromPest, PartialEq, Clone)]
|
||||
#[derive(Debug, FromPest, PartialEq, Eq, Clone)]
|
||||
#[pest_ast(rule(Rule::op_unary))]
|
||||
pub enum UnaryOperator {
|
||||
Pos(PosOperator),
|
||||
|
@ -567,15 +567,15 @@ mod ast {
|
|||
Not(NotOperator),
|
||||
}
|
||||
|
||||
#[derive(Debug, FromPest, PartialEq, Clone)]
|
||||
#[derive(Debug, FromPest, PartialEq, Eq, Clone)]
|
||||
#[pest_ast(rule(Rule::op_pos))]
|
||||
pub struct PosOperator;
|
||||
|
||||
#[derive(Debug, FromPest, PartialEq, Clone)]
|
||||
#[derive(Debug, FromPest, PartialEq, Eq, Clone)]
|
||||
#[pest_ast(rule(Rule::op_neg))]
|
||||
pub struct NegOperator;
|
||||
|
||||
#[derive(Debug, FromPest, PartialEq, Clone)]
|
||||
#[derive(Debug, FromPest, PartialEq, Eq, Clone)]
|
||||
#[pest_ast(rule(Rule::op_not))]
|
||||
pub struct NotOperator;
|
||||
|
||||
|
@ -593,7 +593,7 @@ mod ast {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, FromPest, PartialEq, Clone)]
|
||||
#[derive(Debug, FromPest, PartialEq, Eq, Clone)]
|
||||
#[pest_ast(rule(Rule::primary_expression))]
|
||||
pub enum PrimaryExpression<'ast> {
|
||||
Identifier(IdentifierExpression<'ast>),
|
||||
|
@ -714,7 +714,7 @@ mod ast {
|
|||
TypedIdentifier(TypedIdentifier<'ast>),
|
||||
}
|
||||
|
||||
#[derive(Debug, FromPest, PartialEq, Clone)]
|
||||
#[derive(Debug, FromPest, PartialEq, Eq, Clone)]
|
||||
#[pest_ast(rule(Rule::_mut))]
|
||||
pub struct Mutable {}
|
||||
|
||||
|
@ -754,7 +754,7 @@ mod ast {
|
|||
pub span: Span<'ast>,
|
||||
}
|
||||
|
||||
#[derive(Debug, FromPest, PartialEq, Clone)]
|
||||
#[derive(Debug, FromPest, PartialEq, Eq, Clone)]
|
||||
#[pest_ast(rule(Rule::explicit_generics))]
|
||||
pub struct ExplicitGenerics<'ast> {
|
||||
pub values: Vec<ConstantGenericValue<'ast>>,
|
||||
|
@ -762,7 +762,7 @@ mod ast {
|
|||
pub span: Span<'ast>,
|
||||
}
|
||||
|
||||
#[derive(Debug, FromPest, PartialEq, Clone)]
|
||||
#[derive(Debug, FromPest, PartialEq, Eq, Clone)]
|
||||
#[pest_ast(rule(Rule::constant_generics_value))]
|
||||
pub enum ConstantGenericValue<'ast> {
|
||||
Value(LiteralExpression<'ast>),
|
||||
|
@ -770,7 +770,7 @@ mod ast {
|
|||
Underscore(Underscore<'ast>),
|
||||
}
|
||||
|
||||
#[derive(Debug, FromPest, PartialEq, Clone)]
|
||||
#[derive(Debug, FromPest, PartialEq, Eq, Clone)]
|
||||
#[pest_ast(rule(Rule::underscore))]
|
||||
pub struct Underscore<'ast> {
|
||||
#[pest_ast(outer())]
|
||||
|
@ -793,7 +793,7 @@ mod ast {
|
|||
pub span: Span<'ast>,
|
||||
}
|
||||
|
||||
#[derive(Debug, FromPest, PartialEq, Clone)]
|
||||
#[derive(Debug, FromPest, PartialEq, Eq, Clone)]
|
||||
#[pest_ast(rule(Rule::dot_access))]
|
||||
pub struct DotAccess<'ast> {
|
||||
pub inner: IdentifierOrDecimal<'ast>,
|
||||
|
@ -801,7 +801,7 @@ mod ast {
|
|||
pub span: Span<'ast>,
|
||||
}
|
||||
|
||||
#[derive(Debug, FromPest, PartialEq, Clone)]
|
||||
#[derive(Debug, FromPest, PartialEq, Eq, Clone)]
|
||||
#[pest_ast(rule(Rule::identifier_or_decimal))]
|
||||
pub enum IdentifierOrDecimal<'ast> {
|
||||
Identifier(IdentifierExpression<'ast>),
|
||||
|
@ -928,7 +928,7 @@ mod ast {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, FromPest, PartialEq, Clone)]
|
||||
#[derive(Debug, FromPest, PartialEq, Eq, Clone)]
|
||||
#[pest_ast(rule(Rule::literal))]
|
||||
pub enum LiteralExpression<'ast> {
|
||||
DecimalLiteral(DecimalLiteralExpression<'ast>),
|
||||
|
@ -946,7 +946,7 @@ mod ast {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, FromPest, PartialEq, Clone)]
|
||||
#[derive(Debug, FromPest, PartialEq, Eq, Clone)]
|
||||
#[pest_ast(rule(Rule::decimal_suffix))]
|
||||
pub enum DecimalSuffix<'ast> {
|
||||
U8(U8Suffix<'ast>),
|
||||
|
@ -956,49 +956,49 @@ mod ast {
|
|||
Field(FieldSuffix<'ast>),
|
||||
}
|
||||
|
||||
#[derive(Debug, FromPest, PartialEq, Clone)]
|
||||
#[derive(Debug, FromPest, PartialEq, Eq, Clone)]
|
||||
#[pest_ast(rule(Rule::decimal_suffix_u8))]
|
||||
pub struct U8Suffix<'ast> {
|
||||
#[pest_ast(outer())]
|
||||
pub span: Span<'ast>,
|
||||
}
|
||||
|
||||
#[derive(Debug, FromPest, PartialEq, Clone)]
|
||||
#[derive(Debug, FromPest, PartialEq, Eq, Clone)]
|
||||
#[pest_ast(rule(Rule::decimal_suffix_u16))]
|
||||
pub struct U16Suffix<'ast> {
|
||||
#[pest_ast(outer())]
|
||||
pub span: Span<'ast>,
|
||||
}
|
||||
|
||||
#[derive(Debug, FromPest, PartialEq, Clone)]
|
||||
#[derive(Debug, FromPest, PartialEq, Eq, Clone)]
|
||||
#[pest_ast(rule(Rule::decimal_suffix_u32))]
|
||||
pub struct U32Suffix<'ast> {
|
||||
#[pest_ast(outer())]
|
||||
pub span: Span<'ast>,
|
||||
}
|
||||
|
||||
#[derive(Debug, FromPest, PartialEq, Clone)]
|
||||
#[derive(Debug, FromPest, PartialEq, Eq, Clone)]
|
||||
#[pest_ast(rule(Rule::decimal_suffix_u64))]
|
||||
pub struct U64Suffix<'ast> {
|
||||
#[pest_ast(outer())]
|
||||
pub span: Span<'ast>,
|
||||
}
|
||||
|
||||
#[derive(Debug, FromPest, PartialEq, Clone)]
|
||||
#[derive(Debug, FromPest, PartialEq, Eq, Clone)]
|
||||
#[pest_ast(rule(Rule::decimal_suffix_field))]
|
||||
pub struct FieldSuffix<'ast> {
|
||||
#[pest_ast(outer())]
|
||||
pub span: Span<'ast>,
|
||||
}
|
||||
|
||||
#[derive(Debug, FromPest, PartialEq, Clone)]
|
||||
#[derive(Debug, FromPest, PartialEq, Eq, Clone)]
|
||||
#[pest_ast(rule(Rule::decimal_number))]
|
||||
pub struct DecimalNumber<'ast> {
|
||||
#[pest_ast(outer())]
|
||||
pub span: Span<'ast>,
|
||||
}
|
||||
|
||||
#[derive(Debug, FromPest, PartialEq, Clone)]
|
||||
#[derive(Debug, FromPest, PartialEq, Eq, Clone)]
|
||||
#[pest_ast(rule(Rule::decimal_literal))]
|
||||
pub struct DecimalLiteralExpression<'ast> {
|
||||
pub value: DecimalNumber<'ast>,
|
||||
|
@ -1007,7 +1007,7 @@ mod ast {
|
|||
pub span: Span<'ast>,
|
||||
}
|
||||
|
||||
#[derive(Debug, FromPest, PartialEq, Clone)]
|
||||
#[derive(Debug, FromPest, PartialEq, Eq, Clone)]
|
||||
#[pest_ast(rule(Rule::boolean_literal))]
|
||||
pub struct BooleanLiteralExpression<'ast> {
|
||||
#[pest_ast(outer(with(span_into_str)))]
|
||||
|
@ -1016,7 +1016,7 @@ mod ast {
|
|||
pub span: Span<'ast>,
|
||||
}
|
||||
|
||||
#[derive(Debug, FromPest, PartialEq, Clone)]
|
||||
#[derive(Debug, FromPest, PartialEq, Eq, Clone)]
|
||||
#[pest_ast(rule(Rule::hex_literal))]
|
||||
pub struct HexLiteralExpression<'ast> {
|
||||
pub value: HexNumberExpression<'ast>,
|
||||
|
@ -1024,7 +1024,7 @@ mod ast {
|
|||
pub span: Span<'ast>,
|
||||
}
|
||||
|
||||
#[derive(Debug, FromPest, PartialEq, Clone)]
|
||||
#[derive(Debug, FromPest, PartialEq, Eq, Clone)]
|
||||
#[pest_ast(rule(Rule::hex_number))]
|
||||
pub enum HexNumberExpression<'ast> {
|
||||
U8(U8NumberExpression<'ast>),
|
||||
|
@ -1033,7 +1033,7 @@ mod ast {
|
|||
U64(U64NumberExpression<'ast>),
|
||||
}
|
||||
|
||||
#[derive(Debug, FromPest, PartialEq, Clone)]
|
||||
#[derive(Debug, FromPest, PartialEq, Eq, Clone)]
|
||||
#[pest_ast(rule(Rule::hex_number_u8))]
|
||||
pub struct U8NumberExpression<'ast> {
|
||||
#[pest_ast(outer(with(span_into_str)))]
|
||||
|
@ -1042,7 +1042,7 @@ mod ast {
|
|||
pub span: Span<'ast>,
|
||||
}
|
||||
|
||||
#[derive(Debug, FromPest, PartialEq, Clone)]
|
||||
#[derive(Debug, FromPest, PartialEq, Eq, Clone)]
|
||||
#[pest_ast(rule(Rule::hex_number_u16))]
|
||||
pub struct U16NumberExpression<'ast> {
|
||||
#[pest_ast(outer(with(span_into_str)))]
|
||||
|
@ -1051,7 +1051,7 @@ mod ast {
|
|||
pub span: Span<'ast>,
|
||||
}
|
||||
|
||||
#[derive(Debug, FromPest, PartialEq, Clone)]
|
||||
#[derive(Debug, FromPest, PartialEq, Eq, Clone)]
|
||||
#[pest_ast(rule(Rule::hex_number_u32))]
|
||||
pub struct U32NumberExpression<'ast> {
|
||||
#[pest_ast(outer(with(span_into_str)))]
|
||||
|
@ -1060,7 +1060,7 @@ mod ast {
|
|||
pub span: Span<'ast>,
|
||||
}
|
||||
|
||||
#[derive(Debug, FromPest, PartialEq, Clone)]
|
||||
#[derive(Debug, FromPest, PartialEq, Eq, Clone)]
|
||||
#[pest_ast(rule(Rule::hex_number_u64))]
|
||||
pub struct U64NumberExpression<'ast> {
|
||||
#[pest_ast(outer(with(span_into_str)))]
|
||||
|
@ -1069,7 +1069,7 @@ mod ast {
|
|||
pub span: Span<'ast>,
|
||||
}
|
||||
|
||||
#[derive(Debug, FromPest, PartialEq, Clone)]
|
||||
#[derive(Debug, FromPest, PartialEq, Eq, Clone)]
|
||||
#[pest_ast(rule(Rule::identifier))]
|
||||
pub struct IdentifierExpression<'ast> {
|
||||
#[pest_ast(outer(with(span_into_str)))]
|
||||
|
@ -1091,7 +1091,7 @@ mod ast {
|
|||
span.as_str().to_string()
|
||||
}
|
||||
|
||||
#[derive(Debug, FromPest, PartialEq, Clone)]
|
||||
#[derive(Debug, FromPest, PartialEq, Eq, Clone)]
|
||||
#[pest_ast(rule(Rule::EOI))]
|
||||
#[allow(clippy::upper_case_acronyms)]
|
||||
pub struct EOI;
|
||||
|
@ -1105,7 +1105,7 @@ impl<'ast> From<Pairs<'ast, Rule>> for Prog<'ast> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Clone, Debug)]
|
||||
#[derive(PartialEq, Eq, Clone, Debug)]
|
||||
pub struct Error(PestError<Rule>);
|
||||
|
||||
impl fmt::Display for Error {
|
||||
|
|
|
@ -91,6 +91,8 @@ impl<T: SolidityCompatibleField> SolidityCompatibleScheme<T> for Marlin {
|
|||
type Proof = SolidityProof<Fr, G1Affine>;
|
||||
|
||||
fn export_solidity_verifier(vk: <Marlin as Scheme<T>>::VerificationKey) -> String {
|
||||
use std::fmt::Write;
|
||||
|
||||
let (template, solidity_pairing_lib) =
|
||||
(String::from(CONTRACT_TEMPLATE), solidity_pairing_lib(false));
|
||||
|
||||
|
@ -103,13 +105,15 @@ impl<T: SolidityCompatibleField> SolidityCompatibleScheme<T> for Marlin {
|
|||
.replace("<%vk_populate_index_comms%>", &{
|
||||
let mut populate_index_comms = String::new();
|
||||
for (i, (g, _)) in vk.index_comms.iter().enumerate() {
|
||||
populate_index_comms.push_str(&format!(
|
||||
write!(
|
||||
populate_index_comms,
|
||||
"vk.index_comms[{}] = Pairing.G1Point({});",
|
||||
i,
|
||||
&g.to_string()
|
||||
));
|
||||
)
|
||||
.unwrap();
|
||||
if i < vk.index_comms.len() - 1 {
|
||||
populate_index_comms.push_str("\n ");
|
||||
write!(populate_index_comms, "\n ").unwrap();
|
||||
}
|
||||
}
|
||||
populate_index_comms
|
||||
|
@ -167,10 +171,14 @@ impl<T: SolidityCompatibleField> SolidityCompatibleScheme<T> for Marlin {
|
|||
let mut populate_init_seed = String::new();
|
||||
for i in 0..vk.fs_seed.len() / 32 {
|
||||
let word_32_bytes = hex::encode(&vk.fs_seed[i * 32..i * 32 + 32]);
|
||||
populate_init_seed
|
||||
.push_str(&format!("init_seed[{}] = 0x{};", i, &word_32_bytes));
|
||||
write!(
|
||||
populate_init_seed,
|
||||
"init_seed[{}] = 0x{};",
|
||||
i, &word_32_bytes
|
||||
)
|
||||
.unwrap();
|
||||
if i < vk.fs_seed.len() / 32 - 1 {
|
||||
populate_init_seed.push_str("\n ");
|
||||
write!(populate_init_seed, "\n ").unwrap();
|
||||
}
|
||||
}
|
||||
populate_init_seed
|
||||
|
|
Loading…
Reference in a new issue