Skip to content

Calling Secp256k1::randomize on a verification-only context will abort the process #82

@apoelstra

Description

@apoelstra

TIL that secp256k1_context_randomize actually requires a signing context, despite the docs not mentioning this. See bitcoin-core/secp256k1#573

The following code can trigger a process abort in a unit test (run with cargo test --features "rand")

diff --git a/src/lib.rs b/src/lib.rs
index 81cbc57..2b0a4a7 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1179,6 +1179,13 @@ mod tests {
 
         assert_tokens(&sig, &[Token::BorrowedBytes(&SIG_BYTES[..])]);
     }
+
+    #[cfg(feature="rand")]
+    #[test]
+    fn test_randomize() {
+        let mut s = Secp256k1::verification_only();
+        s.randomize(&mut ::rand::thread_rng());
+    }
 }

 #[cfg(all(test, feature = "unstable"))] 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions