hyperledger-archives / ursa

Hyperledger Ursa (a shared cryptographic library) has moved to end-of-life status, with the components of Ursa still in use moved to their relevant Hyperledger projects (AnonCreds, Indy, Aries and Iroha).
https://wiki.hyperledger.org/display/ursa
Apache License 2.0
321 stars 142 forks source link

`ursa` crashes on seed lenght shorter than 32 bytes for `secp256k1` #213

Open Erigara opened 2 years ago

Erigara commented 2 years ago

Ursa crashes if seed length is less than 32 bytes for secp256k1, but other algorithms work fine with this seed.

The problem seems to be that in other cases the input seed is hashed before being passed to the rng generator.

Minimal example that reproduce issue

use ursa::{
    keys::KeyGenOption,
    signatures::{
        secp256k1::EcdsaSecp256k1Sha256,
        SignatureScheme,
    },
};

fn main() {
    let options = KeyGenOption::UseSeed(vec![1, 2, 3]);
    let key_pair = EcdsaSecp256k1Sha256::new().keypair(Some(options));
    println!("{:?}", key_pair);
}