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

fix capacity overflow error #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

qope
Copy link

@qope qope commented Apr 30, 2023

The test test_overflow is failing due to the inappropriate handling of the limb count in the BigUint implementation.

#[cfg(test)]
mod tests {
    use crate::gadgets::nonnative::CircuitBuilderNonNative;
    use plonky2::{
        field::{secp256k1_base::Secp256K1Base, types::Field},
        iop::witness::PartialWitness,
        plonk::{
            circuit_builder::CircuitBuilder,
            circuit_data::CircuitConfig,
            config::{GenericConfig, PoseidonGoldilocksConfig},
        },
    };

    #[test]
    fn test_overflow() {
        const D: usize = 2;
        type C = PoseidonGoldilocksConfig;
        type F = <C as GenericConfig<D>>::F;
        let config = CircuitConfig::standard_ecc_config();

        let pw = PartialWitness::<F>::new();
        let mut builder = CircuitBuilder::<F, D>::new(config);

        let a = Secp256K1Base::from_canonical_u32(1);
        let b = Secp256K1Base::from_canonical_u32(2);

        let a_t = builder.constant_nonnative(a);
        let b_t = builder.constant_nonnative(b);
        let _c_t = builder.mul_nonnative(&a_t, &b_t);

        let data = builder.build::<C>();
        let proof = data.prove(pw).unwrap();
        data.verify(proof).unwrap();
    }
}

Result

running 1 test
test tests::test_overflow ... FAILED

failures:

---- tests::test_overflow stdout ----
thread 'tests::test_overflow' panicked at 'capacity overflow', library/alloc/src/raw_vec.rs:525:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


failures:
    tests::test_overflow

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 36 filtered out; finished in 0.00s

jorgeantonio21 pushed a commit to jorgeantonio21/plonky2-ecdsa that referenced this pull request Sep 19, 2023
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.

1 participant