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

Authdecode #479

Open
wants to merge 21 commits into
base: feat/poseidon-halo2
Choose a base branch
from
Open

Authdecode #479

wants to merge 21 commits into from

Conversation

themighty1
Copy link
Member

This PR implements the AuthDecode protocol to be used to create zk-friendly commitments.

Temporarily, it uses a zk circuit which reveals to the Verifier the ranges being committed to. In the future, we will modify the circuit to hide the ranges.

@themighty1 themighty1 requested a review from sinui0 April 30, 2024 09:03
@irux
Copy link

irux commented Jul 24, 2024

Any news on this PR?

@themighty1 themighty1 changed the base branch from dev to feat/poseidon-halo2 October 10, 2024 12:45
@themighty1
Copy link
Member Author

The last force-push removes Cargo.toml from the commit, which will simplify dealing with merge conflicts in the integration PR.

@themighty1
Copy link
Member Author

Ready for review.

@themighty1 themighty1 requested review from sinui0 and removed request for sinui0 October 10, 2024 13:53
@themighty1
Copy link
Member Author

@sinui0 , I re-added you for review.

Copy link
Member

@yuroitaki yuroitaki left a comment

Choose a reason for hiding this comment

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

Amazing work 🚀 🚀 🚀 love the generic api design, and how the halo2 circuit implementation is more streamlined and simpler now

blake3 = { workspace = true, optional = true}
cfg-if = "1"
enum-try-as-inner = { workspace = true }
ff = "0.13"
Copy link
Member

Choose a reason for hiding this comment

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

nit: i think we're adopting the format of always using { version = "0.13" } in the project?

[dependencies]
poseidon-halo2 = { workspace = true }

bincode = { workspace = true, optional = true}
Copy link
Member

@yuroitaki yuroitaki Oct 25, 2024

Choose a reason for hiding this comment

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

nit: leave a space in front of "}"

use serde::{Deserialize, Serialize};

/// The statistical security parameter used by the protocol.
pub const SSP: usize = 40;
Copy link
Member

Choose a reason for hiding this comment

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

is this a common widely used acronym? if not it might be better to spell it out to aid understanding when this const is used elsewhere

let plaintext_hash =
backend.commit_plaintext_with_salt(self.encodings.plaintext(), salt.clone());

let (encoding_sum_hash, encoding_sum_salt) = backend.commit_encoding_sum(sum.clone());
Copy link
Member

@yuroitaki yuroitaki Oct 25, 2024

Choose a reason for hiding this comment

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

there is no way for a user to use his own salt for encoding sum commitment?

.map_err(|_| serde::de::Error::custom("the amount of bytes is not 32"))?;

let res = Fr::from_bytes(&bytes);
if res.is_none().into() {
Copy link
Member

Choose a reason for hiding this comment

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

should be able to change L120 - L126 into something simpler and without unwrap()? like

Fr::from_bytes(&bytes)
    .ok_or(serde::de::Error::custom(
        "the bytes are not a valid field element",
     ))

#[derive(Clone, Debug)]
/// The AuthDecode circuit.
pub struct AuthDecodeCircuit {
/// The bits of plaintext which was committed to. Each bit is represente as a field element.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
/// The bits of plaintext which was committed to. Each bit is represente as a field element.
/// The bits of plaintext which was committed to. Each bit is represented as a field element.

pub const FIELD_ELEMENTS: usize = 14;

/// How many least significant bytes of a field element to use to pack the plaintext into.
pub const USABLE_BYTES: usize = 31;
Copy link
Member

Choose a reason for hiding this comment

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

what's the reason we dont use all 32 bytes here?

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.

4 participants