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

core: Fix panic when trying to decrypt the value for a note with an incorrect viewkey #240

Closed
moCello opened this issue Aug 13, 2024 · 0 comments · Fixed by #241
Closed
Labels
fix:bug Something isn't working

Comments

@moCello
Copy link
Member

moCello commented Aug 13, 2024

Describe the bug
When attempting to decrypt the value for an obfuscated note with a view-key that doesn't own the note, the code doesn't error but panics due to entering unreachable code.

To Reproduce
In tests/note_test add:

#[test]
fn note_not_owned() {
    let mut rng = StdRng::seed_from_u64(0xc0b);

    let owner_pk = PublicKey::from(&SecretKey::random(&mut rng));
    let value_blinder = JubJubScalar::random(&mut rng);
    let sender_blinder = [
        JubJubScalar::random(&mut rng),
        JubJubScalar::random(&mut rng),
    ];

    let note = Note::obfuscated(
        &mut rng,
        &owner_pk,
        &owner_pk,
        42,
        value_blinder,
        sender_blinder,
    );

    let not_owner_sk = SecretKey::random(&mut rng);
    let not_owner_vk = ViewKey::from(&not_owner_sk);

    assert!(note.value(Some(&not_owner_vk)).is_err());
}

and run the test:

cargo test --tests note_not_owned

Expected behaviour
In case of an error we should gracefully return the error and not panic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix:bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant