Comments (6)
You claim that the group order must be explicitly stated?
Btw, this is not a secret key , just a random field element...
from curv.
No, actually you can just use SK::new(&mut thread_rng());
I mean for this code:
impl Secp256k1Point {
pub fn random_point() -> Self {
let random_scalar: Secp256k1Scalar = Secp256k1Scalar::new_random(); // <- if it's not a valid secret key, the whole thing crashes
let base_point = Self::generator();
let pk = base_point.scalar_mul(&random_scalar.get_element());
Self {
purpose: "random_point",
ge: pk.get_element(),
}
}
}
from curv.
Using SK::new(&mut thread_rng());
is the same as what I am doing.
The secp256k1 library is taking care on how to securely sample the number in the field. When the consumed library provide this service (and in this case it's even constant time) then I prefer to use it than to write my own random sampler. i.e. to avoid stuff like the first vulnerability in the audit:
https://github.com/KZen-networks/curv/blob/master/audit/kzen-curv-audit%20final%2003.01.2019.pdf
from curv.
Hmm...It's little different since it's possibly continuously generating valid random bytes in the library:
impl SecretKey {
/// Creates a new random secret key. Requires compilation with the "rand" feature.
#[inline]
#[cfg(any(test, feature = "rand"))]
pub fn new<R: Rng + ?Sized>(rng: &mut R) -> SecretKey {
let mut data = random_32_bytes(rng);
unsafe {
while ffi::secp256k1_ec_seckey_verify(
ffi::secp256k1_context_no_precomp,
data.as_ptr(),
) == 0
{
data = random_32_bytes(rng);
}
}
SecretKey(data)
}
// ...
}
from curv.
Suggest changing it to
fn new_random() -> Self {
Self {
purpose: "random",
fe: SK::new(&mut thread_rng()),
}
}
which looks nicer :)
from curv.
this is called rejection sampling and this is the right and secure way to generate this random number.
from curv.
Related Issues (20)
- Update `hmac` dependency HOT 1
- Suboptimal serialization of certain structs HOT 4
- Feature request: serialization in v0.7 HOT 1
- suggested additions to Polynomial HOT 2
- Zero Polynomial degree is returning 0
- Implement Zeroize for `Point<E>`
- ed25519::GE fails in serialization and deserialization HOT 10
- Serialization doesn't work with bincode
- Build error: could not find `traits` in `super` HOT 4
- Update crate to latest revision of source code. HOT 1
- generate pk should know the curve
- Bump p256 to 0.11.1 HOT 3
- Incorrect documentation for `check_point_order_equals_group_order` HOT 2
- Updating `curv` dependency in `kzen-paillier`
- Choices between G1Point and Point<Bls12_381_1> in v0.10.0
- Add support for RustCrypto's crypto-bigint HOT 3
- Why use a point as generator instead of a number in feldman vss?
- Deserialization fails for `Secp256k1Scalar`
- Is pairing still considered experimental?
- Build failing on rust 1.73.0
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from curv.