-
Notifications
You must be signed in to change notification settings - Fork 74
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
base: feat/poseidon-halo2
Are you sure you want to change the base?
Authdecode #479
Conversation
- simpify protocol - rebase on dev - add mock backend - fix failing tests - use dedicated field element for salt
This will make handling of commitments easier for the user since there will be no need to perform bit manipulations.
Any news on this PR? |
21af97d
to
d225791
Compare
The last force-push removes Cargo.toml from the commit, which will simplify dealing with merge conflicts in the integration PR. |
Ready for review. |
@sinui0 , I re-added you for review. |
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.
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" |
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.
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} |
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.
nit: leave a space in front of "}"
use serde::{Deserialize, Serialize}; | ||
|
||
/// The statistical security parameter used by the protocol. | ||
pub const SSP: usize = 40; |
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.
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()); |
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.
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() { |
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.
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. |
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.
/// 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; |
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.
what's the reason we dont use all 32 bytes here?
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.