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

Generate padding point using ChaCha20Rng directly #31

Closed
wants to merge 2 commits into from

Conversation

davxy
Copy link
Collaborator

@davxy davxy commented Sep 16, 2024

Directly generate padding point using blake2b and ChaCha20Rng

use ark_std::{rand::SeedableRng, UniformRand};
use blake2::Digest;
let seed = blake2::Blake2b::digest(b"w3f/ring-proof/common/padding");
Affine::<Curve>::rand(&mut rand_chacha::ChaCha20Rng::from_seed(seed.into()))
Copy link
Collaborator

@burdges burdges Sep 18, 2024

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

@davxy davxy Sep 18, 2024

Choose a reason for hiding this comment

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

Indeed I'd prefer a simpler try and increment. As it would be easily replicable in a python script to store within the spec. Using rand as we're doing here, we mostly rely on the way Rust implemented it. Which is not 100% nice IMHO.

We first need go generate the X coord (I'm assuming weierstrass) and then we recover Y using https://github.com/arkworks-rs/algebra/blob/b33df5cce2d54cf4c9248e4b229c7d6708fa9375/ec/src/models/short_weierstrass/affine.rs#L105

To generate X we use a hashing algorithm applied to something like b"ring-proof-padding" || counter.
(counter is incremented in a loop until we don't find a valid point, which is expected to happen on average after 2 iterations). This is quite similar to the TAI method described in section 5.4.1.1 of https://datatracker.ietf.org/doc/rfc9381/

The only issue is, what hashing we use? I mean, if we use blake2 we can generate an X with at most 512 bits. Is this acceptable (I guess yes, at least yes for all the curves provided by arkworks)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

#32

Copy link
Collaborator

@burdges burdges left a comment

Choose a reason for hiding this comment

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

LGTM but..

@swasilyev should confirm if this point needs to be in the prime order group. Or if he needs a point in the coset somewhere.

@davxy davxy marked this pull request as draft September 18, 2024 10:20
@davxy
Copy link
Collaborator Author

davxy commented Sep 18, 2024

Superseded by #32.

@davxy davxy closed this Sep 18, 2024
@davxy davxy deleted the padding-point-gen branch September 21, 2024 08:03
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.

2 participants