Comments (3)
The asymmetry is intentional. Users of the library are intended to either (more commonly) receive Choice
values or (less commonly) construct Choice
values, and then use those Choice
s to do constant-time operations, not to convert them back into bool
s for use with branches etc.
The method is called unwrap_u8
to indicate that it "unwraps" the type-safe abstraction to provide a "raw" value. It is an escape hatch, which may be required in order to write custom implementations of the subtle
traits (e.g., in the SIMD backend of curve25519-dalek
), but it is not supposed to be the common-path.
Using x != 0
does not work, because that compiles into a branch – the decision to use u8
s rather than bool
s was intentional.
from subtle.
Hmm, so if you see unwrap_u8
as unsafe, maybe it should be an unsafe method?
from subtle.
I don't think that unsafe
is appropriate here, because it indicates that something is outside of the Rust abstract machine, rather than just "this API has sharp edges and can be misused".
from subtle.
Related Issues (20)
- derive macros to extend constant-time comparisons to user-defined aggregate structs
- Use predication intrinsics (i.e. CMOV) for `ConditionallySelectable` HOT 2
- Remove TravisCI and add github worker
- Tiny bug in test HOT 1
- Clarify assembly review
- Exposing constant-time `is_zero`? HOT 3
- Outdated code in https://doc.dalek.rs/src/ ? HOT 1
- Choice: invariant not upheld in release mode HOT 1
- should the `black_box` asm block be marked volatile? HOT 5
- Prusti for verified Rust crypto HOT 2
- Nightly building issue HOT 2
- Conversions between CtOption and Option HOT 1
- Implement ok_or() for CtOption<T> HOT 11
- Subtle2.3.0 cannot be compiled on my machine HOT 5
- Implement `ConditionallySelectable` for `[T; N]`? HOT 2
- Ensuring `no_std` for subtle HOT 4
- Incorrect explanation of Unsafe usages HOT 2
- Alternative license HOT 1
- Combine multiple `CtOption`al results HOT 1
- Support ConditionallySelectable for types that are not Copy HOT 12
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 subtle.