Add ZERO_KEY and ONE_KEY constants
Turns out you cannot initialize constant SecretKeys in any way; these two constants should cover most sane use cases (other good choices are the SECG generator and the Alpha CT generator, but these will wait for a major CT-supporting upgrade, unless demand for them appears.)
This commit is contained in:
parent
fe811b37b2
commit
9e3b93d572
|
@ -1,7 +1,7 @@
|
|||
[package]
|
||||
|
||||
name = "secp256k1"
|
||||
version = "0.5.4"
|
||||
version = "0.5.5"
|
||||
authors = [ "Dawid Ciężarkiewicz <dpc@ucore.info>",
|
||||
"Andrew Poelstra <apoelstra@wpsoftware.net>" ]
|
||||
license = "CC0-1.0"
|
||||
|
|
13
src/key.rs
13
src/key.rs
|
@ -33,11 +33,24 @@ impl_array_newtype!(SecretKey, u8, constants::SECRET_KEY_SIZE);
|
|||
impl_pretty_debug!(SecretKey);
|
||||
|
||||
/// The number 1 encoded as a secret key
|
||||
/// Deprecated; `static` is not what I want; use `ONE_KEY` instead
|
||||
pub static ONE: SecretKey = SecretKey([0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 1]);
|
||||
|
||||
/// The number 0 encoded as a secret key
|
||||
pub const ZERO_KEY: SecretKey = SecretKey([0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0]);
|
||||
|
||||
/// The number 1 encoded as a secret key
|
||||
pub const ONE_KEY: SecretKey = SecretKey([0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 1]);
|
||||
|
||||
/// A Secp256k1 public key, used for verification of signatures
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Debug, Hash)]
|
||||
pub struct PublicKey(ffi::PublicKey);
|
||||
|
|
Loading…
Reference in New Issue