[−][src]Crate nisty
Library for NIST P256 signatures, for when you really need them.
This library completely decouples entropy from key generation and signatures, and offers a similar API as salty.
In particular, all signatures are deterministic, similar to RFC 6979.
The flip side of this is that we need to pull in a CSRNG, for the ultra-rare case where a 32-byte seed does not directly give rise to a valid keypair; we use ChaCha20.
In the backend, this library currently uses micro-ecc, exposed via micro-ecc-sys.
Example
let seed = [1u8; 32]; // use an actually entropic seed let keypair = nisty::Keypair::from(&seed); let message = b"hello, nisty"; let signature = keypair.sign(message); assert!(keypair.public.verify(message, &signature));
Microcontrollers
Because bindgen
, no_std
and Rust's limited feature tree handling don't play nice
together, on microcontrollers the bindings to micro-ecc
need to be pre-generated.
For Cortex-M4 and Cortex-M33 microcontrollers, they are packaged, and it is sufficient
to use nisty
as follows:
[dependencies.nisty]
default-features = false
When compiled as release build, these platforms automatically pick up UMAAL assembly optimizations.
On an NXP LPC55S69, signature generation takes around 6.9M cycles, signature verification around 7.6M.
Structs
Error | Either there is an error, or there is not - no reasons given. |
Keypair | Create keys, generate signatures. |
PublicKey | Public part of a keypair, a point on the curve. |
SecretKey | Secret part of a keypair, a scalar. |
Seed | 32 entropic bytes, input for key generation. |
Signature | Pair of two curve scalars. |
Constants
PUBLICKEY_COMPRESSED_LENGTH | the length of a public key when serialized in compressed format |
PUBLICKEY_LENGTH | the length of a public key when serialized |
SECRETKEY_LENGTH | the length of a secret key when serialized |
SEED_LENGTH | the length of a secret key seed when serialized |
SHA256_LENGTH | the length of a SHA256 digest |
SIGNATURE_LENGTH | the length of a signature when serialized |
Functions
hash_calls | How many hash digests were calculated for signatures so far. |
prehash |
Type Definitions
Result |