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

threshold checking for hotshot state prover #1901

Merged
merged 22 commits into from
Nov 9, 2023
Merged

Conversation

mrain
Copy link
Contributor

@mrain mrain commented Oct 10, 2023

closes: #1900

Should be simple enough

@mrain mrain marked this pull request as draft October 10, 2023 21:58
@mrain
Copy link
Contributor Author

mrain commented Oct 10, 2023

Circuit logic is done.

We may still need to alter the stake table design. As every user now has 2 keys.

Copy link
Contributor

@alxiong alxiong left a comment

Choose a reason for hiding this comment

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

would be great if we can add unit tests incrementally as we build along.

We may still need to alter the stake table design. As every user now has 2 keys.

our current stake table impl is generic over K: Key type, which could be just a tuple of (BLSVerKey, SchnorrVerKey).

also when we are computing the stake table commitment, we can commit over the compressed BLS points concatenated with the uncompressed Schnorr (since we need the full for verification), this will slightly improve the circuit size as we need to hash fewer elements.
(ofc, need consistency inside and outside circuit, luckily, we can hide this optimization under a uniformed abstracted StakeTable::commitment() API)

Cargo.toml Outdated Show resolved Hide resolved
crates/hotshot-state-prover/src/circuit/config.rs Outdated Show resolved Hide resolved
crates/hotshot-state-prover/src/circuit/types.rs Outdated Show resolved Hide resolved
crates/hotshot-state-prover/src/circuit/types.rs Outdated Show resolved Hide resolved
crates/hotshot-state-prover/src/circuit/types.rs Outdated Show resolved Hide resolved
/// - the signer's accumulated weight exceeds the quorum threshold
/// - the commitment of the stake table
/// - all schnorr signatures are valid
pub fn build<ST, P>(
Copy link
Contributor

Choose a reason for hiding this comment

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

this is fn build_for_preprocessing instead? (alternatively, maybe via an enum input argument to indicate preprocessing mode or proving mode)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm thinking whether we should only export a single API for proof generation only, w/o exposing these details about circuit.
These interface issues could be finalized when doing proof generation: #1985

crates/hotshot-state-prover/src/circuit/types.rs Outdated Show resolved Hide resolved

/// HotShot state Variable
#[derive(Clone, Debug)]
pub struct HotShotStateVar {

Choose a reason for hiding this comment

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

Maybe add a From() method converting between HotShotStateVar and HotshotState.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Such From() also needs to take a circuit as input. Doesn't seems possible.

crates/hotshot-state-prover/src/circuit.rs Outdated Show resolved Hide resolved
crates/hotshot-state-prover/src/circuit.rs Outdated Show resolved Hide resolved
crates/hotshot-state-prover/src/circuit.rs Show resolved Hide resolved
@mrain mrain mentioned this pull request Nov 3, 2023
5 tasks
@mrain mrain marked this pull request as ready for review November 8, 2023 16:43
Copy link

@chancharles92 chancharles92 left a comment

Choose a reason for hiding this comment

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

LGTM

crates/types/src/traits/state.rs Outdated Show resolved Hide resolved
crates/hotshot-state-prover/src/circuit.rs Outdated Show resolved Hide resolved
alxiong
alxiong previously approved these changes Nov 9, 2023
@mrain mrain merged commit 7a31cae into develop Nov 9, 2023
7 checks passed
@mrain mrain deleted the state-prover-startup branch November 9, 2023 17:28
dailinsubjam pushed a commit that referenced this pull request Nov 11, 2023
* threshold checking circuit

* change some variables to public

* comments & tests(TBD)

* doing test

* test

* Adding back the bls_comm

* small refactor for test

* use `STAKE_TABLE_CAPACITY`

* Move state definition to another crate

* Formatting

* merge imports

* augment test & comments

* Addressing comments

* duplicated items
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.

[hotshot-state-prover] threshold checking
3 participants