The first constructor requires a Scalar type, which must match the exact same k256 version that vsss_rs uses (currently 0.11, but 0.12 is out). Else, we have this problem:
error[E0277]: the trait bound `vsss_rs::secp256k1::WrappedScalar: From<Scalar>` is not satisfied
...
= help: the following other types implement trait `From<T>`:
<vsss_rs::secp256k1::WrappedScalar as From<k256::arithmetic::scalar::Scalar>>
<vsss_rs::secp256k1::WrappedScalar as From<u64>>
= note: required for `Scalar` to implement `Into<vsss_rs::secp256k1::WrappedScalar>`
The second constructor will not work with 256-bit keys, if I understand correctly.
There also some other constructors (e.g., from_be_bytes_reduced), but it's not clear how one can use them (not a fault of this repo, the elliptic_curves is a bit lacking in this regard).
Why is the above a problem? Consider someone running the examples in this repo:
use k256::{NonZeroScalar, SecretKey};
[...]
let sk = SecretKey::random(&mut osrng);
let secret = WrappedScalar(*sk.to_nonzero_scalar());
Rust will complain that the Scalar type that vsss_rs expects (0.11) is different from the provided k256::Scalar type (0.12). The only way I've found to circumvent this limitation is to use an older version of k256 (0.11), specifically for importing a k256::SecretKey, which will produce a proper k256::Scalar type (0.11).
This is of course a bit esoteric, and prone to breakage. A better suggestion would be to re-export k256::SecretKey from this module (as k256 already does for the elliptic_curves::SecretKey), and let library consumers use that.
Do you agree, do you perhaps have a better suggestion?
The
secp256k1::WrappedScalar
has the following constructors:The problems with these constructors are:
The first constructor requires a
Scalar
type, which must match the exact samek256
version thatvsss_rs
uses (currently 0.11, but 0.12 is out). Else, we have this problem:There also some other constructors (e.g.,
from_be_bytes_reduced
), but it's not clear how one can use them (not a fault of this repo, theelliptic_curves
is a bit lacking in this regard).Why is the above a problem? Consider someone running the examples in this repo:
Rust will complain that the
Scalar
type thatvsss_rs
expects (0.11) is different from the providedk256::Scalar
type (0.12). The only way I've found to circumvent this limitation is to use an older version ofk256
(0.11), specifically for importing ak256::SecretKey
, which will produce a properk256::Scalar
type (0.11).This is of course a bit esoteric, and prone to breakage. A better suggestion would be to re-export
k256::SecretKey
from this module (ask256
already does for theelliptic_curves::SecretKey
), and let library consumers use that.Do you agree, do you perhaps have a better suggestion?