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).

Home Page:https://wiki.hyperledger.org/display/ursa

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Create a subproject for core components

mikelodder7 opened this issue · comments

Ursa will have many traits and structures that will be common across subprojects. The idea is that if at least two subprojects have a common item, this can live in the core subproject.

Here is a list of the currently known components that can live here

As part of this the Keys struct should be changed to be a placeholder trait such that each consuming subproject can expand it in their own way without having to extend an enum.

For example, all the keys are just generic wrappers around byte arrays like PrivateKey. While it works, Rust can provide stronger typing that wrapping a generic Vec.

If PrivateKey were changed to

pub trait PrivateKey: Zeroize {
  fn to_bytes(&self, compressed: bool) -> Vec<u8>;
  fn from_bytes(data: &[u8], compressed: bool) -> UrsaResult<Self>;
}

The BLS, Ed25519, ECDSA could provide an implemented version that is the specific to them that is stronger typed

pub struct BLSPrivateKey([u8; 32]);

impl Zeroize for BLSPrivateKey {...}

impl PrivateKey for BLSPrivateKey {...}

We can similarly apply the same idea to the current enum KeyGenOption.

In the end, key generation should be flexible enough to be usable by any crypto primitive like signatures, short group signatures, post quantum methods, and others.

This also facilitates the FFI and WASM wrappers to just return the generic PrivateKey trait as part of their interfaces without having to worry about the specific implementations.