Comments (3)
Thanks for pointing this out.
I'm assuming when you say "curve25519 typically uses scalars ... and makes the key creator responsible", you're referring to X25519, which is not (currently) a part of dalek — different meanings should have different types, so I think an X25519 implementation would have a different type, like X25519Secret
or something. At the moment we've been busy with some other issues, so X25519 issues are on a back burner.
I think a Scalar
should be an element of ℤ/lℤ, as the documentation suggests — I'll check into this.
from curve25519-dalek.
Yes, I said curve25519 meaning X25519 but Ed25519 clears the low bits to multiply by the cofactor too. If one did not do so, then conversion between Ed25519 and X25519 might require an annoying shift operation.
These schemes have related base points which likely all have order l anyways, so that part is almost surely right, and perhaps important for Ed25519 somehow. Also, a Scalar
in ℤ/8lℤ does "represent" its quotient "scalar" in ℤ/lℤ, and an element chosen uniformly at random in ℤ/8lℤ yields a uniformly random element of ℤ/lℤ.
I doubt anything is wrong here, but it confused me when reading. :)
from curve25519-dalek.
I'm wrong. Adding this test shows your Scalar
is actually in ℤ/lℤ, not ℤ/8lℤ.
#[test]
fn test_highbits() {
let mut rng = ::rand::os::OsRng::new().unwrap();
let mut x = 0u8;
for i in 0..256 {
let s = Scalar::random(&mut rng);
x |= s[31];
}
assert!(x & 0xF0 != 0);
}
It's clear agl's Ed25519 has three bits more in the private scalar's high byte, so your private keys differ by a three bit shift, which costs nothing.
There might however be places where scalar multiplication alone is believed to sanitize the input but does not do so, and the point must first be multiplied by 8.
from curve25519-dalek.
Related Issues (20)
- Incorrect backend selection for non-standard targets HOT 26
- Testing build script in CI HOT 1
- Repo Issue Templates
- 4.0.0 Remaining Breaking Changes HOT 2
- Incompatibilities with sha2 crate HOT 2
- Hashing to curve missing? HOT 2
- CPU auto-detection feature / cfg gate HOT 7
- Failed backend override - Warning or Error
- Elligator2 inverse mapping HOT 5
- Update zeroize package. HOT 3
- Missing `Scalar::from_bits_clamped` HOT 2
- Broken `-Zminimal-versions` build
- `Scalar::from_bits` regression HOT 5
- Backport old tags HOT 3
- curve25519-dalek: disable SIMD on UEFI targets
- curve25519-dalek-derive performs unsound hiding of unsafety
- crypto_box compatibility is broken in [email protected] HOT 1
- ed25519-dalek: SigningKey.to_scalar() docs are incorrect HOT 4
- SubgroupPoint doesn't implement Default/subtle traits
- `Scalar` gets copied when moved revealing the secret value. HOT 9
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 curve25519-dalek.