Skip to content
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: Private input integration #622

Merged
merged 20 commits into from
Nov 25, 2024
Merged

Feat: Private input integration #622

merged 20 commits into from
Nov 25, 2024

Conversation

naure
Copy link
Collaborator

@naure naure commented Nov 21, 2024

Issue #614.
Pending a solution in #625

@naure naure changed the base branch from master to cleanup/platform-range November 21, 2024 19:03
@naure naure force-pushed the feat/private-input-2 branch from dba2a79 to acccad7 Compare November 21, 2024 19:32
_Follow-up to #620_

Simplify the `Platform` type by exposing the `Range` type.

Co-authored-by: Aurélien Nicolas <[email protected]>
Base automatically changed from cleanup/platform-range to cleanup/exclusive-ranges November 22, 2024 07:56
@naure naure requested review from lispc and hero78119 November 22, 2024 11:26
@naure naure marked this pull request as ready for review November 22, 2024 11:26
@naure naure changed the title Feat/private input 2 Feat: Private input integration Nov 22, 2024
@naure naure requested a review from lightsing November 22, 2024 12:08
let priv_io = memory_from_file(&args.private_input);
for (addr, value) in zip(platform.private_io.iter_addresses(), &priv_io) {
vm.init_memory(addr.into(), *value);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we add a comment to say, if len(private_io) != len(private_input_file), then it is right-padded with 0s?

Copy link
Collaborator Author

@naure naure Nov 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. It is not padded. Or precisely it is zero-padded only to the next power-of-two size.

The rest of memory does not exist - unsatisfiable if the program tries to use it.

(added a comment and assert)

Copy link
Collaborator

@matthiasgoergens matthiasgoergens Nov 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For technical reasons, if we are using rkyv, it would be better to pad from the left by default.

That's means the last byte that's specified should always appear in the same position in the VM.

The rest of memory does not exist - unsatisfiable if the program tries to use it.

That's good, and exactly what we want. Can you please make both the doc comment and the emulator reflect that behaviour?

Btw, would it be possible to make both kinds of padding be 'inaccessible' (from the point of view of the VM), instead of a mix of 0 and 'inaccessible'? That would be best!

Base automatically changed from cleanup/exclusive-ranges to master November 22, 2024 14:07
Copy link
Collaborator

@matthiasgoergens matthiasgoergens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For rkyv it would be best if we could pad on the left, ie the last byte specified by the user of the prover should always appear in the same address in the VM. Where the first byte appears should be a function of the length of the input specified.

As far as I can tell, we pad the input given with 0s to the next power of two, and then we pad the rest with ‘inaccessible bytes’. That’s good, but we need them from the left.

We can either hard code this to come from the left, or we can make it so that the ‘core’ functions always need the placement specified exactly, and then have a relatively thin shell of helper functionality on the outside that does the necessary calculations.

(The latter would be useful, if we want to explore other deserialisation schemes, because I suspect rkyv is a bit special in wanting left padding. But we can also just hardcode it now, because having extra mostly unused customisation options around is also a hassle in testing and maintenance.)

Copy link
Collaborator

@matthiasgoergens matthiasgoergens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see my comments.

Specifically I want to highlight two points:

  1. left padding is more useful that right padding for us.
  2. could we unify the padding to be 'inaccessible' values only, instead of a mix of 0 and 'inaccessible'?

If we do right padding by default, please leave a comment that it's because of rkyv. If you make it configurable, then we'll leave the comment on one of the outer layer helper functions.

ceno_emul/src/addr.rs Show resolved Hide resolved
ceno_emul/src/platform.rs Show resolved Hide resolved
ceno_zkvm/src/bin/e2e.rs Show resolved Hide resolved
ceno_zkvm/src/bin/e2e.rs Show resolved Hide resolved
@@ -94,6 +101,17 @@ fn main() {
let elf_bytes = fs::read(&args.elf).expect("read elf file");
let mut vm = VMState::new_from_elf(platform.clone(), &elf_bytes).unwrap();

tracing::info!("Loading private input file: {:?}", args.private_input);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the discussion about private IO, someone suggested to use the term 'hint' throughout?

('Private input' works perfectly fine for me; but I remember some people having strong opinions on this.)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the ref. If the term "hint" is understood I’ll rename things to that.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No worries, you can do that after you finish the sproll-evm test.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ceno_zkvm/src/bin/e2e.rs Show resolved Hide resolved
@naure naure merged commit a76d586 into master Nov 25, 2024
6 checks passed
@naure naure deleted the feat/private-input-2 branch November 25, 2024 17:53
hero78119 added a commit that referenced this pull request Nov 29, 2024
A follow-up PR after #622

In #622 integration test was failed in first place. A proposed fix in
comment
#622 (comment) is
to skip the entire proof when table size should be 0. This fix is
reasonable and fit the expectation, however, the integration test should
NOT failed even BEFORE this fix. It should be garbage-in, garbage out
and shouldn't break the proof.

### Root cause
The root cause is when table size is 1 (we will padding next size which
is 2) or 2, in tower sumcheck there will be empty rounds. In tower
sumcheck verifier, there are bookkeeping variables to tracking each
layer (evaluation, point), and bookkeeping variables will keep updated
when goes through layer by layer verification. However when table size
is 2, there is only one layer, so bookkeeping variables skip updated.
However in this case, default value was wrong. The correct "default"
value of bookkeeping variable should be the output layer evaluations.

This PR correcting the default value design. Also add simple test to
verify the logic.

Co-authored-by: Wu Sung-Ming <[email protected]>
Co-authored-by: naure <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants