-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Allow array of fields on public output #131
Changes from 2 commits
4a4fb69
c879418
3aa65fb
6d7f689
30f31ab
f6a563d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
@ noname.0.7.0 | ||
|
||
DoubleGeneric<1> | ||
DoubleGeneric<1> | ||
DoubleGeneric<1> | ||
DoubleGeneric<1,1,-1> | ||
DoubleGeneric<1,0,0,0,-2> | ||
DoubleGeneric<1,0,-1,0,6> | ||
DoubleGeneric<0,0,-1,1> | ||
DoubleGeneric<1,-1> | ||
DoubleGeneric<1,-1> | ||
(0,0) -> (7,0) | ||
(1,0) -> (8,0) | ||
(2,0) -> (3,1) -> (6,1) | ||
(3,2) -> (4,0) -> (5,0) -> (6,0) | ||
(5,2) -> (7,1) | ||
(6,2) -> (8,1) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
@ noname.0.7.0 | ||
|
||
2 == (v_3 + v_4) * (1) | ||
v_5 == (v_3 + v_4) * (v_3) | ||
v_3 + v_4 + 6 == (v_1) * (1) | ||
v_5 == (v_2) * (1) | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
fn main(pub public_input: Field, private_input: Field) -> [Field; 2] { | ||
let xx = private_input + public_input; | ||
assert_eq(xx, 2); | ||
let yy = xx + 6; | ||
return [yy, xx * public_input]; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -163,12 +163,15 @@ impl<B: Backend> CircuitWriter<B> { | |
|
||
// create public output | ||
if let Some(typ) = &function.sig.return_type { | ||
if typ.kind != TyKind::Field { | ||
unimplemented!(); | ||
match typ.kind { | ||
TyKind::Field => { | ||
circuit_writer.add_public_outputs(1, typ.span); | ||
} | ||
TyKind::Array(_, len) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this is correct as this won't work if you have I think a quick fix here could be to match for |
||
circuit_writer.add_public_outputs(len as usize, typ.span); | ||
} | ||
_ => unimplemented!(), | ||
} | ||
|
||
// create it | ||
circuit_writer.add_public_outputs(1, typ.span); | ||
} | ||
|
||
// public inputs should be handled first | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
^ this last constraint seems really useless, we should optimize that, I'll create an issue :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean the second constraint should be instead
v_2 = (v_3 + v_4) * (v_3)
?v_1
andv_2
are the outputs and they have to be constrainedThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah!
v_2 == (v_3 + v_4) * v_3
would have been better. But I don't think we should look to create such optimization, because an optimization pass that would do inlining would easily inline the last constraint