Skip to content

Commit

Permalink
fix keygen
Browse files Browse the repository at this point in the history
  • Loading branch information
AlbertoSvg committed Mar 27, 2024
1 parent 495393b commit d7a1643
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "zkryptium"
version = "0.2.0"
version = "0.2.1"
edition = "2021"
license = "Apache-2.0"
authors = ["LINKS Foundation"]
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ This library enables the creation of zero-knowledge proofs, exposing cryptograph

```toml
[dependencies]
zkryptium = { version = "0.2.0", default-features = false, features = ["bbsplus"] }
zkryptium = { version = "0.2.1", default-features = false, features = ["bbsplus"] }
```

##### CL2003:
- see the **requirements** above

```toml
[dependencies]
zkryptium = { version = "0.2.0", default-features = false, features = ["cl03"] }
zkryptium = { version = "0.2.1", default-features = false, features = ["cl03"] }
```

### Examples
Expand Down
23 changes: 22 additions & 1 deletion src/bbsplus/keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use crate::{
},
schemes::algorithms::BBSplus,
utils::util::bbsplus_utils::{
hash_to_scalar, i2osp, parse_g2_projective_compressed, parse_g2_projective_uncompressed,
generate_random_secret, hash_to_scalar, i2osp, parse_g2_projective_compressed, parse_g2_projective_uncompressed
},
};
use bls12_381_plus::{G2Affine, G2Projective, Scalar};
Expand Down Expand Up @@ -164,6 +164,27 @@ impl<CS: BbsCiphersuite> KeyPair<BBSplus<CS>> {
private: BBSplusSecretKey(sk),
})
}

/// # Description
/// This operation generates a random keypair (SK, PK)
///
/// # Output:
/// * a keypair [`KeyPair`]
pub fn random() -> Result<Self, Error>
where
CS::Expander: for<'a> ExpandMsg<'a>,
{
let key_material = generate_random_secret(64);

let sk = key_gen::<CS>(&key_material, None, None)?;

let pk = sk_to_pk(sk);

Ok(Self {
public: BBSplusPublicKey(pk),
private: BBSplusSecretKey(sk),
})
}
}

/// https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-bbs-signatures-05#name-secret-key -> SK = KeyGen(key_material, key_info, key_dst)
Expand Down

0 comments on commit d7a1643

Please sign in to comment.